14
14
15
15
# No linker for Mach-O supports the linker argument `--wrap`. Since we use
16
16
# that, unit tests will never work on macos. Use linux/arm64 in docker instead.
17
- if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" )
18
- message ("No linker for Mach-O supports --wrap, will not generate unit-tests" )
19
- return ()
20
- endif ()
21
17
22
18
# We use FindPkgConfig instead of FindPackage because it finds libraries in
23
19
# both linux and macos
@@ -26,7 +22,11 @@ find_package(PkgConfig REQUIRED)
26
22
# Unit testing uses CMocka
27
23
pkg_check_modules (CMOCKA REQUIRED cmocka )
28
24
# u2f tests with hardware uses hidapi-hidraw
29
- pkg_check_modules (HIDAPI REQUIRED hidapi-hidraw )
25
+ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" )
26
+ pkg_check_modules (HIDAPI REQUIRED hidapi )
27
+ else ()
28
+ pkg_check_modules (HIDAPI REQUIRED hidapi-hidraw )
29
+ endif ()
30
30
31
31
message ("hidapi-hidraw " ${HIDAPI_INCLUDE_DIRS} )
32
32
@@ -175,7 +175,7 @@ target_compile_definitions(bitbox PUBLIC TESTING _UNIT_TEST_)
175
175
target_link_libraries (bitbox
176
176
PUBLIC
177
177
secp256k1
178
- ${CMOCKA_LIBRARIES }
178
+ ${CMOCKA_LDFLAGS }
179
179
PRIVATE
180
180
wallycore
181
181
fatfs
@@ -218,7 +218,7 @@ target_include_directories(
218
218
target_compile_definitions (u2f-util PUBLIC "TESTING" _UNIT_TEST_ PRODUCT_BITBOX_MULTI "APP_U2F=1" "APP_BTC=1" "APP_LTC=1" "APP_ETH=1" )
219
219
target_compile_definitions (u2f-util PUBLIC "USE_KECCAK" )
220
220
221
- target_link_libraries (u2f-util PUBLIC ${HIDAPI_LIBRARIES } )
221
+ target_link_libraries (u2f-util PUBLIC ${HIDAPI_LDFLAGS } )
222
222
223
223
224
224
#-----------------------------------------------------------------------------
@@ -257,28 +257,32 @@ set(TEST_LIST
257
257
""
258
258
)
259
259
260
- list (LENGTH TEST_LIST TEST_LIST_LEN )
261
- math (EXPR TEST_LIST_LEN ${TEST_LIST_LEN} -1 )
262
- foreach (I RANGE 0 ${TEST_LIST_LEN} 2 )
263
- math (EXPR I2 ${I} +1 )
264
- list (GET TEST_LIST ${I} TEST_NAME )
265
- list (GET TEST_LIST ${I2} TEST_LINK_ARGS )
266
- set (EXE test_${TEST_NAME} )
267
- add_executable (${EXE} test_${TEST_NAME}.c framework /eh_personality.c )
268
- # asan must be first library in linking order
269
- target_link_libraries (${EXE} PRIVATE
270
- $< $< BOOL:${SANITIZE_ADDRESS} > :asan>
271
- $< $< BOOL:${SANITIZE_UNDEFINED} > :-fsanitize=undefined>
272
- -Wl,--start-group
273
- c-unit-tests_rust_c
274
- bitbox
275
- -Wl,--end-group
276
- ${TEST_LINK_ARGS}
277
- )
278
- if (NOT ${TEST_NAME} STREQUAL "simulator" )
279
- add_test (NAME test_${TEST_NAME} COMMAND ${EXE} )
280
- endif ()
281
- endforeach ()
260
+ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" )
261
+ message ("No linker for Mach-O supports --wrap, will not generate unit-tests" )
262
+ else ()
263
+ list (LENGTH TEST_LIST TEST_LIST_LEN )
264
+ math (EXPR TEST_LIST_LEN ${TEST_LIST_LEN} -1 )
265
+ foreach (I RANGE 0 ${TEST_LIST_LEN} 2 )
266
+ math (EXPR I2 ${I} +1 )
267
+ list (GET TEST_LIST ${I} TEST_NAME )
268
+ list (GET TEST_LIST ${I2} TEST_LINK_ARGS )
269
+ set (EXE test_${TEST_NAME} )
270
+ add_executable (${EXE} test_${TEST_NAME}.c framework /eh_personality.c )
271
+ # asan must be first library in linking order
272
+ target_link_libraries (${EXE} PRIVATE
273
+ $< $< BOOL:${SANITIZE_ADDRESS} > :asan>
274
+ $< $< BOOL:${SANITIZE_UNDEFINED} > :-fsanitize=undefined>
275
+ -Wl,--start-group
276
+ c-unit-tests_rust_c
277
+ bitbox
278
+ -Wl,--end-group
279
+ ${TEST_LINK_ARGS}
280
+ )
281
+ if (NOT ${TEST_NAME} STREQUAL "simulator" )
282
+ add_test (NAME test_${TEST_NAME} COMMAND ${EXE} )
283
+ endif ()
284
+ endforeach ()
285
+ endif ()
282
286
283
287
284
288
# These unit tests for U2F are special because they don't call any bitbox functions directly, instead they go through hid_read/write.
@@ -296,10 +300,10 @@ foreach(TEST_NAME ${U2F_TESTS})
296
300
target_link_libraries (${EXE} PRIVATE
297
301
$< $< BOOL:${SANITIZE_ADDRESS} > :asan>
298
302
$< $< BOOL:${SANITIZE_UNDEFINED} > :-fsanitize=undefined>
299
- -Wl,--start-group
303
+ $< $< NOT: $< PLATFORM_ID:Darwin > > : -Wl,--start-group>
300
304
c-unit-tests_rust_c
301
305
bitbox
302
- -Wl,--end-group
306
+ $< $< NOT: $< PLATFORM_ID:Darwin > > : -Wl,--end-group>
303
307
u2f-util
304
308
)
305
309
target_compile_definitions (${EXE} PRIVATE "TESTING" )
0 commit comments