xref: /freebsd/tests/sys/geom/class/concat/append1.sh (revision 069ac18495ad8fde2748bc94b0f80a50250bb01d)
1#!/bin/sh
2
3# A basic regression test for gconcat append using "gconcat create",
4# i.e., manual mode.
5
6gconcat_check_size()
7{
8    local actual expected name
9
10    name=$1
11    expected=$2
12
13    actual=$(diskinfo /dev/concat/${name} | awk '{print $3}')
14    if [ $actual -eq $expected ]; then
15        echo "ok - Size is ${actual}"
16    else
17        echo "not ok - Size is ${actual}"
18    fi
19}
20
21. `dirname $0`/conf.sh
22
23echo '1..3'
24
25attach_md us0 -t malloc -s 1M || exit 1
26attach_md us1 -t malloc -s 1M || exit 1
27attach_md us2 -t malloc -s 1M || exit 1
28
29gconcat create $name /dev/$us0 /dev/$us1 || exit 1
30devwait
31
32# We should have a 2MB device.  Add another disk and verify that the
33# reported size of the concat device grows accordingly.
34gconcat_check_size "${name}" $((2 * 1024 * 1024))
35gconcat append $name /dev/$us2 || exit 1
36gconcat_check_size "${name}" $((3 * 1024 * 1024))
37
38# Write some data and make sure that we can read it back.
39tmpfile=$(mktemp) || exit 1
40dd if=/dev/random of=$tmpfile bs=1M count=3 || exit 1
41dd if=$tmpfile of=/dev/concat/${name} || exit 1
42if cmp -s $tmpfile /dev/concat/${name}; then
43    echo "ok - Data matches what was written"
44else
45    echo "not ok - Data matches what was written"
46fi
47