xref: /freebsd/contrib/libder/tests/CMakeLists.txt (revision 35c0a8c449fd2b7f75029ebed5e10852240f0865)
1set(FUZZERS fuzz_parallel fuzz_stream fuzz_write)
2set(UTILS )
3set(TESTS test_privkey test_pubkey)
4
5set(ALL_TESTS ${UTILS} ${TESTS})
6
7if(BUILD_FUZZERS)
8	set(UTILS ${UTILS} make_corpus)
9	set(ALL_TESTS ${ALL_TESTS} ${FUZZERS} make_corpus)
10
11	foreach(fuzzer IN LISTS FUZZERS)
12		add_executable(${fuzzer} ${fuzzer}.c)
13
14		target_compile_options(${fuzzer} PUBLIC -fsanitize=fuzzer)
15		target_link_options(${fuzzer} PUBLIC -fsanitize=fuzzer)
16	endforeach()
17
18	target_link_options(fuzz_parallel PUBLIC -pthread)
19endif()
20
21foreach(prog IN LISTS UTILS TESTS)
22	add_executable(${prog} ${prog}.c)
23endforeach()
24
25foreach(prog IN LISTS ALL_TESTS)
26	target_include_directories(${prog} PRIVATE ${CMAKE_SOURCE_DIR}/libder)
27	target_link_libraries(${prog} der_static)
28endforeach()
29
30add_custom_command(TARGET test_privkey POST_BUILD
31	COMMAND ${CMAKE_COMMAND} -E copy
32	${CMAKE_CURRENT_SOURCE_DIR}/repo.priv ${CMAKE_CURRENT_BINARY_DIR}/repo.priv)
33add_custom_command(TARGET test_pubkey POST_BUILD
34	COMMAND ${CMAKE_COMMAND} -E copy
35	${CMAKE_CURRENT_SOURCE_DIR}/repo.pub ${CMAKE_CURRENT_BINARY_DIR}/repo.pub)
36
37add_custom_target(check
38	DEPENDS test_pubkey test_privkey
39	COMMAND "${CMAKE_CURRENT_BINARY_DIR}/test_pubkey"
40	COMMAND "${CMAKE_CURRENT_BINARY_DIR}/test_privkey"
41)
42