Victor Hsieh | 88ac6ca | 2020-11-13 15:20:24 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Run with -u to enter new namespace. |
| 4 | if [[ $1 == "-u" ]]; then |
| 5 | exec unshare -m -U -r $0 |
| 6 | fi |
| 7 | |
| 8 | trap "umount /tmp/mnt" EXIT; |
| 9 | mkdir -p /tmp/mnt |
| 10 | |
| 11 | echo "Mounting authfs in background ..." |
| 12 | strace -o authfs.strace target/debug/authfs \ |
| 13 | /tmp/mnt \ |
| 14 | --local-verified-file 2:testdata/input.4m:testdata/input.4m.merkle_dump:testdata/input.4m.fsv_sig \ |
| 15 | --local-verified-file 3:testdata/input.4k1:testdata/input.4k1.merkle_dump:testdata/input.4k1.fsv_sig \ |
| 16 | --local-verified-file 4:testdata/input.4k:testdata/input.4k.merkle_dump:testdata/input.4k.fsv_sig \ |
| 17 | --local-unverified-file 5:testdata/input.4k \ |
| 18 | & |
| 19 | sleep 0.1 |
| 20 | |
| 21 | echo "Accessing files in authfs ..." |
| 22 | echo |
| 23 | md5sum /tmp/mnt/2 testdata/input.4m |
| 24 | echo |
| 25 | md5sum /tmp/mnt/3 testdata/input.4k1 |
| 26 | echo |
| 27 | md5sum /tmp/mnt/4 /tmp/mnt/5 testdata/input.4k |
| 28 | echo |
| 29 | dd if=/tmp/mnt/2 bs=1000 skip=100 count=50 status=none |md5sum |
| 30 | dd if=testdata/input.4m bs=1000 skip=100 count=50 status=none |md5sum |
| 31 | echo |
| 32 | tac /tmp/mnt/4 |md5sum |
| 33 | tac /tmp/mnt/5 |md5sum |
| 34 | tac testdata/input.4k |md5sum |
| 35 | echo |
| 36 | test -f /tmp/mnt/2 || echo 'FAIL: an expected file is missing' |
| 37 | test -f /tmp/mnt/0 && echo 'FAIL: unexpected file presents' |
| 38 | test -f /tmp/mnt/1 && echo 'FAIL: unexpected file presents, 1 is root dir' |
| 39 | test -f /tmp/mnt/100 && echo 'FAIL: unexpected file presents' |
| 40 | test -f /tmp/mnt/foo && echo 'FAIL: unexpected file presents' |
| 41 | test -f /tmp/mnt/dir/3 && echo 'FAIL: unexpected file presents' |
| 42 | echo "Done!" |