Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec-tests / regression_tests / modules / strategies.cmake @ ea143160

History | View | Annotate | Download (25.5 KB)

1
include(CMakeParseArguments)
2
include(FindUnixCommands)
3

    
4

    
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
  set(options "")
10
  set(oneValueArgs  NODE LUS_FILE  SRC_DIR DST_DIR MAX)
11
  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
  get_lustre_name_ext(${GEN_LUS_FILE} L E)
17
  set(LUSTRE_OUTPUT_DIR "${GEN_DST_DIR}/${L}")
18
  file(COPY ${GEN_LUS_FILE}   DESTINATION  ${LUSTRE_OUTPUT_DIR})
19

    
20
  #generate .lusi if not exists
21
  if(EXISTS ${GEN_SRC_DIR}/${L}.lusi)
22
    file(COPY  ${GEN_SRC_DIR}/${L}.lusi DESTINATION  ${LUSTRE_OUTPUT_DIR})
23
  else()
24
    message("generate ${L}.lusi \n")
25
    Lustre_Compile(LUS_FILE ${GEN_LUS_FILE}
26
      NODE ""
27
      OPTS "-lusi"
28
      DIR ${GEN_SRC_DIR}
29
      DST_DIR ${GEN_DST_DIR})
30
    CUT_OPTIONS("-lusi" GEN_OPTS_CUT_0)
31
    
32
    
33
    execute_process(RESULT_VARIABLE res 
34
     COMMAND ${LUSTRE_COMPILER} ${LUSTREC_ARGS_${L}__${GEN_OPTS_CUT_0}} 
35
     WORKING_DIRECTORY ${GEN_SRC_DIR})
36
    if(${res} STREQUAL "0")
37
      file(COPY  ${GEN_SRC_DIR}/${L}.lusi DESTINATION  ${LUSTRE_OUTPUT_DIR})
38
    else()
39
      message(FATAL_ERROR "${L}.lusi couldn't be generated")
40
    endif()
41
  endif()
42

    
43

    
44
  #generate input and output values
45
  if(EXISTS ${GEN_SRC_DIR}/${L}_${GEN_NODE}_input_values)
46
    file(COPY  ${GEN_SRC_DIR}/${L}_${GEN_NODE}_input_values DESTINATION  ${LUSTRE_OUTPUT_DIR})
47
  elseif(EXISTS ${GEN_SRC_DIR}/${L}.lusi)
48
    message("generate ${L}_${GEN_NODE}_input_values \n")
49
# message (" command is ${JAVA_RUNTIME} -cp ${CMAKE_BINARY_DIR}/modules/ Generate_inputs_lusi ${GEN_NODE} ${L}.lusi ${GEN_MAX}" )
50
    execute_process(RESULT_VARIABLE res 
51
      COMMAND ${JAVA_RUNTIME} -cp ${CMAKE_BINARY_DIR}/modules/ Generate_inputs_lusi ${GEN_NODE} ${L}.lusi ${GEN_MAX}
52
      WORKING_DIRECTORY ${GEN_SRC_DIR})
53

    
54
    if(${res} STREQUAL "0")
55
      file(COPY  ${GEN_SRC_DIR}/${L}_${GEN_NODE}_input_values DESTINATION  ${LUSTRE_OUTPUT_DIR})
56
    else()
57
      message(FATAL_ERROR "${L}_input_values couldn't be generated")
58
    endif()
59
  endif()
60

    
61
  if(GEN_OPTS)
62
    CUT_OPTIONS("${GEN_OPTS}" GEN_OPTS_CUT)
63
  endif()
64
  
65
  if(EXISTS ${GEN_SRC_DIR}/${L}_${GEN_NODE}_${GEN_OPTS_CUT}_output_values)
66
    file(COPY  ${GEN_SRC_DIR}/${L}_${GEN_NODE}_${GEN_OPTS_CUT}_output_values DESTINATION  ${LUSTRE_OUTPUT_DIR})
67
  elseif(EXISTS ${GEN_SRC_DIR}/${L}_${GEN_NODE}_input_values)
68
    message("generate  ${L}_${GEN_NODE}_${GEN_OPTS_CUT}_output_values for reference \n")
69
        
70
    Lustre_Compile(LUS_FILE ${GEN_LUS_FILE}
71
      NODE ${GEN_NODE}
72
      OPTS ${GEN_OPTS}
73
      DIR ${GEN_SRC_DIR}
74
      DST_DIR ${GEN_DST_DIR})
