First tests for bioctl(8), start with scripted creation + passphrase change
authorkn <kn@openbsd.org>
Sun, 20 Aug 2023 23:19:00 +0000 (23:19 +0000)
committerkn <kn@openbsd.org>
Sun, 20 Aug 2023 23:19:00 +0000 (23:19 +0000)
These are meant for CLI bits like passphrase hashing, error handling and
interactive vs. scripted behaviour.

regress/sys/dev/softraid/ and stuff like regress/usr.sbin/installboot/
already test specific softraid(4) disciplines and disk handling.

regress/sbin/bioctl/Makefile [new file with mode: 0644]

diff --git a/regress/sbin/bioctl/Makefile b/regress/sbin/bioctl/Makefile
new file mode 100644 (file)
index 0000000..2994418
--- /dev/null
@@ -0,0 +1,41 @@
+#      $OpenBSD: Makefile,v 1.1 2023/08/20 23:19:00 kn Exp $
+
+BIOCTL ?=              /sbin/bioctl
+
+CHUNKFILE =            disk.img
+CHUNKDEVFILE =         chunk.txt
+VOLDEVFILE =           vol.txt
+
+OLDPW =                        oldsecret
+NEWPW =                        securenew
+
+
+REGRESS_SETUP_ONCE =   create-chunk
+
+create-chunk:
+       dd if=/dev/zero  of=${CHUNKFILE} bs=512k count=0 seek=1 status=none
+       ${SUDO} vnconfig -- ${CHUNKFILE} 1>${CHUNKDEVFILE}
+       echo 'RAID *' | ${SUDO} disklabel -wAT- -- "$$(<${CHUNKDEVFILE})"
+
+
+REGRESS_TARGETS =              scripted-create-volume \
+                               scripted-change-passphrase
+
+scripted-create-volume:
+       printf '%s\n' '${OLDPW}' | \
+               ${SUDO} ${BIOCTL} -s -cC -l"$$(<${CHUNKDEVFILE})a" -- softraid0 | \
+               grep -o 'sd[0-9]*$$' -- 1>${VOLDEVFILE}
+
+scripted-change-passphrase:
+       printf '%s\n%s\n' '${OLDPW}' '${NEWPW}' | \
+               ${SUDO} ${BIOCTL} -s -P -- "$$(<${VOLDEVFILE})"
+
+
+CLEANFILES =           *.txt *.img
+REGRESS_CLEANUP =      cleanup
+
+cleanup:
+       ${SUDO} ${BIOCTL} -d -- "$$(<${VOLDEVFILE})" 2>/dev/null
+       ${SUDO} vnconfig  -u -- "$$(<${CHUNKDEVFILE})" 2>/dev/null
+
+.include <bsd.regress.mk>