run_exec_autotests.bash 21.5 KB
Newer Older
thomasl's avatar
thomasl committed
1
#!/bin/bash
2
3
4
5
6
#/*
# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
# * contributor license agreements.  See the NOTICE file distributed with
# * this work for additional information regarding copyright ownership.
# * The OpenAirInterface Software Alliance licenses this file to You under
Cedric Roux's avatar
Cedric Roux committed
7
# * the OAI Public License, Version 1.1  (the "License"); you may not use this file
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# * except in compliance with the License.
# * You may obtain a copy of the License at
# *
# *      http://www.openairinterface.org/?page_id=698
# *
# * Unless required by applicable law or agreed to in writing, software
# * distributed under the License is distributed on an "AS IS" BASIS,
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# * See the License for the specific language governing permissions and
# * limitations under the License.
# *-------------------------------------------------------------------------------
# * For more information about the OpenAirInterface (OAI) Software Alliance:
# *      contact@openairinterface.org
# */
Rohit Gupta's avatar
Rohit Gupta committed
22
23

# \author Navid Nikaein, Rohit Gupta
thomasl's avatar
thomasl committed
24

25
26
if [ -s $OPENAIR_DIR/cmake_targets/tools/build_helper ] ; then
   source $OPENAIR_DIR/cmake_targets/tools/build_helper
thomasl's avatar
thomasl committed
27
28
29
30
31
else
   echo "Error: no file in the file tree: is OPENAIR_DIR variable set?"
   exit 1
fi

32
33
trap handle_ctrl_c INT

34
source $OPENAIR_DIR/cmake_targets/tools/test_helper
guptar's avatar
guptar committed
35

36

37
SUDO="sudo -E -S"
guptar's avatar
guptar committed
38
tdir=$OPENAIR_DIR/cmake_targets/autotests
39
40
rm -fr $tdir/bin 
mkdir -p $tdir/bin
Rohit Gupta's avatar
Rohit Gupta committed
41
results_file="$tdir/log/results_autotests.xml"
guptar's avatar
guptar committed
42
43
44
45
46
47
48
49

updated=$(svn st -q $OPENAIR_DIR)
if [ "$updated" != "" ] ; then
	echo "some files are not in svn:\n $updated"
fi

cd $tdir 

