From 035ea386d1b6a99a8a1e2ab57cc1fc903569136c Mon Sep 17 00:00:00 2001 From: DRC Date: Thu, 6 Jul 2023 12:04:22 -0400 Subject: [PATCH] Build: Fix regression test concurrency issues - The example-*bit-*-decompress test must run after the example-*bit-*-compress test, since the latter generates testout*-example.jpg. - Add -static to the filenames of all output files generated by the "static" regression tests, to avoid conflicts with the "shared" regression tests. - Add the PID to the filenames of all files generated by the tjunittest packed-pixel image I/O tests. - Check the return value of MD5File() in tjunittest to avoid a segfault if the file doesn't exist. (Prior to the fix described above, that could occur if two instances of tjunittest ran concurrently from the same directory with the same -bmp and -precision arguments.) Fixes #705 --- CMakeLists.txt | 10 ++++++---- tjunittest.c | 8 ++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index efd101a07..f0b9e9377 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1004,7 +1004,7 @@ foreach(libtype ${TEST_LIBTYPES}) if(sample_bits EQUAL 12) set(tjbench tjbench12) - set(testout testout12) + set(testout testout12${suffix}) set(MD5_PPM_GRAY_TILE 2f799249148b1a9d0e61fa4408f6c397) set(MD5_PPM_420_8x8_TILE b25684e1af37be504ee3fd137757353f) @@ -1024,7 +1024,7 @@ foreach(libtype ${TEST_LIBTYPES}) set(MD5_PPM_444_TILE 2f571a032e4dbc8ef40f75219d336b0b) else() set(tjbench tjbench) - set(testout testout) + set(testout testout${suffix}) set(MD5_PPM_GRAY_TILE 2c3b567086e6ca0c5e6d34ad8d6f6fe8) set(MD5_PPM_420_8x8_TILE efca1bdf0226df01777137778cf986ec) @@ -1160,7 +1160,7 @@ foreach(libtype ${TEST_LIBTYPES}) set(cjpeg cjpeg12) set(djpeg djpeg12) set(jpegtran jpegtran12) - set(testout testout12) + set(testout testout12${suffix}) set(TESTORIG testorig12.jpg) set(MD5_JPEG_RGB_ISLOW 9d7369207c520d37f2c1cbfcb82b2964) @@ -1222,7 +1222,7 @@ foreach(libtype ${TEST_LIBTYPES}) set(cjpeg cjpeg) set(djpeg djpeg) set(jpegtran jpegtran) - set(testout testout) + set(testout testout${suffix}) set(TESTORIG testorig.jpg) set(MD5_JPEG_RGB_ISLOW 1d44a406f61da743b5fd31c0a9abdca3) @@ -1632,6 +1632,8 @@ foreach(libtype ${TEST_LIBTYPES}) add_test(example-${sample_bits}bit-${libtype}-decompress ${CMAKE_CROSSCOMPILING_EMULATOR} example${suffix} decompress ${EXAMPLE_12BIT_ARG} ${testout}-example.jpg ${testout}-example.ppm) + set_tests_properties(example-${sample_bits}bit-${libtype}-decompress + PROPERTIES DEPENDS example-${sample_bits}bit-${libtype}-compress) add_test(example-${sample_bits}bit-${libtype}-decompress-cmp ${CMAKE_CROSSCOMPILING_EMULATOR} ${MD5CMP} ${MD5_PPM_EXAMPLE_DECOMPRESS} ${testout}-example.ppm) diff --git a/tjunittest.c b/tjunittest.c index bbe44bb17..b033c4f17 100644 --- a/tjunittest.c +++ b/tjunittest.c @@ -977,8 +977,8 @@ static int doBmpTest(const char *ext, int width, int align, int height, int pf, THROW("Could not allocate memory"); initBitmap(buf, width, pitch, height, pf, bottomUp); - SNPRINTF(filename, 80, "test_bmp%d_%s_%d_%s.%s", precision, pixFormatStr[pf], - align, bottomUp ? "bu" : "td", ext); + SNPRINTF(filename, 80, "test_bmp%d_%s_%d_%s_%d.%s", precision, pixFormatStr[pf], + align, bottomUp ? "bu" : "td", getpid(), ext); if (precision == 8) { TRY_TJ(handle, tj3SaveImage8(handle, filename, (unsigned char *)buf, width, pitch, height, pf)); @@ -990,6 +990,10 @@ static int doBmpTest(const char *ext, int width, int align, int height, int pf, width, pitch, height, pf)); } md5sum = MD5File(filename, md5buf); + if (!md5sum) { + printf("\n Could not determine MD5 sum of %s\n", filename); + retval = -1; goto bailout; + } if (strcasecmp(md5sum, md5ref)) THROW_MD5(filename, md5sum, md5ref);