Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

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

History | View | Annotate | Download (21.7 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
  set(LUSTRE_OUTPUT_DIR "${GEN_DST_DIR}/${L}")
17
  file(COPY ${GEN_LUS_FILE}   DESTINATION  ${LUSTRE_OUTPUT_DIR})
18

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

    
42

    
43
  #generate input and output values
44
  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
    message("generate ${L}_${GEN_NODE}_input_values \n")
48
# message (" command is ${JAVA_RUNTIME} -cp ${CMAKE_BINARY_DIR}/modules/ Generate_inputs_lusi ${GEN_NODE} ${L}.lusi ${GEN_MAX}" )
49
    execute_process(RESULT_VARIABLE res 
50
      COMMAND ${JAVA_RUNTIME} -cp ${CMAKE_BINARY_DIR}/modules/ Generate_inputs_lusi ${GEN_NODE} ${L}.lusi ${GEN_MAX}
51
      WORKING_DIRECTORY ${GEN_SRC_DIR})
52

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

    
60
  if(GEN_OPTS)
61
    CUT_OPTIONS("${GEN_OPTS}" GEN_OPTS_CUT)
62
  endif()
63
  
64
  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
    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
      OPTS ${GEN_OPTS}
72
      DIR ${GEN_SRC_DIR}
73
      DST_DIR ${GEN_DST_DIR})
74
    
75
    execute_process(
76
      COMMAND ${LUSTRE_COMPILER} ${LUSTREC_ARGS_${L}_${GEN_NODE}_${GEN_OPTS_CUT}} 
77
      WORKING_DIRECTORY ${GEN_SRC_DIR})			
78
    execute_process(
79
      COMMAND  make -f ${L}.makefile
80
      WORKING_DIRECTORY ${GEN_SRC_DIR})	
81
    execute_process(RESULT_VARIABLE res 
82
      COMMAND ${BASH} -c "./${L}_${GEN_NODE} < ${L}_${GEN_NODE}_input_values > ${L}_${GEN_NODE}_${GEN_OPTS_CUT}_output_values"
83
      WORKING_DIRECTORY ${GEN_SRC_DIR})	
84
    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 )
85
    if(${res} STREQUAL "0")
86
      file(COPY  ${GEN_SRC_DIR}/${L}_${GEN_NODE}_${GEN_OPTS_CUT}_output_values DESTINATION  ${LUSTRE_OUTPUT_DIR})
87
    else()
88
      message(FATAL_ERROR "${L}_${GEN_NODE}_${GEN_OPTS_CUT}_output_values Error")
89
    endif()
90
  endif()
91

    
92

    
93
endfunction(Copy_or_generate_lusi_input_and_output_values_for_reference)
94

    
95

    
96

    
97

    
98

    
99

    
100

    
101

    
102

    
103

    
104
#****************************second stratefy :generate zustre output.xml for reference
105
function(Copy_or_generate_zustre_output_xml_for_reference )
106
  set(options "")
107
  set(oneValueArgs  NODE LUS_FILE SRC_DIR DST_DIR)
108
  set(multiValueArgs  OPTS )
