diff --git a/esphome/components/socket/__init__.py b/esphome/components/socket/__init__.py index abbbb0f056f..c7b2fec35f8 100644 --- a/esphome/components/socket/__init__.py +++ b/esphome/components/socket/__init__.py @@ -177,7 +177,14 @@ async def to_code(config): def FILTER_SOURCE_FILES() -> list[str]: """Return list of socket implementation files that aren't selected by the user.""" - impl = CORE.config["socket"][CONF_IMPLEMENTATION] + socket_config = CORE.config.get("socket") + if not isinstance(socket_config, dict): + # Config has not been validated yet (or socket isn't configured as a + # mapping for this build, e.g. a C++ unit test build that skips config + # validation). Don't filter -- all impl files are guarded by USE_* + # defines so only the selected implementation contributes code anyway. + return [] + impl = socket_config[CONF_IMPLEMENTATION] # Build list of files to exclude based on selected implementation excluded = [] diff --git a/tests/components/api/test_proto_mac_varint.cpp b/tests/components/api/test_proto_mac_varint.cpp index 7597c898065..317a6fb9d6e 100644 --- a/tests/components/api/test_proto_mac_varint.cpp +++ b/tests/components/api/test_proto_mac_varint.cpp @@ -1,6 +1,7 @@ #include #include +#include #include #include "esphome/components/api/api_buffer.h" @@ -55,7 +56,9 @@ static void verify_mac(uint64_t mac, size_t expected_bytes) { APIBuffer api_buf; api_buf.resize(16); uint8_t *pos = api_buf.data(); - PROTO_ENCODE_DEBUG_INIT(&api_buf); +#ifdef ESPHOME_DEBUG_API + uint8_t *proto_debug_end_ = api_buf.data() + api_buf.size(); +#endif ProtoEncode::encode_varint_raw_48bit(pos PROTO_ENCODE_DEBUG_ARG, mac); size_t new_len = pos - api_buf.data(); @@ -109,6 +112,7 @@ TEST(ProtoMacVarint, AllOnes) { verify_mac(0xFFFFFFFFFFFFULL, 7); } // F // 100 deterministic-random 48-bit MACs to catch regressions across the space. TEST(ProtoMacVarint, RandomSample) { + // NOLINTNEXTLINE(cert-msc32-c,cert-msc51-cpp) -- intentional fixed seed for reproducibility. std::mt19937_64 rng(0xC0FFEE); for (int i = 0; i < 100; i++) { uint64_t mac = rng() & 0xFFFFFFFFFFFFULL;