meson: use get_variable() update to meson 0.51
[mesa-waffle.git] / third_party / cmocka / tests / CMakeLists.txt
blob2f985a5ca0421dd71deea02d93c8388febef34a1
1 project(tests C)
3 include_directories(
4   ${CMAKE_BINARY_DIR}
5   ${CMAKE_CURRENT_SOURCE_DIR}
6   ${CMAKE_SOURCE_DIR}/include
9 set(CMOCKA_TESTS
10     test_alloc
11     test_group_setup_fail
12     test_fixtures
13     test_group_fixtures
14     test_assert_macros
15     test_assert_macros_fail
16     test_exception_handler
17     test_basics
18     test_skip
19     test_setup_fail)
21 foreach(_CMOCKA_TEST ${CMOCKA_TESTS})
22     add_cmocka_test(${_CMOCKA_TEST} ${_CMOCKA_TEST}.c ${CMOCKA_STATIC_LIBRARY})
23 endforeach()
25 ### Special Cases
26 if (${CMAKE_C_COMPILER_ID} MATCHES "(GNU|Clang)")
27     set_source_files_properties(test_cmockery.c PROPERTIES COMPILE_FLAGS "-Wno-deprecated-declarations")
28 endif()
29 add_cmocka_test(test_cmockery test_cmockery.c ${CMOCKA_STATIC_LIBRARY})
31 ### Exceptions
33 # test_assert_macros_fail
34 set_tests_properties(
35     test_skip
36         PROPERTIES
37         PASS_REGULAR_EXPRESSION
38         "\\[  SKIPPED \\] test_check_skip"
41 # test_assert_macros_fail
42 set_tests_properties(
43     test_assert_macros_fail
44         PROPERTIES
45         PASS_REGULAR_EXPRESSION
46         "\\[  FAILED  \\] 1 test"
49 # test_exception_handler
50 if (WIN32)
51     set_tests_properties(
52         test_exception_handler
53             PROPERTIES
54             PASS_REGULAR_EXPRESSION
55             "EXCEPTION_ACCESS_VIOLATION occurred at")
56 else()
57     set_tests_properties(
58         test_exception_handler
59             PROPERTIES
60             PASS_REGULAR_EXPRESSION
61             "Test failed with exception: (Segmentation fault|Segmentation Fault|11)"
62     )
63 endif (WIN32)
65 set_tests_properties(
66     test_setup_fail
67         PROPERTIES
68         WILL_FAIL
69         1
72 set_tests_properties(
73     test_group_setup_fail
74         PROPERTIES
75         WILL_FAIL
76         1
79 add_test (test_setup_fail_1_failed test_setup_fail)
80 set_tests_properties(
81     test_setup_fail_1_failed
82         PROPERTIES
83         PASS_REGULAR_EXPRESSION
84         "\\[  ERROR   \\] int_test_ignored"
87 add_test (test_setup_fail_1_passed test_setup_fail)
88 set_tests_properties(
89     test_setup_fail_1_passed
90         PROPERTIES
91         PASS_REGULAR_EXPRESSION
92         "\\[  PASSED  \\] 1 test\\(s\\)."
95 add_test (test_setup_fail_match_failed test_setup_fail)
96 set_tests_properties(
97     test_setup_fail_match_failed
98         PROPERTIES
99         PASS_REGULAR_EXPRESSION
100         "\\[  ERROR   \\] int_test_ignored"
103 add_test (test_setup_fail_match_passed test_setup_fail)
104 set_tests_properties(
105     test_setup_fail_match_passed
106         PROPERTIES
107         PASS_REGULAR_EXPRESSION
108         "\\[       OK \\] int_test_success"
111 ### Output formats
113 # test output of success, failure, skip, fixture failure
114 set(OUTPUT_TESTS
115     test_basics
116     test_assert_macros_fail
117     test_skip
118     test_setup_fail)
120 set(TEST_OUTPUT_FMTS
121     tap
122     subunit
123     xml)
125 set(test_basics_tap_out
126     "^\t1\\.\\.2[ \n\r]+\tok 1 - null_test_success[ \n\r]+\tok 2 - int_test_success[ \n\r]+ok - tests")
127 set(test_assert_macros_fail_tap_out
128     "^\t1\\.\\.1[ \n\r]+\tnot ok 1 - test_assert_return_code_fail[ \n\r]+\t#[^\n\r]+[\n\r]\t#[^\n\r]+[\n\r]not ok - tests")
130 set(test_skip_tap_out
131     "not ok 1 # SKIP")
132 set(test_setup_fail_tap_out
133     "not ok 1 - int_test_ignored Could not run the test - check test fixtures")
135 set(test_basics_subunit_out
136     "^test: null_test_success[ \n\r]+success: null_test_success")
137 set(test_assert_macros_fail_subunit_out
138     "failure: test_assert_return_code_fail \\[")
139 set(test_skip_subunit_out
140     "^test: test_check_skip[ \n\r]+skip: test_check_skip")
141 set(test_setup_fail_subunit_out
142     "error: int_test_ignored \\[ Could not run the test - check test fixtures \\]")
144 set(test_basics_xml_out
145     "<testsuite name=\"tests\" time=\"[0-9.]+\" tests=\"2\" failures=\"0\" errors=\"0\" skipped=\"0\" >[ \n\r]+<testcase name=\"null_test_success\" time=\"[0-9.]+\" >.*</testcase>")
146 set(test_assert_macros_fail_xml_out
147     "<testcase name=\"test_assert_return_code_fail\" time=\"[0-9.]+\" >[ \n\r]+<failure>")
148 set(test_skip_xml_out
149     "<testcase name=\"test_check_skip\" time=\"[0-9.]+\" >[ \n\r]+<skipped/>")
150 set(test_setup_fail_xml_out
151     "<testcase name=\"int_test_ignored\" time=\"[0-9.]+\" >[ \n\r]+<failure><!\\[CDATA\\[Test setup failed\\]\\]></failure>")
153 foreach(_TEST_OUTPUT_FMT ${TEST_OUTPUT_FMTS})
154     foreach(_OUTPUT_TEST ${OUTPUT_TESTS})
155         set(TEST_NAME ${_OUTPUT_TEST}_${_TEST_OUTPUT_FMT})
156         add_test(${TEST_NAME} ${_OUTPUT_TEST})
158         set_property(
159             TEST
160             ${TEST_NAME}
161             PROPERTY
162                 ENVIRONMENT CMOCKA_MESSAGE_OUTPUT=${_TEST_OUTPUT_FMT}
163             )
165             set_tests_properties(
166                     ${TEST_NAME}
167                     PROPERTIES
168                     PASS_REGULAR_EXPRESSION
169                     ${${TEST_NAME}_out}
170             )
171     endforeach()
172 endforeach()