75
    
76
    execute_process(
77
      COMMAND ${LUSTRE_COMPILER} ${LUSTREC_ARGS_${L}_${GEN_NODE}_${GEN_OPTS_CUT}} 
78
      WORKING_DIRECTORY ${GEN_SRC_DIR})			
79
    execute_process(
80
      COMMAND  make -f ${L}.makefile
81
      WORKING_DIRECTORY ${GEN_SRC_DIR})	
82

    
83
    if(EXISTS ${GEN_SRC_DIR}/${L}_${GEN_NODE})
84
        execute_process(RESULT_VARIABLE res 
85
          COMMAND ${BASH} -c "./${L}_${GEN_NODE} < ${L}_${GEN_NODE}_input_values > ${L}_${GEN_NODE}_${GEN_OPTS_CUT}_output_values"
86
          WORKING_DIRECTORY ${GEN_SRC_DIR})	
87
        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 )
88
        if(${res} STREQUAL "0")
89
          file(COPY  ${GEN_SRC_DIR}/${L}_${GEN_NODE}_${GEN_OPTS_CUT}_output_values DESTINATION  ${LUSTRE_OUTPUT_DIR})
90
        else()
91
          message(FATAL_ERROR "${L}_${GEN_NODE}_${GEN_OPTS_CUT}_output_values Error")
92
        endif()
93
    else()
94
      #Uncomment the first line to remove lustre files in case references are not generated.
95
      #file(REMOVE ${GEN_SRC_DIR}/${L}.lus ${GEN_SRC_DIR}/${L}.lusi ${GEN_SRC_DIR}/${L}.c ${GEN_SRC_DIR}/${L}.h ${GEN_SRC_DIR}/${L}.lusic ${GEN_SRC_DIR}/${L}.makefile)
96
      #message(FATAL_ERROR "deleting ${GEN_SRC_DIR}/${L}.lus example Error")
97
    endif()
98
  endif()
99

    
100

    
101
endfunction(Copy_or_generate_lusi_input_and_output_values_for_reference)
102

    
103

    
104

    
105

    
106

    
107

    
108

    
109

    
110

    
111

    
112
#****************************second stratefy :generate zustre output.xml for reference
113
function(Copy_or_generate_zustre_output_xml_for_reference )
114
  set(options "")
115
  set(oneValueArgs  NODE LUS_FILE SRC_DIR DST_DIR)
116
  set(multiValueArgs  OPTS )