Rohit Gupta's avatar
Rohit Gupta committed
50
51
52
53
54
55
56
57
58
59
60
61
#\param $1 -> name of test case
#\param $2 -> name of compilation program
#\param $3 -> arguments for compilation program
#\param $4 -> name of pre-executable to install kernel modules, etc
#\param $5 -> arguments of pre-executable
#\param $6 -> name of executable
#\param $7 -> arguments for running the program
#\param $8 -> search expression
#\param $9 -> search expression which should NOT be found (for ex. segmentation fault) 
#\param $10 -> number of runs
#\param $11 -> pre_compile program execution
#\param $12 -> class of the test case (compilation, execution)
Rohit Gupta's avatar
Rohit Gupta committed
62
#\param $13 -> output of compilation program that needs to be found for test case to pass
63
#\param $14 -> tags to help identify the test case for readability in output xml file
64
function test_compile() {
Rohit Gupta's avatar
Rohit Gupta committed
65
66
67

    xUnit_start
    test_case_name=$1
68
69
    log_dir=$tdir/log/$test_case_name
    log_file=$log_dir/test.$1.log.txt
Rohit Gupta's avatar
Rohit Gupta committed
70
71
72
73
74
75
76
77
78
79
    compile_prog=$2
    compile_args=$3
    pre_exec_file=$4
    pre_exec_args=$5
    exec_args=$7
    search_expr_array=("${!8}")
    search_expr_negative=$9
    nruns=${10}
    pre_compile_prog=${11}
    class=${12}
Rohit Gupta's avatar
Rohit Gupta committed
80
    compile_prog_out=${13}
81
    tags=${14}
82
83
84
    xmlfile_testcase=$log_dir/test.$1.xml
    #build_dir=$tdir/$1/build
    #exec_file=$build_dir/$6
Rohit Gupta's avatar
Rohit Gupta committed
85
    
86
87
88
89
    #compile_prog_out=`eval "echo $compile_prog_out"`
    #echo "compile_prog_out = $compile_prog_out"
    read -a compile_prog_out_array <<< "$compile_prog_out"

Rohit Gupta's avatar
Rohit Gupta committed
90
91
    #Temporary log file where execution log is stored.
    temp_exec_log=$log_dir/temp_log.txt
92
93
    rm -fr $log_dir
    mkdir -p $log_dir
Rohit Gupta's avatar
Rohit Gupta committed
94
95
96
97
98
99
100
101
102
103
104
105
106
107



    #echo "log_dir = $log_dir"
    #echo "log_file = $log_file"
    #echo "exec_file = $exec_file"
    #echo "exec_args = $exec_args"
    #echo "search_expr = $search_expr"
    #echo "pre_exec_file = $pre_exec_file"
    #echo "nruns = $nruns"
    echo "class = $class"
    
    compile_prog_array=()
    read -a compile_prog_array <<<"$compile_prog"
108
    
109
110
    #tags_array=()
    #read -a tags_array <<<"$tags"
111
    
112
113
114
115
    #pre_compile_prog_array=()
    #readarray -t pre_compile_prog_array <<< "$pre_compile_prog"
    result=1
    result_string=""
Rohit Gupta's avatar
Rohit Gupta committed
116
117
    for (( run_index=1; run_index <= $nruns; run_index++ ))
    do
118
119
120
121
       
    #tags_array_index=0
    #for pre_compile_prog_array_index in "${pre_compile_prog_array[@]}"  
    #do
122
    
123
124
125
126
127
128
129
130
    #for compile_prog_array_index in "${compile_prog_array[@]}"  
    #do
       echo "Compiling test case $test_case_name.${tags} Log file = $log_file"  
       date=`date`
       echo "<COMPILATION LOG file=$test_case_name.${tags} , Run = $run_index>, Date = $date " >> $log_file
       #rm -fr $build_dir
       #mkdir -p $build_dir
       cd $log_dir
Rohit Gupta's avatar
Rohit Gupta committed
131
       {   
132
          uname -a
133
134
135
          compile_log_dir=`eval echo \"$OPENAIR_DIR/cmake_targets/log/\"`
          echo "Removing compilation log files in $compile_log_dir"
          rm -frv $compile_log_dir
136
137
          echo "Executing $pre_exec_file $pre_exe_args ...."
          eval $pre_exec_file  $pre_exec_args
138
139
140
141
          echo "Executing $compile_prog $compile_prog_args ...."
          eval $compile_prog  $compile_prog_args
          echo "Copying compilation log files to test case log directory: $log_dir"
          cp -fvr $OPENAIR_DIR/cmake_targets/log/ $log_dir/compile_log
Rohit Gupta's avatar
Rohit Gupta committed
142
143
144
       }>> $log_file 2>&1
       echo "</COMPILATION LOG>" >> $log_file 2>&1
       if [ "$class" == "compilation" ]; then
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
         for compile_prog_out_index in ${compile_prog_out_array[@]}
            do 
                if  [ -s "$compile_prog_out_index" ]; then
                    let "result = result&1"
                    
                    echo_success "$test_case_name.${tags} RUN = $run_index $compile_prog_out_index = compiled"
                    
                else
                    let "result = result&0"
                            
                    echo_error "$test_case_name.${tags} RUN = $run_index $compile_prog_out_index failed"
                    
                 fi
            done #end of for loop compile_prog_out_index
         if [ "$result" == "1" ]; then
            result_string=$result_string" Run_$run_index = PASS"
         else   
            result_string=$result_string" Run_$run_index = FAIL"           
Rohit Gupta's avatar
Rohit Gupta committed
163
         fi
164

Rohit Gupta's avatar
Rohit Gupta committed
165
       fi
166
167
168
       #let "tags_array_index++"
    #done # End of for loop compile_prog_array
    #done # End of for loop (pre_compile_prog_array_index)
Rohit Gupta's avatar
Rohit Gupta committed
169
    done #End of for loop (run_index)
170
171
172
173
174
175
176
177
    
   
    #If for for some reason upper for loop does not execute, we fail the test case completely
    if [ "$result_string" == "" ]; then
      result=0
    fi
    if [ "$result" == "1" ]; then
      echo_success "$test_case_name.${tags} PASSED"
178
      xUnit_success "compilation" "$test_case_name.$tags" "PASS" "$result_string" "$xmlfile_testcase" ""
179
    else             
Rohit Gupta's avatar
Rohit Gupta committed
180
      echo_error "$test_case_name.${tags} FAILED"
181
      xUnit_fail "compilation" "$test_case_name.$tags" "FAIL" "$result_string" "$xmlfile_testcase" ""
182
    fi
Rohit Gupta's avatar
Rohit Gupta committed
183
184
185
}


