Page MenuHomeFreeBSD

D45535.id139634.diff
No OneTemporary

D45535.id139634.diff

diff --git a/tests/sys/geom/class/Makefile b/tests/sys/geom/class/Makefile
--- a/tests/sys/geom/class/Makefile
+++ b/tests/sys/geom/class/Makefile
@@ -19,6 +19,7 @@
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/1_test.sh b/tests/sys/geom/class/virstor/1_test.sh
new file mode 100644
--- /dev/null
+++ b/tests/sys/geom/class/virstor/1_test.sh
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+. `dirname $0`/conf.sh
+
+echo '1..6'
+
+# Create an md backing device and initialize it with junk
+psecsize=512
+attach_md md0 -t malloc -S $psecsize -s 5M || exit 1
+jot -b uninitialized 0 | dd status=none of=/dev/$md0
+
+# Create a virstor device
+vsizemb=64
+vsize=$((vsizemb * 1024 * 1024))
+gvirstor label -v -s ${vsizemb}M -m 512 $name /dev/$md0 || exit 1
+devwait
+vdev="/dev/virstor/$name"
+
+ssize=$(diskinfo $vdev | awk '{print $2}')
+tap_check_val "sector size" $ssize $psecsize
+
+size=$(diskinfo $vdev | awk '{print $3}')
+tap_check_val "virtual size" $size $vsize
+
+# 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)
+tap_check_val "first block hash" $hashx $hasha
+hashx=$(dd status=none if=$vdev bs=$ssize count=1 skip=$zsector | sha1)
+tap_check_val "last block hash" $hashx $hashz
+
+# Destroy, then retaste and reload
+gvirstor destroy $name || exit 1
+true > /dev/$md0
+[ -c $vdev ] || { echo retaste failed; exit 1; }
+
+# Read back and compare
+hashx=$(dd status=none if=$vdev bs=$ssize count=1 | sha1)
+tap_check_val "first block hash after reload" $hashx $hasha
+hashx=$(dd status=none if=$vdev bs=$ssize count=1 skip=$zsector | sha1)
+tap_check_val "last block hash after reload" $hashx $hashz
+
diff --git a/tests/sys/geom/class/virstor/Makefile b/tests/sys/geom/class/virstor/Makefile
new file mode 100644
--- /dev/null
+++ b/tests/sys/geom/class/virstor/Makefile
@@ -0,0 +1,14 @@
+
+PACKAGE= tests
+
+TESTSDIR= ${TESTSBASE}/sys/geom/class/${.CURDIR:T}
+
+TAP_TESTS_SH+= 1_test
+
+${PACKAGE}FILES+= conf.sh
+
+.for t in ${TAP_TESTS_SH}
+TEST_METADATA.$t+= required_user="root"
+.endfor
+
+.include <bsd.test.mk>
diff --git a/tests/sys/geom/class/virstor/conf.sh b/tests/sys/geom/class/virstor/conf.sh
new file mode 100644
--- /dev/null
+++ b/tests/sys/geom/class/virstor/conf.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+name="$(mktemp -u virstor.XXXXXX)"
+class="virstor"
+base=`basename $0`
+
+tap_check_val()
+{
+ if [ $2 = $3 ]; then
+ echo "ok - $1 is $3"
+ else
+ echo "not ok - $1 is $2 but expected $3"
+ fi
+}
+
+gvirstor_test_cleanup()
+{
+ [ -c /dev/$class/$name ] && gvirstor destroy $name
+ geom_test_cleanup
+}
+trap gvirstor_test_cleanup ABRT EXIT INT TERM
+
+. `dirname $0`/../geom_subr.sh

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 18, 3:34 PM (4 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
25522080
Default Alt Text
D45535.id139634.diff (3 KB)

Event Timeline