117
  cmake_parse_arguments(GEN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
118

    
119
  if(GEN_OPTS)
120
    CUT_OPTIONS("${GEN_OPTS}" ZUS_OPTS_CUT)
121
  endif()
122
  get_lustre_name_ext(${GEN_LUS_FILE} L E)
123

    
124
  #get_filename_component(L ${GEN_LUS_FILE} NAME_WE)
125
  set(LUSTRE_OUTPUT_DIR "${GEN_DST_DIR}/${L}")
126
  if(EXISTS ${GEN_SRC_DIR}/${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml)
127
    file(COPY ${GEN_SRC_DIR}/${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml   DESTINATION  ${LUSTRE_OUTPUT_DIR})
128
    file(READ ${GEN_SRC_DIR}/${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml ${L}_${GEN_NODE}_zustre_output)		
129
  else()
130
    message("generate ${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml for reference\n")
131
    Zustre_Compile(LUS_FILE ${GEN_LUS_FILE}
132
      NODE ${GEN_NODE}
133
      OPTS ${GEN_OPTS}
134
      DST_DIR ${GEN_DST_DIR}
135
      )
136

    
137
    execute_process(RESULT_VARIABLE res 
138
      OUTPUT_VARIABLE ${L}_${GEN_NODE}_zustre_output
139
      COMMAND  ${ZUSTRE_COMPILER} ${ZUSTRE_ARGS_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}} 
140
      WORKING_DIRECTORY ${GEN_SRC_DIR})
141
    
142
    file(WRITE ${GEN_SRC_DIR}/${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml ${${L}_${GEN_NODE}_zustre_output})
143
    file(COPY ${GEN_SRC_DIR}/${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml   DESTINATION  ${LUSTRE_OUTPUT_DIR})
144
    
145
  endif()
146
  if( ${${L}_${GEN_NODE}_zustre_output} MATCHES "<Answer>CEX</Answer>")
147
    set(ZUSTRE_ANSWER "CEX")
148
  elseif( ${${L}_${GEN_NODE}_zustre_output} MATCHES "<Answer>SAFE</Answer>")
149
    set(ZUSTRE_ANSWER "SAFE")
150
  elseif( ${${L}_${GEN_NODE}_zustre_output} MATCHES "<Answer>TIMEOUT</Answer>")
151
    set(ZUSTRE_ANSWER "TIMEOUT")
152
  else()
153
    set(ZUSTRE_ANSWER "ERROR")
154
  endif()
155
  set(ZUSTRE_ANSWER_${L}_${GEN_NODE} "${ZUSTRE_ANSWER}" PARENT_SCOPE)
156
endfunction(Copy_or_generate_zustre_output_xml_for_reference )
157

    
158

    
159

    
160

    
161

    
162

    
163

    
164
#***********************third strategy: Compile with zustre and compare
165

    
166
function(Zustre_compile_and_compare_to_reference)
167
  set(options "")
168
  set(oneValueArgs  NODE LUS_FILE  TESTS_PREFIX CALL_ID SRC_DIR DST_DIR)
169
  set(multiValueArgs  OPTS )
170
  cmake_parse_arguments(GEN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
171

    
172

    
173
  get_lustre_name_ext(${GEN_LUS_FILE} L E)
174
  #get_filename_component(L ${GEN_LUS_FILE} NAME_WE)
175
  
176
  Lustre_Compile(LUS_FILE ${GEN_LUS_FILE}
177
    NODE ""
178
    OPTS "-horn"
179
    DST_DIR ${GEN_DST_DIR}
180
    )
181
  CUT_OPTIONS("-horn" LUS_OPTS_CUT)
182
   
183
  add_test(NAME ${GEN_TESTS_PREFIX}_COMPIL_LUSTRE_HORN_${L}__${LUS_OPTS_CUT}_${GEN_CALL_ID}
184
    COMMAND  ${LUSTRE_COMPILER} ${LUSTREC_ARGS_${L}__${LUS_OPTS_CUT}} 
185
    )
186

    
187
  Zustre_Compile(LUS_FILE ${GEN_LUS_FILE}
188
    NODE ${GEN_NODE}
189
    OPTS ${GEN_OPTS}
190
    DST_DIR ${GEN_DST_DIR}
191
    )
192
  
193
  if(GEN_OPTS)
194
    CUT_OPTIONS("${GEN_OPTS}" ZUS_OPTS_CUT)
195
  endif()
196
  
197
  set(ZUSTRE_OUTPUT_DIR ${ZUSTRE_OUTPUT_DIR_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}})
198
  
199
  set(ZUSTRE_ARGS_TEMP "${ZUSTRE_ARGS_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}}" "> ${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml")
200
  JOIN("${ZUSTRE_ARGS_TEMP}" " " ZUSTRE_ARGS)
201
  
202
  add_test(NAME ${GEN_TESTS_PREFIX}_COMPIL_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID}
203
    COMMAND bash -c "${ZUSTRE_COMPILER} ${ZUSTRE_ARGS}"
204
    WORKING_DIRECTORY ${ZUSTRE_OUTPUT_DIR}
205
    )
206
  SET_TESTS_PROPERTIES (  ${GEN_TESTS_PREFIX}_COMPIL_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID}
207
    PROPERTIES FAIL_REGULAR_EXPRESSION "AssertionError;ERROR;Failed;Traceback"
208
    DEPENDS ${GEN_TESTS_PREFIX}_COMPIL_LUSTRE_HORN_${L}__${LUS_OPTS_CUT}_${GEN_CALL_ID})
209
  
210
  add_test(NAME ${GEN_TESTS_PREFIX}_COMPARE_REF_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID}
211
    COMMAND ${CMAKE_COMMAND} -DREF=${GEN_DST_DIR}/${L}/${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml
212
                             -DGEN=${ZUSTRE_OUTPUT_DIR}/${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml
213
    	    -P ${CMAKE_SOURCE_DIR}/modules/compare_ref_zustre.cmake
214

    
215
    WORKING_DIRECTORY ${ZUSTRE_OUTPUT_DIR}
216
    )
217
  SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_COMPARE_REF_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID}
218
    PROPERTIES REQUIRED_FILES  "${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml"
219
    DEPENDS ${GEN_TESTS_PREFIX}_COMPIL_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID})
220

    
221
  
222
  # add_test(NAME ${GEN_TESTS_PREFIX}_TAILGEN_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID}
223
  #   COMMAND bash -c "tail -n +8 ${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml > ${L}_tailed1.xml; | grep Answer | awk '{$1=$1};1'"
224
  #   WORKING_DIRECTORY ${ZUSTRE_OUTPUT_DIR}
225
  #   )
226
  # SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_TAILGEN_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID}
227
  #   PROPERTIES REQUIRED_FILES  ${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml
228
  #   DEPENDS ${GEN_TESTS_PREFIX}_COMPIL_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID})
229
  
230
  # add_test(NAME ${GEN_TESTS_PREFIX}_TAILREF_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID}
231
  #   COMMAND bash -c "tail -n +8 ${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml > ${L}_${GEN_NODE}_tailed2.xml"
232
  #   WORKING_DIRECTORY ${GEN_DST_DIR}/${L}/
233
  #   )
234
  # SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_TAILREF_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID}
235
  #   PROPERTIES REQUIRED_FILES  ${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml
236
  #   DEPENDS ${GEN_TESTS_PREFIX}_TAILGEN_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID})
237
  
238
  
239
  # add_test(NAME ${GEN_TESTS_PREFIX}_DIFF_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID}
240
  #   COMMAND ${CMAKE_COMMAND} -E compare_files  ${L}_tailed1.xml  ../${L}_${GEN_NODE}_tailed2.xml
241
  #   WORKING_DIRECTORY ${ZUSTRE_OUTPUT_DIR}
242
  #   )
243
  # SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_DIFF_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID}
244
  #   PROPERTIES REQUIRED_FILES  ${L}_tailed1.xml
245
  #   DEPENDS ${GEN_TESTS_PREFIX}_TAILREF_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID})	
246

    
247
endfunction(Zustre_compile_and_compare_to_reference)
248

    
249

    
250

    
251

    
252

    
253

    
254

    
255

    
256

    
257
#***********************fourth strategy: compare in case of CEX examples the Zustre trace with lustrec
258
function(Compare_Zustre_and_Lustrec_outputs)
259
  set(options MYJAVADIFF)
260
  set(oneValueArgs  NODE LUS_FILE  CALL_ID TESTS_PREFIX SRC_DIR DST_DIR DIFF_EPSILON)
261
  set(multiValueArgs  OPTS )
262
  cmake_parse_arguments(GEN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
263

    
264
  
265
  get_lustre_name_ext(${GEN_LUS_FILE} L E)
266
  #get_filename_component(L ${GEN_LUS_FILE} NAME_WE)
267

    
268
  Zustre_Compile(LUS_FILE ${GEN_LUS_FILE}
269
    NODE ${GEN_NODE}
270
    OPTS ${GEN_OPTS}
271
    DST_DIR ${GEN_DST_DIR}
272
    )
273
  if(GEN_OPTS)
274
    CUT_OPTIONS("${GEN_OPTS}" ZUS_OPTS_CUT)
275
  endif()
276
  set(ZUSTRE_OUTPUT_DIR ${ZUSTRE_OUTPUT_DIR_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}})
277
 
278

    
279

    
280
  add_test(NAME ${GEN_TESTS_PREFIX}_XPathParser_lusi_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID}
281
    COMMAND ${JAVA_RUNTIME} -cp ${CMAKE_BINARY_DIR}/modules/ XPathParser_lusi ${GEN_NODE} ../${L}.lusi ${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml
282
    WORKING_DIRECTORY ${ZUSTRE_OUTPUT_DIR}
283
    )
284
  SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_XPathParser_lusi_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID}
