Project

General

Profile

Download (21.5 KB) Statistics
| Branch: | Tag: | Revision:
1 c79336a0 bourbouh
include(CMakeParseArguments)
2 cac038b0 bourbouh
include(FindUnixCommands)
3 c79336a0 bourbouh
4 cac038b0 bourbouh
5
6
7
#******************first stratefy :generate input values and their outputs for reference
8
function(Copy_or_generate_lusi_input_and_output_values_for_reference )
9 c79336a0 bourbouh
  set(options "")
10 cac038b0 bourbouh
  set(oneValueArgs  NODE LUS_FILE  SRC_DIR DST_DIR MAX)
11 c79336a0 bourbouh
  set(multiValueArgs  OPTS )
12
  cmake_parse_arguments(GEN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
13
14
  #message("check references files for ${GEN_LUS_FILE}  ")
15
  get_filename_component(L ${GEN_LUS_FILE} NAME_WE)
16 cac038b0 bourbouh
  set(LUSTRE_OUTPUT_DIR "${GEN_DST_DIR}/${L}")
17 c79336a0 bourbouh
  file(COPY ${GEN_LUS_FILE}   DESTINATION  ${LUSTRE_OUTPUT_DIR})
18
19
  #generate .lusi if not exists
20 cac038b0 bourbouh
  if(EXISTS ${GEN_SRC_DIR}/${L}.lusi)
21
    file(COPY  ${GEN_SRC_DIR}/${L}.lusi DESTINATION  ${LUSTRE_OUTPUT_DIR})
22 c79336a0 bourbouh
  else()
23
    message("generate ${L}.lusi \n")
24
    Lustre_Compile(LUS_FILE ${GEN_LUS_FILE}
25
      NODE ""
26
      OPTS "-lusi"
27 cac038b0 bourbouh
      DIR ${GEN_SRC_DIR}
28
      DST_DIR ${GEN_DST_DIR})
29
    CUT_OPTIONS("-lusi" GEN_OPTS_CUT_0)
30
    
31 c79336a0 bourbouh
    
32
    execute_process(RESULT_VARIABLE res 
33 cac038b0 bourbouh
     COMMAND ${LUSTRE_COMPILER} ${LUSTREC_ARGS_${L}__${GEN_OPTS_CUT_0}} 
34
     WORKING_DIRECTORY ${GEN_SRC_DIR})
35 c79336a0 bourbouh
    if(${res} STREQUAL "0")
36 cac038b0 bourbouh
      file(COPY  ${GEN_SRC_DIR}/${L}.lusi DESTINATION  ${LUSTRE_OUTPUT_DIR})
37 c79336a0 bourbouh
    else()
38
      message(FATAL_ERROR "${L}.lusi couldn't be generated")
39
    endif()
40
  endif()
41
42 cac038b0 bourbouh
43 c79336a0 bourbouh
  #generate input and output values
44 cac038b0 bourbouh
  if(EXISTS ${GEN_SRC_DIR}/${L}_${GEN_NODE}_input_values)
45
    file(COPY  ${GEN_SRC_DIR}/${L}_${GEN_NODE}_input_values DESTINATION  ${LUSTRE_OUTPUT_DIR})
46
  elseif(EXISTS ${GEN_SRC_DIR}/${L}.lusi)
47 c79336a0 bourbouh
    message("generate ${L}_${GEN_NODE}_input_values \n")
48 ff8f35e0 ploc
# message (" command is ${JAVA_RUNTIME} -cp ${CMAKE_BINARY_DIR}/modules/ Generate_inputs_lusi ${GEN_NODE} ${L}.lusi ${GEN_MAX}" )
49 c79336a0 bourbouh
    execute_process(RESULT_VARIABLE res 
50
      COMMAND ${JAVA_RUNTIME} -cp ${CMAKE_BINARY_DIR}/modules/ Generate_inputs_lusi ${GEN_NODE} ${L}.lusi ${GEN_MAX}
51 cac038b0 bourbouh
      WORKING_DIRECTORY ${GEN_SRC_DIR})
52 c79336a0 bourbouh
53
    if(${res} STREQUAL "0")
54 cac038b0 bourbouh
      file(COPY  ${GEN_SRC_DIR}/${L}_${GEN_NODE}_input_values DESTINATION  ${LUSTRE_OUTPUT_DIR})
55 c79336a0 bourbouh
    else()
56
      message(FATAL_ERROR "${L}_input_values couldn't be generated")
57
    endif()
58
  endif()
59
60
  if(GEN_OPTS)
61 cac038b0 bourbouh
    CUT_OPTIONS("${GEN_OPTS}" GEN_OPTS_CUT)
62 c79336a0 bourbouh
  endif()
63
  
64 cac038b0 bourbouh
  if(EXISTS ${GEN_SRC_DIR}/${L}_${GEN_NODE}_${GEN_OPTS_CUT}_output_values)
65
    file(COPY  ${GEN_SRC_DIR}/${L}_${GEN_NODE}_${GEN_OPTS_CUT}_output_values DESTINATION  ${LUSTRE_OUTPUT_DIR})
66
  elseif(EXISTS ${GEN_SRC_DIR}/${L}_${GEN_NODE}_input_values)
67 c79336a0 bourbouh
    message("generate  ${L}_${GEN_NODE}_${GEN_OPTS_CUT}_output_values for reference \n")
68
        
69
    Lustre_Compile(LUS_FILE ${GEN_LUS_FILE}
70
      NODE ${GEN_NODE}
71 cac038b0 bourbouh
      OPTS ${GEN_OPTS}
72
      DIR ${GEN_SRC_DIR}
73
      DST_DIR ${GEN_DST_DIR})
74 c79336a0 bourbouh
    
75
    execute_process(
76 cac038b0 bourbouh
      COMMAND ${LUSTRE_COMPILER} ${LUSTREC_ARGS_${L}_${GEN_NODE}_${GEN_OPTS_CUT}} 
77
      WORKING_DIRECTORY ${GEN_SRC_DIR})			
78 c79336a0 bourbouh
    execute_process(
79
      COMMAND  make -f ${L}.makefile
80 cac038b0 bourbouh
      WORKING_DIRECTORY ${GEN_SRC_DIR})	
81 8451150a hbourbou
82
if(EXISTS ${GEN_SRC_DIR}/${L}_${GEN_NODE})
83 c79336a0 bourbouh
    execute_process(RESULT_VARIABLE res 
84
      COMMAND ${BASH} -c "./${L}_${GEN_NODE} < ${L}_${GEN_NODE}_input_values > ${L}_${GEN_NODE}_${GEN_OPTS_CUT}_output_values"
85 cac038b0 bourbouh
      WORKING_DIRECTORY ${GEN_SRC_DIR})	
86
    file(REMOVE ${GEN_SRC_DIR}/${L}_${GEN_NODE} ${GEN_SRC_DIR}/io_frontend.o ${GEN_SRC_DIR}/${L}.c ${GEN_SRC_DIR}/${L}.h ${GEN_SRC_DIR}/${L}.lusic ${GEN_SRC_DIR}/${L}.makefile ${GEN_SRC_DIR}/${L}.o ${GEN_SRC_DIR}/${L}_alloc.h ${GEN_SRC_DIR}/${L}_main.c ${GEN_SRC_DIR}/${L}_main.o )
87 c79336a0 bourbouh
    if(${res} STREQUAL "0")
88 cac038b0 bourbouh
      file(COPY  ${GEN_SRC_DIR}/${L}_${GEN_NODE}_${GEN_OPTS_CUT}_output_values DESTINATION  ${LUSTRE_OUTPUT_DIR})
89 c79336a0 bourbouh
    else()
90
      message(FATAL_ERROR "${L}_${GEN_NODE}_${GEN_OPTS_CUT}_output_values Error")
91
    endif()
92
  endif()
93 8451150a hbourbou
  endif()
94 c79336a0 bourbouh
95
96 cac038b0 bourbouh
endfunction(Copy_or_generate_lusi_input_and_output_values_for_reference)
97
98
99
100
101
102
103
104
105
106
107
#****************************second stratefy :generate zustre output.xml for reference
108
function(Copy_or_generate_zustre_output_xml_for_reference )
109
  set(options "")
110
  set(oneValueArgs  NODE LUS_FILE SRC_DIR DST_DIR)
111
  set(multiValueArgs  OPTS )
112
  cmake_parse_arguments(GEN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
113
114
  if(GEN_OPTS)
115
    CUT_OPTIONS("${GEN_OPTS}" ZUS_OPTS_CUT)
116
  endif()
117 d895591e ploc
  get_lustre_name_ext(${GEN_LUS_FILE} L E)
118
119
  #get_filename_component(L ${GEN_LUS_FILE} NAME_WE)
120 cac038b0 bourbouh
  set(LUSTRE_OUTPUT_DIR "${GEN_DST_DIR}/${L}")
121
  if(EXISTS ${GEN_SRC_DIR}/${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml)
122
    file(COPY ${GEN_SRC_DIR}/${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml   DESTINATION  ${LUSTRE_OUTPUT_DIR})
123
    file(READ ${GEN_SRC_DIR}/${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml ${L}_${GEN_NODE}_zustre_output)		
124
  else()
125
    message("generate ${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml for reference\n")
126
    Zustre_Compile(LUS_FILE ${GEN_LUS_FILE}
127
      NODE ${GEN_NODE}
128
      OPTS ${GEN_OPTS}
129
      DST_DIR ${GEN_DST_DIR}
130
      )
131
132
    execute_process(RESULT_VARIABLE res 
133
      OUTPUT_VARIABLE ${L}_${GEN_NODE}_zustre_output
134
      COMMAND  ${ZUSTRE_COMPILER} ${ZUSTRE_ARGS_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}} 
135
      WORKING_DIRECTORY ${GEN_SRC_DIR})
136
    
137
    file(WRITE ${GEN_SRC_DIR}/${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml ${${L}_${GEN_NODE}_zustre_output})
138
    file(COPY ${GEN_SRC_DIR}/${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml   DESTINATION  ${LUSTRE_OUTPUT_DIR})
139
    
140
  endif()
141
  if( ${${L}_${GEN_NODE}_zustre_output} MATCHES "<Answer>CEX</Answer>")
142
    set(ZUSTRE_ANSWER "CEX")
143
  elseif( ${${L}_${GEN_NODE}_zustre_output} MATCHES "<Answer>SAFE</Answer>")
144
    set(ZUSTRE_ANSWER "SAFE")
145
  elseif( ${${L}_${GEN_NODE}_zustre_output} MATCHES "<Answer>TIMEOUT</Answer>")
146
    set(ZUSTRE_ANSWER "TIMEOUT")
147
  else()
148
    set(ZUSTRE_ANSWER "ERROR")
149
  endif()
150
  set(ZUSTRE_ANSWER_${L}_${GEN_NODE} "${ZUSTRE_ANSWER}" PARENT_SCOPE)
151
endfunction(Copy_or_generate_zustre_output_xml_for_reference )
152
153
154
155
156
157
158
159
#***********************third strategy: Compile with zustre and compare
160
161
function(Zustre_compile_and_compare_to_reference)
162
  set(options "")
163
  set(oneValueArgs  NODE LUS_FILE  TESTS_PREFIX CALL_ID SRC_DIR DST_DIR)
164
  set(multiValueArgs  OPTS )
165
  cmake_parse_arguments(GEN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
166
167
168 d895591e ploc
  get_lustre_name_ext(${GEN_LUS_FILE} L E)
169
  #get_filename_component(L ${GEN_LUS_FILE} NAME_WE)
170 cac038b0 bourbouh
  
171
  Lustre_Compile(LUS_FILE ${GEN_LUS_FILE}
172
    NODE ""
173
    OPTS "-horn"
174
    DST_DIR ${GEN_DST_DIR}
175
    )
176
  CUT_OPTIONS("-horn" LUS_OPTS_CUT)
177
   
178
  add_test(NAME ${GEN_TESTS_PREFIX}_COMPIL_LUSTRE_HORN_${L}__${LUS_OPTS_CUT}_${GEN_CALL_ID}
179
    COMMAND  ${LUSTRE_COMPILER} ${LUSTREC_ARGS_${L}__${LUS_OPTS_CUT}} 
180
    )
181
182
  Zustre_Compile(LUS_FILE ${GEN_LUS_FILE}
183
    NODE ${GEN_NODE}
184
    OPTS ${GEN_OPTS}
185
    DST_DIR ${GEN_DST_DIR}
186
    )
187
  
188
  if(GEN_OPTS)
189
    CUT_OPTIONS("${GEN_OPTS}" ZUS_OPTS_CUT)
190
  endif()
191
  
192
  set(ZUSTRE_OUTPUT_DIR ${ZUSTRE_OUTPUT_DIR_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}})
193
  
194
  set(ZUSTRE_ARGS_TEMP "${ZUSTRE_ARGS_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}}" "> ${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml")
195
  JOIN("${ZUSTRE_ARGS_TEMP}" " " ZUSTRE_ARGS)
196
  
197
  add_test(NAME ${GEN_TESTS_PREFIX}_COMPIL_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID}
198
    COMMAND bash -c "${ZUSTRE_COMPILER} ${ZUSTRE_ARGS}"
199
    WORKING_DIRECTORY ${ZUSTRE_OUTPUT_DIR}
200
    )
201
  SET_TESTS_PROPERTIES (  ${GEN_TESTS_PREFIX}_COMPIL_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID}
202 5600dad4 bourbouh
    PROPERTIES FAIL_REGULAR_EXPRESSION "AssertionError;ERROR;Failed;Traceback"
203 cac038b0 bourbouh
    DEPENDS ${GEN_TESTS_PREFIX}_COMPIL_LUSTRE_HORN_${L}__${LUS_OPTS_CUT}_${GEN_CALL_ID})
204
  
205 6d1a5792 ploc
  add_test(NAME ${GEN_TESTS_PREFIX}_COMPARE_REF_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID}
206
    COMMAND ${CMAKE_COMMAND} -DREF=${GEN_DST_DIR}/${L}/${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml
207
                             -DGEN=${ZUSTRE_OUTPUT_DIR}/${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml
208
    	    -P ${CMAKE_SOURCE_DIR}/modules/compare_ref_zustre.cmake
209
210 cac038b0 bourbouh
    WORKING_DIRECTORY ${ZUSTRE_OUTPUT_DIR}
211
    )
212 6d1a5792 ploc
  SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_COMPARE_REF_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID}
213
    PROPERTIES REQUIRED_FILES  "${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml"
214 cac038b0 bourbouh
    DEPENDS ${GEN_TESTS_PREFIX}_COMPIL_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID})
215 6d1a5792 ploc
216 cac038b0 bourbouh
  
217 6d1a5792 ploc
  # add_test(NAME ${GEN_TESTS_PREFIX}_TAILGEN_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID}
218
  #   COMMAND bash -c "tail -n +8 ${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml > ${L}_tailed1.xml; | grep Answer | awk '{$1=$1};1'"
219
  #   WORKING_DIRECTORY ${ZUSTRE_OUTPUT_DIR}
220
  #   )
221
  # SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_TAILGEN_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID}
222
  #   PROPERTIES REQUIRED_FILES  ${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml
223
  #   DEPENDS ${GEN_TESTS_PREFIX}_COMPIL_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID})
224 cac038b0 bourbouh
  
225 6d1a5792 ploc
  # add_test(NAME ${GEN_TESTS_PREFIX}_TAILREF_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID}
226
  #   COMMAND bash -c "tail -n +8 ${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml > ${L}_${GEN_NODE}_tailed2.xml"
227
  #   WORKING_DIRECTORY ${GEN_DST_DIR}/${L}/
228
  #   )
229
  # SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_TAILREF_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID}
230
  #   PROPERTIES REQUIRED_FILES  ${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml
231
  #   DEPENDS ${GEN_TESTS_PREFIX}_TAILGEN_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID})
232 cac038b0 bourbouh
  
233 6d1a5792 ploc
  
234
  # add_test(NAME ${GEN_TESTS_PREFIX}_DIFF_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID}
235
  #   COMMAND ${CMAKE_COMMAND} -E compare_files  ${L}_tailed1.xml  ../${L}_${GEN_NODE}_tailed2.xml
236
  #   WORKING_DIRECTORY ${ZUSTRE_OUTPUT_DIR}
237
  #   )
238
  # SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_DIFF_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID}
239
  #   PROPERTIES REQUIRED_FILES  ${L}_tailed1.xml
240
  #   DEPENDS ${GEN_TESTS_PREFIX}_TAILREF_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID})	
241 cac038b0 bourbouh
242
endfunction(Zustre_compile_and_compare_to_reference)
243
244
245
246
247
248
249
250
251
252
#***********************fourth strategy: compare in case of CEX examples the Zustre trace with lustrec
253
function(Compare_Zustre_and_Lustrec_outputs)
254 ff8f35e0 ploc
  set(options MYJAVADIFF)
255
  set(oneValueArgs  NODE LUS_FILE  CALL_ID TESTS_PREFIX SRC_DIR DST_DIR DIFF_EPSILON)
256 cac038b0 bourbouh
  set(multiValueArgs  OPTS )
257
  cmake_parse_arguments(GEN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
258
259
  
260 d895591e ploc
  get_lustre_name_ext(${GEN_LUS_FILE} L E)
261
  #get_filename_component(L ${GEN_LUS_FILE} NAME_WE)
262 cac038b0 bourbouh
263
  Zustre_Compile(LUS_FILE ${GEN_LUS_FILE}
264
    NODE ${GEN_NODE}
265
    OPTS ${GEN_OPTS}
266
    DST_DIR ${GEN_DST_DIR}
267
    )
268
  if(GEN_OPTS)
269
    CUT_OPTIONS("${GEN_OPTS}" ZUS_OPTS_CUT)
270
  endif()
271
  set(ZUSTRE_OUTPUT_DIR ${ZUSTRE_OUTPUT_DIR_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}})
272
 
273
274
275
  add_test(NAME ${GEN_TESTS_PREFIX}_XPathParser_lusi_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID}
276
    COMMAND ${JAVA_RUNTIME} -cp ${CMAKE_BINARY_DIR}/modules/ XPathParser_lusi ${GEN_NODE} ../${L}.lusi ${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml
277
    WORKING_DIRECTORY ${ZUSTRE_OUTPUT_DIR}
278
    )
279
  SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_XPathParser_lusi_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID}
280
    PROPERTIES REQUIRED_FILES  ${GEN_DST_DIR}/${L}/${L}.lusi 
281
    DEPENDS ${GEN_TESTS_PREFIX}_COMPIL_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID} )	
