From owner-dev-commits-src-main@freebsd.org Mon Jun 14 21:34:34 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 57C19654A47; Mon, 14 Jun 2021 21:34:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4G3l8V1ykqz3Gd0; Mon, 14 Jun 2021 21:34:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2CE4E1C07B; Mon, 14 Jun 2021 21:34:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15ELYYJ9067434; Mon, 14 Jun 2021 21:34:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15ELYYKH067433; Mon, 14 Jun 2021 21:34:34 GMT (envelope-from git) Date: Mon, 14 Jun 2021 21:34:34 GMT Message-Id: <202106142134.15ELYYKH067433@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 86461b646df5 - main - gconcat: Add some simple regression tests for the new append verb MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 86461b646df5da8117ddf051d212bcd13b5593f8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Jun 2021 21:34:34 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=86461b646df5da8117ddf051d212bcd13b5593f8 commit 86461b646df5da8117ddf051d212bcd13b5593f8 Author: Mark Johnston AuthorDate: 2021-06-14 19:18:49 +0000 Commit: Mark Johnston 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