guptar's avatar
guptar committed
186
187
188
189
190
191
192
193
194

#\param $1 -> name of test case
#\param $2 -> name of compilation program
#\param $3 -> arguments for compilation program
#\param $4 -> name of pre-executable to install kernel modules, etc
#\param $5 -> arguments of pre-executable
#\param $6 -> name of executable
#\param $7 -> arguments for running the program
#\param $8 -> search expression
195
196
#\param $9 -> search expression which should NOT be found (for ex. segmentation fault) 
#\param $10 -> number of runs
Rohit Gupta's avatar
Rohit Gupta committed
197
198
#\param $11 -> pre_compile program execution
#\param $12 -> class of the test case (compilation, execution)
199
200
#\param $13 -> output of compilation program that needs to be found for test case to pass
#\param $14 -> tags to help identify the test case for readability in output xml file
201
#\param $15 => password for the user to run certain commands as sudo
202
#\param $16 => test config file params to be modified
Raphael Defosseux's avatar
Raphael Defosseux committed
203
#\param $17 => bypass flag if main_exec if available
204
#\param $18 -> desc to help identify the test case for readability in output xml file
guptar's avatar
guptar committed
205

206
function test_compile_and_run() {
guptar's avatar
guptar committed
207
    xUnit_start
Rohit Gupta's avatar
Rohit Gupta committed
208
    test_case_name=$1
209
210
    log_dir=$tdir/log/$test_case_name
    log_file=$log_dir/test.$1.log.txt
guptar's avatar
guptar committed
211
212
213
214
    compile_prog=$2
    compile_args=$3
    pre_exec_file=$4
    pre_exec_args=$5
215
    main_exec=$6
guptar's avatar
guptar committed
216
    exec_args=$7
guptar's avatar
guptar committed
217
    search_expr_array=("${!8}")
218
219
    search_expr_negative=$9
    nruns=${10}
Rohit Gupta's avatar
Rohit Gupta committed
220
221
    pre_compile_prog=${11}
    class=${12}
222
223
    compile_prog_out=${13}
    tags=${14}
224
    mypassword=${15}
225
    test_config_file=${16}
Raphael Defosseux's avatar
Raphael Defosseux committed
226
    bypass_compile=${17}
227
    desc=${18}
228

guptar's avatar
guptar committed
229
    build_dir=$tdir/$1/build
230
231
    #exec_file=$build_dir/$6
    xmlfile_testcase=$log_dir/test.$1.xml
guptar's avatar
guptar committed
232
233
    #Temporary log file where execution log is stored.
    temp_exec_log=$log_dir/temp_log.txt
234
    export OPENAIR_LOGDIR=$log_dir
235
236
237
238
239
    rm -fr $log_dir
    mkdir -p $log_dir
    
    echo "" > $temp_exec_log
    echo "" > $log_file
240
241
242
    #echo "log_dir = $log_dir"
    #echo "log_file = $log_file"
    #echo "exec_file = $exec_file"
Rohit Gupta's avatar
Rohit Gupta committed
243
    #echo "exec_args = $exec_args"
244
245
246
    #echo "search_expr = $search_expr"
    #echo "pre_exec_file = $pre_exec_file"
    #echo "nruns = $nruns"
Rohit Gupta's avatar
Rohit Gupta committed
247
    echo "class = $class"
248
    #echo "desc = $desc"
guptar's avatar
guptar committed
249
    
250
251
    #compile_prog_array=()
    #read -a compile_prog_array <<<"$compile_prog"
252
253
254
255

    #test_config_file=`eval "echo \"$test_config_file\" "`

    #echo "test_config_file = $test_config_file"
Rohit Gupta's avatar
Rohit Gupta committed
256
  
257
258
    tags_array=()
    read -a tags_array <<<"$tags"
259
260
    desc_array=()
    readarray -t desc_array <<<"$desc"
261
262
263
    
    main_exec_args_array=()
    readarray -t main_exec_args_array <<< "$exec_args"
264
    
Raphael Defosseux's avatar
Raphael Defosseux committed
265
266
267
268
269
270
271
    REAL_MAIN_EXEC=`eval "echo $main_exec"`
    if [ "$bypass_compile" == "1" ] && [ -f $REAL_MAIN_EXEC ]
    then
        echo "Bypassing compilation for $main_exec"
    else
        rm -fr $OPENAIR_DIR/cmake_targets/log

272
273
274
275
    #for search_expr in "${compile_prog_array[@]}"  
    #do
       echo "Compiling test case $test_case_name Log file = $log_file"  
       echo "<COMPILATION LOG file=$log_file>" >> $log_file
Rohit Gupta's avatar
Rohit Gupta committed
276

277
278
       #rm -fr $build_dir
       #mkdir -p $build_dir
Rohit Gupta's avatar
Rohit Gupta committed
279

280
       cd $log_dir
Rohit Gupta's avatar
Rohit Gupta committed
281
       {   
282
          uname -a
283
284
285
286
287
288
289
290
          echo "Executing $pre_compile_prog"
          eval $pre_compile_prog
 
          if [ "$test_config_file" != "" ]; then
            echo "Modifying test_config_file parameters..."
            echo "$test_config_file" |xargs -L 1 $OPENAIR_DIR/cmake_targets/autotests/tools/search_repl.py 
          fi
          echo "Executing $compile_prog $compile_args"
291
292
293
          eval "$compile_prog $compile_args"
          echo "Copying compilation log files to test case log directory: $log_dir"
          cp -fvr $OPENAIR_DIR/cmake_targets/log/ $log_dir/compile_log
Rohit Gupta's avatar
Rohit Gupta committed
294
295
       }>> $log_file 2>&1
       echo "</COMPILATION LOG>" >> $log_file 2>&1
296
    #done
Raphael Defosseux's avatar
Raphael Defosseux committed
297
    fi
298
    
Rohit Gupta's avatar
Rohit Gupta committed
299
300
    #process the test case if it is that of execution
    if [ "$class" == "execution" ]; then
301
302
303
      tags_array_index=0
      for main_exec_args_array_index in "${main_exec_args_array[@]}"  
      do
304
305
        global_result=1
        result_string=""
306
307
308
        PROPER_DESC=`echo ${desc_array[$tags_array_index]} | sed -e "s@^.*Test cases.*(Test@Test@" -e "s@^ *(@@" -e"s/)$//" -e "s/),$//"`
        echo_info "$PROPER_DESC"

309
       for (( run_index=1; run_index <= $nruns; run_index++ ))
Rohit Gupta's avatar
Rohit Gupta committed
310
        do
311
312
          temp_exec_log=$log_dir/test.$test_case_name.${tags_array[$tags_array_index]}.run_$run_index
          echo "" > $temp_exec_log
guptar's avatar
guptar committed
313

314
315
316
317
318
          echo "Executing test case $test_case_name.${tags_array[$tags_array_index]}, Run Index = $run_index, Execution Log file = $temp_exec_log"

          echo "-----------------------------------------------------------------------------" >> $temp_exec_log  2>&1
          echo "<EXECUTION LOG Test Case = $test_case_name.${tags_array[$tags_array_index]}, Run = $run_index >" >> $temp_exec_log  2>&1
           
319
          if [ -n "$pre_exec_file" ]; then
320
            {  echo " Executing $pre_exec_file $pre_exec_args " 
321
               eval " $pre_exec_file $pre_exec_args " ; }>> $temp_exec_log  2>&1
322

323
          fi
324
325
          echo "Executing $main_exec $main_exec_args_array_index "
          echo "Executing $main_exec $main_exec_args_array_index " >> $temp_exec_log
326
          { uname -a ; eval "$main_exec $main_exec_args_array_index" ;} >> $temp_exec_log  2>&1
327

328
          echo "</EXECUTION LOG Test Case = $test_case_name.${tags_array[$tags_array_index]},  Run = $run_index >" >> $temp_exec_log  2>&1
329
          cat $temp_exec_log >> $log_file  2>&1
330
          
guptar's avatar
guptar committed
331
    
332
333
334
          result=1
          for search_expr in "${search_expr_array[@]}"
          do
guptar's avatar
guptar committed
335
     
336
            search_result=`grep -E "$search_expr" $temp_exec_log`
guptar's avatar
guptar committed
337

338
339
            #echo "search_expr  =   $search_expr"
            #echo "search_result = $search_result"
guptar's avatar
guptar committed
340

341
342
343
344
345
346
            if [ -z "$search_result" ]; then
              let "result = result & 0"
            else
              let "result = result & 1"
            fi
          done
347
348
349
350
351
352
353
          
          #If we find a negative search result then there is crash of program and test case is failed even if above condition is true
          search_result=`grep -iE "$search_expr_negative" $temp_exec_log`
          if [ -n "$search_result" ]; then
            result=0
          fi
          let "global_result = global_result & result"
guptar's avatar
guptar committed
354

355
          #echo "result = $result"
356
357
358
          
          #this is a result of this run
          #test_case_result=""
359
          if [ "$result" -eq "0" ]; then
360
361
            result_string=$result_string" Run_$run_index =FAIL"
            echo_error "$test_case_name.${tags_array[$tags_array_index]} RUN = $run_index Result = FAIL"
362
          fi
guptar's avatar
guptar committed
363

364
          if [ "$result" -eq "1" ]; then
365
366
            result_string=$result_string" Run_$run_index =PASS"
            echo_success "$test_case_name.${tags_array[$tags_array_index]} RUN = $run_index Result = PASS"
367
          fi
guptar's avatar
guptar committed
368

369
          
370
371
372
373
374
375
        done #End of for loop (nindex)

       echo " Result String = $result_string" 

       if [ "$result_string" == "" ]; then
           echo_error "execution $test_case_name.$compile_prog.${tags_array[$tags_array_index]} Run_Result = \"$result_string\"  Result = FAIL"
376
	   xUnit_fail "execution" "$test_case_name.${tags_array[$tags_array_index]}" "FAIL" "$result_string" "$xmlfile_testcase" "$PROPER_DESC"
377
378
379
       else
        if [ "$global_result" == "0" ]; then
           echo_error "execution $test_case_name.${tags_array[$tags_array_index]} Run_Result = \"$result_string\" Result =  FAIL"
380
           xUnit_fail "execution" "$test_case_name.${tags_array[$tags_array_index]}" "FAIL" "$result_string" "$xmlfile_testcase" "$PROPER_DESC"
381
382
383
384
        fi

        if [ "$global_result" == "1" ]; then
            echo_success "execution $test_case_name.${tags_array[$tags_array_index]} Run_Result = \"$result_string\"  Result = PASS "
385
	    xUnit_success "execution" "$test_case_name.${tags_array[$tags_array_index]}" "PASS" "$result_string"   "$xmlfile_testcase"  "$PROPER_DESC"
386
387
388
        fi  
       fi

389
       let "tags_array_index++"
390
     done 
Rohit Gupta's avatar
Rohit Gupta committed
391
   fi
392
   rm -fr $build_dir
guptar's avatar
guptar committed
393
394
}