282
  
283
  Lustre_Compile(LUS_FILE ${lus_file}
284
    NODE ${GEN_NODE}
285
    OPTS ""
286
    DIR ${ZUSTRE_OUTPUT_DIR}
287
    DST_DIR ${GEN_DST_DIR})
288
  
289
  set(LUS_OPTS_CUT "")
290
  add_test(NAME ${GEN_TESTS_PREFIX}_COMPIL_LUSTRE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
291
    COMMAND  ${LUSTRE_COMPILER} ${LUSTREC_ARGS_${L}_${GEN_NODE}_${LUS_OPTS_CUT}} 
292
    WORKING_DIRECTORY ${ZUSTRE_OUTPUT_DIR}
293
    )
294
295
  add_test(NAME ${GEN_TESTS_PREFIX}_MAKE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
296
    COMMAND  make -f ${L}.makefile
297
    WORKING_DIRECTORY ${ZUSTRE_OUTPUT_DIR}
298
    )
299
  SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_MAKE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
300
    PROPERTIES DEPENDS ${GEN_TESTS_PREFIX}_COMPIL_LUSTRE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
301
    REQUIRED_FILES ${L}.makefile
302
    )
303
  
304
  
305
  if (BASH)
306
    add_test(
307
      NAME ${GEN_TESTS_PREFIX}_BIN_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID} 