109
  cmake_parse_arguments(GEN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
110

    
111
  if(GEN_OPTS)
112
    CUT_OPTIONS("${GEN_OPTS}" ZUS_OPTS_CUT)
113
  endif()
114
  get_lustre_name_ext(${GEN_LUS_FILE} L E)
115

    
116
  #get_filename_component(L ${GEN_LUS_FILE} NAME_WE)
117
  set(LUSTRE_OUTPUT_DIR "${GEN_DST_DIR}/${L}")
118
  if(EXISTS ${GEN_SRC_DIR}/${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml)
119
    file(COPY ${GEN_SRC_DIR}/${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml   DESTINATION  ${LUSTRE_OUTPUT_DIR})
120
    file(READ ${GEN_SRC_DIR}/${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml ${L}_${GEN_NODE}_zustre_output)		
121
  else()
122
    message("generate ${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml for reference\n")
123
    Zustre_Compile(LUS_FILE ${GEN_LUS_FILE}
124
      NODE ${GEN_NODE}
125
      OPTS ${GEN_OPTS}
126
      DST_DIR ${GEN_DST_DIR}
127
      )
128

    
129
    execute_process(RESULT_VARIABLE res 
130
      OUTPUT_VARIABLE ${L}_${GEN_NODE}_zustre_output
131
      COMMAND  ${ZUSTRE_COMPILER} ${ZUSTRE_ARGS_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}} 
132
      WORKING_DIRECTORY ${GEN_SRC_DIR})
133
    
134
    file(WRITE ${GEN_SRC_DIR}/${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml ${${L}_${GEN_NODE}_zustre_output})
135
    file(COPY ${GEN_SRC_DIR}/${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml   DESTINATION  ${LUSTRE_OUTPUT_DIR})
136
    
137
  endif()
138
  if( ${${L}_${GEN_NODE}_zustre_output} MATCHES "<Answer>CEX</Answer>")
139
    set(ZUSTRE_ANSWER "CEX")
140
  elseif( ${${L}_${GEN_NODE}_zustre_output} MATCHES "<Answer>SAFE</Answer>")
141
    set(ZUSTRE_ANSWER "SAFE")
142
  elseif( ${${L}_${GEN_NODE}_zustre_output} MATCHES "<Answer>TIMEOUT</Answer>")
143
    set(ZUSTRE_ANSWER "TIMEOUT")
144
  else()
145
    set(ZUSTRE_ANSWER "ERROR")
146
  endif()
147
  set(ZUSTRE_ANSWER_${L}_${GEN_NODE} "${ZUSTRE_ANSWER}" PARENT_SCOPE)
148
endfunction(Copy_or_generate_zustre_output_xml_for_reference )
149

    
150

    
151

    
152

    
153

    
154

    
155

    
156
#***********************third strategy: Compile with zustre and compare
157

    
158
function(Zustre_compile_and_compare_to_reference)
159
  set(options "")
160
  set(oneValueArgs  NODE LUS_FILE  TESTS_PREFIX CALL_ID SRC_DIR DST_DIR)
161
  set(multiValueArgs  OPTS )
162
  cmake_parse_arguments(GEN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
163

    
164

    
165
  get_lustre_name_ext(${GEN_LUS_FILE} L E)
166
  #get_filename_component(L ${GEN_LUS_FILE} NAME_WE)
167
  
168
  Lustre_Compile(LUS_FILE ${GEN_LUS_FILE}
169
    NODE ""
170
    OPTS "-horn"
171
    DST_DIR ${GEN_DST_DIR}
172
    )
173
  CUT_OPTIONS("-horn" LUS_OPTS_CUT)
174
   
175
  add_test(NAME ${GEN_TESTS_PREFIX}_COMPIL_LUSTRE_HORN_${L}__${LUS_OPTS_CUT}_${GEN_CALL_ID}
176
    COMMAND  ${LUSTRE_COMPILER} ${LUSTREC_ARGS_${L}__${LUS_OPTS_CUT}} 
177
    )
178

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

    
207
    WORKING_DIRECTORY ${ZUSTRE_OUTPUT_DIR}
208
    )
209
  SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_COMPARE_REF_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID}
210
    PROPERTIES REQUIRED_FILES  "${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml"
211
    DEPENDS ${GEN_TESTS_PREFIX}_COMPIL_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID})
212

    
213
  
214
  # add_test(NAME ${GEN_TESTS_PREFIX}_TAILGEN_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID}
215
  #   COMMAND bash -c "tail -n +8 ${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml > ${L}_tailed1.xml; | grep Answer | awk '{$1=$1};1'"
216
  #   WORKING_DIRECTORY ${ZUSTRE_OUTPUT_DIR}
217
  #   )
218
  # SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_TAILGEN_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID}
219
  #   PROPERTIES REQUIRED_FILES  ${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml
220
  #   DEPENDS ${GEN_TESTS_PREFIX}_COMPIL_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID})
221
  
222
  # add_test(NAME ${GEN_TESTS_PREFIX}_TAILREF_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}_${GEN_NODE}_tailed2.xml"
224
  #   WORKING_DIRECTORY ${GEN_DST_DIR}/${L}/
225
  #   )
226
  # SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_TAILREF_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}_TAILGEN_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID})
229
  
230
  
231
  # add_test(NAME ${GEN_TESTS_PREFIX}_DIFF_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID}
232
  #   COMMAND ${CMAKE_COMMAND} -E compare_files  ${L}_tailed1.xml  ../${L}_${GEN_NODE}_tailed2.xml
233
  #   WORKING_DIRECTORY ${ZUSTRE_OUTPUT_DIR}
234
  #   )
235
  # SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_DIFF_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID}
236
  #   PROPERTIES REQUIRED_FILES  ${L}_tailed1.xml
237
  #   DEPENDS ${GEN_TESTS_PREFIX}_TAILREF_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID})	
238

    
239
endfunction(Zustre_compile_and_compare_to_reference)
240

    
241

    
242

    
243

    
244

    
245

    
246

    
247

    
248

    
249
#***********************fourth strategy: compare in case of CEX examples the Zustre trace with lustrec
250
function(Compare_Zustre_and_Lustrec_outputs)
251
  set(options MYJAVADIFF)
252
  set(oneValueArgs  NODE LUS_FILE  CALL_ID TESTS_PREFIX SRC_DIR DST_DIR DIFF_EPSILON)
253
  set(multiValueArgs  OPTS )
254
  cmake_parse_arguments(GEN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
255

    
256
  
257
  get_lustre_name_ext(${GEN_LUS_FILE} L E)
258
  #get_filename_component(L ${GEN_LUS_FILE} NAME_WE)
259

    
260
  Zustre_Compile(LUS_FILE ${GEN_LUS_FILE}
261
    NODE ${GEN_NODE}
262
    OPTS ${GEN_OPTS}
263
    DST_DIR ${GEN_DST_DIR}
264
    )
265
  if(GEN_OPTS)
266
    CUT_OPTIONS("${GEN_OPTS}" ZUS_OPTS_CUT)
267
  endif()
268
  set(ZUSTRE_OUTPUT_DIR ${ZUSTRE_OUTPUT_DIR_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}})
269
 
270

    
271

    
272
  add_test(NAME ${GEN_TESTS_PREFIX}_XPathParser_lusi_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID}
273
    COMMAND ${JAVA_RUNTIME} -cp ${CMAKE_BINARY_DIR}/modules/ XPathParser_lusi ${GEN_NODE} ../${L}.lusi ${L}_${GEN_NODE}_${ZUS_OPTS_CUT}.xml
274
    WORKING_DIRECTORY ${ZUSTRE_OUTPUT_DIR}
275
    )
276
  SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_XPathParser_lusi_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID}
