This file is indexed.

/usr/share/camitk-3.3/cmake/macros/CamiTKAddTest.cmake is in libcamitk3-dev 3.3.2-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!
#! @ingroup group_sdk_cmake
#!
#! camitk_add_test is a macro to add a new test to the CTest infrastructure
#! It encapsulates CMake add_test and adds useful way of testing programs.
#! It cannot operate on its on, you need to call camitk_init_test first (and only once) before
#! calling camitk_add_test
#!
#! Details on the runned test can be found in ${CMAKE_BINARY_DIR}/Testing/Temporary/target#
#! where target is the executable name (see camitk_init_test() macro), and # is the test order number.
#!
#! Usage:
#! \code
#! camitk_add_test(EXECUTABLE_ARGS "arg1 arg2 arg3"
#!                 PASS_FILE pristineOutput
#!                 PASS_REGULAR_EXPRESSION regexp
#!                 FAIL_REGULAR_EXPRESSION regexp
#! )
#! \endcode
#!
#! \param EXECUTABLE_ARGS (optional)          The executable arguments (all in double quotes), typically each test will have different arguments. Can be empty
#! \param PASS_FILE (optional)                If specified the test to perform is to compare the output of the command to this file. It the output is the same, then the test is passed, otherwise it is failed.
#! \param PASS_REGULAR_EXPRESSION (optional)  This is equivalent to "PASS_REGULAR_EXPRESSION regexp" property for the test, see http://www.cmake.org/Wiki/CTest:FAQ#My_test_does_not_return_non-zero_on_failure._What_can_I_do.3F
#! \param FAIL_REGULAR_EXPRESSION             This is equivalent to "FAIL_REGULAR_EXPRESSION regexp" property for the test, see http://www.cmake.org/Wiki/CTest:FAQ#My_test_does_not_return_non-zero_on_failure._What_can_I_do.3F
#!
#! If no argument are given, it does the equivalent as add_test(name target)
#!
#! \note
#!   You can only choose one between nothing, PASS_FILE, PASS_REGULAR_EXPRESSION and FAIL_REGULAR_EXPRESSION
#!
#! Example invocation:
#!
#! \code
#!
#! add_executable(myprogram)
#!
#! ...
#! # Start the test series for myprogram
#! camitk_init_test(myprogram)
#! camitk_add_test(EXECUTABLE_ARGS "-a inputfile.xml -c" PASS_FILE pristineOuputToCompareTo.xml) # will be called myprogram1
#! ...
#! camitk_add_test(...) # myprogram2
#!
#! \endcode
#
#! @sa camitk_init_test
macro(camitk_add_test)
    parse_arguments(CAMITK_ADD_TEST
        "EXECUTABLE_ARGS;PASS_FILE;PASS_REGULAR_EXPRESSION;FAIL_REGULAR_EXPRESSION;PASS_FILE_OUTPUT;TEST_SUFFIX;PROJECT_NAME;"  # possible lists #PASS_FILE -> compare the std output to a ref file # PASS_FILE_OUTPUT -> compare two files given as parameters
        "" # possible options
        ${ARGN}
    )

    math(EXPR CAMITK_TEST_ID "${CAMITK_TEST_ID} + 1")
    set(CAMITK_TEST_NAME "${CAMITK_TEST_BASENAME}${CAMITK_ADD_TEST_TEST_SUFFIX}${CAMITK_TEST_ID}")
    set(CAMITK_TEST_LIST ${CAMITK_TEST_LIST} ${CAMITK_TEST_NAME})
#     message(STATUS "Configuring test ${CAMITK_TEST_NAME}")

    #CAMITK_INSTALL_PREFIX is camitk/src/sdk directory ...
    set(CAMITK_INSTALL_PREFIX ${SDK_TOP_LEVEL_SOURCE_DIR})

    # create test output directory
    set(CAMITK_TEST_OUTPUT_DIR "${CMAKE_BINARY_DIR}/Testing/Temporary/${CAMITK_TEST_NAME}")
