aboutsummaryrefslogtreecommitdiff
path: root/run-tests-on-android.sh
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2017-08-03 14:52:32 -0700
committerElliott Hughes <enh@google.com>2017-08-09 12:49:34 -0700
commitd3633b18c34ebe2fe073c0e53282547e0929de0f (patch)
tree0f18f030f8384ef0e8ae6877febf0cec646c7e0c /run-tests-on-android.sh
parent3f4a99df44648fad709708ee68e55bec9afafeab (diff)
downloadtoybox-d3633b18c34ebe2fe073c0e53282547e0929de0f.tar.gz
Check in my Android test-running script.android-o-iot-preview-5o-iot-preview-5
Also update the documentation in Android.mk. Bug: N/A Test: ran tests Change-Id: Id986221f274101fff4d42b2a538bf39cd4956e06
Diffstat (limited to 'run-tests-on-android.sh')
-rwxr-xr-xrun-tests-on-android.sh50
1 files changed, 50 insertions, 0 deletions
diff --git a/run-tests-on-android.sh b/run-tests-on-android.sh
new file mode 100755
index 00000000..aefbdc0b
--- /dev/null
+++ b/run-tests-on-android.sh
@@ -0,0 +1,50 @@
+#!/bin/bash
+
+# Copy the toybox tests across.
+adb shell mkdir /data/local/tmp/toybox-tests/
+adb push tests/ /data/local/tmp/toybox-tests/
+adb push scripts/runtest.sh /data/local/tmp/toybox-tests/
+
+# Make a temporary directory on the device.
+tmp_dir=`adb shell TMPDIR=/data/local/tmp mktemp --directory`
+
+test_toy() {
+ toy=$1
+
+ echo
+
+ location=$(adb shell "which $toy")
+ if [ $? -ne 0 ]; then
+ echo "-- $toy not present"
+ return
+ fi
+
+ echo "-- $toy"
+
+ implementation=$(adb shell "realpath $location")
+ if [ "$implementation" != "/system/bin/toybox" ]; then
+ echo "-- note: $toy is non-toybox implementation"
+ fi
+
+ adb shell -t "export FILES=/data/local/tmp/toybox-tests/tests/files/ ; \
+ export VERBOSE=1 ; \
+ export CMDNAME=$toy; \
+ export C=$toy; \
+ export LANG=en_US.UTF-8; \
+ cd $tmp_dir ; \
+ source /data/local/tmp/toybox-tests/runtest.sh ; \
+ source /data/local/tmp/toybox-tests/tests/$toy.test"
+}
+
+if [ "$#" -eq 0 ]; then
+ # Run all the tests.
+ for t in tests/*.test; do
+ toy=`echo $t | sed 's|tests/||' | sed 's|\.test||'`
+ test_toy $toy
+ done
+else
+ # Just run the tests for the given toys.
+ for toy in "$@"; do
+ test_toy $toy
+ done
+fi