The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 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 | |
| 17 | datadir=/tmp/${USER} |
| 18 | base=$OUT |
| 19 | framework=$base/system/framework |
| 20 | apps=$base/data/app |
| 21 | |
| 22 | export ANDROID_PRINTF_LOG=tag |
| 23 | export ANDROID_LOG_TAGS='*:w' # was: jdwp:i dalvikvm:i dalvikvmi:i' |
| 24 | export ANDROID_DATA=$datadir |
| 25 | export ANDROID_ROOT=$base/system |
| 26 | |
| 27 | debug_opts=-Xcheck:jni |
| 28 | |
| 29 | OPTS=`getopt -o dl: --long debug,log:,help -n $0 -- "$@"` |
| 30 | |
| 31 | if [ $? != 0 ]; then echo "Terminating..." >&2; exit 1; fi |
| 32 | |
| 33 | eval set -- "$OPTS" |
| 34 | |
| 35 | while 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 |
| 51 | done |
| 52 | |
| 53 | export LD_LIBRARY_PATH=$base/system/lib |
| 54 | export DYLD_LIBRARY_PATH=$base/system/lib |
| 55 | |
| 56 | exe=$base/system/bin/dalvikvm |
| 57 | bpath=$framework/core.jar:$framework/ext.jar:$framework/framework.jar |
| 58 | cpath=$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 | |
| 66 | rm -rf ${datadir}/xml_source |
| 67 | mkdir -p ${datadir}/xml_source |
| 68 | mkdir -p ${datadir}/dalvik-cache |
| 69 | cd $ANDROID_BUILD_TOP/dalvik |
| 70 | cp -R libcore/xml/src/test/resources/* ${datadir}/xml_source |
| 71 | |
| 72 | cd $datadir |
| 73 | exec $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 "$@" |