1# 2# 3# Compiling/running tests 4 5if (use_context) 6 add_definitions(-DUSE_CBOR_CONTEXT) 7endif() 8 9set ( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${dist_dir}/test ) 10 11function (create_test name) 12 add_executable ( ${name}_test ${name}_test.c ) 13 target_link_libraries ( ${name}_test PRIVATE cn-cbor ) 14 target_include_directories ( ${name}_test PRIVATE ../include ) 15 add_test ( NAME ${name} COMMAND ${name}_test ) 16endfunction() 17 18create_test ( cbor ) 19include ( CTest ) 20 21if (APPLE) 22 # difftest uses Apple-specific memory tests 23 add_executable (cn-test test.c ) 24 target_include_directories ( cn-test PRIVATE ../include ) 25 target_link_libraries ( cn-test PRIVATE cn-cbor ) 26 27 configure_file(cases.cbor cases.cbor COPYONLY) 28 configure_file(expected.out expected.out COPYONLY) 29 30 add_custom_target(difftest 31 COMMAND env MallocStackLogging=true ./cn-test >new.out 32 COMMAND diff new.out expected.out 33 DEPENDS cn-test 34 WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} 35 COMMENT "generate differences between actual and expected output") 36 37endif() 38