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