Project

General

Profile

Revision 01b56d34 regression_tests/lustre_files/success/lego_robot/controller/CMakeLists.txt

View differences:

regression_tests/lustre_files/success/lego_robot/controller/CMakeLists.txt
1 1
cmake_minimum_required(VERSION 2.8.4)
2
include(FindUnixCommands)
3 2

  
4 3

  
4
set(LUSTRE_OPTIONS_OPT "" )
5
set(MAX_INPUT_VALUE 100)
5 6

  
6 7

  
7 8

  
8
#take all lustre files
9
set(GLOBAL_LUSTRE_FILES "")
10
LUSTREFILES(LFILES ${CMAKE_CURRENT_SOURCE_DIR} )
11
list(APPEND GLOBAL_LUSTRE_FILES ${LFILES})
12
FOREACH(lfile ${LFILES})
13
	get_filename_component(L ${lfile} NAME_WE)
14
	set(LUSTRE_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/${L}")
15
	file(COPY ${lfile}   DESTINATION  ${LUSTRE_OUTPUT_DIR})
16
	if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${L}.lusi)
17
	file(COPY  ${L}.lusi DESTINATION  ${LUSTRE_OUTPUT_DIR})
18
	else()
19
		message("generate ${L}.lusi \n")
20
		Lustre_Compile(LUS_FILE ${lfile}
21
				NODE ""
22
				OPTS "-lusi")				
23
		set(LUS_OPTS_CUT ${LUSTRE_OPTS_POSTFIX_${L}})
24
		execute_process(RESULT_VARIABLE res 
25
					COMMAND ${LUSTRE_COMPILER} ${LUSTREC_ARGS_${L}__${LUS_OPTS_CUT}} 
26
					WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
27
		if(${res} STREQUAL "0")
28
			file(COPY  ${L}.lusi DESTINATION  ${LUSTRE_OUTPUT_DIR})
29
		else()
30
			message("${L}.lusi Error")
31
		endif()
32
	endif()
33
	if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${L}_input_values)
34
		file(COPY  ${L}_input_values DESTINATION  ${LUSTRE_OUTPUT_DIR})
35
	elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${L}.lusi)
36
		message("generate input_values \n")
37
		execute_process(RESULT_VARIABLE res 
38
					COMMAND ${JAVA_RUNTIME} -cp ${CMAKE_BINARY_DIR}/modules/ Generate_inputs_lusi ${L} ${L}.lusi 
39
					WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
40
		if(${res} STREQUAL "0")
41
			file(COPY  ${L}_input_values DESTINATION  ${LUSTRE_OUTPUT_DIR})
42
		else()
43
			message("${L}_input_values Error")
44
		endif()
45
	endif()
46
	if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${L}_output_values)
47
		file(COPY  ${L}_output_values DESTINATION  ${LUSTRE_OUTPUT_DIR})
48
	elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${L}_input_values)
49
		message("generate output_values for reference \n")
50
		set(LUSTRE_NODE_OPT  "${L}")
51
		
52
		Lustre_Compile(LUS_FILE ${lfile}
53
						NODE ${LUSTRE_NODE_OPT}
54
						OPTS ""
55
						DIR ${CMAKE_CURRENT_SOURCE_DIR})
56
						
57
		set(LUS_OPTS_CUT ${LUSTRE_OPTS_POSTFIX_${L}})
58
		
59
		execute_process(
60
					COMMAND ${LUSTRE_COMPILER} ${LUSTREC_ARGS_${L}_${LUSTRE_NODE_OPT}_${LUS_OPTS_CUT}} 
61
					WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})			
62
		execute_process(
63
					COMMAND  make -f ${L}.makefile
64
					WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})	
65
		execute_process(RESULT_VARIABLE res 
66
					COMMAND ${BASH} -c "./${L}_${LUSTRE_NODE_OPT} < ${L}_input_values > ${L}_output_values"
67
					WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})	
68
		file(REMOVE ${L}_${LUSTRE_NODE_OPT} io_frontend.o ${L}.c ${L}.h ${L}.lusic ${L}.makefile ${L}.o ${L}_alloc.h ${L}_main.c ${L}_main.o )
69
		if(${res} STREQUAL "0")
70
			file(COPY  ${L}_output_values DESTINATION  ${LUSTRE_OUTPUT_DIR})
71
		else()
72
			message("${L} output_values Error")
73
		endif()
74
	endif()
