summaryrefslogtreecommitdiffstats
path: root/test/etc/host-run-test-jar
blob: d95559fd5d4ea8d484483be7eb373f9f77d22fc2 (plain)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/bin/sh
#
# Run the code in test.jar using the host-mode virtual machine. The jar should
# contain a top-level class named Main to run.

msg() {
    if [ "$QUIET" = "n" ]; then
        echo "$@"
    fi
}

DEBUGGER="n"
GDB="n"
INTERPRETER="n"
VERIFY="y"
OPTIMIZE="y"
INVOKE_WITH=""
DEV_MODE="n"
QUIET="n"
FLAGS=""

while true; do
    if [ "x$1" = "x--quiet" ]; then
        QUIET="y"
        shift
    elif [ "x$1" = "x--lib" ]; then
        shift
        if [ "x$1" = "x" ]; then
            echo "$0 missing argument to --lib" 1>&2
            exit 1
        fi
        LIB="$1"
        shift
    elif [ "x$1" = "x--boot" ]; then
        shift
        BOOT_OPT="$1"
        shift
    elif [ "x$1" = "x--debug" ]; then
        DEBUGGER="y"
        shift
    elif [ "x$1" = "x--gdb" ]; then
        GDB="y"
        DEV_MODE="y"
        shift
    elif [ "x$1" = "x--invoke-with" ]; then
        shift
        if [ "x$1" = "x" ]; then
            echo "$0 missing argument to --invoke-with" 1>&2
            exit 1
        fi
        if [ "x$INVOKE_WITH" = "x" ]; then
            INVOKE_WITH="$1"
        else
            INVOKE_WITH="$INVOKE_WITH $1"
        fi
        shift
    elif [ "x$1" = "x--dev" ]; then
        DEV_MODE="y"
        shift
    elif [ "x$1" = "x--interpreter" ]; then
        INTERPRETER="y"
        shift
    elif [ "x$1" = "x--no-verify" ]; then
        VERIFY="n"
        shift
    elif [ "x$1" = "x--no-optimize" ]; then
        OPTIMIZE="n"
        shift
    elif [ "x$1" = "x-Xcompiler-option" ]; then
        shift
        option="$1"
        FLAGS="${FLAGS} -Xcompiler-option $option"
        shift
    elif [ "x$1" = "x--runtime-option" ]; then
        shift
        option="$1"
        FLAGS="${FLAGS} $option"
        shift
    elif [ "x$1" = "x--" ]; then
        shift
        break
    elif expr "x$1" : "x--" >/dev/null 2>&1; then
        echo "unknown $0 option: $1" 1>&2
        exit 1
    else
        break
    fi
done

msg "------------------------------"

mkdir $DEX_LOCATION/dalvik-cache
if [ $? -ne 0 ]; then
    exit
fi

export ANDROID_PRINTF_LOG=brief
if [ "$DEV_MODE" = "y" ]; then
    export ANDROID_LOG_TAGS='*:d'
else
    export ANDROID_LOG_TAGS='*:s'
fi
export ANDROID_DATA="$DEX_LOCATION"
export ANDROID_ROOT="${ANDROID_HOST_OUT}"
export LD_LIBRARY_PATH="${ANDROID_ROOT}/lib"
export DYLD_LIBRARY_PATH="${ANDROID_ROOT}/lib"

exe="${ANDROID_ROOT}/bin/dalvikvm"

if [ "$DEBUGGER" = "y" ]; then
    PORT=8000
    msg "Waiting for jdb to connect:"
    msg "    jdb -attach localhost:$PORT"
    DEBUGGER_OPTS="-agentlib:jdwp=transport=dt_socket,address=$PORT,server=y,suspend=y"
fi

if [ "$GDB" = "y" ]; then
    gdb=gdb
    gdbargs="--args $exe"
    # Enable for Emacs "M-x gdb" support. TODO: allow extra gdb arguments on command line.
    # gdbargs="--annotate=3 $gdbargs"
fi

if [ "$INTERPRETER" = "y" ]; then
    INT_OPTS="-Xint"
fi

JNI_OPTS="-Xjnigreflimit:512 -Xcheck:jni"

if [ "$DEV_MODE" = "y" ]; then
  echo $cmdline "$@"
fi

cd $ANDROID_BUILD_TOP
$INVOKE_WITH $gdb $exe $gdbargs -XXlib:$LIB $JNI_OPTS $FLAGS $INT_OPTS $DEBUGGER_OPTS $BOOT_OPT -cp $DEX_LOCATION/$TEST_NAME.jar Main "$@"