File: run_test.sh

package info (click to toggle)
simulavr 1.0.0%2Bgit20160221.e53413b-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,740 kB
  • sloc: cpp: 35,491; python: 6,995; ansic: 3,567; makefile: 1,075; sh: 653; asm: 414; tcl: 320; javascript: 32
file content (52 lines) | stat: -rwxr-xr-x 1,230 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash

# get filename for report
REPORT_FILE=$1
OUTPUT_FILE=`basename $1 .report`.output
if [ `uname -s | cut -b-7` = "MINGW32" ]; then
  EXPECTED_RESULT=`echo "$2" | cut -d, -f 2`
else
  EXPECTED_RESULT=`echo "$2" | cut -d, -f 1`
fi
TARGET=$3
if [ ! "$4" = "--" ]; then
  echo "error: argument error, \$4 has to be '--'!"
  exit 2
fi
shift 4

# run simulavr, this uses all other arguments
echo "$*"
if [ ${GNUTIME} = yes ]; then
  (/usr/bin/time -p $*) > ${REPORT_FILE}.stdout 2> ${REPORT_FILE}.stderr
  RESULT=$?
else
  # bash builtin time command!
  (time -p $*) > ${REPORT_FILE}.stdout 2> ${REPORT_FILE}.stderr
  RESULT=$?
fi

# write report
echo "${TARGET} `tail -n 2 ${REPORT_FILE}.stderr | head -1 | cut "-d " -f 2`" > ${REPORT_FILE}

# write output
echo "stdout:" > $OUTPUT_FILE
cat ${REPORT_FILE}.stdout >> $OUTPUT_FILE
echo "" >> $OUTPUT_FILE
echo "stderr:" >> $OUTPUT_FILE
cat ${REPORT_FILE}.stderr >> $OUTPUT_FILE
echo "" >> $OUTPUT_FILE

# give back exit code
RES=0
if [ ! "$RESULT" = "$EXPECTED_RESULT" ]; then
  echo ""
  echo "error: return code from simulavr = $RESULT, expected = $EXPECTED_RESULT!"
  echo ""
  cat $OUTPUT_FILE
  RES=1
fi
rm -f ${REPORT_FILE}.stdout ${REPORT_FILE}.stderr
exit $RES

# EOF