308
      COMMAND ${BASH} -c "./${L}_${GEN_NODE} < input_values > ${L}_${GEN_NODE}_outputs"
309
      WORKING_DIRECTORY ${ZUSTRE_OUTPUT_DIR}
310
      )
311
    SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_BIN_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
312
      PROPERTIES REQUIRED_FILES ${L}_${GEN_NODE}
313
      DEPENDS ${GEN_TESTS_PREFIX}_MAKE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID})
314
  else()
315
    message(FATAL_ERROR "Unknown shell command for ${CMAKE_HOST_SYSTEM_NAME}")
316
  endif()
317
318
  #************** compare **********************************
319 ff8f35e0 ploc
  if (${MYJAVADIFF})
320
    add_test(NAME ${GEN_TESTS_PREFIX}_COMPARE_OUTPUTS_OF_LUSTREC_ZUSTRE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
321
      COMMAND ${JAVA_RUNTIME} -cp ${CMAKE_BINARY_DIR}/modules/ compare_lustrec_outputs ${L}_${GEN_NODE}_outputs ZUSTRE_output_values ${DIFF_EPSILON}
322
      WORKING_DIRECTORY ${ZUSTRE_OUTPUT_DIR}
323
      )
324
  else()
325
    add_test(NAME ${GEN_TESTS_PREFIX}_COMPARE_OUTPUTS_OF_LUSTREC_ZUSTRE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
326
      COMMAND diff -y ${L}_${GEN_NODE}_outputs ZUSTRE_output_values
327
      WORKING_DIRECTORY ${ZUSTRE_OUTPUT_DIR}
328
      )
