aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/test/CMakeLists.txt
blob: df8db292f65586df3b8f22b959c4301d1c3dbe74 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
add_subdirectory(sigsegv)

find_package(Python3 REQUIRED COMPONENTS Interpreter)

set(python_test_args
    --no-header -v
    --durations 0 --durations-min 1.0
    "${CMAKE_CURRENT_SOURCE_DIR}/py"
    --server "$<TARGET_FILE:server>"
    --worker "$<TARGET_FILE:worker>"
    --client "$<TARGET_FILE:client>"
    --sigsegv "$<TARGET_FILE:sigsegv>"
    --project-version "${PROJECT_VERSION}")

function(add_python_tests name)
    list(POP_FRONT ARGV)
    add_test(NAME "${name}"
        WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/py"
        COMMAND ${ARGV})
    set_tests_properties("${name}" PROPERTIES TIMEOUT 600)
endfunction()

add_python_tests(python_tests_default
    Python3::Interpreter -m pytest ${python_test_args} -m "not flame_graph")

# Use pytest-html to generate an HTML report.
if(NOT DEFINED TEST_REPORT_DIR)
    set(TEST_REPORT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
endif()

add_python_tests(python_tests_report
    Python3::Interpreter -m pytest ${python_test_args} -m "not flame_graph"
        --html "${TEST_REPORT_DIR}/index.html")

# A subset of tests, excluding long-running stress tests.
add_python_tests(python_tests_sanity
    Python3::Interpreter -m pytest ${python_test_args} -m "not flame_graph and not stress")

# Same, but run under Valgrind.
add_python_tests(python_tests_valgrind
    Python3::Interpreter -m pytest ${python_test_args} -m "not flame_graph and not stress"
        --valgrind "${CMAKE_CURRENT_SOURCE_DIR}/../scripts/valgrind.sh")

if(NOT DEFINED FLAME_GRAPHS_DIR)
    set(FLAME_GRAPHS_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
endif()

add_python_tests(python_tests_flame_graphs
    Python3::Interpreter -m pytest ${python_test_args} -m "flame_graph"
        --flamegraph "${CMAKE_CURRENT_SOURCE_DIR}/../scripts/flamegraph.sh"
        --flame-graphs-dir "${FLAME_GRAPHS_DIR}")