285
    PROPERTIES REQUIRED_FILES  ${GEN_DST_DIR}/${L}/${L}.lusi 
286
    DEPENDS ${GEN_TESTS_PREFIX}_COMPIL_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID} )	
287
  
288
  Lustre_Compile(LUS_FILE ${lus_file}
289
    NODE ${GEN_NODE}
290
    OPTS ""
291
    DIR ${ZUSTRE_OUTPUT_DIR}
292
    DST_DIR ${GEN_DST_DIR})
293
  
294
  set(LUS_OPTS_CUT "")
295
  add_test(NAME ${GEN_TESTS_PREFIX}_COMPIL_LUSTRE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
296
    COMMAND  ${LUSTRE_COMPILER} ${LUSTREC_ARGS_${L}_${GEN_NODE}_${LUS_OPTS_CUT}} 
297
    WORKING_DIRECTORY ${ZUSTRE_OUTPUT_DIR}
298
    )
299

    
300
  add_test(NAME ${GEN_TESTS_PREFIX}_MAKE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
301
    COMMAND  make -f ${L}.makefile
302
    WORKING_DIRECTORY ${ZUSTRE_OUTPUT_DIR}
303
    )
304
  SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_MAKE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
305
    PROPERTIES DEPENDS ${GEN_TESTS_PREFIX}_COMPIL_LUSTRE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
