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