329
  endif()
330 cac038b0 bourbouh
  SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_COMPARE_OUTPUTS_OF_LUSTREC_ZUSTRE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
331
    PROPERTIES REQUIRED_FILES ${L}_${GEN_NODE}_outputs
332
    DEPENDS ${GEN_TESTS_PREFIX}_BIN_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID} )
333
  
334
  
335
336
337
338
339
endfunction()
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
#******************************fifth strategy, test the lustrec binary with outputs of reference
364
365
366
function(Lustre_compile_and_compare_to_reference)
367 ff8f35e0 ploc
  set(options MYJAVADIFF)
368
  set(oneValueArgs  NODE LUS_FILE CALL_ID  TESTS_PREFIX SRC_DIR DST_DIR DIFF_EPSILON)
369 cac038b0 bourbouh
  set(multiValueArgs  OPTS )
370
  cmake_parse_arguments(GEN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
371
372 d895591e ploc
  get_lustre_name_ext(${GEN_LUS_FILE} L E)
373
  #get_filename_component(L ${GEN_LUS_FILE} NAME_WE)
374 cac038b0 bourbouh
  # First command generate C files from Lustre file
375
  Lustre_Compile(LUS_FILE ${GEN_LUS_FILE}
376
    NODE ${GEN_NODE}
377
    OPTS ${GEN_OPTS}
378
    DST_DIR ${GEN_DST_DIR}
379
    )
380
  if(GEN_OPTS)
381
    CUT_OPTIONS("${GEN_OPTS}" LUS_OPTS_CUT)
382
  endif()
383
384
  add_test(NAME ${GEN_TESTS_PREFIX}_COMPIL_LUSTRE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
385
    COMMAND  ${LUSTRE_COMPILER} ${LUSTREC_ARGS_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
386
    WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
387
    )
388
389
  #********************* make -f ${L}.makefile ***************************
390
  add_test(NAME ${GEN_TESTS_PREFIX}_MAKE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
391
    COMMAND  make -f ${L}.makefile
392
    WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
393
    )
394
  SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_MAKE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
395
    PROPERTIES DEPENDS ${GEN_TESTS_PREFIX}_COMPIL_LUSTRE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
396
    REQUIRED_FILES ${L}.makefile
397
    )
398
  
399
  #************** execute C binary **********************************
400
  
401
  if (BASH)
402
    add_test(
403
      NAME ${GEN_TESTS_PREFIX}_BIN_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID} 
404
      COMMAND ${BASH} -c "./${L}_${GEN_NODE} < ../${L}_${GEN_NODE}_input_values > ${L}_${GEN_NODE}_${LUS_OPTS_CUT}_output_values"
405
      WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
406
      )
