source: doc/theses/andrew_beach_MMath/code/test.sh@ 06c61e2

ADT ast-experimental enum forall-pointer-decay jacob/cs343-translation new-ast-unique-expr pthread-emulation qualifiedEnum
Last change on this file since 06c61e2 was 209dfe2, checked in by Andrew Beach <ajbeach@…>, 4 years ago

The exception benchmark can now also extract results from files.

  • Property mode set to 100755
File size: 3.3 KB
Line 
1#!/usr/bin/env bash
2
3# Usage:
4# test.sh LANGUAGE TEST
5# Run the TEST in LANGUAGE.
6# test.sh -b SOURCE_FILE...
7# Build a test from SOURCE_FILE(s).
8# test.sh -v LANGUAGE TEST FILE
9# View the result from TEST in LANGUAGE stored in FILE.
10
11readonly ITERATIONS=1000000 # 1 000 000, one million
12readonly STACK_HEIGHT=100
13
14# Build Test Programs:
15# Mini-Make: TARGET SOURCE COMMAND ARGS...
16mmake() (
17 if [ ! -e "$1" -o "$1" -ot "$2" ]; then
18 "${@:3}"
19 fi
20)
21
22build() (
23 case "$1" in
24 *.cfa)
25 # Requires a symbolic link.
26 mmake "${1%.cfa}" "$1" ./cfa -DNDEBUG -nodebug -O3 "$1" -o "${1%.cfa}"
27 ;;
28 *.cpp)
29 mmake "${1%.cpp}-cpp" "$1" g++ -DNDEBUG -O3 "$1" -o "${1%.cpp}-cpp"
30 ;;
31 *.java)
32 mmake "${1%.java}.class" "$1" javac "$1"
33 ;;
34 *)
35 echo "Don't know how to build:" $1 >&2
36 exit 2
37 ;;
38 esac
39)
40
41if [ "-b" = "$1" ]; then
42 for file in "${@:2}"; do
43 build $file
44 done
45 exit 0
46elif [ "-v" = "$1" -a 4 = "$#" ]; then
47 TEST_LANG="$2"
48 TEST_CASE="$3"
49 VIEW_FILE="$4"
50elif [ 2 -eq "$#" ]; then
51 TEST_LANG="$1"
52 TEST_CASE="$2"
53else
54 echo "Unknown call pattern." >&2
55 exit 2
56fi
57
58# Run Test Programs:
59# Used in place of unsupported language/test combinations.
60unsupported() {
61 echo "Run-Time: NA"
62}
63
64case "$TEST_CASE" in
65cond-match-all)
66 CFAT="./cond-catch $ITERATIONS 1"
67 CFAR="./cond-fixup $ITERATIONS 1"
68 CPP="./cond-catch-cpp $ITERATIONS 1"
69 JAVA="java CondCatch $ITERATIONS 1"
70 PYTHON="./cond_catch.py $ITERATIONS 1"
71 ;;
72cond-match-none)
73 CFAT="./cond-catch $ITERATIONS 0"
74 CFAR="./cond-fixup $ITERATIONS 0"
75 CPP="./cond-catch-cpp $ITERATIONS 0"
76 JAVA="java CondCatch $ITERATIONS 0"
77 PYTHON="./cond_catch.py $ITERATIONS 0"
78 ;;
79cross-catch)
80 CFAT="./cross-catch $ITERATIONS"
81 CFAR="./cross-resume $ITERATIONS"
82 CPP="./cross-catch-cpp $ITERATIONS"
83 JAVA="java CrossCatch $ITERATIONS"
84 PYTHON="./cross_catch.py $ITERATIONS"
85 ;;
86cross-finally)
87 CFAT="./cross-finally $ITERATIONS"
88 CFAR=unsupported
89 CPP=unsupported
90 JAVA="java CrossFinally $ITERATIONS"
91 PYTHON="./cross_finally.py $ITERATIONS"
92 ;;
93raise-detor)
94 CFAT="./throw-detor $ITERATIONS $STACK_HEIGHT"
95 CFAR="./resume-detor $ITERATIONS $STACK_HEIGHT"
96 CPP="./throw-detor-cpp $ITERATIONS $STACK_HEIGHT"
97 JAVA=unsupported
98 PYTHON=unsupported
99 ;;
100raise-empty)
101 CFAT="./throw-empty $ITERATIONS $STACK_HEIGHT"
102 CFAR="./resume-empty $ITERATIONS $STACK_HEIGHT"
103 CPP="./throw-empty-cpp $ITERATIONS $STACK_HEIGHT"
104 JAVA="java ThrowEmpty $ITERATIONS $STACK_HEIGHT"
105 PYTHON="./throw_empty.py $ITERATIONS $STACK_HEIGHT"
106 ;;
107raise-finally)
108 CFAT="./throw-finally $ITERATIONS $STACK_HEIGHT"
109 CFAR="./resume-finally $ITERATIONS $STACK_HEIGHT"
110 CPP=unsupported
111 JAVA="java ThrowFinally $ITERATIONS $STACK_HEIGHT"
112 PYTHON="./throw_finally.py $ITERATIONS $STACK_HEIGHT"
113 ;;
114raise-other)
115 CFAT="./throw-other $ITERATIONS $STACK_HEIGHT"
116 CFAR="./resume-other $ITERATIONS $STACK_HEIGHT"
117 CPP="./throw-other-cpp $ITERATIONS $STACK_HEIGHT"
118 JAVA="java ThrowOther $ITERATIONS $STACK_HEIGHT"
119 PYTHON="./throw_other.py $ITERATIONS $STACK_HEIGHT"
120 ;;
121*)
122 echo "No such test: $TEST_CASE" >&2
123 exit 2
124 ;;
125esac
126
127case "$TEST_LANG" in
128cfa-t) CALL="$CFAT";;
129cfa-r) CALL="$CFAR";;
130cpp) CALL="$CPP";;
131java) CALL="$JAVA";;
132python) CALL="$PYTHON";;
133*)
134 echo "No such language: $TEST_LANG" >&2
135 exit 2
136 ;;
137esac
138
139echo $CALL
140
141if [ -n "$VIEW_FILE" ]; then
142 grep -A 1 -B 0 "$CALL" "$VIEW_FILE" | sed -n -e 's!Run-Time (ns): !!;T;p'
143 exit
144fi
145
146$CALL
Note: See TracBrowser for help on using the repository browser.