diff --git a/src/tests/testmain.c b/src/tests/testmain.c index 86499c7f..c320eef4 100644 --- a/src/tests/testmain.c +++ b/src/tests/testmain.c @@ -37,6 +37,7 @@ #endif #include "../struct.h" #include "../global.h" +#include "../io.h" #include "../gfx2log.h" #include "tests.h" @@ -95,7 +96,7 @@ byte Windows_open; dword Key; -char tmpdir[40]; +char tmpdir[256]; static const struct { int (*test_func)(void); @@ -112,6 +113,9 @@ static const struct { */ int init(void) { +#ifdef WIN32 + char temp[256]; +#endif srandom(time(NULL)); #ifdef ENABLE_FILENAMES_ICONV // iconv is used to convert filenames @@ -125,7 +129,12 @@ int init(void) cd_utf16_inv = iconv_open(FROMCODE, "UTF-16LE"); // From UTF16 to UTF8 #endif #endif /* ENABLE_FILENAMES_ICONV */ - snprintf(tmpdir, sizeof(tmpdir), "/tmp/grafx2-test.XXXXXX"); +#ifdef WIN32 + GetTempPathA(sizeof(temp), temp); + snprintf(tmpdir, sizeof(tmpdir), "%s%sgrafx2-test.XXXXXX", temp, PATH_SEPARATOR); +#else + snprintf(tmpdir, sizeof(tmpdir), "%s%sgrafx2-test.XXXXXX", "/tmp", PATH_SEPARATOR); +#endif if (mkdtemp(tmpdir) == NULL) { perror("mkdtemp"); diff --git a/src/tests/tests.c b/src/tests/tests.c index 920c6ddc..0d0d3dd8 100644 --- a/src/tests/tests.c +++ b/src/tests/tests.c @@ -31,9 +31,11 @@ #include #include #include +#include "tests.h" #include "../struct.h" #include "../oldies.h" #include "../packbits.h" +#include "../io.h" #include "../gfx2log.h" // random()/srandom() not available with mingw32 @@ -180,7 +182,7 @@ int Test_Packbits(void) byte buffer[1024]; T_PackBits_data pb_data; - snprintf(tempfilename, sizeof(tempfilename), "/tmp/gfx2test-packbits-%lx", random()); + snprintf(tempfilename, sizeof(tempfilename), "%s%sgfx2test-packbits-%lx", tmpdir, PATH_SEPARATOR, random()); GFX2_Log(GFX2_DEBUG, "tempfile %s\n", tempfilename); f = fopen(tempfilename, "wb"); if (f == NULL)