407
    SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_BIN_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
408
      PROPERTIES REQUIRED_FILES ${L}_${GEN_NODE}
409
      DEPENDS ${GEN_TESTS_PREFIX}_MAKE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID})
410
  else()
411
    message(FATAL_ERROR "Unknown shell command ${BASH} -c for ${CMAKE_HOST_SYSTEM_NAME}")
412
  endif()
413
414
  #************** execute C binary **********************************
415 ff8f35e0 ploc
  if (${MYJAVADIFF})
416
    add_test(NAME ${GEN_TESTS_PREFIX}_DIFF_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
417 f4893943 ploc
      COMMAND ${JAVA_RUNTIME} -cp ${CMAKE_BINARY_DIR}/modules/ compare_lustrec_outputs ${L}_${GEN_NODE}_${LUS_OPTS_CUT}_output_values ../${L}_${GEN_NODE}__${LUS_OPTS_CUT}_output_values ${DIFF_EPSILON}
418 ff8f35e0 ploc
      WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
419
      )
420
  else()
421
    add_test(NAME ${GEN_TESTS_PREFIX}_DIFF_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
422 f4893943 ploc
      COMMAND diff -y ${L}_${GEN_NODE}_${LUS_OPTS_CUT}_output_values ../${L}_${GEN_NODE}_${LUS_OPTS_CUT}_output_values 
423 ff8f35e0 ploc
      WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
424
      )
