source: branches/dev-5819/jm_tests.in @ 13903

Last change on this file since 13903 was 13903, checked in by aramle, 5 weeks ago

#5819 Testing without mktemp continuing.

File size: 19.6 KB
Line 
1#!/bin/bash
2# Script for running JModelica.org test suites.
3# Copy this file to somewhere in your PATH.
4# You may need to change variables below (in the copy) to match your system.
5# Type "tests -h" for usage.
6# Requires Unix-like system with bash, grep, dc, mktemp, uname and sed.
7
8merge_path() {
9  if [ "$1" = "" ]; then
10    if [ "$3" = "" ]; then
11      echo $2
12    else
13      echo $3@SEP@$2
14    fi
15  else
16    echo $1@SEP@$2
17  fi
18}
19
20# ====== Variables to set ======
21
22# Memory allocation for the ant process
23ANT_OPTS="-Xmx4g"
24
25# Default tests - run if no tests are chosen
26# Possible values: modelica, optimica, python or combination (e.g. "modelica optimica")
27DEFAULT_TESTS="optimica python"
28
29# Default arguments - always parse these arguments before command line
30DEFAULT_ARGS=""
31
32# Variables set by configure script
33JMODELICA_HOME="@prefix@"
34JMODELICA_SRC="@abs_top_srcdir@"
35IPOPT_HOME="@IPOPT_HOME@"
36IPOPT32_HOME="@IPOPT_HOME@"
37IPOPT64_HOME="@IPOPT64_HOME@"
38PYTHON64_HOME="@PYTHON64_HOME@"
39PYTHON32_HOME="@PYTHON_HOME@"
40SUNDIALS_HOME="@prefix@/ThirdParty/Sundials"
41CASADI_HOME="@prefix@/ThirdParty/CasADi"
42CASADI64_HOME="@prefix@/ThirdParty/CasADi64"
43CASADI_INTERFACE_HOME="@prefix@/lib/casadi_interface"
44CASADI_INTERFACE_HOME64="@prefix@/lib/casadi_interface64"
45CASADI_INTERFACE_HOME32=${CASADI_INTERFACE_HOME}
46ECLIPSE_HOME="@ECLIPSE_HOME@"
47JPYPE32_JVM="@JVMDLL_HOME@/jvm.dll"
48JPYPE64_JVM="@JVMDLL64_HOME@/jvm.dll"
49ORIG_PATH="@ORIG_PATH@"
50BUILD="@abs_builddir@"
51if [[ "${JAVA_HOME}" == "" ]]; then
52  JAVA_HOME="@_JAVA_HOME_@"
53fi
54
55if [[ "${PYTHON64_HOME}" != "" ]]; then
56DEFAULT_TESTS="${DEFAULT_TESTS} python64"
57fi
58
59# ====== End variables to set ======
60
61# Configure Bash
62set -o pipefail
63
64PYTHONPATH64="${JMODELICA_HOME}/Python_64/"
65PYTHONPATH32="$(merge_path "${PYTHONPATH}" "${JMODELICA_HOME}/Python/")"
66PYTHONPATH="$PYTHONPATH32"
67
68# To know if we are running python 64 tests
69PYTHON64=0
70
71# Default paths to ant files used for unit tests
72if [[ -z "${MC_ANT_ARGS}" ]]; then
73    MC_ANT_ARGS=${JMODELICA_SRC}/Compiler/ModelicaCompiler/build.xml
74fi
75if [[ -z "${OC_ANT_ARGS}" ]]; then
76    OC_ANT_ARGS=${JMODELICA_SRC}/Compiler/OptimicaCompiler/build.xml
77fi
78
79# Find operating system
80SYS="$(uname -s)"
81if [[ "${SYS}" == "Darwin" ]]; then
82  SYS=Mac
83elif [[ "${SYS:0:5}" == "MINGW" ]]; then
84  SYS=Win
85fi
86
87# Update library path
88if [[ "${SUNDIALS_HOME}" != "" ]]; then
89  LIB_PATH="${SUNDIALS_HOME}/lib"
90fi
91if [[ "${IPOPT_HOME}" != "" ]]; then
92  LIB_PATH="$(merge_path "${LIB_PATH}" "${IPOPT_HOME}/lib")"
93fi
94if [[ "${CASADI_HOME}" != "" ]]; then
95  LIB_PATH="$(merge_path "${LIB_PATH}" "${CASADI_HOME}/lib")"
96fi
97if [[ "${LIB_PATH}" != "" ]]; then
98  LD_LIBRARY_PATH="$(merge_path "${LD_LIBRARY_PATH}" "${LIB_PATH}" /lib)"
99fi
100
101# Test sets
102if [[ "${PYTHON64_HOME}" != "" ]]; then
103    test_set_a="modelica optimica python python64"
104    tests="modelica optimica python python64"
105else
106    test_set_a="modelica optimica python"
107    tests="modelica optimica python"
108fi
109test_set_j="modelica optimica"
110test_set_m="modelica"
111test_set_o="optimica"
112test_set_p="python"
113test_set_z="python64"
114
115# Standard set of tags
116TAGS="-a stddist_base -a noncompliantfmi"
117if [[ "${IPOPT_HOME}" != "" ]]; then
118  TAGS="${TAGS} -a ipopt"
119  if [[ "${SYS}" == Win ]]; then
120    TAGS="${TAGS} -a windows_base"
121  fi
122  if [[ -e "${JMODELICA_HOME}/Python/casadi" ]]; then
123    TAGS="${TAGS} -a casadi_base"
124  else
125    echo Skipping casadi tests, since CasADi does not seem to be installed.
126  fi
127fi
128
129# Standard set of tags
130TAGS64="-a stddist_base -a noncompliantfmi"
131if [[ "${IPOPT64_HOME}" != "" ]]; then
132  TAGS64="${TAGS64} -a ipopt"
133  if [[ "${SYS}" == Win ]]; then
134    TAGS64="${TAGS64} -a windows_base"
135  fi
136  if [[ -e "${JMODELICA_HOME}/Python_64/casadi" ]]; then
137    TAGS64="${TAGS64} -a casadi_base"
138  else
139    echo Skipping casadi tests, since CasADi does not seem to be installed.
140  fi
141fi
142
143# Extend with all tests for default version of Python/bitness
144if [[ "${PYTHON64_HOME}" != "" ]]; then
145    TAGS64="${TAGS64} -a stddist_full"
146    if [[ "${IPOPT64_HOME}" != "" ]]; then
147        if [[ "${SYS}" == Win ]]; then
148            TAGS64="${TAGS64} -a windows_full"
149        fi
150        if [[ -e "${JMODELICA_HOME}/Python_64/casadi" ]]; then
151            TAGS64="${TAGS64} -a casadi_full"
152        fi
153    fi 
154else
155    TAGS="${TAGS} -a stddist_full"
156    if [[ "${IPOPT_HOME}" != "" ]]; then
157        if [[ "${SYS}" == Win ]]; then
158            TAGS="${TAGS} -a windows_full"
159        fi
160        if [[ -e "${JMODELICA_HOME}/Python/casadi" ]]; then
161            TAGS="${TAGS} -a casadi_full"
162        else
163            echo Skipping casadi tests, since CasADi does not seem to be installed.
164        fi
165    fi
166fi
167
168# Functions for running specific tests
169function modelica_tests() {
170  junit_test Modelica
171}
172
173function optimica_tests() {
174  echo "in optimica_tests()"
175  junit_test Optimica
176}
177
178TESTS_DIR="${JMODELICA_HOME}/Python/tests_jmodelica"
179function find_python_tests() {
180  if [[ "${TESTS}" == "" ]]; then
181    TESTS="$(find ${TESTS_DIR} -name \*.py | grep test_)"
182  fi
183}
184
185function python_tests() {
186  if [ "${KEEP_PYTHON}" == 1 ]; then
187    TEST_DIR="$(pwd)/tests_$(date "+%F_%H-%M-%S")"
188    mkdir ${TEST_DIR}
189  else
190    TEST_DIR="$(pwd)/tests_tmp"
191    mkdir ${TEST_DIR}
192    ls -la
193  fi
194  print_name Python
195  res=0
196  echo "in python_tests OUTPUT=${OUTPUT}"
197  echo "in python_tests  TEST_DIR=${TEST_DIR}"
198  case ${OUTPUT} in
199    v)
200      if build_jmodelica 2>&1 | log; then
201        find_python_tests
202        cd ${TEST_DIR}
203        python_tests_v || res=1
204      fi
205      ;;
206    q)
207      if build_jmodelica 2>&1 | log > /dev/null; then
208        find_python_tests
209        cd ${TEST_DIR}
210        python_tests_q | filter_python_separate || res=1
211      else
212        echo BUILD FAILED
213      fi
214      ;;
215    n)
216      if [[ "${NO_BUILD_JMODELICA}" != "1" ]]; then
217        echo "OUTPUT=${OUTPUT}"
218        echo "NO_BUILD_JMODELICA=${NO_BUILD_JMODELICA}"
219        echo Building...
220      fi
221      if build_jmodelica | log > /dev/null; then
222        find_python_tests
223        cd ${TEST_DIR}
224        python_tests_n | filter_python_separate || res=1
225      fi
226      ;;
227  esac
228  if [ ! "${KEEP_PYTHON}" == 1 ]; then
229    cd ..
230    rm -rf ${TEST_DIR}
231  fi
232  return $res
233}
234
235TESTS64_DIR="${JMODELICA_HOME}/Python_64/tests_jmodelica"
236function python64_tests() {
237    # Set necessary paths etc to run 64 bit tests
238    PYTHONPATH=${PYTHONPATH64}
239    PYTHONHOME=${PYTHON64_HOME}
240    JPYPE_JVM=${JPYPE64_JVM}
241    CASADI_LIB_HOME=${CASADI64_HOME}/lib
242    CASADI_INTERFACE_HOME=${CASADI_INTERFACE_HOME64}
243    PATH=${PYTHON64_HOME}:${PYTHON64_HOME}/Scripts:${PYTHON64_HOME}/Lib:${IPOPT64_HOME}/bin:${CASADI_LIB_HOME}:"${PATH}"
244    TESTS32=$TESTS
245    TESTS=$TESTS64
246    TAGS32=$TAGS
247    TAGS=$TAGS64
248    TESTS_DIR=${TESTS64_DIR}
249    PYTHON64=1
250    # Call python_tests
251    res=0
252    python_tests || res=1
253    # Reset to original paths etc that was for original Python
254    TESTS=$TESTS32
255    TAGS=$TAGS32
256    PYTHON64=0
257    PYTHONPATH=${PYTHONPATH32}
258    PYTHONHOME=${PYTHON32_HOME}
259    JPYPE_JVM=${JPYPE32_JVM}
260    CASADI_LIB_HOME=${CASADI_HOME}/lib
261    CASADI_INTERFACE_HOME=${CASADI_INTERFACE_HOME32}
262    PATH="${ORIG_PATH}"
263    TESTS_DIR="${JMODELICA_HOME}/Python/tests_jmodelica"
264    return $res
265}
266
267function python_tests_v() {
268    res=0
269    for TEST in ${TESTS}; do
270      echo ""
271      echo "Running ${TEST}"
272      # echo ${TEST} | sed -e 's!^.*jmodelica.!Running !'
273      nose_test ${TEST} \
274      | log \
275      || res=1
276    done
277    return $res
278}
279
280function python_tests_q() {
281    res=0
282    for TEST in ${TESTS}; do
283      echo "" | log > /dev/null
284      echo ${TEST} | sed -e 's!^.*jmodelica.!Running !' | log > /dev/null
285      nose_test ${TEST} 2>&1 \
286      | log \
287      | sed -n -e 's!^OK$!PASSED!ip' -e 's!^FAILED !TEST FAILED!p' \
288      || (res=1 && echo NOSETESTS_NOT_OK)
289    done
290    return $res
291}
292
293function python_tests_n() {
294    PATTERN="[-=]{40,}"
295    res=0
296    for TEST in ${TESTS}; do
297      echo "" | log
298      echo ${TEST} | sed -e 's!^.*jmodelica.!Running !' | log
299      nose_test ${TEST} 2>&1 \
300      | log \
301      | egrep -v '^Exception .* ignored$' \
302      | egrep -A500 "${PATTERN}" \
303      | sed -e 's!^OK$!PASSED!' -e 's!^FAILED !TEST FAILED!' \
304      || (res=1 && echo NOSETESTS_NOT_OK)
305    done
306    return $res
307}
308
309# Helper functions
310function print_name() {
311  if [[ "${OUTPUT}" == q ]]; then
312    echo -n "$1... "
313  else
314    echo ======= $1 =======
315  fi
316}
317
318function log() {
319  if [ "${LOG}" == 1 ]; then
320      tee -a "${LOGFILE}"
321  else
322      cat
323  fi
324}
325
326function filter_python_separate() {
327  TMP=$(mktemp -q /tmp/jm_tests.XXXXXX 2>/dev/null) 
328  tee ${TMP} | egrep -v "(PASSED|TEST FAILED|NOSETESTS_NOT_OK)"
329  cat ${TMP} \
330  | sed -n \
331        -e '1 i\
332            0 0 0' \
333        -e 's!^TEST FAILED(errors=\([0-9]*\))!\1+!p' \
334        -e 's!^TEST FAILED(failures=\([0-9]*\))!r\1+r!p' \
335        -e 's!^TEST FAILED(errors=\([0-9]*\), failures=\([0-9]*\))!\1+r\2+r!p' \
336        -e 's!^NOSETESTS_NOT_OK!sar1+rla!p' \
337        -e '$ a\
338            n[ ]nn[ ]np' \
339  | dc \
340  | sed \
341    -e 's!0 0 [1-9].*!CRASHED!' \
342    -e 's!0 0 0!PASSED!' \
343    -e 's!\([0-9]\+\) \([0-9]\+\) .*!TEST FAILED (errors=\1, failures=\2)!'
344  rm -f ${TMP}
345}
346 
347function junit_test() {
348  print_name $1
349  cd ${BUILD}/java
350  echo "doing ls..."
351  ls -la
352  res=0
353  case ${OUTPUT} in
354    v) junit_test_v $1 || res=1 ;;
355    q) junit_test_q $1 || res=1 ;;
356    n) junit_test_n $1 || res=1 ;;
357  esac
358  if [ -n "${XML_RES_PATH:-}" ]; then
359    cp "${BUILD}/doc/junit-reports/TESTS-TestSuites.xml" "${XML_RES_PATH}"
360  fi
361  return $res
362}
363
364function junit_test_v() {
365    res=0
366    ant_test $1 2>&1 \
367        | log \
368        || res=1
369    return $res
370}
371
372function junit_test_q() {
373    res=0
374    ant_test $1 2>&1 \
375        | log \
376        | egrep "(\[(jastadd|junit)\]|BUILD FAILED|\[java\] Error when parsing file:)" \
377        | sed -n \
378            -e '1 i\
379                0 0' \
380            -e 's!^.*\[jastadd\] \(Semantic errors\|Syntax error\).*$!BUILD FAILED!' \
381            -e 's!^.*\[java\] Error when parsing file:.*$!BUILD FAILED!' \
382            -e 's!^.*Failures: \([0-9]*\), Errors: \([0-9]*\),.*$!r\1+r\2+!p' \
383            -e 's!^.*\(BUILD FAILED\).*$![\1]pq!p' \
384            -e '$ a\
385                [errors=]nn[, failures=]np' \
386        | dc \
387        | sed \
388            -e 's!errors=0, failures=0!PASSED!' \
389            -e 's!\(errors=.*, failures=.*\)!TEST FAILED (\1)!' \
390        || res=1
391    return $res
392}
393
394function junit_test_n() {
395    echo "in junit_test_n"
396    res=0
397    ant_test $1 \
398        | log \
399        | egrep "(\[junit\]|\[(java|jastadd)\].*([Ee]rror|[A-Za-z.]*:[1-9][0-9]*))" \
400        || res=1
401    return $res
402}
403
404function nose_test() {
405  nosetests `compute_nose_extra_args "${TEST}"` ${TAGS} -v $1
406}
407
408function ant_test() {
409  echo "MC_ANT_ARGS=${MC_ANT_ARGS}"
410  echo "OC_ANT_ARGS=${OC_ANT_ARGS}"
411  echo "BUILD=${BUILD}"
412  echo "CLEAN_JUNIT=${CLEAN_JUNIT}"
413    if [[ "$1" == "Modelica" ]]; then
414        ant -f ${MC_ANT_ARGS} -Dtarget=${BUILD} ${CLEAN_JUNIT} test
415    else
416        ant -f ${OC_ANT_ARGS} -Dtarget=${BUILD} ${CLEAN_JUNIT} test
417    fi
418  echo "about to ls"
419  ls -la ${BUILD}
420}
421
422function build_jmodelica() {
423  if [[ "${NO_BUILD_JMODELICA}" != "1" ]]; then
424    if [[ -d ${BUILD} ]]; then
425      cd ${BUILD}
426      ${CLEAN_BUILD}
427      make && make install
428    else
429      echo Cannot build, build dir does not exist!
430      exit 1
431    fi
432  fi
433}
434
435function switch_test_flags() {
436  STATE=0
437  for a in $*; do
438    if [[ "${test[${!a}]}" != 1 ]]; then
439      STATE=1
440    fi
441  done
442  for a in $*; do
443    test[${!a}]=${STATE}
444  done
445}
446
447function compute_nose_extra_args() { # Argument is test name
448    if [ -n "${XML_RES_PATH:-}" ]; then
449        RES_FILE_NAME=`echo $1 | sed -e 's!^.*jmodelica.!!g' -e 's!/!_!g'`
450        if [[ "$PYTHON64" = 1 ]]; then
451            RES_FILE_NAME="python64_${RES_FILE_NAME}"
452        fi
453        echo --with-xunit --xunit-file=${XML_RES_PATH}/${RES_FILE_NAME}.xml
454    fi
455}
456
457function read_args() {
458  TESTS=
459  TESTS64=
460  ARG_TYPE=flag
461  echo "DEFAULT_ARGS=${DEFAULT_ARGS}"
462  for a in ${DEFAULT_ARGS} "$@"; do
463    echo a=$a
464    if [[ "$(echo $a | head -c1)" == "-" ]]; then
465      ARG_TYPE=flag
466    fi
467    FLAG=0
468    case ${ARG_TYPE} in
469      flag)
470        FLAG=1
471        echo FLAG=$FLAG
472        ;;
473      tag)
474        TAGS="${TAGS} -a ${a}"
475        ;;
476      tag64)
477        TAGS64="${TAGS64} -a ${a}"
478        ;;
479      file)
480        if [[ -f "${a}" ]]; then
481          FILE="$(readlink -f ${a})"
482        else
483          FILE="${TESTS_DIR}/${a}"
484          FILE64="${TESTS64_DIR}/${a}"
485        fi
486        if [[ -f ${FILE} ]]; then
487          TESTS="${TESTS} ${FILE}"
488        else
489          echo "Cannot find test file ${a}"
490          exit
491        fi
492        if [[ "${PYTHON64_HOME}" != "" ]]; then
493         if [[ -f ${FILE64} ]]; then
494          TESTS64="${TESTS64} ${FILE64}"
495         else
496           echo "Cannot find test file ${a}"
497           exit
498         fi
499        fi
500        ;;
501      xmlResPath)
502        XML_RES_PATH=${a}
503        ARG_TYPE=flag
504        ;;
505    esac
506    if [[ ${FLAG} == 1 ]]; then
507      echo "In flag == 1 with a=${a}"
508      a_split=""
509      for ((i=0; i<${#a}; i++)); do a_split="$a_split ${a:$i:1}"; done
510      echo a_split="$a_split"
511      for b in $a_split; do
512        HAVE_READ_ARGS=1
513        echo b=${b}
514        case ${b} in
515          -)
516            ;;
517          v|q|n)
518            OUTPUT=${b}
519            ;;
520          a|j|m|o|p)
521            test_set="test_set_${b}"
522            switch_test_flags ${!test_set}
523            ;;
524          z)
525            if ! [[ "${PYTHON64_HOME}" != "" ]]; then
526                echo "Python 64 bit tests not supported!"
527                exit
528            fi
529            test_set="test_set_${b}"
530            switch_test_flags ${!test_set}
531            ;;
532          c|C)
533            CLEAN_JUNIT=clean
534            if [[ "${b}" == C ]]; then
535              CLEAN_BUILD="make clean"
536            fi
537            ;;
538          i)
539            NO_BUILD_JMODELICA=1
540            ;;
541          k)
542            KEEP_PYTHON=1
543            ;;
544          l)
545            LOG=$((1-LOG))
546            ;;
547          f)
548            ARG_TYPE=file
549            ;;
550          t)
551            TAGS=""
552            ARG_TYPE=tag
553            ;;
554          u)
555            if ! [[ "${PYTHON64_HOME}" != "" ]]; then
556                echo "Python 64 bit tests not supported!"
557                exit
558            fi
559            TAGS64=""
560            ARG_TYPE=tag64
561            ;;
562          g)
563            if ! [[ "${PYTHON64_HOME}" != "" ]]; then
564                echo "Python 64 bit tests not supported!"
565                exit
566            fi
567            ARG_TYPE=tag
568            ;;
569          r)
570            ARG_TYPE=tag64
571            ;;
572          x)
573            ARG_TYPE=xmlResPath
574            ;;
575          e)
576            ERROR_ON_TEST_FAIL=1
577            ;;
578          h)
579            echo "usage: tests [-ajmopzvnqcCh] { [-(t|u|g|r) [tag1 ...]] } [-f file1 ...] [-x path]"
580            echo "The -ajmopz options each control a set of tests, and select all tests in set "
581            echo "for running, or, if all in set are already selected, deselects them. "
582            echo "Thus, \"tests -am\" runs all tests except modelica. If no tests are chosen, "
583            echo "a default set is run (${DEFAULT_TESTS})." 
584            echo "  -a   Select/deselect all tests"
585            echo "  -j   Select/deselect junit tests"
586            echo "  -m   Select/deselect modelica tests"
587            echo "  -o   Select/deselect optimca tests"
588            echo "  -p   Select/deselect python tests"
589            echo "  -z   Select/deselect python 64 bit tests (not always a valid option)"
590            echo "  -v   Verbose output, show everything"
591            echo "  -n   Normal output, only show results and compilation errors"
592            echo "  -q   Quiet output, only show brief results"
593            echo "  -c   Do a clean before junit tests"
594            echo "  -C   Do a clean before each test suite"
595            echo "  -i   Do not re-build before python tests"
596            echo "  -k   Keep generated files from python tests"
597            echo "  -l   Toggle creating log file with the equivalent of the output with -v" 
598            echo "       (on by default)"
599            echo "  -t   When running python tests, only run tests marked with one of the "
600            echo "       listed tags. If given without tags, all tests are run. If -t is "
601            echo "       given several times, only the last one will be used (not always a valid option)"
602            echo "  -u   When running python64 tests, only run tests marked with one of the "
603            echo "       listed tags. If given without tags, all tests are run. If -u is "
604            echo "       given several times, only the last one will be used"
605            echo "  -g   When running python tests, add the listed tags to the tags to use"
606            echo "  -r   When running python 64tests, add the listed tags to the tags to use"
607            echo "  -f   When running python tests, only run tests from the listed files. "
608            echo "       Paths relative to the tests directory are accepted, as well as "
609            echo "       absolute or relative to current directory"
610            echo "  -x   Path to folder where jUnit like xml files are written. The xml files"
611            echo "       contains the results of the tests. Currently doesn't handle spaces"
612            echo "       in the supplied path!"
613            echo "  -e   When enabled, exit with error code (after running all "
614            echo "       tests) if any test suite return with an error code or a test fails"
615            echo "       regular failures or errors). Default behaviour is exit 0.".
616            echo "       Requires -x".
617            echo "  -h   Print this help and exit"
618            exit
619            ;;
620          *)
621            echo "Unknown flag -${b}"
622            exit
623            ;;
624        esac
625      done
626    else
627      HAVE_READ_ARGS=1
628    fi
629  done
630}
631
632# === Main ===
633OUTPUT=n
634LOGFILE="$(pwd)/tests.log"
635LOG=1
636i=0
637for a in ${tests}; do
638    test[${i}]=0
639    (( ${a}=i++ ))
640done
641export JAVA_HOME JMODELICA_HOME IPOPT_HOME PYTHONPATH LD_LIBRARY_PATH ANT_OPTS SUNDIALS_HOME
642TIME=$(date +%s)
643
644echo "TIME = ${TIME}"
645echo "before read_args"
646HAVE_READ_ARGS=0
647echo "PATH=${PATH}"
648echo "args $@"
649read_args "$@"
650if [[ $HAVE_READ_ARGS == 0 ]]; then
651echo "Reading args to jm_tests failed, retrying..."
652read_args "$@"
653fi
654echo "after read_args"
655echo "Writing to LOGFILE=${LOGFILE}"
656if [[ $ERROR_ON_TEST_FAIL == 1 ]]; then
657    if [[ -z $XML_RES_PATH ]]; then
658        echo "-e needs -x"
659        exit 1
660    fi
661fi
662
663if [ "${LOG}" == 1 ]; then
664  echo "Log of jm_tests $(date):" > "${LOGFILE}"
665  echo "Finished writing log..."
666fi
667
668ANY_ON=0
669for a in ${tests}; do
670  if [[ "${test[${!a}]}" == 1 ]]; then
671    ANY_ON=1
672  fi
673done
674
675echo "ANY_ON=${ANY_ON}"
676echo "DEFAULT_TESTS=${DEFAULT_TESTS}"
677if [[ "${ANY_ON}" == 0 ]]; then
678  switch_test_flags ${DEFAULT_TESTS}
679fi
680
681# If on Windows, inform user about bug in ticket #766
682if [[ ${SYS} == Win ]]; then
683  echo Note: If modelica or optimica tests seem to hang, press enter a couple of times.
684fi
685
686res=0
687
688for a in ${tests}; do
689  if [[ "${test[${!a}]}" == 1 ]]; then
690    echo "Printing going with ${a}_tests"
691  fi
692done
693for a in ${tests}; do
694  if [[ "${test[${!a}]}" == 1 ]]; then
695    echo "going with ${a}_tests"
696    ${a}_tests || res=1
697  fi
698done
699
700if [[ "${OUTPUT}" != q ]]; then
701  echo ========================
702fi
703echo $(date +%s) ${TIME}"-[Total time: ]nd60/n[:]n60%[0n]sxd10>xp" | dc
704
705# Rename test names in xml when run with 64 bit python
706if [ -n "${XML_RES_PATH:-}" ]; then
707    for f in ${XML_RES_PATH}/*; do
708        if [[ "${f}" == *"python64_"* ]]; then
709            sed -e 's#classname=\"#classname=\"python64.#g' $f > temp.xml
710            mv -f temp.xml $f
711        fi
712    done
713fi
714
715if [[ "${ERROR_ON_TEST_FAIL}" == 1 ]]; then
716    if [[ $res == 0 ]]; then
717        grep -R testsuite $XML_RES_PATH | sed -n -e "/.*errors=\"[0]*[1-9][0-9]*\".*/ q1" -e "/.*failures=\"[0]*[1-9][0-9]*\".*/ q1"
718        exit $?
719    fi
720    exit $res
721else
722    exit 0
723fi
Note: See TracBrowser for help on using the repository browser.