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