source: doc/theses/andrew_beach_MMath/code/test.sh @ 98233b3

ADTast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 98233b3 was 209dfe2, checked in by Andrew Beach <ajbeach@…>, 3 years ago

The exception benchmark can now also extract results from files.

  • Property mode set to 100755
File size: 3.3 KB
RevLine 
[acb38ce9]1#!/usr/bin/env bash
2
[209dfe2]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.
[acb38ce9]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.
[63e3ed8]26                mmake "${1%.cfa}" "$1" ./cfa -DNDEBUG -nodebug -O3 "$1" -o "${1%.cfa}"
[acb38ce9]27                ;;
28        *.cpp)
[63e3ed8]29                mmake "${1%.cpp}-cpp" "$1" g++ -DNDEBUG -O3 "$1" -o "${1%.cpp}-cpp"
[acb38ce9]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
[209dfe2]46elif [ "-v" = "$1" -a 4 = "$#" ]; then
47    TEST_LANG="$2"
48    TEST_CASE="$3"
49    VIEW_FILE="$4"
[6f27b67]50elif [ 2 -eq "$#" ]; then
[63e3ed8]51        TEST_LANG="$1"
52        TEST_CASE="$2"
[605673f]53else
[63e3ed8]54        echo "Unknown call pattern." >&2
55        exit 2
[acb38ce9]56fi
57
58# Run Test Programs:
59# Used in place of unsupported language/test combinations.
60unsupported() {
61        echo "Run-Time: NA"
62}
63
[605673f]64case "$TEST_CASE" in
[acb38ce9]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"
[63e3ed8]70        PYTHON="./cond_catch.py $ITERATIONS 1"
[acb38ce9]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"
[63e3ed8]77        PYTHON="./cond_catch.py $ITERATIONS 0"
[acb38ce9]78        ;;
79cross-catch)
80        CFAT="./cross-catch $ITERATIONS"
81        CFAR="./cross-resume $ITERATIONS"
82        CPP="./cross-catch-cpp $ITERATIONS"
83        JAVA="java CrossCatch $ITERATIONS"
[63e3ed8]84        PYTHON="./cross_catch.py $ITERATIONS"
[acb38ce9]85        ;;
86cross-finally)
87        CFAT="./cross-finally $ITERATIONS"
88        CFAR=unsupported
89        CPP=unsupported
90        JAVA="java CrossFinally $ITERATIONS"
[63e3ed8]91        PYTHON="./cross_finally.py $ITERATIONS"
[acb38ce9]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
[63e3ed8]98        PYTHON=unsupported
[acb38ce9]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"
[63e3ed8]105        PYTHON="./throw_empty.py $ITERATIONS $STACK_HEIGHT"
[acb38ce9]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"
[63e3ed8]112        PYTHON="./throw_finally.py $ITERATIONS $STACK_HEIGHT"
[acb38ce9]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"
[63e3ed8]119        PYTHON="./throw_other.py $ITERATIONS $STACK_HEIGHT"
[acb38ce9]120        ;;
121*)
[605673f]122        echo "No such test: $TEST_CASE" >&2
[acb38ce9]123        exit 2
124        ;;
125esac
126
[605673f]127case "$TEST_LANG" in
[209dfe2]128cfa-t) CALL="$CFAT";;
129cfa-r) CALL="$CFAR";;
130cpp) CALL="$CPP";;
131java) CALL="$JAVA";;
132python) CALL="$PYTHON";;
[605673f]133*)
134        echo "No such language: $TEST_LANG" >&2
135        exit 2
[63e3ed8]136        ;;
[acb38ce9]137esac
[209dfe2]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.