1#!/bin/sh
2#
3# Run the core library tests.
4#
5# You can build and run the unit tests as follows (assuming sh/bash;
6# csh users should modify to suit):
7#
8#   $ cd <client>/device
9#   $ . envsetup.sh
10#   $ lunch 2
11#   $ make
12#   $ make CtsCoreTests
13#   $ ./dalvik/run-core-tests.sh
14#
15# Note: You may also specify a specific test as an argument.
16
17datadir=/tmp/${USER}
18base=$OUT
19framework=$base/system/framework
20apps=$base/data/app
21
22export ANDROID_PRINTF_LOG=tag
23export ANDROID_LOG_TAGS='*:w' # was: jdwp:i dalvikvm:i dalvikvmi:i'
24export ANDROID_DATA=$datadir
25export ANDROID_ROOT=$base/system
26
27debug_opts=-Xcheck:jni
28
29OPTS=`getopt -o dl: --long debug,log:,help -n $0 -- "$@"`
30
31if [ $? != 0 ]; then echo "Terminating..." >&2; exit 1; fi
32
33eval set -- "$OPTS"
34
35while true; do
36    case "$1" in
37        -d|--debug) debug_opts="$debug_opts -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y"; shift ;;
38        -l) export ANDROID_LOG_TAGS='*:'$2; shift 2 ;;
39        --log) export ANDROID_LOG_TAGS="$2"; shift 2 ;;
40        --help)
41            echo usage: $0 [-d\|--debug] [-l\|--log] test.class.name;
42            printf "\t%-15s%s\n" "-d|--debug" "wait for the debugger";
43            printf "\t%-15s%s\n" "-l" "set the global logging level";
44            printf "\t%-15s%s\n" "--log" "set the logging TAG";
45            printf "\t%-15s%s\n" "--help" "this message";
46            exit 1;
47        ;;
48        --) shift; break ;;
49        *) echo "Internal Error!" >&2; exit 1 ;;
50    esac
51done
52
53export LD_LIBRARY_PATH=$base/system/lib
54export DYLD_LIBRARY_PATH=$base/system/lib
55
56exe=$base/system/bin/dalvikvm
57bpath=$framework/core.jar:$framework/ext.jar:$framework/framework.jar
58cpath=$framework/core-tests.jar
59
60# Notes:
61# (1) The IO tests create lots of files in the current directory, so we change
62#     to /tmp first.
63# (2) Some of the core tests need a hell of a lot of memory, so we use a
64#     large value for both heap and stack. 
65
66rm -rf ${datadir}/xml_source
67mkdir -p ${datadir}/xml_source
68mkdir -p ${datadir}/dalvik-cache
69cd $ANDROID_BUILD_TOP/dalvik
70cp -R libcore/xml/src/test/resources/* ${datadir}/xml_source
71
72cd $datadir
73exec $valgrind $exe \
74     -Duser.language=en -Duser.region=US -Djava.io.tmpdir=$datadir \
75     -Xmx512M -Xss32K \
76     -Xbootclasspath:$bpath -classpath $cpath $debug_opts \
77     com.google.coretests.Main "$@"
78