277
    PROPERTIES REQUIRED_FILES  ${GEN_DST_DIR}/${L}/${L}.lusi 
278
    DEPENDS ${GEN_TESTS_PREFIX}_COMPIL_ZUSTRE_${L}_${GEN_NODE}_${ZUS_OPTS_CUT}_${GEN_CALL_ID} )	
279
  
280
  Lustre_Compile(LUS_FILE ${lus_file}
281
    NODE ${GEN_NODE}
282
    OPTS ""
283
    DIR ${ZUSTRE_OUTPUT_DIR}
284
    DST_DIR ${GEN_DST_DIR})
285
  
286
  set(LUS_OPTS_CUT "")
287
  add_test(NAME ${GEN_TESTS_PREFIX}_COMPIL_LUSTRE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
288
    COMMAND  ${LUSTRE_COMPILER} ${LUSTREC_ARGS_${L}_${GEN_NODE}_${LUS_OPTS_CUT}} 
289
    WORKING_DIRECTORY ${ZUSTRE_OUTPUT_DIR}
290
    )
291

    
292
  add_test(NAME ${GEN_TESTS_PREFIX}_MAKE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
293
    COMMAND  make -f ${L}.makefile
294
    WORKING_DIRECTORY ${ZUSTRE_OUTPUT_DIR}
295
    )
296
  SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_MAKE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
297
    PROPERTIES DEPENDS ${GEN_TESTS_PREFIX}_COMPIL_LUSTRE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