thomasl's avatar
thomasl committed
395
396
397
dbin=$OPENAIR_DIR/cmake_targets/autotests/bin
dlog=$OPENAIR_DIR/cmake_targets/autotests/log

guptar's avatar
guptar committed
398

399
function print_help() {
Rohit Gupta's avatar
Rohit Gupta committed
400
401
402
403
404
405
406
407
 echo_info '
This program runs automated test case system for OpenAirInterface
You should have ubuntu 14.xx, updated, and the Linux kernel >= 3.14
Options
-h | --help
   This help
-g | --run-group
   Run test cases in a group. For example, ./run_exec_autotests "0101* 010102"
Rohit Gupta's avatar
Rohit Gupta committed
408
409
-p
   Use password for logging
Raphael Defosseux's avatar
Raphael Defosseux committed
410
411
412
413
414
415
-np | --no-password
   No need for a password
-q | --quiet
   Quiet  mode;  eliminate  informational  messages and comment prompts.
-b | --bypass-compile
   Bypass compilation of main-exec if already present
Rohit Gupta's avatar
Rohit Gupta committed
416
417
'
}
thomasl's avatar
thomasl committed
418

419
function main () {
Raphael Defosseux's avatar
Raphael Defosseux committed
420
421
QUIET=0
BYPASS_COMPILE=0
Rohit Gupta's avatar
Rohit Gupta committed
422
RUN_GROUP=0
Rohit Gupta's avatar
Rohit Gupta committed
423
424
SET_PASSWORD=0
passwd=""
425
426
427
test_case_group=""
test_case_group_array=()
test_case_array=()
428
echo_info "Note that the user should be sudoer for executing certain commands, for example loading kernel modules"
Rohit Gupta's avatar
Rohit Gupta committed
429

Rohit Gupta's avatar
Rohit Gupta committed
430
431
432
433
434
435

until [ -z "$1" ]
  do
    case "$1" in
       -g | --run-group)
            RUN_GROUP=1
