mirror of
https://github.com/kdave/btrfs-progs
synced 2025-01-14 09:40:47 +00:00
1804dcaa4b
When the test environment is in 'docker', there's some delay before the device mapper nodes appear in /dev/mapper. Add a delay before the test continues, usually 1 second was enough but give it more just in case. Add ad fallback to skip the test if the device node does not show up, this is a problem in the running environment and the testsuite should continue. Signed-off-by: David Sterba <dsterba@suse.com>
53 lines
1.5 KiB
Bash
Executable File
53 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
# a long device name must pass the SSD test
|
|
|
|
source "$TEST_TOP/common"
|
|
|
|
check_prereq mkfs.btrfs
|
|
check_dm_target_support linear
|
|
|
|
setup_root_helper
|
|
prepare_test_dev
|
|
|
|
# Randomize last 4 characters to prevent clashes of device name on the same system
|
|
chars=( {0..9} {a..z} {A..Z} )
|
|
rand=${chars[$RANDOM % 62]}${chars[$RANDOM % 62]}${chars[$RANDOM % 62]}${chars[$RANDOM % 62]}
|
|
|
|
# prep device
|
|
dmname=\
|
|
btrfs-test-with-very-long-name-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA$rand
|
|
dmdev="/dev/mapper/$dmname"
|
|
|
|
run_check truncate -s0 img
|
|
chmod a+w img
|
|
run_check truncate -s2g img
|
|
|
|
loopdev=`run_check_stdout $SUDO_HELPER losetup --find --show img`
|
|
run_check $SUDO_HELPER dmsetup create "$dmname" --table "0 1048576 linear $loopdev 0"
|
|
|
|
# Setting up the device may need some time to appear
|
|
sleep 5
|
|
if ! [ -b "$dmdev" ]; then
|
|
_not_run "dm device created but not visible in /dev/mapper"
|
|
fi
|
|
|
|
dmbase=`readlink -f "$dmdev"`
|
|
base=`basename "$dmbase"`
|
|
rot="/sys/class/block/$base/queue/rotational"
|
|
|
|
# switch rotational
|
|
run_check cat $rot
|
|
echo 0 | run_check $SUDO_HELPER tee "$rot"
|
|
run_check cat "$rot"
|
|
|
|
# test
|
|
run_check_stdout $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$@" "$dmdev" |
|
|
grep -q 'SSD detected:.*yes' || _fail 'SSD not detected'
|
|
run_check $SUDO_HELPER "$TOP/btrfs" inspect-internal dump-super "$dmdev"
|
|
|
|
# cleanup
|
|
run_check $SUDO_HELPER dmsetup remove "$dmname"
|
|
run_mayfail $SUDO_HELPER losetup -d "$loopdev"
|
|
run_check truncate -s0 img
|
|
rm img
|