425
  endif()
426 cac038b0 bourbouh
  SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_DIFF_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
427
    PROPERTIES REQUIRED_FILES  ${L}_${GEN_NODE}_${LUS_OPTS_CUT}_output_values
428
    DEPENDS ${GEN_TESTS_PREFIX}_BIN_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID} )
429
430
endfunction()
431
432
433
434
435
436 29e431d5 ploc
#******************************sixth strategy, subset of fifth, no execution, just calls to lustrec
437
438
439
function(Lustre_compile_options)
440
  set(options "")
441
  set(oneValueArgs  NODE LUS_FILE CALL_ID  TESTS_PREFIX SRC_DIR DST_DIR)
442
  set(multiValueArgs  OPTS )
443
  cmake_parse_arguments(GEN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
444
445 d895591e ploc
  get_lustre_name_ext(${GEN_LUS_FILE} L E)
446
  #get_filename_component(L ${GEN_LUS_FILE} NAME_WE)
447 29e431d5 ploc
  # First command generate C files from Lustre file
448
  Lustre_Compile(LUS_FILE ${GEN_LUS_FILE}
449
    NODE ${GEN_NODE}
450
    OPTS ${GEN_OPTS}
451
    DST_DIR ${GEN_DST_DIR}
452
    )
453
  if(GEN_OPTS)
454
    CUT_OPTIONS("${GEN_OPTS}" LUS_OPTS_CUT)
455
  endif()
456
457
  add_test(NAME ${GEN_TESTS_PREFIX}_COMPIL_LUSTRE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
458
    COMMAND  ${LUSTRE_COMPILER} ${LUSTREC_ARGS_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
459
    WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
460
    )
461
462
  #********* EMF Validation
463
  STRING(FIND "${LUS_OPTS_CUT}" "emf" matchres)
464
  IF(${matchres} EQUAL 0)
465
    add_test(
466
      NAME ${GEN_TESTS_PREFIX}_EMF_VALIDATE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID} 
467
      COMMAND ${BASH} -c "cat ./${L}.emf | python -m json.tool"
468
      WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
469
      )
470
    SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_EMF_VALIDATE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
471
      PROPERTIES REQUIRED_FILES ${L}.emf
472
      DEPENDS ${GEN_TESTS_PREFIX}_COMPIL_LUSTRE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID})
