1# ################################################################ 2# zstd - Makefile 3# Copyright (C) Yann Collet 2014-present 4# All rights reserved. 5# 6# BSD license 7# 8# Redistribution and use in source and binary forms, with or without modification, 9# are permitted provided that the following conditions are met: 10# 11# * Redistributions of source code must retain the above copyright notice, this 12# list of conditions and the following disclaimer. 13# 14# * Redistributions in binary form must reproduce the above copyright notice, this 15# list of conditions and the following disclaimer in the documentation and/or 16# other materials provided with the distribution. 17# 18# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28# 29# You can contact the author at : 30# - zstd homepage : http://www.zstd.net/ 31# ################################################################ 32 33project(tests) 34 35# name: Cache variable name. The value is expected to be a semicolon-separated 36# list of command line flags 37# default_value: Value to initialize the option with. Can be space separated. 38function(AddTestFlagsOption name default_value doc) 39 string(STRIP "${default_value}" default_value) 40 string(REGEX REPLACE " +" ";" default_value "${default_value}") 41 set(${name} ${default_value} CACHE STRING "${doc}") 42 mark_as_advanced(${name}) 43endfunction() 44 45set(CMAKE_INCLUDE_CURRENT_DIR TRUE) 46 47# Define programs directory, where sources and header files are located 48set(LIBRARY_DIR ${ZSTD_SOURCE_DIR}/lib) 49set(PROGRAMS_DIR ${ZSTD_SOURCE_DIR}/programs) 50set(TESTS_DIR ${ZSTD_SOURCE_DIR}/tests) 51include_directories(${TESTS_DIR} ${PROGRAMS_DIR} ${LIBRARY_DIR} ${LIBRARY_DIR}/common ${LIBRARY_DIR}/compress ${LIBRARY_DIR}/dictBuilder) 52 53add_executable(datagen ${PROGRAMS_DIR}/datagen.c ${TESTS_DIR}/datagencli.c) 54target_link_libraries(datagen libzstd_static) 55 56# 57# fullbench 58# 59add_executable(fullbench ${PROGRAMS_DIR}/datagen.c ${PROGRAMS_DIR}/util.c ${PROGRAMS_DIR}/timefn.c ${PROGRAMS_DIR}/benchfn.c ${PROGRAMS_DIR}/benchzstd.c ${TESTS_DIR}/fullbench.c) 60target_link_libraries(fullbench libzstd_static) 61add_test(NAME fullbench COMMAND fullbench) 62 63# 64# fuzzer 65# 66add_executable(fuzzer ${PROGRAMS_DIR}/datagen.c ${PROGRAMS_DIR}/util.c ${PROGRAMS_DIR}/timefn.c ${TESTS_DIR}/fuzzer.c) 67target_link_libraries(fuzzer libzstd_static) 68AddTestFlagsOption(ZSTD_FUZZER_FLAGS "$ENV{FUZZERTEST} $ENV{FUZZER_FLAGS}" 69 "Semicolon-separated list of flags to pass to the fuzzer test (see `fuzzer -h` for usage)") 70add_test(NAME fuzzer COMMAND fuzzer ${ZSTD_FUZZER_FLAGS}) 71# Disable the timeout since the run time is too long for the default timeout of 72# 1500 seconds and varies considerably between low-end and high-end CPUs. 73# set_tests_properties(fuzzer PROPERTIES TIMEOUT 0) 74 75# 76# zstreamtest 77# 78add_executable(zstreamtest ${PROGRAMS_DIR}/datagen.c ${PROGRAMS_DIR}/util.c ${PROGRAMS_DIR}/timefn.c ${TESTS_DIR}/seqgen.c ${TESTS_DIR}/zstreamtest.c) 79target_link_libraries(zstreamtest libzstd_static) 80AddTestFlagsOption(ZSTD_ZSTREAM_FLAGS "$ENV{ZSTREAM_TESTTIME} $ENV{FUZZER_FLAGS}" 81 "Semicolon-separated list of flags to pass to the zstreamtest test (see `zstreamtest -h` for usage)") 82add_test(NAME zstreamtest COMMAND zstreamtest ${ZSTD_ZSTREAM_FLAGS}) 83 84# 85# playTests.sh 86# 87AddTestFlagsOption(ZSTD_PLAYTESTS_FLAGS "$ENV{PLAYTESTS_FLAGS}" 88 "Semicolon-separated list of flags to pass to the playTests.sh test") 89add_test(NAME playTests COMMAND sh -c "\"${TESTS_DIR}/playTests.sh\" ${ZSTD_PLAYTESTS_FLAGS}") 90if (ZSTD_BUILD_PROGRAMS) 91 set_property(TEST playTests APPEND PROPERTY ENVIRONMENT 92 "ZSTD_BIN=$<TARGET_FILE:zstd>" 93 "DATAGEN_BIN=$<TARGET_FILE:datagen>" 94 ) 95else() 96 message(STATUS "Disabling playTests.sh test because ZSTD_BUILD_PROGRAMS is not enabled") 97 set_tests_properties(playTests PROPERTIES DISABLED YES) 98endif() 99 100# Label the "Medium" set of tests (see TESTING.md) 101set_property(TEST fuzzer zstreamtest playTests APPEND PROPERTY LABELS Medium) 102 103add_executable(paramgrill ${PROGRAMS_DIR}/benchfn.c ${PROGRAMS_DIR}/benchzstd.c ${PROGRAMS_DIR}/datagen.c ${PROGRAMS_DIR}/util.c ${PROGRAMS_DIR}/timefn.c ${TESTS_DIR}/paramgrill.c) 104if (UNIX) 105 target_link_libraries(paramgrill libzstd_static m) #m is math library 106else() 107 target_link_libraries(paramgrill libzstd_static) 108endif () 109