reference-run-test-classes revision f6c387128427e121477c1b32ad35cdcaa5101ba3
1#!/bin/sh
2#
3# Run the code in a classes directory on a host-local reference virtual
4# machine. The jar should contain a top-level class named Main to run.
5#
6# Options:
7#   --quiet       -- don't chatter
8#   --debug       -- wait for debugger to attach
9#   --no-verify   -- turn off verification (on by default)
10
11msg() {
12    if [ "$QUIET" = "n" ]; then
13        echo "$@"
14    fi
15}
16
17DEBUG="n"
18QUIET="n"
19VERIFY="y"
20
21while true; do
22    if [ "x$1" = "x--quiet" ]; then
23        QUIET="y"
24        shift
25    elif [ "x$1" = "x--debug" ]; then
26        DEBUG="y"
27        shift
28    elif [ "x$1" = "x--no-verify" ]; then
29        VERIFY="n"
30        shift
31    elif [ "x$1" = "x--" ]; then
32        shift
33        break
34    elif expr "x$1" : "x--" >/dev/null 2>&1; then
35        echo "unknown option: $1" 1>&2
36        exit 1
37    else
38        break
39    fi
40done
41
42if [ "$VERIFY" = "y" ]; then
43    VERIFY_ARG="-Xverify:all"
44    msg "Performing verification"
45else
46    VERIFY_ARG="-Xverify:none"
47    msg "Skipping verification"
48fi
49
50if [ "$DEBUG" = "y" ]; then
51    PORT=8000
52    msg "Waiting for debugger to connect on localhost:$PORT"
53    DEBUG_OPTS="-agentlib:jdwp=transport=dt_socket,address=$PORT,server=y,suspend=y"
54fi
55
56${JAVA} ${DEBUG_OPTS} -ea ${VERIFY_ARG} -classpath classes Main "$@"
57