436
            test_case_group=$2
437
            test_case_group=`sed "s/\+/\*/g" <<<  "${test_case_group}"` # Replace + with * for bash string substituion
438
            echo_info "Will execute test cases only in group $test_case_group"
Rohit Gupta's avatar
Rohit Gupta committed
439
            shift 2;;
Rohit Gupta's avatar
Rohit Gupta committed
440
441
442
443
        -p)
            SET_PASSWORD=1
            passwd=$2
            shift 2;;
Raphael Defosseux's avatar
Raphael Defosseux committed
444
445
446
447
448
449
450
451
452
453
        -np|--no-password)
            SET_PASSWORD=1
            shift ;;
        -q|--quiet)
            QUIET=1
            shift ;;
        -b|--bypass-compile)
            BYPASS_COMPILE=1
            echo "bypass option ON"
            shift ;;
Rohit Gupta's avatar
Rohit Gupta committed
454
455
456
457
458
459
460
461
462
        -h | --help)
            print_help
            exit 1;;
	*)
	    print_help
            echo_fatal "Unknown option $1"
            break;;
   esac
  done
Rohit Gupta's avatar
Rohit Gupta committed
463

464
465
if [ "$SET_PASSWORD" != "1" ]; then
   read -s -p "Enter Password: " passwd
