Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/tests/sys/geom/class/concat/append1.sh
39638 views
1
#!/bin/sh
2
3
# A basic regression test for gconcat append using "gconcat create",
4
# i.e., manual mode.
5
6
gconcat_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
23
echo '1..3'
24
25
attach_md us0 -t malloc -s 1M || exit 1
26
attach_md us1 -t malloc -s 1M || exit 1
27
attach_md us2 -t malloc -s 1M || exit 1
28
29
gconcat create $name /dev/$us0 /dev/$us1 || exit 1
30
devwait
31
32
# We should have a 2MB device. Add another disk and verify that the
33
# reported size of the concat device grows accordingly.
34
gconcat_check_size "${name}" $((2 * 1024 * 1024))
35
gconcat append $name /dev/$us2 || exit 1
36
gconcat_check_size "${name}" $((3 * 1024 * 1024))
37
38
# Write some data and make sure that we can read it back.
39
tmpfile=$(mktemp) || exit 1
40
dd if=/dev/random of=$tmpfile bs=1M count=3 || exit 1
41
dd if=$tmpfile of=/dev/concat/${name} || exit 1
42
if cmp -s $tmpfile /dev/concat/${name}; then
43
echo "ok - Data matches what was written"
44
else
45
echo "not ok - Data matches what was written"
46
fi
47
48