OSDN Git Service

Revert "Stop building getprop"
[android-x86/external-toybox.git] / run-tests-on-android.sh
1 #!/bin/bash
2
3 # Copy the toybox tests across.
4 adb shell mkdir /data/local/tmp/toybox-tests/
5 adb push tests/ /data/local/tmp/toybox-tests/
6 adb push scripts/runtest.sh /data/local/tmp/toybox-tests/
7
8 # Make a temporary directory on the device.
9 tmp_dir=`adb shell TMPDIR=/data/local/tmp mktemp --directory`
10
11 test_toy() {
12   toy=$1
13
14   echo
15
16   location=$(adb shell "which $toy")
17   if [ $? -ne 0 ]; then
18     echo "-- $toy not present"
19     return
20   fi
21
22   echo "-- $toy"
23
24   implementation=$(adb shell "realpath $location")
25   if [ "$implementation" != "/system/bin/toybox" ]; then
26     echo "-- note: $toy is non-toybox implementation"
27   fi
28
29   adb shell -t "export FILES=/data/local/tmp/toybox-tests/tests/files/ ; \
30                 export VERBOSE=1 ; \
31                 export CMDNAME=$toy; \
32                 export C=$toy; \
33                 export LANG=en_US.UTF-8; \
34                 cd $tmp_dir ; \
35                 source /data/local/tmp/toybox-tests/runtest.sh ; \
36                 source /data/local/tmp/toybox-tests/tests/$toy.test"
37 }
38
39 if [ "$#" -eq 0 ]; then
40   # Run all the tests.
41   for t in tests/*.test; do
42     toy=`echo $t | sed 's|tests/||' | sed 's|\.test||'`
43     test_toy $toy
44   done
45 else
46   # Just run the tests for the given toys.
47   for toy in "$@"; do
48     test_toy $toy
49   done
50 fi