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

Last change on this file since 13891 was 13891, checked in by aramle, 7 weeks ago

#5819 Correcting typo.

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