1 project(cmocka-examples C CXX)
5 ${CMAKE_CURRENT_SOURCE_DIR}
6 ${CMOCKA_PUBLIC_INCLUDE_DIRS}
9 add_definitions(-DUNIT_TESTING=1)
11 add_executable(calculator_test calculator.c calculator_test.c)
12 target_link_libraries(calculator_test ${CMOCKA_SHARED_LIBRARY})
14 add_test(calculator_test ${CMAKE_CURRENT_BINARY_DIR}/calculator_test)
16 add_executable(allocate_module_test allocate_module.c allocate_module_test.c)
17 target_link_libraries(allocate_module_test ${CMOCKA_SHARED_LIBRARY})
19 # This is a test that should detect leaks and overflows and will fail for that
20 add_test(allocate_module_test ${CMAKE_CURRENT_BINARY_DIR}/allocate_module_test)
24 PASS_REGULAR_EXPRESSION
25 "\\[ FAILED \\] 3 test"
28 add_executable(assert_macro_test assert_macro.c assert_macro_test.c)
29 target_link_libraries(assert_macro_test ${CMOCKA_SHARED_LIBRARY})
31 add_test(assert_macro_test ${CMAKE_CURRENT_BINARY_DIR}/assert_macro_test)
35 PASS_REGULAR_EXPRESSION
36 "\\[ FAILED \\] 2 test"
39 add_executable(assert_module_test assert_module.c assert_module_test.c)
40 target_link_libraries(assert_module_test ${CMOCKA_SHARED_LIBRARY})
42 add_test(assert_module_test ${CMAKE_CURRENT_BINARY_DIR}/assert_macro_test)
46 PASS_REGULAR_EXPRESSION
47 "\\[ FAILED \\] 2 test"
50 add_executable(customer_database_test customer_database.c customer_database_test.c)
51 target_link_libraries(customer_database_test ${CMOCKA_SHARED_LIBRARY})
53 add_test(customer_database_test ${CMAKE_CURRENT_BINARY_DIR}/customer_database_test)
55 add_executable(key_value_test key_value.c key_value_test.c)
56 target_link_libraries(key_value_test ${CMOCKA_SHARED_LIBRARY})
58 add_test(key_value_test ${CMAKE_CURRENT_BINARY_DIR}/key_value_test)
60 add_executable(product_database_test product_database.c product_database_test.c)
61 target_link_libraries(product_database_test ${CMOCKA_SHARED_LIBRARY})
63 add_test(product_database_test ${CMAKE_CURRENT_BINARY_DIR}/product_database_test)
67 PASS_REGULAR_EXPRESSION
68 "\\[ FAILED \\] 2 test"
71 if (${CMAKE_C_COMPILER_ID} MATCHES "(GNU|Clang)")
72 add_subdirectory(chef_wrap)
75 add_executable(run_tests run_tests.c)
76 target_link_libraries(run_tests ${CMOCKA_SHARED_LIBRARY})
78 add_test(run_tests ${CMAKE_CURRENT_BINARY_DIR}/run_tests)