Debian Codegraph @

tests/unittests/CMakeLists.txt

raw
1 project(unittests C)
2
3 set(LIBSSH_UNIT_TESTS
4 torture_bignum
5 torture_buffer
6 torture_bytearray
7 torture_callbacks
8 torture_crypto
9 torture_init
10 torture_list
11 torture_misc
12 torture_config
13 torture_options
14 torture_isipaddr
15 torture_knownhosts_parsing
16 torture_hashes
17 torture_packet_filter
18 torture_temp_dir
19 torture_temp_file
20 torture_push_pop_dir
21 torture_session_keys
22 torture_string
23 torture_tokens
24 )
25
26 set(LIBSSH_THREAD_UNIT_TESTS
27 torture_rand
28 torture_threads_init
29 torture_threads_buffer
30 torture_threads_crypto
31 )
32
33 set(TORTURE_UNIT_ENVIRONMENT
34 "LSAN_OPTIONS=suppressions=${libssh-tests_SOURCE_DIR}/suppressions/lsan.supp;")
35 if (OPENSSL_FOUND)
36 list(APPEND TORTURE_UNIT_ENVIRONMENT OPENSSL_ENABLE_SHA1_SIGNATURES=1)
37 endif (OPENSSL_FOUND)
38
39 if (UNIX AND NOT WIN32)
40 set(LIBSSH_UNIT_TESTS
41 ${LIBSSH_UNIT_TESTS}
42 # this uses a socketpair
43 torture_packet
44 # requires ssh-keygen
45 torture_keyfiles
46 torture_pki
47 torture_pki_rsa
48 torture_pki_dsa
49 torture_pki_ed25519
50 torture_pki_sk_ed25519
51 torture_pki_sshsig
52 # requires /dev/null
53 torture_channel
54 )
55 if (HAVE_IFADDRS_H)
56 set(LIBSSH_UNIT_TESTS
57 ${LIBSSH_UNIT_TESTS}
58 # requires some non-standard API from netdb.h, in.h
59 # and arpa/inet.h for handling IP addresses
60 torture_config_match_localnetwork
61 )
62 endif (HAVE_IFADDRS_H)
63 if (WITH_SERVER)
64 set(LIBSSH_UNIT_TESTS
65 ${LIBSSH_UNIT_TESTS}
66 torture_bind_config)
67
68 if (WITH_GEX)
69 set(LIBSSH_UNIT_TESTS
70 ${LIBSSH_UNIT_TESTS}
71 torture_moduli)
72 endif()
73 endif()
74
75 if (WITH_PKCS11_URI)
76 set(LIBSSH_UNIT_TESTS
77 ${LIBSSH_UNIT_TESTS}
78 torture_pki_rsa_uri
79 torture_pki_ecdsa_uri
80 )
81 if (WITH_PKCS11_PROVIDER)
82 set(LIBSSH_UNIT_TESTS
83 ${LIBSSH_UNIT_TESTS}
84 torture_pki_ed25519_uri
85 )
86 list(APPEND TORTURE_UNIT_ENVIRONMENT
87 PKCS11_PROVIDER_DEBUG=file:/tmp/p11prov-debug.log)
88 endif()
89 endif()
90
91 if (WITH_FIDO2)
92 set(LIBSSH_UNIT_TESTS
93 ${LIBSSH_UNIT_TESTS}
94 torture_pki_sk
95 )
96 endif (WITH_FIDO2)
97
98 if (HAVE_ECC)
99 set(LIBSSH_UNIT_TESTS
100 ${LIBSSH_UNIT_TESTS}
101 torture_pki_ecdsa
102 torture_pki_sk_ecdsa
103 )
104 endif()
105
106 set(LIBSSH_THREAD_UNIT_TESTS
107 ${LIBSSH_THREAD_UNIT_TESTS}
108 # requires pthread
109 torture_threads_pki_rsa
110 )
111 if (WITH_SERVER)
112 set(LIBSSH_THREAD_UNIT_TESTS
113 ${LIBSSH_THREAD_UNIT_TESTS}
114 torture_unit_server
115 torture_server_x11
116 torture_forwarded_tcpip_callback
117 torture_server_direct_tcpip
118 )
119 endif (WITH_SERVER)
120 endif (UNIX AND NOT WIN32)
121
122 if (HAVE_LIBFIDO2)
123 set(LIBSSH_UNIT_TESTS
124 ${LIBSSH_UNIT_TESTS}
125 torture_sk_usbhid
126 )
127 endif (HAVE_LIBFIDO2)
128
129 if (WITH_SFTP)
130 set(LIBSSH_UNIT_TESTS
131 ${LIBSSH_UNIT_TESTS}
132 torture_unit_sftp
133 )
134 endif (WITH_SFTP)
135
136 foreach(_UNIT_TEST ${LIBSSH_UNIT_TESTS})
137 add_cmocka_test(${_UNIT_TEST}
138 SOURCES ${_UNIT_TEST}.c
139 COMPILE_OPTIONS ${DEFAULT_C_COMPILE_FLAGS}
140 LINK_LIBRARIES ${TEST_TARGET_LIBRARIES}
141 )
142
143 set_property(TEST ${_UNIT_TEST}
144 PROPERTY
145 ENVIRONMENT ${TORTURE_UNIT_ENVIRONMENT})
146 endforeach()
147
148 if (CMAKE_USE_PTHREADS_INIT)
149 foreach(_UNIT_TEST ${LIBSSH_THREAD_UNIT_TESTS})
150 add_cmocka_test(${_UNIT_TEST}
151 SOURCES ${_UNIT_TEST}.c
152 COMPILE_OPTIONS ${DEFAULT_C_COMPILE_FLAGS}
153 LINK_LIBRARIES ${TEST_TARGET_LIBRARIES} Threads::Threads
154 )
155
156 set_property(TEST ${_UNIT_TEST}
157 PROPERTY
158 ENVIRONMENT ${TORTURE_UNIT_ENVIRONMENT})
159 endforeach()
160 endif ()
161