diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /third_party/jpeg-xl/lib/jxl_tests.cmake | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/jpeg-xl/lib/jxl_tests.cmake')
-rw-r--r-- | third_party/jpeg-xl/lib/jxl_tests.cmake | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/third_party/jpeg-xl/lib/jxl_tests.cmake b/third_party/jpeg-xl/lib/jxl_tests.cmake new file mode 100644 index 0000000000..eec4149fba --- /dev/null +++ b/third_party/jpeg-xl/lib/jxl_tests.cmake @@ -0,0 +1,96 @@ +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file. + +include(jxl_lists.cmake) + +if(BUILD_TESTING OR JPEGXL_ENABLE_TOOLS) +# Library with test-only code shared between all tests / fuzzers. +add_library(jxl_testlib-internal STATIC ${JPEGXL_INTERNAL_TESTLIB_FILES}) +target_compile_options(jxl_testlib-internal PRIVATE + ${JPEGXL_INTERNAL_FLAGS} + ${JPEGXL_COVERAGE_FLAGS} +) +target_compile_definitions(jxl_testlib-internal PUBLIC + -DTEST_DATA_PATH="${JPEGXL_TEST_DATA_PATH}") +target_include_directories(jxl_testlib-internal PUBLIC + "${PROJECT_SOURCE_DIR}" +) +target_link_libraries(jxl_testlib-internal + hwy + jxl-internal + jxl_threads +) +endif() + +if(NOT BUILD_TESTING) + return() +endif() + +list(APPEND JPEGXL_INTERNAL_TESTS + # TODO(deymo): Move this to tools/ + ../tools/djxl_fuzzer_test.cc + ../tools/gauss_blur_test.cc +) + +find_package(GTest) + +set(JXL_WASM_TEST_LINK_FLAGS "") +if (EMSCRIPTEN) + # The emscripten linking step takes too much memory and crashes during the + # wasm-opt step when using -O2 optimization level + set(JXL_WASM_TEST_LINK_FLAGS "\ + -O1 \ + -s USE_LIBPNG=1 \ + -s ALLOW_MEMORY_GROWTH=1 \ + -s SINGLE_FILE=1 \ + -s EXIT_RUNTIME=1 \ + -s NODERAWFS=1 \ + ") + if (JPEGXL_ENABLE_WASM_TRHEADS) + set(JXL_WASM_TEST_LINK_FLAGS "${JXL_WASM_TEST_LINK_FLAGS} \ + -s PROXY_TO_PTHREAD \ + -s USE_PTHREADS=1 \ + ") + endif() +endif() # EMSCRIPTEN + +# Individual test binaries: +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tests) +foreach (TESTFILE IN LISTS JPEGXL_INTERNAL_TESTS) + # The TESTNAME is the name without the extension or directory. + get_filename_component(TESTNAME ${TESTFILE} NAME_WE) + if(TESTFILE STREQUAL ../tools/djxl_fuzzer_test.cc) + add_executable(${TESTNAME} ${TESTFILE} ../tools/djxl_fuzzer.cc) + else() + add_executable(${TESTNAME} ${TESTFILE}) + endif() + if(EMSCRIPTEN) + set_target_properties(${TESTNAME} PROPERTIES LINK_FLAGS "${JXL_WASM_TEST_LINK_FLAGS}") + else() + set_target_properties(${TESTNAME} PROPERTIES LINK_FLAGS "${JPEGXL_COVERAGE_LINK_FLAGS}") + endif() + target_compile_options(${TESTNAME} PRIVATE + ${JPEGXL_INTERNAL_FLAGS} + # Add coverage flags to the test binary so code in the private headers of + # the library is also instrumented when running tests that execute it. + ${JPEGXL_COVERAGE_FLAGS} + ) + target_link_libraries(${TESTNAME} + gmock + GTest::GTest + GTest::Main + jxl_testlib-internal + jxl_extras-internal + ) + if(TESTFILE STREQUAL ../tools/gauss_blur_test.cc) + target_link_libraries(${TESTNAME} jxl_gauss_blur) + endif() + + # Output test targets in the test directory. + set_target_properties(${TESTNAME} PROPERTIES PREFIX "tests/") + if (WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + set_target_properties(${TESTNAME} PROPERTIES COMPILE_FLAGS "-Wno-error") + endif () + # 240 seconds because some build types (e.g. coverage) can be quite slow. + gtest_discover_tests(${TESTNAME} DISCOVERY_TIMEOUT 240) +endforeach () |