306
    REQUIRED_FILES ${L}.makefile
307
    )
308
  
309
  
310
  if (BASH)
311
    add_test(
312
      NAME ${GEN_TESTS_PREFIX}_BIN_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID} 
313
      COMMAND ${BASH} -c "./${L}_${GEN_NODE} < input_values > ${L}_${GEN_NODE}_outputs"
314
      WORKING_DIRECTORY ${ZUSTRE_OUTPUT_DIR}
315
      )
316
    SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_BIN_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
317
      PROPERTIES REQUIRED_FILES ${L}_${GEN_NODE}
318
      DEPENDS ${GEN_TESTS_PREFIX}_MAKE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID})
319
  else()
320
    message(FATAL_ERROR "Unknown shell command for ${CMAKE_HOST_SYSTEM_NAME}")
321
  endif()
322

    
323
  #************** compare **********************************
324
  if (${MYJAVADIFF})
325
    add_test(NAME ${GEN_TESTS_PREFIX}_COMPARE_OUTPUTS_OF_LUSTREC_ZUSTRE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
326
      COMMAND ${JAVA_RUNTIME} -cp ${CMAKE_BINARY_DIR}/modules/ compare_lustrec_outputs ${L}_${GEN_NODE}_outputs ZUSTRE_output_values ${DIFF_EPSILON}
327
      WORKING_DIRECTORY ${ZUSTRE_OUTPUT_DIR}
328
      )
329
  else()
330
    add_test(NAME ${GEN_TESTS_PREFIX}_COMPARE_OUTPUTS_OF_LUSTREC_ZUSTRE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
331
      COMMAND diff -y ${L}_${GEN_NODE}_outputs ZUSTRE_output_values
332
      WORKING_DIRECTORY ${ZUSTRE_OUTPUT_DIR}
333
      )
334
  endif()
335
  SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_COMPARE_OUTPUTS_OF_LUSTREC_ZUSTRE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
336
    PROPERTIES REQUIRED_FILES ${L}_${GEN_NODE}_outputs
337
    DEPENDS ${GEN_TESTS_PREFIX}_BIN_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID} )
338
  
339
  
340

    
341

    
342

    
343

    
344
endfunction()
345

    
346

    
347

    
348

    
349

    
350

    
351

    
352

    
353

    
354

    
355

    
356

    
357

    
358

    
359

    
360

    
361

    
362

    
363

    
364

    
365

    
366

    
367

    
368
#******************************fifth strategy, test the lustrec binary with outputs of reference
369

    
370

    
371
function(Lustre_compile_and_compare_to_reference)
372
  set(options MYJAVADIFF)
373
  set(oneValueArgs  NODE LUS_FILE CALL_ID  TESTS_PREFIX SRC_DIR DST_DIR DIFF_EPSILON)
374
  set(multiValueArgs  OPTS )
375
  cmake_parse_arguments(GEN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
376

    
377
  get_lustre_name_ext(${GEN_LUS_FILE} L E)
378
  #get_filename_component(L ${GEN_LUS_FILE} NAME_WE)
379
  # First command generate C files from Lustre file
380
  Lustre_Compile(LUS_FILE ${GEN_LUS_FILE}
381
    NODE ${GEN_NODE}
382
    OPTS ${GEN_OPTS}
383
    DST_DIR ${GEN_DST_DIR}
384
    )
385
  if(GEN_OPTS)
386
    CUT_OPTIONS("${GEN_OPTS}" LUS_OPTS_CUT)
387
  endif()
388

    
389
  add_test(NAME ${GEN_TESTS_PREFIX}_COMPIL_LUSTRE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
390
    COMMAND  ${LUSTRE_COMPILER} ${LUSTREC_ARGS_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
391
    WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
392
    )
393

    
394
  #********************* make -f ${L}.makefile ***************************
395
  add_test(NAME ${GEN_TESTS_PREFIX}_MAKE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
396
    COMMAND  make -f ${L}.makefile
397
    WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
398
    )
399
  SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_MAKE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
400
    PROPERTIES DEPENDS ${GEN_TESTS_PREFIX}_COMPIL_LUSTRE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
401
    REQUIRED_FILES ${L}.makefile
402
    )
403
  
404
  #************** execute C binary **********************************
405
  
406
  if (BASH)
407
    add_test(
408
      NAME ${GEN_TESTS_PREFIX}_BIN_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID} 
409
      COMMAND ${BASH} -c "./${L}_${GEN_NODE} < ../${L}_${GEN_NODE}_input_values > ${L}_${GEN_NODE}_${LUS_OPTS_CUT}_output_values"
410
      WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
411
      )