Rohit Gupta's avatar
Rohit Gupta committed
466
467
468
fi

tmpfile=`mktemp`
469
echo $passwd | $SUDO echo $HOME > $tmpfile
Rohit Gupta's avatar
Rohit Gupta committed
470
tstsudo=`cat $tmpfile`
Rohit Gupta's avatar
Rohit Gupta committed
471
if [ "$tstsudo" != "$HOME" ]; then
472
  echo "$USER might not have sudo privileges. Exiting" 
Rohit Gupta's avatar
Rohit Gupta committed
473
  exit
474
475
else
  echo "$USER has sudo privileges"
Rohit Gupta's avatar
Rohit Gupta committed
476
477
478
fi
echo "tstsudo = $tstsudo"
rm -fr $tmpfile
479

Rohit Gupta's avatar
Rohit Gupta committed
480
481
xml_conf="$OPENAIR_DIR/cmake_targets/autotests/test_case_list.xml"

482
test_case_list=`xmlstarlet sel -T -t -m /testCaseList/testCase -s A:N:- "@id" -v "@id" -n $xml_conf`
483
test_case_excl_list=`xmlstarlet sel -t -v "/testCaseList/TestCaseExclusionList" $xml_conf`
Raphael Defosseux's avatar
Raphael Defosseux committed
484
if [ $QUIET -eq 0 ]; then echo "Test Case Exclusion List = $test_case_excl_list "; fi
485
486
487
488

