I am trying to write unit test cases using CMAKE ctest .
I want to do unit test on my custom add and inverse function.
The difference between add and inverse test cases
snippshort of my cmake file is showed below :
add_custom_command(
OUTPUT ${output_file_y} ${output_file_txt}
COMMAND ${MY_EXECUTABLE}
ARGS
-lh ${bin_file} 0x10000000
if((${function} STREQUAL "add"))
-lh ${input_file0} 0x10100000
-lh ${input_file1} 0x10200000
elseif((${function} STREQUAL "inverse"))
-lh ${input_file0} 0x10c00000
endif()
${options}
-outfile ${output_file_y}
> ${output_file_txt}
MAIN_DEPENDENCY ${bin_file}
DEPENDS ${map_file} ${input_file0}
COMMENT "Executing ${base_name_mangled}"
)
After doing this I got below Error:
/bin/sh: 1: Syntax error: "(" unexpected ninja: build stopped:
subcommand failed.
Temporary Fixed:
if((${function} STREQUAL "add"))
add_custom_command(
OUTPUT ${output_file_y} ${output_file_txt}
COMMAND ${MY_EXECUTABLE}
ARGS
-lh ${bin_file} 0x10000000
-lh ${input_file0} 0x10100000
-lh ${input_file1} 0x10200000
${options}
-outfile ${output_file_y}
> ${output_file_txt}
MAIN_DEPENDENCY ${bin_file}
DEPENDS ${map_file} ${input_file0}
COMMENT "Executing ${base_name_mangled}"
)
elseif((${function} STREQUAL "inverse"))
add_custom_command(
OUTPUT ${output_file_y} ${output_file_txt}
COMMAND ${MY_EXECUTABLE}
ARGS
-lh ${bin_file} 0x10000000
-lh ${input_file0} 0x10c00000
${options}
-outfile ${output_file_y}
> ${output_file_txt}
MAIN_DEPENDENCY ${bin_file}
DEPENDS ${map_file} ${input_file0}
COMMENT "Executing ${base_name_mangled}"
)
endif()
But in temporary Fixed,it has more copy & paste code .I want to avoid this and combine both the add_custom_command together.
Is there any way to do so.
User contributions licensed under CC BY-SA 3.0