From nobody Mon Jun 10 17:34:41 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Vyf7k1yCTz5MK77; Mon, 10 Jun 2024 17:34:42 +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 4Vyf7j703dz40m5; Mon, 10 Jun 2024 17:34:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1718040882; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CD4qut4vP0U2vUj+wtYY92DJiVgP2zeB4wpAVV9pG+E=; b=gMSteZmUD5/KD5bkmsesceg8inqWBspwPS5UDrNmO0Q6rhuPx4i1BjzyqY517ARymkCfU4 ACaSfZ1jKzppJ7VNdSfDW6rXUl0jmCqi5vvPzb7uY2/JAAwHJXIFbutFxvylzo9rsQ6LuI m6sh71apLUTDczL55wMcnvStusFZAsv4VdRfS1icJIuaabBJTkFjPk9OoWPtP/RtzJjYcn xUjy9BNg+2ZFtc3nvtMjV7ZCxXgo92zUFf7yryeUJjUtVjPmCSaavKXpVomuZ48O6ypbiK kJphBdBZEtuy0JxDHafMOp42hZJTu26poYrQ8nhMUAszg6j9G8M5eT63iQz9Tg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1718040882; a=rsa-sha256; cv=none; b=cERCJowu1cyQGbii6H0SgNQBwIQ1HtRN8T1dMEf9Vb7NSgh55ItQWtFEnXTmP0ZAcC5rqb nkx8w36Mj7ufmB1hLNKH2zjbGEF2hOISBioLE0tyPYFyMKFKT6OhmSN7WKhBQf/1gKse+o gnsrxJq/Jf6lWoDpsA5G/y3cLn6DENXviiEna6fBbeyb6pjitVuOKcOsjdZn7W9QTaMWO5 UHYOuuUdh54fnO2coOlPD0vp6NyjYB9tQyGgmg/msjJL8h0yLlc2b4dhJbu4KkA/kWe6a+ S05cogr/eTd2G9PY7D1JDcuoNU6zerhQCE23J5SBP7FcQGZnibATCJ9kw+AVQw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1718040882; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CD4qut4vP0U2vUj+wtYY92DJiVgP2zeB4wpAVV9pG+E=; b=i1dG9ojukdOD1aOQoVVTn1WU6jh3Gkj1WXsTki35EgQh88y2+wBKdBRAXUkWDu3jz11ADq Pz/TThIzUzygvyc3mjjisCfHUHxDL1xK1fpMy8QgUT+o1FYorqIfXythjJjC2RqsqOnQTn b9TMdvcDmY5661i4Nss0wCC7cWr2BFpPWpU+TGmF3iN5F29MmQ87UbBy+YI/fVDwN20Mjj yoOoc0DEySXk6EohO+2jCt/oMwDNw+A3b1l6T53r4kO16TH8h5Ewu1TRO2MRHao6WTlAgC IPmzAwFWPMuh39OoGhIBjFBRn0hgP8hcaXyg65/LuqGgeByhcPi5xN+jbi6uAw== 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 4Vyf7j6T7WzZrm; Mon, 10 Jun 2024 17:34:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 45AHYfLV058108; Mon, 10 Jun 2024 17:34:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 45AHYf4a058105; Mon, 10 Jun 2024 17:34:41 GMT (envelope-from git) Date: Mon, 10 Jun 2024 17:34:41 GMT Message-Id: <202406101734.45AHYf4a058105@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ryan Libby Subject: git: 7affbeeab1c9 - main - virstor: basic functional test List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rlibby X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7affbeeab1c99685012df0d72df2d7a87e09e472 Auto-Submitted: auto-generated The branch main has been updated by rlibby: URL: https://cgit.FreeBSD.org/src/commit/?id=7affbeeab1c99685012df0d72df2d7a87e09e472 commit 7affbeeab1c99685012df0d72df2d7a87e09e472 Author: Ryan Libby AuthorDate: 2024-06-10 17:32:22 +0000 Commit: Ryan Libby CommitDate: 2024-06-10 17:32:22 +0000 virstor: basic functional test Reviewed by: asomers, markj Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D45535 --- tests/sys/geom/class/Makefile | 1 + tests/sys/geom/class/virstor/Makefile | 9 ++++ tests/sys/geom/class/virstor/conf.sh | 31 ++++++++++++ tests/sys/geom/class/virstor/virstor_test.sh | 73 ++++++++++++++++++++++++++++ 4 files changed, 114 insertions(+) diff --git a/tests/sys/geom/class/Makefile b/tests/sys/geom/class/Makefile index 10b01a043ddf..b640b0b46859 100644 --- a/tests/sys/geom/class/Makefile +++ b/tests/sys/geom/class/Makefile @@ -19,6 +19,7 @@ TESTS_SUBDIRS+= shsec TESTS_SUBDIRS+= stripe TESTS_SUBDIRS+= union TESTS_SUBDIRS+= uzip +TESTS_SUBDIRS+= virstor ${PACKAGE}FILES+= geom_subr.sh diff --git a/tests/sys/geom/class/virstor/Makefile b/tests/sys/geom/class/virstor/Makefile new file mode 100644 index 000000000000..67242879e33f --- /dev/null +++ b/tests/sys/geom/class/virstor/Makefile @@ -0,0 +1,9 @@ +PACKAGE= tests + +TESTSDIR= ${TESTSBASE}/sys/geom/class/${.CURDIR:T} + +ATF_TESTS_SH+= virstor_test + +${PACKAGE}FILES+= conf.sh + +.include diff --git a/tests/sys/geom/class/virstor/conf.sh b/tests/sys/geom/class/virstor/conf.sh new file mode 100644 index 000000000000..46b0fd1308a3 --- /dev/null +++ b/tests/sys/geom/class/virstor/conf.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +class="virstor" +base=$(atf_get ident) +TEST_VIRSTOR_DEVS_FILE="${TMPDIR}/test_virstor_devs.$(basename $0)" + +gvirstor_dev_setup() +{ + # Pick a random name and record it for cleanup. + local vdevbase="$(mktemp -u virstor.XXXXXX)" || aft_fail "mktemp" + echo "$vdevbase" >> "$TEST_VIRSTOR_DEVS_FILE" + eval "${1}='${vdevbase}'" +} + +gvirstor_test_cleanup() +{ + local vdevbase + if [ -f "$TEST_VIRSTOR_DEVS_FILE" ]; then + while read vdevbase; do + if [ -c "/dev/$class/$vdevbase" ]; then + echo "# Destroying test virstor device:" \ + "$vdevbase" + gvirstor destroy "$vdevbase" + fi + done < "$TEST_VIRSTOR_DEVS_FILE" + fi + geom_test_cleanup +} + +ATF_TEST=true +. `dirname $0`/../geom_subr.sh diff --git a/tests/sys/geom/class/virstor/virstor_test.sh b/tests/sys/geom/class/virstor/virstor_test.sh new file mode 100644 index 000000000000..4f2047bffe97 --- /dev/null +++ b/tests/sys/geom/class/virstor/virstor_test.sh @@ -0,0 +1,73 @@ +# +# Copyright (c) 2024 Dell Inc. or its subsidiaries. All Rights Reserved. +# +# SPDX-License-Identifier: BSD-2-Clause +# + +. $(atf_get_srcdir)/conf.sh + +atf_test_case basic cleanup +basic_head() +{ + atf_set "descr" "geom virstor basic functional test" + atf_set "require.user" "root" +} +basic_body() +{ + geom_atf_test_setup + # Choose a virstor device name + gvirstor_dev_setup name + + # Create an md backing device and initialize it with junk + psecsize=512 + attach_md md -t swap -S $psecsize -s 5M || atf_fail "attach_md" + jot -b uninitialized 0 | dd status=none of=/dev/$md 2> /dev/null + + # Create a virstor device + vsizemb=64 + vsize=$((vsizemb * 1024 * 1024)) + atf_check -o ignore -e ignore \ + gvirstor label -v -s ${vsizemb}M -m 512 $name /dev/$md + devwait + vdev="/dev/$class/$name" + + ssize=$(diskinfo $vdev | awk '{print $2}') + atf_check_equal $psecsize $ssize + + size=$(diskinfo $vdev | awk '{print $3}') + atf_check_equal $vsize $size + + # Write the first and last sectors of the virtual address space + hasha=$(jot -b a 0 | head -c $ssize | sha1) + hashz=$(jot -b z 0 | head -c $ssize | sha1) + zsector=$((vsize / ssize - 1)) + jot -b a 0 | dd status=none of=$vdev bs=$ssize count=1 conv=notrunc + jot -b z 0 | dd status=none of=$vdev bs=$ssize count=1 conv=notrunc \ + seek=$zsector + + # Read back and compare + hashx=$(dd status=none if=$vdev bs=$ssize count=1 | sha1) + atf_check_equal $hasha $hashx + hashx=$(dd status=none if=$vdev bs=$ssize count=1 skip=$zsector | sha1) + atf_check_equal $hashz $hashx + + # Destroy, then retaste and reload + atf_check -o ignore gvirstor destroy $name + true > /dev/$md + devwait + + # Read back and compare + hashx=$(dd status=none if=$vdev bs=$ssize count=1 | sha1) + atf_check_equal $hasha $hashx + hashx=$(dd status=none if=$vdev bs=$ssize count=1 skip=$zsector | sha1) + atf_check_equal $hashz $hashx +} +basic_cleanup() +{ + gvirstor_test_cleanup +} + +atf_init_test_cases() +{ + atf_add_test_case basic +}