"Fossies" - the Fresh Open Source Software Archive

Member "btrfs-progs-v5.4/tests/misc-tests/023-device-usage-with-missing-device/test.sh" (3 Dec 2019, 1053 Bytes) of package /linux/misc/btrfs-progs-v5.4.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/bash
    2 # check if 'device slack' is reported as zero when a device is missing
    3 
    4 source "$TEST_TOP/common"
    5 
    6 check_prereq btrfs-image
    7 check_prereq mkfs.btrfs
    8 check_prereq btrfs
    9 
   10 setup_root_helper
   11 
   12 test_run()
   13 {
   14     # empty filesystem, with enough redundancy so degraded mount works
   15     run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f -d raid1 -m raid1 "$dev1" "$dev2"
   16 
   17     TEST_DEV="$dev1"
   18     run_check_mount_test_dev
   19     run_check $SUDO_HELPER "$TOP/btrfs" filesystem usage "$TEST_MNT"
   20     run_check_stdout $SUDO_HELPER "$TOP/btrfs" device usage "$TEST_MNT" | \
   21         grep -q "slack.*16\\.00EiB" && _fail
   22     run_check_umount_test_dev
   23 
   24     run_mayfail wipefs -a "$dev2"
   25     run_check $SUDO_HELPER losetup -d "$dev2"
   26     unset loopdevs[2]
   27 
   28     run_check_mount_test_dev -o degraded,ro
   29     run_check $SUDO_HELPER "$TOP/btrfs" filesystem usage "$TEST_MNT"
   30     run_check_stdout $SUDO_HELPER "$TOP/btrfs" device usage "$TEST_MNT" | \
   31         grep -q "slack.*16\\.00EiB" && _fail
   32     run_check_umount_test_dev
   33 }
   34 
   35 setup_loopdevs 2
   36 prepare_loopdevs
   37 dev1=${loopdevs[1]}
   38 dev2=${loopdevs[2]}
   39 test_run
   40 cleanup_loopdevs