473
  endif()
474
475
endfunction()
476
477
478
479 d895591e ploc
#****************************** LustreT strategies: generating the MCDC coverage 
480
481 29e431d5 ploc
482 d895591e ploc
function(LustreT_MCDC)
483
  set(options "")
484
  set(oneValueArgs  NODE LUS_FILE CALL_ID  SRC_DIR DST_DIR)
485
  set(multiValueArgs  OPTS )
486
  cmake_parse_arguments(GEN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
487
488
  get_lustre_name_ext(${GEN_LUS_FILE} L E)
489
#  get_filename_component(L ${GEN_LUS_FILE} NAME_WE)
490
  # First command generate C files from Lustre file
491
  Lustre_Compile(LUS_FILE ${GEN_LUS_FILE}
492
    NODE ${GEN_NODE}
493
    OPTS ${GEN_OPTS}
494
    DIR "${GEN_DST_DIR}/${L}/node_${GEN_NODE}_MCDC"
495
#    DST_DIR ${GEN_DST_DIR}
496
    )
497
498
#    set(LUSTRE_OUTPUT_DIR "${OUTPUT_PATH}/${L}/node_${LUS_NODE}")
499
500
  file(MAKE_DIRECTORY "${GEN_DST_DIR}/${L}/node_${GEN_NODE}_MCDC")
501
502
  add_test(NAME LUSTRET_MCDC_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
503
    COMMAND  ${LUSTRE_T} -mcdc-cond ${LUSTREC_ARGS_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
504
    WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
505
    )
506
507
   set(MCDC_SRC "${GEN_DST_DIR}/${L}/node_${GEN_NODE}_MCDC/${L}.mcdc.lus")
508
   Lustre_Compile(LUS_FILE "${MCDC_SRC}"
509
     NODE ${GEN_NODE}
510
     OPTS ${GEN_OPTS}
511
     DIR "${GEN_DST_DIR}/${L}/node_${GEN_NODE}_MCDC"
512
 #    DST_DIR ${GEN_DST_DIR}
513
     )
514
515
  
516
  add_test(NAME LUSTRET_MCDC_COMPILE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
517
    COMMAND  ${LUSTRE_COMPILER} ${LUSTREC_ARGS_${L}.mcdc_${GEN_NODE}_${LUS_OPTS_CUT}}
518
    WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_mcdc_${GEN_NODE}_${LUS_OPTS_CUT}}
519
    )
520
521
  SET_TESTS_PROPERTIES ( LUSTRET_MCDC_COMPILE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
522
    PROPERTIES 
523
    DEPENDS LUSTRET_MCDC_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID})
