# This file contains two macro to implement the following # - to generate source for test procedure # - to execute it # - to check coverage # - to generate test report MACRO(tp_init) message("macro tp_init") execute_process( COMMAND basename ${CMAKE_CURRENT_LIST_DIR} OUTPUT_VARIABLE TP_NAME OUTPUT_STRIP_TRAILING_WHITESPACE ) ENDMACRO() MACRO(tp_test_and_coverage) message("macro tp_test_and_coverage") set(CMAKE_C_FLAGS "-Wall -Wextra -std=c99 -g -O0 -m32") add_executable(${TP_NAME} ${DIR_ENV}/main.c ${DIR_ENV}/test_env.c tp.c ${STUB}) set_source_files_properties(tp.c PROPERTIES GENERATED TRUE) set_source_files_properties(tp.c PROPERTIES COMPILE_FLAGS "-fprofile-arcs -ftest-coverage -std=c99 -g -O0 -m32") target_link_libraries(${TP_NAME} gcov) # generate test procedure # by executing our tool gen_tp.sh (generate test procedure) add_custom_command( OUTPUT tp.c DEPENDS ${TP_DIR}/${TP_FILE} COMMAND ${DIR_TOOL}/gen_tp.sh tp.c ${CMAKE_CURRENT_SOURCE_DIR}/test.c ${TP_FILE} COMMENT "generating tp.c" ) # run test procedure add_custom_command( TARGET ${TP_NAME} POST_BUILD COMMAND ${DIR_TOOL}/run_tp.sh ${TP_NAME} ${TP_FILE} COMMENT "running ${TP_NAME}" ) # check coverage add_custom_command( TARGET ${TP_NAME} POST_BUILD COMMAND ${DIR_TOOL}/run_gcov.sh ${TP_NAME} ${TP_FILE} COMMENT "processing test coverage ${TP_NAME}" ) # generate report add_custom_command( TARGET ${TP_NAME} POST_BUILD COMMAND ${DIR_TOOL}/gen_report.sh ${TP_NAME} ${TP_FILE} ${DIR_REPORT} COMMENT "generating test report ${TP_NAME}" ) ENDMACRO() #eof