xref: /freebsd/tests/sys/geom/class/concat/append1.sh (revision 96950419f15510287080c557174e0d8409f06956)
186461b64SMark Johnston#!/bin/sh
286461b64SMark Johnston
386461b64SMark Johnston# A basic regression test for gconcat append using "gconcat create",
486461b64SMark Johnston# i.e., manual mode.
586461b64SMark Johnston
686461b64SMark Johnstongconcat_check_size()
786461b64SMark Johnston{
886461b64SMark Johnston    local actual expected name
986461b64SMark Johnston
1086461b64SMark Johnston    name=$1
1186461b64SMark Johnston    expected=$2
1286461b64SMark Johnston
1386461b64SMark Johnston    actual=$(diskinfo /dev/concat/${name} | awk '{print $3}')
1486461b64SMark Johnston    if [ $actual -eq $expected ]; then
1586461b64SMark Johnston        echo "ok - Size is ${actual}"
1686461b64SMark Johnston    else
1786461b64SMark Johnston        echo "not ok - Size is ${actual}"
1886461b64SMark Johnston    fi
1986461b64SMark Johnston}
2086461b64SMark Johnston
2186461b64SMark Johnston. `dirname $0`/conf.sh
2286461b64SMark Johnston
2386461b64SMark Johnstonecho '1..3'
2486461b64SMark Johnston
25*96950419SGleb Smirnoffattach_md us0 -t malloc -s 1M || exit 1
26*96950419SGleb Smirnoffattach_md us1 -t malloc -s 1M || exit 1
27*96950419SGleb Smirnoffattach_md us2 -t malloc -s 1M || exit 1
2886461b64SMark Johnston
2986461b64SMark Johnstongconcat create $name /dev/$us0 /dev/$us1 || exit 1
3086461b64SMark Johnstondevwait
3186461b64SMark Johnston
3286461b64SMark Johnston# We should have a 2MB device.  Add another disk and verify that the
3386461b64SMark Johnston# reported size of the concat device grows accordingly.
3486461b64SMark Johnstongconcat_check_size "${name}" $((2 * 1024 * 1024))
3586461b64SMark Johnstongconcat append $name /dev/$us2 || exit 1
3686461b64SMark Johnstongconcat_check_size "${name}" $((3 * 1024 * 1024))
3786461b64SMark Johnston
3886461b64SMark Johnston# Write some data and make sure that we can read it back.
3986461b64SMark Johnstontmpfile=$(mktemp) || exit 1
4086461b64SMark Johnstondd if=/dev/random of=$tmpfile bs=1M count=3 || exit 1
4186461b64SMark Johnstondd if=$tmpfile of=/dev/concat/${name} || exit 1
4286461b64SMark Johnstonif cmp -s $tmpfile /dev/concat/${name}; then
4386461b64SMark Johnston    echo "ok - Data matches what was written"
4486461b64SMark Johnstonelse
4586461b64SMark Johnston    echo "not ok - Data matches what was written"
4686461b64SMark Johnstonfi
47