Debian Codegraph @

test.sh

raw symbols SCIP
1 #!/usr/bin/env bash
2
3 set -E
4
5 setup() {
6 # volume and file sizes are specifically chosen so that naive copy will not have enough space
7 fallocate -l 200M .btrfs.img
8 mkfs.btrfs -f .btrfs.img
9
10 mkdir -p .btrfs-mnt
11 sudo mount -o loop .btrfs.img .btrfs-mnt
12 sudo chmod a+rwx .btrfs-mnt
13
14 cat /dev/random | head -c 50M > .btrfs-mnt/src.bin
15
16 # chopping 16K from start and 16K from end
17 cat .btrfs-mnt/src.bin | tail -c +16K | tail -c +2 | head -c -16K > .btrfs-mnt/src-part.bin
18
19 }
20
21 test() {
22 cargo test
23
24 diff -q .btrfs-mnt/src.bin .btrfs-mnt/dest.bin
25 diff -q .btrfs-mnt/src-part.bin .btrfs-mnt/dest-part.bin
26 diff -q .btrfs-mnt/clone-range-small.bin .btrfs-mnt/copy-range-small.bin
27 }
28
29 teardown() {
30 code=$?
31 trap - ERR
32
33 sudo umount .btrfs-mnt
34 rm -r .btrfs-mnt
35 rm .btrfs.img
36
37 exit $code
38 }
39
40 setup
41 trap teardown ERR
42 test
43 teardown