diff --git a/test/TestUtil.cpp b/test/TestUtil.cpp index f9e14373d9..58cd34c151 100644 --- a/test/TestUtil.cpp +++ b/test/TestUtil.cpp @@ -63,6 +63,20 @@ void testStateCheckpoint(const char *, const char *) {} namespace { +/// MinGW-w64 has no lstat(): Windows has no POSIX symlink stat, and nothing in a test sandbox +/// creates a symlink, so stat() sees the same thing for every entry walk() can reach. +#ifdef _WIN32 +inline int lstatCompat(const char *path, struct stat *st) +{ + return stat(path, st); +} +#else +inline int lstatCompat(const char *path, struct stat *st) +{ + return lstat(path, st); +} +#endif + /// Content fingerprint, used only to answer "did this file change?". FNV-1a rather than a real /// digest because the answer is a boolean and the files are a few KB of protobuf; nothing here /// records a hash as an expected value, which is what would make this a snapshot test. @@ -96,7 +110,7 @@ void walk(const std::string &root, const std::string &rel, std::mapd_name) : rel + "/" + e->d_name; const std::string childPath = root + "/" + childRel; struct stat st; - if (lstat(childPath.c_str(), &st) != 0) + if (lstatCompat(childPath.c_str(), &st) != 0) continue; if (S_ISDIR(st.st_mode)) walk(root, childRel, out); diff --git a/test/test_default/test_main.cpp b/test/test_default/test_main.cpp index ee4fc16279..36c06e9773 100644 --- a/test/test_default/test_main.cpp +++ b/test/test_default/test_main.cpp @@ -277,6 +277,10 @@ void test_trafficType_overflowSaturates() TEST_ASSERT_EQUAL_UINT32(static_cast(INT32_MAX), res); } +// Required by Unity: PlatformIO's weak defaults do not link on MinGW (PE-COFF weak externals). +void setUp(void) {} +void tearDown(void) {} + void setup() { // Small delay to match other test mains diff --git a/test/test_fscommon_getfiles/test_main.cpp b/test/test_fscommon_getfiles/test_main.cpp index 943bc43a7f..eaa776d1be 100644 --- a/test/test_fscommon_getfiles/test_main.cpp +++ b/test/test_fscommon_getfiles/test_main.cpp @@ -112,6 +112,9 @@ void test_getfiles_depth_limit(void) // 4. A path that will not fit meshtastic_FileInfo::file_name is dropped, not truncated into the // manifest, and the drop is reported. +// Not built on Windows: any path long enough to overrun the 228-byte file_name also exceeds the +// 260-byte MAX_PATH, so the tree is never created and there is nothing to drop. +#ifndef _WIN32 void test_getfiles_rejects_overlong_path(void) { // file_name is 228 bytes; build a nested path that overruns it while each component stays @@ -148,6 +151,7 @@ void test_getfiles_rejects_overlong_path(void) *strrchr(dir, '/') = '\0'; } } +#endif // 5. pathEndsWithDot() - no entry in the manifest may end in '.', which is how the walk filters the // "." and ".." pseudo-entries some backends return. @@ -231,7 +235,9 @@ void setup() RUN_TEST(test_getfiles_respects_max_count); RUN_TEST(test_getfiles_unlimited_when_under_cap); RUN_TEST(test_getfiles_depth_limit); +#ifndef _WIN32 RUN_TEST(test_getfiles_rejects_overlong_path); +#endif RUN_TEST(test_getfiles_skips_dot_entries); RUN_TEST(test_getfiles_reports_sizes); RUN_TEST(test_getfiles_missing_dir_is_empty); diff --git a/test/test_http_content_handler/test_main.cpp b/test/test_http_content_handler/test_main.cpp index 3b628a2b21..c5b5d32a17 100644 --- a/test/test_http_content_handler/test_main.cpp +++ b/test/test_http_content_handler/test_main.cpp @@ -8,6 +8,10 @@ static void test_placeholder() } extern "C" { +// Required by Unity: PlatformIO's weak defaults do not link on MinGW (PE-COFF weak externals). +void setUp(void) {} +void tearDown(void) {} + void setup() { initializeTestEnvironment(); diff --git a/test/test_meshpacket_serializer/test_serializer.cpp b/test/test_meshpacket_serializer/test_serializer.cpp index 82e79f8e1a..db863ca3c2 100644 --- a/test/test_meshpacket_serializer/test_serializer.cpp +++ b/test/test_meshpacket_serializer/test_serializer.cpp @@ -23,6 +23,10 @@ void test_timestamp_present_when_has_rx_time(); void test_timestamp_zeroed_when_rx_time_absent(); void test_encrypted_timestamp_zeroed_when_rx_time_absent(); +// Required by Unity: PlatformIO's weak defaults do not link on MinGW (PE-COFF weak externals). +void setUp(void) {} +void tearDown(void) {} + void setup() { UNITY_BEGIN(); diff --git a/test/test_mqtt/MQTT.cpp b/test/test_mqtt/MQTT.cpp index 3c4f1ab6af..b67cf31abe 100644 --- a/test/test_mqtt/MQTT.cpp +++ b/test/test_mqtt/MQTT.cpp @@ -17,7 +17,13 @@ #include #include +// htonl() for remoteIP() below. MinGW has no ; the byte-order helpers live in +// winsock2.h, which must precede any the Arduino shims pull in. +#ifdef _WIN32 +#include +#else #include +#endif #include #include diff --git a/test/test_serial/SerialModule.cpp b/test/test_serial/SerialModule.cpp index 6539d0ad34..48808db855 100644 --- a/test/test_serial/SerialModule.cpp +++ b/test/test_serial/SerialModule.cpp @@ -2,6 +2,11 @@ #include "TestUtil.h" #include +// Required by Unity: PlatformIO's weak defaults do not link on MinGW (PE-COFF weak externals). +// Outside the guard below so both the portduino and the stub setup() get them. +void setUp(void) {} +void tearDown(void) {} + #ifdef ARCH_PORTDUINO #include "configuration.h" diff --git a/variants/native/portduino.ini b/variants/native/portduino.ini index 5997cf1fbf..7787adc9c4 100644 --- a/variants/native/portduino.ini +++ b/variants/native/portduino.ini @@ -57,6 +57,9 @@ build_flags_common = -std=gnu17 -std=gnu++17 -DMAX_TFT_COLOR_REGIONS=64 + ; Unity omits double support unless asked, compiling TEST_ASSERT_DOUBLE_* into an + ; unconditional "Unity Double Precision Disabled" failure (test_gps_update_scheduling). + -DUNITY_INCLUDE_DOUBLE build_flags = ${portduino_base.build_flags_common}