Path: blob/main/tests/sys/geom/class/concat/append2.sh
39638 views
#!/bin/sh12# A basic regression test for gconcat append using "gconcat label",3# i.e., automatic mode.45gconcat_check_size()6{7local actual expected name89name=$110expected=$21112actual=$(diskinfo /dev/concat/${name} | awk '{print $3}')13if [ $actual -eq $expected ]; then14echo "ok - Size is ${actual}"15else16echo "not ok - Size is ${actual}"17fi18}1920. `dirname $0`/conf.sh2122echo '1..4'2324ss=5122526f1=$(mktemp) || exit 127truncate -s $((1024 * 1024 + $ss)) $f128f2=$(mktemp) || exit 129truncate -s $((1024 * 1024 + $ss)) $f230f3=$(mktemp) || exit 131truncate -s $((1024 * 1024 + $ss)) $f33233attach_md us0 -f $f1 -S $ss || exit 134attach_md us1 -f $f2 -S $ss || exit 135attach_md us2 -f $f3 -S $ss || exit 13637gconcat label $name /dev/$us0 /dev/$us1 || exit 138devwait3940# We should have a 2MB device. Add another disk and verify that the41# reported size of the concat device grows accordingly. A sector from42# each disk is reserved for the metadata sector.43gconcat_check_size "${name}" $((2 * 1024 * 1024))44gconcat append $name /dev/$us2 || exit 145gconcat_check_size "${name}" $((3 * 1024 * 1024))4647copy=$(mktemp) || exit 148dd if=/dev/random of=$copy bs=1M count=3 || exit 149dd if=$copy of=/dev/concat/${name} || exit 15051# Stop the concat device and destroy the backing providers.52gconcat stop ${name} || exit 153detach_md $us054detach_md $us155detach_md $us25657# Re-create the providers and verify that the concat device comes58# back and that the data is still there.59attach_md us0 -f $f1 -S $ss || exit 160attach_md us1 -f $f2 -S $ss || exit 161attach_md us2 -f $f3 -S $ss || exit 16263devwait6465# Make sure that the66if [ -c /dev/concat/${name} ]; then67echo "ok - concat device was instantiated"68else69echo "not ok - concat device was instantiated"70fi7172if cmp -s $copy /dev/concat/${name}; then73echo "ok - Data was persisted across gconcat stop"74else75echo "not ok - Data was persisted across gconcat stop"76fi777879