75
ENDFOREACH()
76

  
77
#first combination :no option
78
set(LUSTRE_OPTIONS_OPT "")
79
FOREACH(lus_file ${GLOBAL_LUSTRE_FILES})
9
set(subdir ${CMAKE_CURRENT_SOURCE_DIR})
10
LUSTREFILES(LFILES ${subdir} )
11
set(TESTS_PREFIX "lego_robot_controller")
12
set(SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
13
set(DST_DIR "${CMAKE_CURRENT_BINARY_DIR}")
14
FOREACH(lus_file ${LFILES})
80 15
	get_filename_component(L ${lus_file} NAME_WE)
81
	set(LUSTRE_NODE_OPT  "${L}")
82
	
83
	# First command generate C files from Lustre file
84
	Lustre_Compile(LUS_FILE ${lus_file}
85
					NODE ${LUSTRE_NODE_OPT}
86
					OPTS ${LUSTRE_OPTIONS_OPT})
87
					
88
	set(LUS_OPTS_CUT ${LUSTRE_OPTS_POSTFIX_${L}})
89
	add_test(NAME lego_robot_controller_COMPIL_LUSTRE_${L}_${LUSTRE_NODE_OPT}_${LUS_OPTS_CUT}
90
			COMMAND  ${LUSTRE_COMPILER} ${LUSTREC_ARGS_${L}_${LUSTRE_NODE_OPT}_${LUS_OPTS_CUT}} 
16
	set(NODE_NAME  "${L}")
17
	Copy_or_generate_lusi_input_and_output_values_for_reference(
18
		LUS_FILE ${lus_file}
19
		NODE ${NODE_NAME}
20
		OPTS ${LUSTRE_OPTIONS_OPT}
21
		MAX ${MAX_INPUT_VALUE}  	#maximum value for input values.
22
		SRC_DIR ${SRC_DIR}
23
		DST_DIR ${DST_DIR}
91 24
	)
92 25

  
93
	 #********************* make -f ${L}.makefile ***************************
94
	 add_test(NAME lego_robot_controller_MAKE_${L}_${LUSTRE_NODE_OPT}_${LUS_OPTS_CUT}
95
			COMMAND  make -f ${L}.makefile
96
			WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${LUSTRE_NODE_OPT}_${LUS_OPTS_CUT}}
26
	Lustre_compile_and_compare_to_reference(
27
		LUS_FILE ${lus_file}
28
		NODE ${NODE_NAME}
29
		TESTS_PREFIX ${TESTS_PREFIX}
30
		OPTS ${LUSTRE_OPTIONS_OPT}
31
		CALL_ID "1"
32
		SRC_DIR ${SRC_DIR}
33
		DST_DIR ${DST_DIR}
97 34
	)
98
	SET_TESTS_PROPERTIES ( lego_robot_controller_MAKE_${L}_${LUSTRE_NODE_OPT}_${LUS_OPTS_CUT}
99
	 PROPERTIES DEPENDS lego_robot_controller_COMPIL_LUSTRE_${L}_${LUSTRE_NODE_OPT}_${LUS_OPTS_CUT}
100
				REQUIRED_FILES ${L}.makefile
101
				)
102
	 
103
	 #************** execute C binary **********************************
104
	
105
	if (BASH)
106
		add_test(
107
			NAME lego_robot_controller_BIN_${L}_${LUSTRE_NODE_OPT}_${LUS_OPTS_CUT} 
108
			COMMAND ${BASH} -c "./${L}_${LUSTRE_NODE_OPT} < ../${L}_input_values > ${L}_${LUSTRE_NODE_OPT}_outputs"
109
			WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${LUSTRE_NODE_OPT}_${LUS_OPTS_CUT}}
110
		)
111
		SET_TESTS_PROPERTIES ( lego_robot_controller_BIN_${L}_${LUSTRE_NODE_OPT}_${LUS_OPTS_CUT}
112
			PROPERTIES REQUIRED_FILES ${L}_${LUSTRE_NODE_OPT}
113
				DEPENDS lego_robot_controller_MAKE_${L}_${LUSTRE_NODE_OPT}_${LUS_OPTS_CUT})
114
	else()
115
		message(FATAL_ERROR "Unknown shell command ${BASH} -c for ${CMAKE_HOST_SYSTEM_NAME}")
116
	endif()
117 35

  
118
	 #************** execute C binary **********************************
119
	 add_test(NAME lego_robot_controller_DIFF_${L}_${LUSTRE_NODE_OPT}_${LUS_OPTS_CUT}
120
			COMMAND ${CMAKE_COMMAND} -E compare_files ${L}_${LUSTRE_NODE_OPT}_outputs ../${L}_output_values 
121
			WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${LUSTRE_NODE_OPT}_${LUS_OPTS_CUT}}
122
	)
123
	SET_TESTS_PROPERTIES ( lego_robot_controller_DIFF_${L}_${LUSTRE_NODE_OPT}_${LUS_OPTS_CUT}
124
	 PROPERTIES REQUIRED_FILES ${L}_${LUSTRE_NODE_OPT}_outputs
125
				DEPENDS lego_robot_controller_BIN_${L}_${LUSTRE_NODE_OPT}_${LUS_OPTS_CUT} )
126 36
ENDFOREACH()
127 37

  
38

  
128 39
add_custom_target(lego_robot_controller COMMAND ${CMAKE_CTEST_COMMAND} -R lego_robot_controller)
129 40

  
41

  
42

  

Also available in: Unified diff