git: 86461b646df5 - main - gconcat: Add some simple regression tests for the new append verb
Mark Johnston
markj at FreeBSD.org
Mon Jun 14 21:34:34 UTC 2021
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=86461b646df5da8117ddf051d212bcd13b5593f8
commit 86461b646df5da8117ddf051d212bcd13b5593f8
Author: Mark Johnston <markj at FreeBSD.org>
AuthorDate: 2021-06-14 19:18:49 +0000
Commit: Mark Johnston <markj at FreeBSD.org>
CommitDate: 2021-06-14 21:31:28 +0000
gconcat: Add some simple regression tests for the new append verb
Sponsored by: The FreeBSD Foundation
---
tests/sys/geom/class/concat/Makefile | 2 +
tests/sys/geom/class/concat/append1.sh | 47 ++++++++++++++++++++
tests/sys/geom/class/concat/append2.sh | 78 ++++++++++++++++++++++++++++++++++
3 files changed, 127 insertions(+)
diff --git a/tests/sys/geom/class/concat/Makefile b/tests/sys/geom/class/concat/Makefile
index b0849962aa01..380eca093038 100644
--- a/tests/sys/geom/class/concat/Makefile
+++ b/tests/sys/geom/class/concat/Makefile
@@ -6,6 +6,8 @@ TESTSDIR= ${TESTSBASE}/sys/geom/class/${.CURDIR:T}
TAP_TESTS_SH+= 1_test
TAP_TESTS_SH+= 2_test
+TAP_TESTS_SH+= append1
+TAP_TESTS_SH+= append2
${PACKAGE}FILES+= conf.sh
diff --git a/tests/sys/geom/class/concat/append1.sh b/tests/sys/geom/class/concat/append1.sh
new file mode 100644
index 000000000000..0331fe4503af
--- /dev/null
+++ b/tests/sys/geom/class/concat/append1.sh
@@ -0,0 +1,47 @@
+#!/bin/sh
+# $FreeBSD$
+
+# A basic regression test for gconcat append using "gconcat create",
+# i.e., manual mode.
+
+gconcat_check_size()
+{
+ local actual expected name
+
+ name=$1
+ expected=$2
+
+ actual=$(diskinfo /dev/concat/${name} | awk '{print $3}')
+ if [ $actual -eq $expected ]; then
+ echo "ok - Size is ${actual}"
+ else
+ echo "not ok - Size is ${actual}"
+ fi
+}
+
+. `dirname $0`/conf.sh
+
+echo '1..3'
+
+us0=$(attach_md -t malloc -s 1M) || exit 1
+us1=$(attach_md -t malloc -s 1M) || exit 1
+us2=$(attach_md -t malloc -s 1M) || exit 1
+
+gconcat create $name /dev/$us0 /dev/$us1 || exit 1
+devwait
+
+# We should have a 2MB device. Add another disk and verify that the
+# reported size of the concat device grows accordingly.
+gconcat_check_size "${name}" $((2 * 1024 * 1024))
+gconcat append $name /dev/$us2 || exit 1
+gconcat_check_size "${name}" $((3 * 1024 * 1024))
+
+# Write some data and make sure that we can read it back.
+tmpfile=$(mktemp) || exit 1
+dd if=/dev/random of=$tmpfile bs=1M count=3 || exit 1
+dd if=$tmpfile of=/dev/concat/${name} || exit 1
+if cmp -s $tmpfile /dev/concat/${name}; then
+ echo "ok - Data matches what was written"
+else
+ echo "not ok - Data matches what was written"
+fi
diff --git a/tests/sys/geom/class/concat/append2.sh b/tests/sys/geom/class/concat/append2.sh
new file mode 100644
index 000000000000..e9f39c34746a
--- /dev/null
+++ b/tests/sys/geom/class/concat/append2.sh
@@ -0,0 +1,78 @@
+#!/bin/sh
+# $FreeBSD$
+
+# A basic regression test for gconcat append using "gconcat label",
+# i.e., automatic mode.
+
+gconcat_check_size()
+{
+ local actual expected name
+
+ name=$1
+ expected=$2
+
+ actual=$(diskinfo /dev/concat/${name} | awk '{print $3}')
+ if [ $actual -eq $expected ]; then
+ echo "ok - Size is ${actual}"
+ else
+ echo "not ok - Size is ${actual}"
+ fi
+}
+
+. `dirname $0`/conf.sh
+
+echo '1..4'
+
+ss=512
+
+f1=$(mktemp) || exit 1
+truncate -s $((1024 * 1024 + $ss)) $f1
+f2=$(mktemp) || exit 1
+truncate -s $((1024 * 1024 + $ss)) $f2
+f3=$(mktemp) || exit 1
+truncate -s $((1024 * 1024 + $ss)) $f3
+
+us0=$(attach_md -f $f1 -S $ss) || exit 1
+us1=$(attach_md -f $f2 -S $ss) || exit 1
+us2=$(attach_md -f $f3 -S $ss) || exit 1
+
+gconcat label $name /dev/$us0 /dev/$us1 || exit 1
+devwait
+
+# We should have a 2MB device. Add another disk and verify that the
+# reported size of the concat device grows accordingly. A sector from
+# each disk is reserved for the metadata sector.
+gconcat_check_size "${name}" $((2 * 1024 * 1024))
+gconcat append $name /dev/$us2 || exit 1
+gconcat_check_size "${name}" $((3 * 1024 * 1024))
+
+copy=$(mktemp) || exit 1
+dd if=/dev/random of=$copy bs=1M count=3 || exit 1
+dd if=$copy of=/dev/concat/${name} || exit 1
+
+# Stop the concat device and destroy the backing providers.
+gconcat stop ${name} || exit 1
+detach_md $us0
+detach_md $us1
+detach_md $us2
+
+# Re-create the providers and verify that the concat device comes
+# back and that the data is still there.
+us0=$(attach_md -f $f1 -S $ss) || exit 1
+us1=$(attach_md -f $f2 -S $ss) || exit 1
+us2=$(attach_md -f $f3 -S $ss) || exit 1
+
+devwait
+
+# Make sure that the
+if [ -c /dev/concat/${name} ]; then
+ echo "ok - concat device was instantiated"
+else
+ echo "not ok - concat device was instantiated"
+fi
+
+if cmp -s $copy /dev/concat/${name}; then
+ echo "ok - Data was persisted across gconcat stop"
+else
+ echo "not ok - Data was persisted across gconcat stop"
+fi
More information about the dev-commits-src-all
mailing list