test_case_excl_list=`sed "s/\+/\*/g" <<< "$test_case_excl_list" ` # Replace + with * for bash string substituion

read -a test_case_excl_array <<< "$test_case_excl_list"
Rohit Gupta's avatar
Rohit Gupta committed
489

Raphael Defosseux's avatar
Raphael Defosseux committed
490
if [ $QUIET -eq 0 ]; then echo "test_case_list = $test_case_list"; fi
Rohit Gupta's avatar
Rohit Gupta committed
491

Raphael Defosseux's avatar
Raphael Defosseux committed
492
if [ $QUIET -eq 0 ]; then echo "Test Case Exclusion List = $test_case_excl_list \n"; fi
493

Rohit Gupta's avatar
Rohit Gupta committed
494
495
readarray -t test_case_array <<<"$test_case_list"

496
497
read -a test_case_group_array <<< "$test_case_group"
 
Rohit Gupta's avatar
Rohit Gupta committed
498
499
for search_expr in "${test_case_array[@]}"
  do
500
501
502
503
504
505
506
507
508
509
510
511
512
513
    flag_run_test_case=0
    # search if this test case needs to be executed
    if [ "$RUN_GROUP" -eq "1" ]; then
       for search_group in "${test_case_group_array[@]}"
       do  
          if [[ $search_expr == $search_group ]];then
             flag_run_test_case=1
             echo_info "Test case $search_expr match found in group"
             break
          fi
       done
    else
       flag_run_test_case=1
    fi
514

515
516
517
518
    for search_excl in "${test_case_excl_array[@]}"
       do  
          if [[ $search_expr == $search_excl ]];then
             flag_run_test_case=0
Raphael Defosseux's avatar
Raphael Defosseux committed
519
             if [ $QUIET -eq 0 ]; then echo_info "Test case $search_expr match found in test case excl group. Will skip the test case for execution..."; fi
520
521
522
523
             break
          fi
       done

524

525
526
527
528
529
    #We skip this test case if it is not in the group list
    if [ "$flag_run_test_case" -ne "1" ]; then
      continue
    fi

Rohit Gupta's avatar
Rohit Gupta committed
530
    name=$search_expr
531
532
533
534
535
536
537
538
539
540
541
542
543
544
    class=`xmlstarlet sel -t -v "/testCaseList/testCase[@id='$search_expr']/class" $xml_conf`
    desc=`xmlstarlet sel -t -v "/testCaseList/testCase[@id='$search_expr']/desc" $xml_conf`
    pre_compile_prog=`xmlstarlet sel -t -v "/testCaseList/testCase[@id='$search_expr']/pre_compile_prog" $xml_conf`
    compile_prog=`xmlstarlet sel -t -v "/testCaseList/testCase[@id='$search_expr']/compile_prog" $xml_conf`
    compile_prog_args=`xmlstarlet sel -t -v "/testCaseList/testCase[@id='$search_expr']/compile_prog_args" $xml_conf`
    pre_exec=`xmlstarlet sel -t -v "/testCaseList/testCase[@id='$search_expr']/pre_exec" $xml_conf`
    pre_exec_args=`xmlstarlet sel -t -v "/testCaseList/testCase[@id='$search_expr']/pre_exec_args" $xml_conf`
    main_exec=`xmlstarlet sel -t -v "/testCaseList/testCase[@id='$search_expr']/main_exec" $xml_conf`
    main_exec_args=`xmlstarlet sel -t -v "/testCaseList/testCase[@id='$search_expr']/main_exec_args" $xml_conf`
    search_expr_true=`xmlstarlet sel -t -v "/testCaseList/testCase[@id='$search_expr']/search_expr_true" $xml_conf`
    search_expr_false=`xmlstarlet sel -t -v "/testCaseList/testCase[@id='$search_expr']/search_expr_false" $xml_conf`
    nruns=`xmlstarlet sel -t -v "/testCaseList/testCase[@id='$search_expr']/nruns" $xml_conf`
    compile_prog_out=`xmlstarlet sel -t -v "/testCaseList/testCase[@id='$search_expr']/compile_prog_out" $xml_conf`
    tags=`xmlstarlet sel -t -v "/testCaseList/testCase[@id='$search_expr']/tags" $xml_conf`