298
    REQUIRED_FILES ${L}.makefile
299
    )
300
  
301
  
302
  if (BASH)
303
    add_test(
304
      NAME ${GEN_TESTS_PREFIX}_BIN_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID} 
305
      COMMAND ${BASH} -c "./${L}_${GEN_NODE} < input_values > ${L}_${GEN_NODE}_outputs"
306
      WORKING_DIRECTORY ${ZUSTRE_OUTPUT_DIR}
307
      )
308
    SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_BIN_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
309
      PROPERTIES REQUIRED_FILES ${L}_${GEN_NODE}
310
      DEPENDS ${GEN_TESTS_PREFIX}_MAKE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID})
311
  else()
312
    message(FATAL_ERROR "Unknown shell command for ${CMAKE_HOST_SYSTEM_NAME}")
313
  endif()
314

    
315
  #************** compare **********************************
316
  if (${MYJAVADIFF})
317
    add_test(NAME ${GEN_TESTS_PREFIX}_COMPARE_OUTPUTS_OF_LUSTREC_ZUSTRE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
318
      COMMAND ${JAVA_RUNTIME} -cp ${CMAKE_BINARY_DIR}/modules/ compare_lustrec_outputs ${L}_${GEN_NODE}_outputs ZUSTRE_output_values ${DIFF_EPSILON}
319
      WORKING_DIRECTORY ${ZUSTRE_OUTPUT_DIR}
320
      )
321
  else()
322
    add_test(NAME ${GEN_TESTS_PREFIX}_COMPARE_OUTPUTS_OF_LUSTREC_ZUSTRE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
323
      COMMAND diff -y ${L}_${GEN_NODE}_outputs ZUSTRE_output_values
324
      WORKING_DIRECTORY ${ZUSTRE_OUTPUT_DIR}
325
      )
326
  endif()
327
  SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_COMPARE_OUTPUTS_OF_LUSTREC_ZUSTRE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
328
    PROPERTIES REQUIRED_FILES ${L}_${GEN_NODE}_outputs
329
    DEPENDS ${GEN_TESTS_PREFIX}_BIN_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID} )
330
  
331
  
332

    
333

    
334

    
335

    
336
endfunction()
337

    
338

    
339

    
340

    
341

    
342

    
343

    
344

    
345

    
346

    
347

    
348

    
349

    
350

    
351

    
352

    
353

    
354

    
355

    
356

    
357

    
358

    
359

    
360
#******************************fifth strategy, test the lustrec binary with outputs of reference
361

    
362

    
363
function(Lustre_compile_and_compare_to_reference)
364
  set(options MYJAVADIFF)
365
  set(oneValueArgs  NODE LUS_FILE CALL_ID  TESTS_PREFIX SRC_DIR DST_DIR DIFF_EPSILON)
366
  set(multiValueArgs  OPTS )
367
  cmake_parse_arguments(GEN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
368

    
369
  get_lustre_name_ext(${GEN_LUS_FILE} L E)
370
  #get_filename_component(L ${GEN_LUS_FILE} NAME_WE)
371
  # First command generate C files from Lustre file
372
  Lustre_Compile(LUS_FILE ${GEN_LUS_FILE}
373
    NODE ${GEN_NODE}
374
    OPTS ${GEN_OPTS}
375
    DST_DIR ${GEN_DST_DIR}
376
    )
377
  if(GEN_OPTS)
378
    CUT_OPTIONS("${GEN_OPTS}" LUS_OPTS_CUT)
379
  endif()
380

    
381
  add_test(NAME ${GEN_TESTS_PREFIX}_COMPIL_LUSTRE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
382
    COMMAND  ${LUSTRE_COMPILER} ${LUSTREC_ARGS_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
383
    WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
384
    )
385

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

    
411
  #************** execute C binary **********************************
412
  if (${MYJAVADIFF})
413
    add_test(NAME ${GEN_TESTS_PREFIX}_DIFF_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
414
      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}
415
      WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
416
      )
417
  else()
418
    add_test(NAME ${GEN_TESTS_PREFIX}_DIFF_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
419
      COMMAND diff -y ${L}_${GEN_NODE}_${LUS_OPTS_CUT}_output_values ../${L}_${GEN_NODE}_${LUS_OPTS_CUT}_output_values 
420
      WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
421
      )
422
  endif()
423
  SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_DIFF_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
424
    PROPERTIES REQUIRED_FILES  ${L}_${GEN_NODE}_${LUS_OPTS_CUT}_output_values
425
    DEPENDS ${GEN_TESTS_PREFIX}_BIN_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID} )
