-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathandroid-test.sh
executable file
·83 lines (65 loc) · 2.55 KB
/
android-test.sh
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
#!/usr/bin/env bash
SCRIPT_DIR=$(dirname $0)
# NOTE: this script simply pushes the mpg123 binary to the device, and decodes
# an .mp3 file -> .wav file. it does NOT yet run any of the test binaries built
# by `make check`
LIB_NAME="libmpg123"
BUILD_DIR="$SCRIPT_DIR/build/android"
TEST_DIR="/data/local/tmp/$LIB_NAME/test"
if [ -z "$TEST_FILE" ]; then
TEST_FILE="$SCRIPT_DIR/src/tests/sweep.mp3"
echo "Test file not set: using default -> $TEST_FILE"
echo "Set TEST_FILE variable and re-run to customize"
else
echo "Using test file: $TEST_FILE"
fi
echo
TEST_FILE_IN_NAME=$(basename $TEST_FILE)
TEST_FILE_OUT_NAME="${TEST_FILE_IN_NAME%.mp3}.wav"
# make sure one device is accessible with parameters passed to script
ECHO=$(adb $@ shell echo 2>&1 )
if [ -n "$ECHO" ]; then
echo "Error running adb (specify device with -d or -s if more than one device is connected): $ECHO"
adb devices
exit 1
fi
# remove existing test files
adb $@ shell "rm -r $TEST_DIR" > /dev/null
adb $@ shell "mkdir -p $TEST_DIR" > /dev/null
ABIS=`adb $@ shell getprop ro.product.cpu.abilist`
print_message() {
echo "[==========================================================]"
echo "| [$LIB_NAME]: $1"
echo "[==========================================================]"
}
for ABI in $(echo $ABIS | tr "," "\n"); do
if [ $ABI == "armeabi" ]; then
print_message "skipping deprecated ABI: [$ABI]"; echo
continue
fi
print_message "testing ABI [$ABI]"
# create test directory for ABI on device
TEST_ABI_DIR="$TEST_DIR/$ABI"
adb $@ shell mkdir -p $TEST_ABI_DIR > /dev/null
# creat test output directory
OUTPUT_DIR="$BUILD_DIR/$ABI/test"
mkdir -p $OUTPUT_DIR > /dev/null
# push test binary to device
pushd "$BUILD_DIR/$ABI/bin" > /dev/null
adb $@ push mpg123 $TEST_ABI_DIR > /dev/null
popd > /dev/null
# push test libraries to device
pushd "$BUILD_DIR/$ABI/lib" > /dev/null
adb $@ push ./*.so $TEST_ABI_DIR > /dev/null
popd > /dev/null
# push test resources to device
adb $@ push $TEST_FILE $TEST_ABI_DIR > /dev/null
# run mpg123 to convert test file to .wav on device
adb $@ shell -t "cd $TEST_ABI_DIR && LD_LIBRARY_PATH=. ./mpg123 -w $TEST_FILE_OUT_NAME $TEST_FILE_IN_NAME"
# pull output file to test output directory
adb $@ pull "$TEST_ABI_DIR/$TEST_FILE_OUT_NAME" "$OUTPUT_DIR/" > /dev/null
echo "Test file output: $OUTPUT_DIR/$TEST_FILE_OUT_NAME"
echo
done
print_message "tests finished for ABIS: [$ABIS]"; echo
echo "NOTE: make sure to verify the test file output manually."