blob: 5cf5f10c44f3ebe97556fc14d5f1e53cd40c375e [file] [log] [blame]
Victor Hsiehf01f3232020-12-11 13:31:31 -08001#!/system/bin/sh
2
3# TODO(victorhsieh): Create a standard Android test for continuous integration.
4#
5# How to run this test:
6#
7# Setup:
8# $ adb push testdata/input.4m* /data/local/tmp
9#
10# Shell 1:
11# $ adb shell 'cd /data/local/tmp && exec 9</system/bin/sh 8<input.4m 7<input.4m.merkle_dump 6<input.4m.fsv_sig 5<input.4m 4<input.4m.merkle_dump.bad 3<input.4m.fsv_sig fd_server --ro-fds 9 --ro-fds 8:7:6 --ro-fds 5:4:3'
12#
13# Shell 2:
14# $ adb push tools/device-test.sh /data/local/tmp/ && adb shell /data/local/tmp/device-test.sh
15
16# Run with -u to enter new namespace.
17if [[ $1 == "-u" ]]; then
18 exec unshare -mUr $0
19fi
20
21cd /data/local/tmp
22
23MOUNTPOINT=/data/local/tmp/authfs
24trap "umount ${MOUNTPOINT}" EXIT;
25mkdir -p ${MOUNTPOINT}
26
27size=$(du -b /system/bin/sh |awk '{print $1}')
28size2=$(du -b input.4m |awk '{print $1}')
29
30echo "Mounting authfs in background ..."
31
32# TODO(170494765): Replace /dev/null (currently not used) with a valid
33# certificate.
34authfs \
35 ${MOUNTPOINT} \
36 --local-verified-file 2:input.4m:input.4m.merkle_dump:input.4m.fsv_sig:/dev/null \
37 --local-verified-file 3:input.4k1:input.4k1.merkle_dump:input.4k1.fsv_sig:/dev/null \
38 --local-verified-file 4:input.4k:input.4k.merkle_dump:input.4k.fsv_sig:/dev/null \
39 --local-unverified-file 5:/system/bin/sh \
40 --remote-unverified-file 6:9:${size} \
41 --remote-verified-file 7:8:${size2}:/dev/null \
42 --remote-verified-file 8:5:${size2}:/dev/null \
43 &
44sleep 0.1
45
46echo "Accessing files in authfs ..."
47md5sum ${MOUNTPOINT}/2 input.4m
48echo
49md5sum ${MOUNTPOINT}/3 input.4k1
50echo
51md5sum ${MOUNTPOINT}/4 input.4k
52echo
53md5sum ${MOUNTPOINT}/5 /system/bin/sh
54md5sum ${MOUNTPOINT}/6
55echo
56md5sum ${MOUNTPOINT}/7 input.4m
57echo
58echo Checking error cases...
59cat /data/local/tmp/authfs/8 2>&1 |grep -q ": I/O error" || echo "Failed to catch the problem"
60echo "Done!"