426

    
427
endfunction()
428

    
429

    
430

    
431

    
432

    
433
#******************************sixth strategy, subset of fifth, no execution, just calls to lustrec
434

    
435

    
436
function(Lustre_compile_options)
437
  set(options "")
438
  set(oneValueArgs  NODE LUS_FILE CALL_ID  TESTS_PREFIX SRC_DIR DST_DIR)
439
  set(multiValueArgs  OPTS )
440
  cmake_parse_arguments(GEN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
441

    
442
  get_lustre_name_ext(${GEN_LUS_FILE} L E)
443
  #get_filename_component(L ${GEN_LUS_FILE} NAME_WE)
444
  # First command generate C files from Lustre file
445
  Lustre_Compile(LUS_FILE ${GEN_LUS_FILE}
446
    NODE ${GEN_NODE}
447
    OPTS ${GEN_OPTS}
448
    DST_DIR ${GEN_DST_DIR}
449
    )
450
  if(GEN_OPTS)
451
    CUT_OPTIONS("${GEN_OPTS}" LUS_OPTS_CUT)
452
  endif()
453

    
454
  add_test(NAME ${GEN_TESTS_PREFIX}_COMPIL_LUSTRE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
455
    COMMAND  ${LUSTRE_COMPILER} ${LUSTREC_ARGS_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
456
    WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
457
    )
458

    
459
  #********* EMF Validation
460
  STRING(FIND "${LUS_OPTS_CUT}" "emf" matchres)
461
  IF(${matchres} EQUAL 0)
462
    add_test(
463
      NAME ${GEN_TESTS_PREFIX}_EMF_VALIDATE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID} 
464
      COMMAND ${BASH} -c "cat ./${L}.emf | python -m json.tool"
465
      WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
466
      )
467
    SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_EMF_VALIDATE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
468
      PROPERTIES REQUIRED_FILES ${L}.emf
469
      DEPENDS ${GEN_TESTS_PREFIX}_COMPIL_LUSTRE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID})
470
  endif()
471

    
472
endfunction()
473

    
474

    
475

    
476
#****************************** LustreT strategies: generating the MCDC coverage 
477

    
478

    
479
function(LustreT_MCDC)
480
  set(options "")
481
  set(oneValueArgs  NODE LUS_FILE CALL_ID TESTS_PREFIX SRC_DIR DST_DIR)
482
  set(multiValueArgs  OPTS )
483
  cmake_parse_arguments(GEN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
484

    
485
  get_lustre_name_ext(${GEN_LUS_FILE} L E)
486
#  get_filename_component(L ${GEN_LUS_FILE} NAME_WE)
487
  # First command generate C files from Lustre file
488
  Lustre_Compile(LUS_FILE ${GEN_LUS_FILE}
489
    NODE ${GEN_NODE}
490
    OPTS ${GEN_OPTS}
491
    DIR "${GEN_DST_DIR}/${L}/node_${GEN_NODE}_MCDC"
492
#    DST_DIR ${GEN_DST_DIR}
493
    )
494

    
495
#    set(LUSTRE_OUTPUT_DIR "${OUTPUT_PATH}/${L}/node_${LUS_NODE}")
496

    
497
  file(MAKE_DIRECTORY "${GEN_DST_DIR}/${L}/node_${GEN_NODE}_MCDC")
498

    
499
  add_test(NAME ${GEN_TESTS_PREFIX}_LUSTRET_MCDC_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
500
    COMMAND  ${LUSTRE_T} -mcdc-cond ${LUSTREC_ARGS_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
501
    WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
502
    )
503

    
504
   set(MCDC_SRC "${GEN_DST_DIR}/${L}/node_${GEN_NODE}_MCDC/${L}.mcdc.lus")
505
   Lustre_Compile(LUS_FILE "${MCDC_SRC}"
506
     NODE ${GEN_NODE}
507
     OPTS ${GEN_OPTS}
508
     DIR "${GEN_DST_DIR}/${L}/node_${GEN_NODE}_MCDC"
509
 #    DST_DIR ${GEN_DST_DIR}
510
     )
511

    
512
  
513
  add_test(NAME ${GEN_TESTS_PREFIX}_LUSTRET_MCDC_COMPILE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
514
    COMMAND  ${LUSTRE_COMPILER} ${LUSTREC_ARGS_${L}.mcdc_${GEN_NODE}_${LUS_OPTS_CUT}}
515
    WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_mcdc_${GEN_NODE}_${LUS_OPTS_CUT}}
516
    )
517

    
518
  SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_LUSTRET_MCDC_COMPILE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
519
    PROPERTIES 
520
    DEPENDS ${GEN_TESTS_PREFIX}_LUSTRET_MCDC_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID})