545
    test_config_file=`xmlstarlet sel -t -v "/testCaseList/testCase[@id='$search_expr']/test_config_file" $xml_conf`
Rohit Gupta's avatar
Rohit Gupta committed
546

Rohit Gupta's avatar
Rohit Gupta committed
547
548
549
550
551
    echo "class = $class"
    echo "name = $name"
    echo "Description = $desc"
    echo "pre_compile_prog = $pre_compile_prog"
    echo "compile_prog = $compile_prog"
552
553
    echo "compile_prog_args = $compile_prog_args"
    echo "compile_prog_out = $compile_prog_out"
Rohit Gupta's avatar
Rohit Gupta committed
554
555
556
557
558
559
560
561
    echo "pre_exec = $pre_exec"
    echo "pre_exec_args = $pre_exec_args"
    echo "main_exec = $main_exec"
    echo "main_exec_args = $main_exec_args"
    echo "search_expr_true = $search_expr_true"
    echo "search_expr_false = $search_expr_false"
    echo "nruns = $nruns"

562

Rohit Gupta's avatar
Rohit Gupta committed
563
    #eval $pre_exec
564
    compile_prog_out=`eval echo \"$compile_prog_out\"`
Rohit Gupta's avatar
Rohit Gupta committed
565
566
567

    search_array_true=()

Raphael Defosseux's avatar
Raphael Defosseux committed
568
569
    IFS=\"                  #set the shell field separator
    set -f                  #dont try to glob 
Rohit Gupta's avatar
Rohit Gupta committed
570
571
572
573
574
575
576
577
578
579
580
581
582
    #set -- $search_expr_true             #split on $IFS
    for i in $search_expr_true
      do echo "i = $i"
        if [ -n "$i" ] && [ "$i" != " " ]; then
          search_array_true+=("$i")
          #echo "inside i = \"$i\" "
        fi 
      done
    unset IFS 

    #echo "arg1 = ${search_array_true[0]}"
    #echo " arg2 = ${search_array_true[1]}"
    if [ "$class" == "compilation" ]; then
583
        test_compile "$name" "$compile_prog" "$compile_prog_args" "$pre_exec" "$pre_exec_args" "$main_exec" "$main_exec_args" "search_array_true[@]" "$search_expr_false" "$nruns" "$pre_compile_prog" "$class" "$compile_prog_out" "$tags" "$desc"
584
    elif  [ "$class" == "execution" ]; then
585
        echo \'passwd\' | $SUDO killall -q oaisim_nos1
586
        test_compile_and_run "$name" "$compile_prog" "$compile_prog_args" "$pre_exec" "$pre_exec_args" "$main_exec" "$main_exec_args" "search_array_true[@]" "$search_expr_false" "$nruns" "$pre_compile_prog" "$class" "$compile_prog_out" "$tags" "$mypassword" "$test_config_file" "$BYPASS_COMPILE" "$desc"
Rohit Gupta's avatar
Rohit Gupta committed
587
    else
Rohit Gupta's avatar
Rohit Gupta committed
588
        echo "Unexpected class of test case...Skipping the test case $name ...."
Rohit Gupta's avatar
Rohit Gupta committed
589
590
591
592
593
594
595
596
    fi

    done
    
    

}

597
598
uname -a

Rohit Gupta's avatar
Rohit Gupta committed
599
main "$@"
Rohit Gupta's avatar
Rohit Gupta committed
600
601
602
603
604
605
606
607
608

xUnit_write "$results_file"

echo "Test Results are written to $results_file"

exit