| #!/system/bin/sh |
| |
| # TODO(victorhsieh): Create a standard Android test for continuous integration. |
| # |
| # How to run this test: |
| # |
| # Setup: |
| # $ adb push testdata/input.4m* /data/local/tmp |
| # $ adb push tools/device-test.sh /data/local/tmp/ |
| # |
| # Shell 1: |
| # $ adb shell /data/local/tmp/device-test.sh --run-fd-server |
| # |
| # Shell 2: |
| # $ adb shell /data/local/tmp/device-test.sh |
| |
| cd /data/local/tmp |
| cat /dev/null > output |
| |
| if [[ $1 == "--run-fd-server" ]]; then |
| exec 9</system/bin/sh 8<input.4m 7<input.4m.merkle_dump 6<input.4m \ |
| 5<input.4m.merkle_dump.bad 4<input.4m.fsv_sig 3<>output \ |
| fd_server --ro-fds 9 --ro-fds 8:7:4 --ro-fds 6:5:4 --rw-fds 3 |
| fi |
| |
| # Run with -u to enter new namespace. |
| if [[ $1 == "-u" ]]; then |
| exec unshare -mUr $0 |
| fi |
| |
| MOUNTPOINT=/data/local/tmp/authfs |
| trap "umount ${MOUNTPOINT}" EXIT; |
| mkdir -p ${MOUNTPOINT} |
| |
| size=$(du -b /system/bin/sh |awk '{print $1}') |
| size2=$(du -b input.4m |awk '{print $1}') |
| |
| echo "Mounting authfs in background ..." |
| |
| # TODO(170494765): Replace /dev/null (currently not used) with a valid |
| # certificate. |
| authfs \ |
| ${MOUNTPOINT} \ |
| --local-ro-file 2:input.4m:input.4m.merkle_dump:input.4m.fsv_sig:/dev/null \ |
| --local-ro-file 3:input.4k1:input.4k1.merkle_dump:input.4k1.fsv_sig:/dev/null \ |
| --local-ro-file 4:input.4k:input.4k.merkle_dump:input.4k.fsv_sig:/dev/null \ |
| --local-ro-file-unverified 5:/system/bin/sh \ |
| --remote-ro-file-unverified 6:9:${size} \ |
| --remote-ro-file 7:8:${size2}:/dev/null \ |
| --remote-ro-file 8:6:${size2}:/dev/null \ |
| --remote-new-rw-file 9:3 \ |
| & |
| sleep 0.1 |
| |
| echo "Accessing files in authfs ..." |
| md5sum ${MOUNTPOINT}/2 input.4m |
| echo |
| md5sum ${MOUNTPOINT}/3 input.4k1 |
| echo |
| md5sum ${MOUNTPOINT}/4 input.4k |
| echo |
| md5sum ${MOUNTPOINT}/5 /system/bin/sh |
| md5sum ${MOUNTPOINT}/6 |
| echo |
| md5sum ${MOUNTPOINT}/7 input.4m |
| echo |
| cat input.4m > ${MOUNTPOINT}/9 |
| md5sum ${MOUNTPOINT}/9 output |
| echo |
| echo Checking error cases... |
| cat /data/local/tmp/authfs/8 2>&1 |grep -q ": I/O error" || echo "Failed to catch the problem" |
| echo "Done!" |