521
  
522
endfunction()
523

    
524
#****************************** LustreT strategies: generating the mutants
525

    
526

    
527
function(LustreT_mutants)
528
  set(options "")
529
  set(oneValueArgs  NODE LUS_FILE CALL_ID TESTS_PREFIX  SRC_DIR DST_DIR)
530
  set(multiValueArgs  OPTS )
531
  cmake_parse_arguments(GEN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
532

    
533
  get_lustre_name_ext(${GEN_LUS_FILE} L E)
534
#  get_filename_component(L ${GEN_LUS_FILE} NAME_WE)
535
  # First command generate C files from Lustre file
536
  Lustre_Compile(LUS_FILE ${GEN_LUS_FILE}
537
    NODE ${GEN_NODE}
538
    OPTS ${GEN_OPTS}
539
    DIR "${GEN_DST_DIR}/${L}/node_${GEN_NODE}_Mutants"
540
#    DST_DIR ${GEN_DST_DIR}
541
    )
542

    
543
#    set(LUSTRE_OUTPUT_DIR "${OUTPUT_PATH}/${L}/node_${LUS_NODE}")
544

    
545
  file(MAKE_DIRECTORY "${GEN_DST_DIR}/${L}/node_${GEN_NODE}_Mutants")
546

    
547
  add_test(NAME ${GEN_TESTS_PREFIX}_LUSTRET_MUTATION_GEN_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
548
    COMMAND  ${LUSTRE_T} ${LUSTREC_ARGS_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
549
    WORKING_DIRECTORY ${LUSTRE_OUTPUT_DIR_${L}_${GEN_NODE}_${LUS_OPTS_CUT}}
550
    )
551

    
552
  add_test(NAME ${GEN_TESTS_PREFIX}_LUSTRET_MUTATION_BUILDMAKE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
553
    COMMAND  "cmake" "."
554
    WORKING_DIRECTORY ${GEN_DST_DIR}/${L}/node_${GEN_NODE}_Mutants
555
    )
556

    
557
  add_test(NAME ${GEN_TESTS_PREFIX}_LUSTRET_MUTATION_BUILDBIN_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
558
    COMMAND  "make"
559
    WORKING_DIRECTORY ${GEN_DST_DIR}/${L}/node_${GEN_NODE}_Mutants
560
    )
561

    
562
  SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_LUSTRET_MUTATION_BUILDMAKE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
563
    PROPERTIES 
564
    DEPENDS ${GEN_TESTS_PREFIX}_LUSTRET_MUTATION_GEN_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID} )
565

    
566
  SET_TESTS_PROPERTIES ( ${GEN_TESTS_PREFIX}_LUSTRET_MUTATION_BUILDBIN_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID}
567
    PROPERTIES 
568
    DEPENDS ${GEN_TESTS_PREFIX}_LUSTRET_MUTATION_BUILDMAKE_${L}_${GEN_NODE}_${LUS_OPTS_CUT}_${GEN_CALL_ID} )
569

    
570
endfunction()
571

    
572

    
573

    
574

    
575

    
576