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

Last change on this file since 13867 was 13867, checked in by aramle, 6 weeks ago

#5819 Adding a retrying fallback in case reading of args fails.

File size: 19.4 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=$(mktemp -dq /tmp/jm_tests.XXXXXX)
191  fi
192  print_name Python
193  res=0
194  case ${OUTPUT} in
195    v)
196      if build_jmodelica 2>&1 | log; then
197        find_python_tests
198        cd ${TEST_DIR}
199        python_tests_v || res=1
200      fi
201      ;;
202    q)
203      if build_jmodelica 2>&1 | log > /dev/null; then
204        find_python_tests
205        cd ${TEST_DIR}
206        python_tests_q | filter_python_separate || res=1
207      else
208        echo BUILD FAILED
209      fi
210      ;;
211    n)
212      if [[ "${NO_BUILD_JMODELICA}" != "1" ]]; then
213        echo "OUTPUT=${OUTPUT}"
214        echo "NO_BUILD_JMODELICA=${NO_BUILD_JMODELICA}"
215        echo Building...
216      fi
217      if build_jmodelica | log > /dev/null; then
218        find_python_tests
219        cd ${TEST_DIR}
220        python_tests_n | filter_python_separate || res=1
221      fi
222      ;;
223  esac
224  if [ ! "${KEEP_PYTHON}" == 1 ]; then
225    cd ..
226    rm -rf ${TEST_DIR}
227  fi
228  return $res
229}
230
231TESTS64_DIR="${JMODELICA_HOME}/Python_64/tests_jmodelica"
232function python64_tests() {
233    # Set necessary paths etc to run 64 bit tests
234    PYTHONPATH=${PYTHONPATH64}
235    PYTHONHOME=${PYTHON64_HOME}
236    JPYPE_JVM=${JPYPE64_JVM}
237    CASADI_LIB_HOME=${CASADI64_HOME}/lib
238    CASADI_INTERFACE_HOME=${CASADI_INTERFACE_HOME64}
239    PATH=${PYTHON64_HOME}:${PYTHON64_HOME}/Scripts:${PYTHON64_HOME}/Lib:${IPOPT64_HOME}/bin:${CASADI_LIB_HOME}:"${PATH}"
240    TESTS32=$TESTS
241    TESTS=$TESTS64
242    TAGS32=$TAGS
243    TAGS=$TAGS64
244    TESTS_DIR=${TESTS64_DIR}
245    PYTHON64=1
246    # Call python_tests
247    res=0
248    python_tests || res=1
249    # Reset to original paths etc that was for original Python
250    TESTS=$TESTS32
251    TAGS=$TAGS32
252    PYTHON64=0
253    PYTHONPATH=${PYTHONPATH32}
254    PYTHONHOME=${PYTHON32_HOME}
255    JPYPE_JVM=${JPYPE32_JVM}
256    CASADI_LIB_HOME=${CASADI_HOME}/lib
257    CASADI_INTERFACE_HOME=${CASADI_INTERFACE_HOME32}
258    PATH="${ORIG_PATH}"
259    TESTS_DIR="${JMODELICA_HOME}/Python/tests_jmodelica"
260    return $res
261}
262
263function python_tests_v() {
264    res=0
265    for TEST in ${TESTS}; do
266      echo ""
267      echo ${TEST} | sed -e 's!^.*jmodelica.!Running !'
268      nose_test ${TEST} \
269      | log \
270      || res=1
271    done
272    return $res
273}
274
275function python_tests_q() {
276    res=0
277    for TEST in ${TESTS}; do
278      echo "" | log > /dev/null
279      echo ${TEST} | sed -e 's!^.*jmodelica.!Running !' | log > /dev/null
280      nose_test ${TEST} 2>&1 \
281      | log \
282      | sed -n -e 's!^OK$!PASSED!ip' -e 's!^FAILED !TEST FAILED!p' \
283      || (res=1 && echo NOSETESTS_NOT_OK)
284    done
285    return $res
286}
287
288function python_tests_n() {
289    PATTERN="[-=]{40,}"
290    res=0
291    for TEST in ${TESTS}; do
292      echo "" | log
293      echo ${TEST} | sed -e 's!^.*jmodelica.!Running !' | log
294      nose_test ${TEST} 2>&1 \
295      | log \
296      | egrep -v '^Exception .* ignored$' \
297      | egrep -A500 "${PATTERN}" \
298      | sed -e 's!^OK$!PASSED!' -e 's!^FAILED !TEST FAILED!' \
299      || (res=1 && echo NOSETESTS_NOT_OK)
300    done
301    return $res
302}
303
304# Helper functions
305function print_name() {
306  if [[ "${OUTPUT}" == q ]]; then
307    echo -n "$1... "
308  else
309    echo ======= $1 =======
310  fi
311}
312
313function log() {
314  if [ "${LOG}" == 1 ]; then
315      tee -a "${LOGFILE}"
316  else
317      cat
318  fi
319}
320
321function filter_python_separate() {
322  TMP=$(mktemp -q /tmp/jm_tests.XXXXXX 2>/dev/null) 
323  tee ${TMP} | egrep -v "(PASSED|TEST FAILED|NOSETESTS_NOT_OK)"
324  cat ${TMP} \
325  | sed -n \
326        -e '1 i\
327            0 0 0' \
328        -e 's!^TEST FAILED(errors=\([0-9]*\))!\1+!p' \
329        -e 's!^TEST FAILED(failures=\([0-9]*\))!r\1+r!p' \
330        -e 's!^TEST FAILED(errors=\([0-9]*\), failures=\([0-9]*\))!\1+r\2+r!p' \
331        -e 's!^NOSETESTS_NOT_OK!sar1+rla!p' \
332        -e '$ a\
333            n[ ]nn[ ]np' \
334  | dc \
335  | sed \
336    -e 's!0 0 [1-9].*!CRASHED!' \
337    -e 's!0 0 0!PASSED!' \
338    -e 's!\([0-9]\+\) \([0-9]\+\) .*!TEST FAILED (errors=\1, failures=\2)!'
339  rm -f ${TMP}
340}
341 
342function junit_test() {
343  print_name $1
344  cd ${BUILD}/java
345  echo "doing ls..."
346  ls -la
347  res=0
348  case ${OUTPUT} in
349    v) junit_test_v $1 || res=1 ;;
350    q) junit_test_q $1 || res=1 ;;
351    n) junit_test_n $1 || res=1 ;;
352  esac
353  if [ -n "${XML_RES_PATH:-}" ]; then
354    cp "${BUILD}/doc/junit-reports/TESTS-TestSuites.xml" "${XML_RES_PATH}"
355  fi
356  return $res
357}
358
359function junit_test_v() {
360    res=0
361    ant_test $1 2>&1 \
362        | log \
363        || res=1
364    return $res
365}
366
367function junit_test_q() {
368    res=0
369    ant_test $1 2>&1 \
370        | log \
371        | egrep "(\[(jastadd|junit)\]|BUILD FAILED|\[java\] Error when parsing file:)" \
372        | sed -n \
373            -e '1 i\
374                0 0' \
375            -e 's!^.*\[jastadd\] \(Semantic errors\|Syntax error\).*$!BUILD FAILED!' \
376            -e 's!^.*\[java\] Error when parsing file:.*$!BUILD FAILED!' \
377            -e 's!^.*Failures: \([0-9]*\), Errors: \([0-9]*\),.*$!r\1+r\2+!p' \
378            -e 's!^.*\(BUILD FAILED\).*$![\1]pq!p' \
379            -e '$ a\
380                [errors=]nn[, failures=]np' \
381        | dc \
382        | sed \
383            -e 's!errors=0, failures=0!PASSED!' \
384            -e 's!\(errors=.*, failures=.*\)!TEST FAILED (\1)!' \
385        || res=1
386    return $res
387}
388
389function junit_test_n() {
390    echo "in junit_test_n"
391    res=0
392    ant_test $1 \
393        | log \
394        | egrep "(\[junit\]|\[(java|jastadd)\].*([Ee]rror|[A-Za-z.]*:[1-9][0-9]*))" \
395        || res=1
396    return $res
397}
398
399function nose_test() {
400  nosetests `compute_nose_extra_args "${TEST}"` ${TAGS} -v $1
401}
402
403function ant_test() {
404  echo "MC_ANT_ARGS=${MC_ANT_ARGS}"
405  echo "OC_ANT_ARGS=${OC_ANT_ARGS}"
406  echo "BUILD=${BUILD}"
407  echo "CLEAN_JUNIT=${CLEAN_JUNIT}"
408    if [[ "$1" == "Modelica" ]]; then
409        ant ${ANT_OPTS} -f ${MC_ANT_ARGS} -Dtarget=${BUILD} ${CLEAN_JUNIT} test
410    else
411        ant ${ANT_OPTS} -f ${OC_ANT_ARGS} -Dtarget=${BUILD} ${CLEAN_JUNIT} test
412    fi
413  echo "about to ls"
414  ls -la ${BUILD}
415}
416
417function build_jmodelica() {
418  if [[ "${NO_BUILD_JMODELICA}" != "1" ]]; then
419    if [[ -d ${BUILD} ]]; then
420      cd ${BUILD}
421      ${CLEAN_BUILD}
422      make && make install
423    else
424      echo Cannot build, build dir does not exist!
425      exit 1
426    fi
427  fi
428}
429
430function switch_test_flags() {
431  STATE=0
432  for a in $*; do
433    if [[ "${test[${!a}]}" != 1 ]]; then
434      STATE=1
435    fi
436  done
437  for a in $*; do
438    test[${!a}]=${STATE}
439  done
440}
441
442function compute_nose_extra_args() { # Argument is test name
443    if [ -n "${XML_RES_PATH:-}" ]; then
444        RES_FILE_NAME=`echo $1 | sed -e 's!^.*jmodelica.!!g' -e 's!/!_!g'`
445        if [[ "$PYTHON64" = 1 ]]; then
446            RES_FILE_NAME="python64_${RES_FILE_NAME}"
447        fi
448        echo --with-xunit --xunit-file=${XML_RES_PATH}/${RES_FILE_NAME}.xml
449    fi
450}
451
452function read_args() {
453  TESTS=
454  TESTS64=
455  ARG_TYPE=flag
456  echo "DEFAULT_ARGS=${DEFAULT_ARGS}"
457  for a in ${DEFAULT_ARGS} "$@"; do
458    echo a=$a
459    if [[ "$(echo $a | head -c1)" == "-" ]]; then
460      ARG_TYPE=flag
461    fi
462    FLAG=0
463    case ${ARG_TYPE} in
464      flag)
465        FLAG=1
466        echo FLAG=$FLAG
467        ;;
468      tag)
469        TAGS="${TAGS} -a ${a}"
470        ;;
471      tag64)
472        TAGS64="${TAGS64} -a ${a}"
473        ;;
474      file)
475        if [[ -f "${a}" ]]; then
476          FILE="$(readlink -f ${a})"
477        else
478          FILE="${TESTS_DIR}/${a}"
479          FILE64="${TESTS64_DIR}/${a}"
480        fi
481        if [[ -f ${FILE} ]]; then
482          TESTS="${TESTS} ${FILE}"
483        else
484          echo "Cannot find test file ${a}"
485          exit
486        fi
487        if [[ "${PYTHON64_HOME}" != "" ]]; then
488         if [[ -f ${FILE64} ]]; then
489          TESTS64="${TESTS64} ${FILE64}"
490         else
491           echo "Cannot find test file ${a}"
492           exit
493         fi
494        fi
495        ;;
496      xmlResPath)
497        XML_RES_PATH=${a}
498        ARG_TYPE=flag
499        ;;
500    esac
501    if [[ ${FLAG} == 1 ]]; then
502      echo "In flag == 1"
503      echo "" ${a}|sed 's!\(.\)!\1 !g'
504      for b in $(echo "" ${a}|sed 's!\(.\)!\1 !g'); do
505        HAVE_READ_ARGS=1
506        echo b=${b}
507        case ${b} in
508          -)
509            ;;
510          v|q|n)
511            OUTPUT=${b}
512            ;;
513          a|j|m|o|p)
514            test_set="test_set_${b}"
515            switch_test_flags ${!test_set}
516            ;;
517          z)
518            if ! [[ "${PYTHON64_HOME}" != "" ]]; then
519                echo "Python 64 bit tests not supported!"
520                exit
521            fi
522            test_set="test_set_${b}"
523            switch_test_flags ${!test_set}
524            ;;
525          c|C)
526            CLEAN_JUNIT=clean
527            if [[ "${b}" == C ]]; then
528              CLEAN_BUILD="make clean"
529            fi
530            ;;
531          i)
532            NO_BUILD_JMODELICA=1
533            ;;
534          k)
535            KEEP_PYTHON=1
536            ;;
537          l)
538            LOG=$((1-LOG))
539            ;;
540          f)
541            ARG_TYPE=file
542            ;;
543          t)
544            TAGS=""
545            ARG_TYPE=tag
546            ;;
547          u)
548            if ! [[ "${PYTHON64_HOME}" != "" ]]; then
549                echo "Python 64 bit tests not supported!"
550                exit
551            fi
552            TAGS64=""
553            ARG_TYPE=tag64
554            ;;
555          g)
556            if ! [[ "${PYTHON64_HOME}" != "" ]]; then
557                echo "Python 64 bit tests not supported!"
558                exit
559            fi
560            ARG_TYPE=tag
561            ;;
562          r)
563            ARG_TYPE=tag64
564            ;;
565          x)
566            ARG_TYPE=xmlResPath
567            ;;
568          e)
569            ERROR_ON_TEST_FAIL=1
570            ;;
571          h)
572            echo "usage: tests [-ajmopzvnqcCh] { [-(t|u|g|r) [tag1 ...]] } [-f file1 ...] [-x path]"
573            echo "The -ajmopz options each control a set of tests, and select all tests in set "
574            echo "for running, or, if all in set are already selected, deselects them. "
575            echo "Thus, \"tests -am\" runs all tests except modelica. If no tests are chosen, "
576            echo "a default set is run (${DEFAULT_TESTS})." 
577            echo "  -a   Select/deselect all tests"
578            echo "  -j   Select/deselect junit tests"
579            echo "  -m   Select/deselect modelica tests"
580            echo "  -o   Select/deselect optimca tests"
581            echo "  -p   Select/deselect python tests"
582            echo "  -z   Select/deselect python 64 bit tests (not always a valid option)"
583            echo "  -v   Verbose output, show everything"
584            echo "  -n   Normal output, only show results and compilation errors"
585            echo "  -q   Quiet output, only show brief results"
586            echo "  -c   Do a clean before junit tests"
587            echo "  -C   Do a clean before each test suite"
588            echo "  -i   Do not re-build before python tests"
589            echo "  -k   Keep generated files from python tests"
590            echo "  -l   Toggle creating log file with the equivalent of the output with -v" 
591            echo "       (on by default)"
592            echo "  -t   When running python tests, only run tests marked with one of the "
593            echo "       listed tags. If given without tags, all tests are run. If -t is "
594            echo "       given several times, only the last one will be used (not always a valid option)"
595            echo "  -u   When running python64 tests, only run tests marked with one of the "
596            echo "       listed tags. If given without tags, all tests are run. If -u is "
597            echo "       given several times, only the last one will be used"
598            echo "  -g   When running python tests, add the listed tags to the tags to use"
599            echo "  -r   When running python 64tests, add the listed tags to the tags to use"
600            echo "  -f   When running python tests, only run tests from the listed files. "
601            echo "       Paths relative to the tests directory are accepted, as well as "
602            echo "       absolute or relative to current directory"
603            echo "  -x   Path to folder where jUnit like xml files are written. The xml files"
604            echo "       contains the results of the tests. Currently doesn't handle spaces"
605            echo "       in the supplied path!"
606            echo "  -e   When enabled, exit with error code (after running all "
607            echo "       tests) if any test suite return with an error code or a test fails"
608            echo "       regular failures or errors). Default behaviour is exit 0.".
609            echo "       Requires -x".
610            echo "  -h   Print this help and exit"
611            exit
612            ;;
613          *)
614            echo "Unknown flag -${b}"
615            exit
616            ;;
617        esac
618      done
619    else
620      HAVE_READ_ARGS=1
621    fi
622  done
623}
624
625# === Main ===
626OUTPUT=n
627LOGFILE="$(pwd)/tests.log"
628LOG=1
629i=0
630for a in ${tests}; do
631    test[${i}]=0
632    (( ${a}=i++ ))
633done
634export JAVA_HOME JMODELICA_HOME IPOPT_HOME PYTHONPATH LD_LIBRARY_PATH ANT_OPTS SUNDIALS_HOME
635TIME=$(date +%s)
636
637echo "TIME = ${TIME}"
638echo "before read_args"
639HAVE_READ_ARGS=0
640echo "PATH=${PATH}"
641echo "args $@"
642read_args "$@"
643if [[ $HAVE_READ_ARGS == 0 ]]; then
644echo "Reading args to jm_tests failed, retrying..."
645read_args "$@"
646fi
647echo "after read_args"
648echo "Writing to LOGFILE=${LOGFILE}"
649if [[ $ERROR_ON_TEST_FAIL == 1 ]]; then
650    if [[ -z $XML_RES_PATH ]]; then
651        echo "-e needs -x"
652        exit 1
653    fi
654fi
655
656if [ "${LOG}" == 1 ]; then
657  echo "Log of jm_tests $(date):" > "${LOGFILE}"
658  echo "Finished writing log..."
659fi
660
661ANY_ON=0
662for a in ${tests}; do
663  if [[ "${test[${!a}]}" == 1 ]]; then
664    ANY_ON=1
665  fi
666done
667
668echo "ANY_ON=${ANY_ON}"
669echo "DEFAULT_TESTS=${DEFAULT_TESTS}"
670if [[ "${ANY_ON}" == 0 ]]; then
671  switch_test_flags ${DEFAULT_TESTS}
672fi
673
674# If on Windows, inform user about bug in ticket #766
675if [[ ${SYS} == Win ]]; then
676  echo Note: If modelica or optimica tests seem to hang, press enter a couple of times.
677fi
678
679res=0
680
681for a in ${tests}; do
682  if [[ "${test[${!a}]}" == 1 ]]; then
683    echo "Printing going with ${a}_tests"
684  fi
685done
686for a in ${tests}; do
687  if [[ "${test[${!a}]}" == 1 ]]; then
688    echo "going with ${a}_tests"
689    ${a}_tests || res=1
690  fi
691done
692
693if [[ "${OUTPUT}" != q ]]; then
694  echo ========================
695fi
696echo $(date +%s) ${TIME}"-[Total time: ]nd60/n[:]n60%[0n]sxd10>xp" | dc
697
698# Rename test names in xml when run with 64 bit python
699if [ -n "${XML_RES_PATH:-}" ]; then
700    for f in ${XML_RES_PATH}/*; do
701        if [[ "${f}" == *"python64_"* ]]; then
702            sed -e 's#classname=\"#classname=\"python64.#g' $f > temp.xml
703            mv -f temp.xml $f
704        fi
705    done
706fi
707
708if [[ "${ERROR_ON_TEST_FAIL}" == 1 ]]; then
709    if [[ $res == 0 ]]; then
710        grep -R testsuite $XML_RES_PATH | sed -n -e "/.*errors=\"[0]*[1-9][0-9]*\".*/ q1" -e "/.*failures=\"[0]*[1-9][0-9]*\".*/ q1"
711        exit $?
712    fi
713    exit $res
714else
715    exit 0
716fi
Note: See TracBrowser for help on using the repository browser.