412
    SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_BIN_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
413
      PROPERTIES REQUIRED_FILES ${L}_${GEN_NODE}
414
      DEPENDS ${GEN_TESTS_PREFIX}_MAKE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID})
415
  else()
416
    message(FATAL_ERROR "Unknown shell command ${BASH} -c for ${CMAKE_HOST_SYSTEM_NAME}")
417
  endif()
418

    
419
  #************** execute C binary **********************************
420
  if (${MYJAVADIFF})
421
    add_test(NAME ${GEN_TESTS_PREFIX}_DIFF_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
422
      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}
423
      WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
424
      )
425
  else()
426
    add_test(NAME ${GEN_TESTS_PREFIX}_DIFF_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
427
      COMMAND diff -y ${L}_${GEN_NODE}_${LUS_OPTS_CUT}_output_values ../${L}_${GEN_NODE}_${LUS_OPTS_CUT}_output_values 
428
      WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
429
      )
430
  endif()
431
  SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_DIFF_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
432
    PROPERTIES REQUIRED_FILES  ${L}_${GEN_NODE}_${LUS_OPTS_CUT}_output_values
433
    DEPENDS ${GEN_TESTS_PREFIX}_BIN_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID} )
434

    
435
endfunction()
436

    
437

    
438

    
439

    
440

    
441
#******************************sixth strategy, subset of fifth, no execution, just calls to lustrec
442

    
443

    
444
function(Lustre_compile_options)
445
  set(options "")
446
  set(oneValueArgs  NODE LUS_FILE CALL_ID  TESTS_PREFIX SRC_DIR DST_DIR)
447
  set(multiValueArgs  OPTS )
448
  cmake_parse_arguments(GEN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
449

    
450
  get_lustre_name_ext(${GEN_LUS_FILE} L E)
451
  #get_filename_component(L ${GEN_LUS_FILE} NAME_WE)
452
  # First command generate C files from Lustre file
453
  Lustre_Compile(LUS_FILE ${GEN_LUS_FILE}
454
    NODE ${GEN_NODE}
455
    OPTS ${GEN_OPTS}
456
    DST_DIR ${GEN_DST_DIR}
457
    )
458
  if(GEN_OPTS)
459
    CUT_OPTIONS("${GEN_OPTS}" LUS_OPTS_CUT)
460
  endif()
461

    
462
  add_test(NAME ${GEN_TESTS_PREFIX}_COMPIL_LUSTRE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
463
    COMMAND  ${LUSTRE_COMPILER} ${LUSTREC_ARGS_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
464
    WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
465
    )
466

    
467
  #********* EMF Validation
468
  STRING(FIND "${LUS_OPTS_CUT}" "emf" matchres)
469
  IF(${matchres} EQUAL 0)
470
    add_test(
471
      NAME ${GEN_TESTS_PREFIX}_EMF_VALIDATE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID} 
472
      COMMAND ${BASH} -c "cat ./${L}.json | python -m json.tool"
473
      WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
474
      )
475
    SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_EMF_VALIDATE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
476
      PROPERTIES REQUIRED_FILES ${L}.json
477
      DEPENDS ${GEN_TESTS_PREFIX}_COMPIL_LUSTRE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID})
478
  endif()
479

    
480
endfunction()
481

    
482

    
483

    
484
#****************************** LustreT strategies: generating the MCDC coverage 
485

    
486

    
487
function(LustreT_MCDC)
488
  set(options "")
489
  set(oneValueArgs  NODE LUS_FILE CALL_ID TESTS_PREFIX SRC_DIR DST_DIR)
490
  set(multiValueArgs  OPTS )