524
  
525
endfunction()
526
527
#****************************** LustreT strategies: generating the mutants
528
529
530
function(LustreT_mutants)
531
  set(options "")
532
  set(oneValueArgs  NODE LUS_FILE CALL_ID  SRC_DIR DST_DIR)
533
  set(multiValueArgs  OPTS )
534
  cmake_parse_arguments(GEN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
535
536
  get_lustre_name_ext(${GEN_LUS_FILE} L E)
537
#  get_filename_component(L ${GEN_LUS_FILE} NAME_WE)
538
  # First command generate C files from Lustre file
539
  Lustre_Compile(LUS_FILE ${GEN_LUS_FILE}
540
    NODE ${GEN_NODE}
541
    OPTS ${GEN_OPTS}
542
    DIR "${GEN_DST_DIR}/${L}/node_${GEN_NODE}_Mutants"
543
#    DST_DIR ${GEN_DST_DIR}
544
    )
545
546
#    set(LUSTRE_OUTPUT_DIR "${OUTPUT_PATH}/${L}/node_${LUS_NODE}")
547
548
  file(MAKE_DIRECTORY "${GEN_DST_DIR}/${L}/node_${GEN_NODE}_Mutants")
549
550
  add_test(NAME LUSTRET_MUTATION_GEN_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
551
    COMMAND  ${LUSTRE_T} ${LUSTREC_ARGS_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
552
    WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
553
    )
554
555
  add_test(NAME LUSTRET_MUTATION_BUILDMAKE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
556
    COMMAND  "cmake" "."
557
    WORKING_DIRECTORY ${GEN_DST_DIR}/${L}/node_${GEN_NODE}_Mutants
558
    )
559
560
  add_test(NAME LUSTRET_MUTATION_BUILDBIN_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
561
    COMMAND  "make"
562
    WORKING_DIRECTORY ${GEN_DST_DIR}/${L}/node_${GEN_NODE}_Mutants
563
    )
564
565
  SET_TESTS_PROPERTIES ( LUSTRET_MUTATION_BUILDMAKE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
566
    PROPERTIES 
567
    DEPENDS LUSTRET_MUTATION_GEN_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID} )
568
569
  SET_TESTS_PROPERTIES ( LUSTRET_MUTATION_BUILDBIN_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
570
    PROPERTIES 
571
    DEPENDS LUSTRET_MUTATION_BUILDMAKE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID} )
572
573
endfunction()
574 29e431d5 ploc
575 cac038b0 bourbouh
576
577
578