#     message(STATUS "Creating test output dir ${CAMITK_TEST_OUTPUT_DIR}")
    execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CAMITK_TEST_OUTPUT_DIR})
    # check which test is to be done
    if(CAMITK_ADD_TEST_PASS_FILE)
        add_test(NAME ${CAMITK_TEST_NAME}
                COMMAND ${CMAKE_COMMAND}
                                -DCAMITK_TEST_COMMAND=${CAMITK_INIT_TEST_EXECUTABLE}
                                -DCAMITK_TEST_COMMAND_ARG=${CAMITK_ADD_TEST_EXECUTABLE_ARGS}
                                -DCAMITK_TEST_PASS_FILE=${CAMITK_ADD_TEST_PASS_FILE}
                                -DCAMITK_TEST_OUTPUT_DIR=${CAMITK_TEST_OUTPUT_DIR}
                                -DCAMITK_TEST_NAME=${CAMITK_TEST_NAME}
                                -P ${CAMITK_INSTALL_PREFIX}/cmake/modules/macros/CamiTKTestPassFile.cmake
        )
    elseif(CAMITK_ADD_TEST_PASS_FILE_OUTPUT)
        add_test(NAME ${CAMITK_TEST_NAME}
                COMMAND ${CMAKE_COMMAND}
                                -DCAMITK_TEST_COMMAND=${CAMITK_INIT_TEST_EXECUTABLE}
                                -DCAMITK_TEST_COMMAND_ARG=${CAMITK_ADD_TEST_EXECUTABLE_ARGS}
                                -DCAMITK_TEST_PASS_FILE=${CAMITK_ADD_TEST_PASS_FILE_OUTPUT}
                                -DCAMITK_TEST_OUTPUT_DIR=${CAMITK_TEST_OUTPUT_DIR}
                                -DCAMITK_TEST_NAME=${CAMITK_TEST_NAME}
                                -P ${CAMITK_INSTALL_PREFIX}/cmake/modules/macros/CamiTKTestCompareFile.cmake
        )
    else()
        # set output files for more advanced checking/debugging
        set(CAMITK_TEST_COMMAND_FILE ${CAMITK_TEST_OUTPUT_DIR}/command) # which command is run to test the exectable
        # cleanup
        execute_process(COMMAND ${CMAKE_COMMAND} -E remove -f ${CAMITK_TEST_COMMAND_FILE} )
        file(WRITE ${CAMITK_TEST_COMMAND_FILE} "Test command: ${CAMITK_INIT_TEST_EXECUTABLE} ${CAMITK_ADD_TEST_EXECUTABLE_ARGS}\nPASS_REGULAR_EXPRESSION: '${CAMITK_ADD_TEST_PASS_REGULAR_EXPRESSION}'\n")

        if(CAMITK_ADD_TEST_EXECUTABLE_ARGS)
            # expands all arguments
            string(REPLACE " " ";" CAMITK_TEST_COMMAND_ARG_LIST ${CAMITK_ADD_TEST_EXECUTABLE_ARGS})
        else()
            set(CAMITK_TEST_COMMAND_ARG_LIST)
        endif()
        
        # add the simple test command
        add_test(NAME ${CAMITK_TEST_NAME}
                COMMAND ${CAMITK_INIT_TEST_EXECUTABLE} ${CAMITK_TEST_COMMAND_ARG_LIST}
        )

        # add properties if needed
        if(CAMITK_ADD_TEST_PASS_REGULAR_EXPRESSION)
        set_tests_properties(${CAMITK_TEST_NAME} PROPERTIES PASS_REGULAR_EXPRESSION ${CAMITK_ADD_TEST_PASS_REGULAR_EXPRESSION})
        else()
        if(CAMITK_ADD_TEST_FAIL_REGULAR_EXPRESSION)
            set_tests_properties(${CAMITK_TEST_NAME} PROPERTIES FAIL_REGULAR_EXPRESSION ${CAMITK_ADD_TEST_FAIL_REGULAR_EXPRESSION})
        endif()
        endif()
    endif()

    # set the label for tests
	if( CAMITK_ADD_TEST_PROJECT_NAME )
        set_tests_properties( ${CAMITK_TEST_NAME} PROPERTIES LABELS ${CAMITK_ADD_TEST_PROJECT_NAME} )#associate tests to a project name in CDash 
	else()
	    set_tests_properties( ${CAMITK_TEST_NAME} PROPERTIES LABELS ${CAMITK_TEST_BASENAME} )
	endif()

endmacro()