491
  cmake_parse_arguments(GEN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
492

    
493
  get_lustre_name_ext(${GEN_LUS_FILE} L E)
494
#  get_filename_component(L ${GEN_LUS_FILE} NAME_WE)
495
  # First command generate C files from Lustre file
496
  Lustre_Compile(LUS_FILE ${GEN_LUS_FILE}
497
    NODE ${GEN_NODE}
498
    OPTS ${GEN_OPTS}
499
    DIR "${GEN_DST_DIR}/${L}/node_${GEN_NODE}_MCDC"
500
#    DST_DIR ${GEN_DST_DIR}
501
    )
502

    
503
#    set(LUSTRE_OUTPUT_DIR "${OUTPUT_PATH}/${L}/node_${LUS_NODE}")
504

    
505
  file(MAKE_DIRECTORY "${GEN_DST_DIR}/${L}/node_${GEN_NODE}_MCDC")
506

    
507
  add_test(NAME ${GEN_TESTS_PREFIX}_LUSTRET_MCDC_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
508
    COMMAND  ${LUSTRE_T} -mcdc-cond ${LUSTREC_ARGS_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
509
    WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
510
    )
511

    
512
   set(MCDC_SRC "${GEN_DST_DIR}/${L}/node_${GEN_NODE}_MCDC/${L}.mcdc.lus")
513
   Lustre_Compile(LUS_FILE "${MCDC_SRC}"
514
     NODE ${GEN_NODE}
515
     OPTS ${GEN_OPTS}
516
     DIR "${GEN_DST_DIR}/${L}/node_${GEN_NODE}_MCDC"
517
 #    DST_DIR ${GEN_DST_DIR}
518
     )
519

    
520
  
521
  add_test(NAME ${GEN_TESTS_PREFIX}_LUSTRET_MCDC_COMPILE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
522
    COMMAND  ${LUSTRE_COMPILER} ${LUSTREC_ARGS_${L}.mcdc_${GEN_NODE}_${LUS_OPTS_CUT}}
523
    WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_mcdc_${GEN_NODE}_${LUS_OPTS_CUT}}
524
    )
525

    
526
  SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_LUSTRET_MCDC_COMPILE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
527
    PROPERTIES 
528
    DEPENDS ${GEN_TESTS_PREFIX}_LUSTRET_MCDC_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID})
529
  
530
endfunction()
531

    
532
#****************************** LustreT strategies: generating the mutants
533

    
534

    
535
function(LustreT_mutants)
536
  set(options "")
537
  set(oneValueArgs  NODE LUS_FILE CALL_ID TESTS_PREFIX  SRC_DIR DST_DIR)
538
  set(multiValueArgs  OPTS )
539
  cmake_parse_arguments(GEN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
540

    
541
  get_lustre_name_ext(${GEN_LUS_FILE} L E)
542
#  get_filename_component(L ${GEN_LUS_FILE} NAME_WE)
543
  # First command generate C files from Lustre file
544
  Lustre_Compile(LUS_FILE ${GEN_LUS_FILE}
545
    NODE ${GEN_NODE}
546
    OPTS ${GEN_OPTS}
547
    DIR "${GEN_DST_DIR}/${L}/node_${GEN_NODE}_Mutants"
548
#    DST_DIR ${GEN_DST_DIR}
549
    )
550

    
551
#    set(LUSTRE_OUTPUT_DIR "${OUTPUT_PATH}/${L}/node_${LUS_NODE}")
552

    
553
  file(MAKE_DIRECTORY "${GEN_DST_DIR}/${L}/node_${GEN_NODE}_Mutants")
554

    
555
  add_test(NAME ${GEN_TESTS_PREFIX}_LUSTRET_MUTATION_GEN_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
556
    COMMAND  ${LUSTRE_T} ${LUSTREC_ARGS_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
557
    WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
558
    )
559

    
560
  add_test(NAME ${GEN_TESTS_PREFIX}_LUSTRET_MUTATION_BUILDMAKE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
561
    COMMAND  "cmake" "."
562
    WORKING_DIRECTORY ${GEN_DST_DIR}/${L}/node_${GEN_NODE}_Mutants
563
    )
564

    
565
  add_test(NAME ${GEN_TESTS_PREFIX}_LUSTRET_MUTATION_BUILDBIN_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
566
    COMMAND  "make"
567
    WORKING_DIRECTORY ${GEN_DST_DIR}/${L}/node_${GEN_NODE}_Mutants
568
    )
569

    
570
  SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_LUSTRET_MUTATION_BUILDMAKE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
571
    PROPERTIES 
572
    DEPENDS ${GEN_TESTS_PREFIX}_LUSTRET_MUTATION_GEN_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID} )
