tests: Key regress.c's Windows portability macros on _WIN32

TEST_NULL_DEVICE, TEST_SETENV, TEST_UNSETENV, and TEST_MKDIR were
gated on USE_WINDOWS_API, while the arpa/inet.h/direct.h include
guard a few lines above keys on _WIN32. Whether mkdir(), setenv(),
and /dev/null work as expected is a libc availability question, not
a wolfSSH API-selection one, so _WIN32 is the more direct fit and
now both guards in this file agree.

No behavior change: USE_WINDOWS_API is only ever set when _WIN32 is
already defined, so this does not change which branch any current
build takes.

Verified with the MinGW cross compiler both with WOLFSSH_SFTP defined
and without, and confirmed a plain Linux build still passes
tests/regress.test and tests/unit.test.
pull/1247/head
Hideki Miyazaki 2026-09-08 18:22:19 -04:00 committed by John Safranek
parent 0bb371a4b2
commit 343582a61e
1 changed files with 8 additions and 4 deletions

View File

@ -9380,8 +9380,10 @@ static void TestClientBuffersIdempotent(void)
} }
#endif #endif
/* Windows has no /dev/null; the null device there is "NUL". */ /* Windows has no /dev/null; the null device there is "NUL". Keyed on
#ifdef USE_WINDOWS_API * _WIN32, like the arpa/inet.h/direct.h include guard above: this is a
* libc-availability question, not a wolfSSH API-selection one. */
#ifdef _WIN32
#define TEST_NULL_DEVICE "NUL" #define TEST_NULL_DEVICE "NUL"
#else #else
#define TEST_NULL_DEVICE "/dev/null" #define TEST_NULL_DEVICE "/dev/null"
@ -13371,8 +13373,10 @@ static int KnownHostsCheckCapture(const byte* pubKey, word32 pubKeySz,
* enough for this test's own HOME juggling. WMKDIR is not an option here: * enough for this test's own HOME juggling. WMKDIR is not an option here:
* it is only defined when wolfssh/port.h is built with SFTP, SCP, or sshd * it is only defined when wolfssh/port.h is built with SFTP, SCP, or sshd
* support, and this test compiles whenever WOLFSSL_BASE64_ENCODE is set, * support, and this test compiles whenever WOLFSSL_BASE64_ENCODE is set,
* independent of those. */ * independent of those. Keyed on _WIN32 rather than USE_WINDOWS_API for
#ifdef USE_WINDOWS_API * the same reason as TEST_NULL_DEVICE above: mkdir()/setenv() availability
* is a libc question. */
#ifdef _WIN32
#define TEST_SETENV(n,v) _putenv_s((n), (v)) #define TEST_SETENV(n,v) _putenv_s((n), (v))
#define TEST_UNSETENV(n) _putenv_s((n), "") #define TEST_UNSETENV(n) _putenv_s((n), "")
#define TEST_MKDIR(p,m) _mkdir((p)) #define TEST_MKDIR(p,m) _mkdir((p))