573

    
574
  SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_LUSTRET_MUTATION_BUILDBIN_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
575
    PROPERTIES 
576
    DEPENDS ${GEN_TESTS_PREFIX}_LUSTRET_MUTATION_BUILDMAKE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID} )
577

    
578
endfunction()
579

    
580

    
581

    
582

    
583
#****************************** Lustrec Compile for ADA and compare to reference
584

    
585
function(Lustre_compile_to_ADA_and_compare_to_reference)
586
  set(options "")
587
  set(oneValueArgs  NODE LUS_FILE CALL_ID  TESTS_PREFIX SRC_DIR DST_DIR DIFF_EPSILON)
588
  set(multiValueArgs  OPTS )
589
  cmake_parse_arguments(GEN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
590

    
591
  get_lustre_name_ext(${GEN_LUS_FILE} L E)
592
  #get_filename_component(L ${GEN_LUS_FILE} NAME_WE)
593
  # First command generate ADA files from Lustre file
594
  Lustre_Compile(LUS_FILE ${GEN_LUS_FILE}
595
    NODE ${GEN_NODE}
596
    OPTS ${GEN_OPTS}  
597
    DST_DIR ${GEN_DST_DIR}
598
    )
599
  if(GEN_OPTS)
600
    CUT_OPTIONS("${GEN_OPTS}" LUS_OPTS_CUT)
601
  endif()
602

    
603
  add_test(NAME ${GEN_TESTS_PREFIX}_COMPIL_ADA_LUSTRE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
604
    COMMAND  ${LUSTRE_COMPILER} ${LUSTREC_ARGS_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
605
    WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
606
    )
607

    
608
  #********************* gprbuild ${L}.gpr ***************************
609
  add_test(NAME ${GEN_TESTS_PREFIX}_ADA_GPRBUILD_EXE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
610
    COMMAND  gprbuild -p ${L}_exe.gpr
611
    WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
612
    )
613
  SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_ADA_GPRBUILD_EXE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
614
    PROPERTIES DEPENDS ${GEN_TESTS_PREFIX}_COMPIL_ADA_LUSTRE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
615
    REQUIRED_FILES ${L}_exe.gpr
616
    )
617
  add_test(NAME ${GEN_TESTS_PREFIX}_ADA_GPRBUILD_LIB_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
618
    COMMAND  gprbuild -p ${L}_lib.gpr
619
    WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
620
    )
621
  SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_ADA_GPRBUILD_LIB_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
622
    PROPERTIES DEPENDS ${GEN_TESTS_PREFIX}_COMPIL_ADA_LUSTRE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
623
    REQUIRED_FILES ${L}_lib.gpr
624
    )
625
  
626
  #************** execute C binary **********************************
627
  
628
  if (BASH)
629
    add_test(
630
      NAME ${GEN_TESTS_PREFIX}_ADA_BIN_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID} 
631
      COMMAND ${BASH} -c "./bin/ada_main < ../${L}_${GEN_NODE}_input_values > ${L}_${GEN_NODE}_${LUS_OPTS_CUT}_output_values"
632
      WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
633
      )
634
    SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_ADA_BIN_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
635
      PROPERTIES # REQUIRED_FILES ${L}_${GEN_NODE}
636
      DEPENDS ${GEN_TESTS_PREFIX}_ADA_GPRBUILD_EXE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID})
637
  else()
638
    message(FATAL_ERROR "Unknown shell command ${BASH} -c for ${CMAKE_HOST_SYSTEM_NAME}")
639
  endif()
640

    
641
  #************** execute C binary **********************************
642

    
643
  add_test(NAME ${GEN_TESTS_PREFIX}_ADA_DIFF_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
644
    COMMAND diff -y ${L}_${GEN_NODE}_${LUS_OPTS_CUT}_output_values ../${L}_${GEN_NODE}_${LUS_OPTS_CUT}_output_values
645
    WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
646
    )
647
  SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_ADA_DIFF_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
648
    PROPERTIES REQUIRED_FILES  ${L}_${GEN_NODE}_${LUS_OPTS_CUT}_output_values
649
    DEPENDS ${GEN_TESTS_PREFIX}_ADA_BIN_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID} )
650

    
651
endfunction()