On Sun, Aug 27, 2017 at 11:44 PM, Mike Larkin <mlar...@azathoth.net> wrote:

> On Sun, Aug 27, 2017 at 02:24:08PM -0700, Carlos Cardenas wrote:
> > Howdy.
> >
> > Below is patch for some initial parsing tests for vmd:
> > * Memory string parsing (too small, invalid size, and rounding)
> > * Max disk path
> > * Max vm name
> > * Max kernel path
> > * Max NICs
> >
> > More tests to come.
> >
> > One item missing is the proper hook into regress/usr.sbin/Makefile
> > as it was unknown if they should be run all the time or only for
> > REGRESS_FULL.  Comments?
> >
> > Ok?
> >
>
> The diff doesn't apply. I think it got mangled. Can you send it again
> without line wrapping?


Re-sending.

+--+
Carlos

diff --git regress/usr.sbin/vmd/Makefile regress/usr.sbin/vmd/Makefile
new file mode 100644
index 00000000000..d7b3794710a
--- /dev/null
+++ regress/usr.sbin/vmd/Makefile
@@ -0,0 +1,44 @@
+# $OpenBSD: $
+
+# TARGETS
+# vmd-pass: load vmd-pass-*.conf through vmd and check against
vmd-pass-*.ok
+# vmd-fail: load vmd-fail-*.conf through vmd and check against
vmd-fail-*.ok
+
+VMD_PASS=1 2 3
+VMD_FAIL=1 2 3 4 5 6 7
+
+MAKEOBJDIRPREFIX=
+
+SHELL=/bin/sh
+
+.MAIN: all
+
+.for n in ${VMD_PASS}
+VMD_PASS_TARGETS+=vmd_pass${n}
+
+vmd_pass${n}:
+       ${SUDO} vmd -n -f ${.CURDIR}/vmd-pass-${n}.conf 2>&1 | \
+           diff -u ${.CURDIR}/vmd-pass-${n}.ok /dev/stdin
+.endfor
+
+vmd-pass:      ${VMD_PASS_TARGETS}
+REGRESS_TARGETS+=vmd-pass
+REGRESS_ROOT_TARGETS+=vmd-pass
+
+.for n in ${VMD_FAIL}
+VMD_FAIL_TARGETS+=vmd_fail${n}
+
+vmd_fail${n}:
+       ${SUDO} vmd -n -f ${.CURDIR}/vmd-fail-${n}.conf 2>&1 | \
+           diff -u ${.CURDIR}/vmd-fail-${n}.ok /dev/stdin
+.endfor
+
+vmd-fail:      ${VMD_FAIL_TARGETS}
+REGRESS_TARGETS+=vmd-fail
+REGRESS_ROOT_TARGETS+=vmd-fail
+
+alltests: ${REGRESS_TARGETS}
+
+.PHONY: ${REGRESS_TARGETS}
+
+.include <bsd.regress.mk>
diff --git regress/usr.sbin/vmd/vmd-fail-1.conf
regress/usr.sbin/vmd/vmd-fail-1.conf
new file mode 100644
index 00000000000..3e3006a057d
--- /dev/null
+++ regress/usr.sbin/vmd/vmd-fail-1.conf
@@ -0,0 +1,12 @@
+# $OpenBSD: $
+# Fail on kernel keyword; has been replaced by boot.
+ramdisk="/bsd.rd"
+switch "sw" {
+    add vether0
+}
+vm "x" {
+    kernel $ramdisk
+    memory 2G
+    disable
+    interface { switch "sw" }
+}
diff --git regress/usr.sbin/vmd/vmd-fail-1.ok
regress/usr.sbin/vmd/vmd-fail-1.ok
new file mode 100644
index 00000000000..02fcd909b1e
--- /dev/null
+++ regress/usr.sbin/vmd/vmd-fail-1.ok
@@ -0,0 +1 @@
+/usr/src/regress/usr.sbin/vmd/vmd-fail-1.conf:8: syntax error
diff --git regress/usr.sbin/vmd/vmd-fail-2.conf
regress/usr.sbin/vmd/vmd-fail-2.conf
new file mode 100644
index 00000000000..69cf1c4e630
--- /dev/null
+++ regress/usr.sbin/vmd/vmd-fail-2.conf
@@ -0,0 +1,5 @@
+# $OpenBSD: $
+# Fail on memory (less than 1MB)
+vm "x" {
+    memory 1048575
+}
diff --git regress/usr.sbin/vmd/vmd-fail-2.ok
regress/usr.sbin/vmd/vmd-fail-2.ok
new file mode 100644
index 00000000000..4abf9f32b09
--- /dev/null
+++ regress/usr.sbin/vmd/vmd-fail-2.ok
@@ -0,0 +1,2 @@
+size must be at least one megabyte
+/usr/src/regress/usr.sbin/vmd/vmd-fail-2.conf:4: failed to parse size:
1048575
diff --git regress/usr.sbin/vmd/vmd-fail-3.conf
regress/usr.sbin/vmd/vmd-fail-3.conf
new file mode 100644
index 00000000000..a8767829159
--- /dev/null
+++ regress/usr.sbin/vmd/vmd-fail-3.conf
@@ -0,0 +1,4 @@
+# $OpenBSD: $
+# Fail on VM name (> 32chars)
+vm "abcdefghijklmnopqrstuvwxyz0123456789" {
+}
diff --git regress/usr.sbin/vmd/vmd-fail-3.ok
regress/usr.sbin/vmd/vmd-fail-3.ok
new file mode 100644
index 00000000000..788b7e53657
--- /dev/null
+++ regress/usr.sbin/vmd/vmd-fail-3.ok
@@ -0,0 +1 @@
+/usr/src/regress/usr.sbin/vmd/vmd-fail-3.conf:3: vm name too long
diff --git regress/usr.sbin/vmd/vmd-fail-4.conf
regress/usr.sbin/vmd/vmd-fail-4.conf
new file mode 100644
index 00000000000..83c59c2e61e
--- /dev/null
+++ regress/usr.sbin/vmd/vmd-fail-4.conf
@@ -0,0 +1,5 @@
+# $OpenBSD: $
+# Fail on nifs (> 4)
+vm "a" {
+    nifs 5
+}
diff --git regress/usr.sbin/vmd/vmd-fail-4.ok
regress/usr.sbin/vmd/vmd-fail-4.ok
new file mode 100644
index 00000000000..c533cba38d0
--- /dev/null
+++ regress/usr.sbin/vmd/vmd-fail-4.ok
@@ -0,0 +1 @@
+/usr/src/regress/usr.sbin/vmd/vmd-fail-4.conf:4: syntax error
diff --git regress/usr.sbin/vmd/vmd-fail-5.conf
regress/usr.sbin/vmd/vmd-fail-5.conf
new file mode 100644
index 00000000000..c53cfd32968
--- /dev/null
+++ regress/usr.sbin/vmd/vmd-fail-5.conf
@@ -0,0 +1,6 @@
+# $OpenBSD: $
+# Fail on boot path (> 128)
+ramdisk="/some/absolutepath/somewhere/abcdefghijklmnopqrstuvwxyz0123456789/abcdefghijklmnopqrstuvwxyz0123456789/abcdefghijklmnopqrstuvwxyz0123456789/bsd.rd"
+vm "x" {
+    kernel $ramdisk
+}
diff --git regress/usr.sbin/vmd/vmd-fail-5.ok
regress/usr.sbin/vmd/vmd-fail-5.ok
new file mode 100644
index 00000000000..f17303c6838
--- /dev/null
+++ regress/usr.sbin/vmd/vmd-fail-5.ok
@@ -0,0 +1 @@
+/usr/src/regress/usr.sbin/vmd/vmd-fail-5.conf:5: syntax error
diff --git regress/usr.sbin/vmd/vmd-fail-6.conf
regress/usr.sbin/vmd/vmd-fail-6.conf
new file mode 100644
index 00000000000..5fc12df895f
--- /dev/null
+++ regress/usr.sbin/vmd/vmd-fail-6.conf
@@ -0,0 +1,6 @@
+# $OpenBSD: $
+# Fail on disk path (> 128)
+rdisk="/some/absolutepath/somewhere/abcdefghijklmnopqrstuvwxyz0123456789/abcdefghijklmnopqrstuvwxyz0123456789/abcdefghijklmnopqrstuvwxyz0123456789/bsd.img"
+vm "x" {
+    disk $rdisk
+}
diff --git regress/usr.sbin/vmd/vmd-fail-6.ok
regress/usr.sbin/vmd/vmd-fail-6.ok
new file mode 100644
index 00000000000..0318af699b3
--- /dev/null
+++ regress/usr.sbin/vmd/vmd-fail-6.ok
@@ -0,0 +1,2 @@
+disk path too long
+/usr/src/regress/usr.sbin/vmd/vmd-fail-6.conf:5: failed to parse disks:
/some/absolutepath/somewhere/abcdefghijklmnopqrstuvwxyz0123456789/abcdefghijklmnopqrstuvwxyz0123456789/abcdefghijklmnopqrstuvwxyz0123456789/bsd.img
diff --git regress/usr.sbin/vmd/vmd-fail-7.conf
regress/usr.sbin/vmd/vmd-fail-7.conf
new file mode 100644
index 00000000000..e0ad8a32cc6
--- /dev/null
+++ regress/usr.sbin/vmd/vmd-fail-7.conf
@@ -0,0 +1,9 @@
+# $OpenBSD: $
+# Fail on num disks (> 4)
+vm "x" {
+    disk "disk0.img"
+    disk "disk1.img"
+    disk "disk2.img"
+    disk "disk3.img"
+    disk "disk4.img"
+}
diff --git regress/usr.sbin/vmd/vmd-fail-7.ok
regress/usr.sbin/vmd/vmd-fail-7.ok
new file mode 100644
index 00000000000..ae00505c6d7
--- /dev/null
+++ regress/usr.sbin/vmd/vmd-fail-7.ok
@@ -0,0 +1,2 @@
+too many disks
+/usr/src/regress/usr.sbin/vmd/vmd-fail-7.conf:8: failed to parse disks:
disk4.img
diff --git regress/usr.sbin/vmd/vmd-pass-1.conf
regress/usr.sbin/vmd/vmd-pass-1.conf
new file mode 100644
index 00000000000..8be389826df
--- /dev/null
+++ regress/usr.sbin/vmd/vmd-pass-1.conf
@@ -0,0 +1,12 @@
+# $OpenBSD: $
+# Pass on boot keyword as it has replaced the kernel keyword.
+ramdisk="/bsd.rd"
+switch "sw" {
+    add vether0
+}
+vm "x" {
+    boot $ramdisk
+    memory 2G
+    disable
+    interface { switch "sw" }
+}
diff --git regress/usr.sbin/vmd/vmd-pass-1.ok
regress/usr.sbin/vmd/vmd-pass-1.ok
new file mode 100644
index 00000000000..403d828b763
--- /dev/null
+++ regress/usr.sbin/vmd/vmd-pass-1.ok
@@ -0,0 +1 @@
+configuration OK
diff --git regress/usr.sbin/vmd/vmd-pass-2.conf
regress/usr.sbin/vmd/vmd-pass-2.conf
new file mode 100644
index 00000000000..f30d8b63468
--- /dev/null
+++ regress/usr.sbin/vmd/vmd-pass-2.conf
@@ -0,0 +1,5 @@
+# $OpenBSD: $
+# Pass on memory (rounding to 1023MB)
+vm "x" {
+    memory 1048575K
+}
diff --git regress/usr.sbin/vmd/vmd-pass-2.ok
regress/usr.sbin/vmd/vmd-pass-2.ok
new file mode 100644
index 00000000000..def650c449e
--- /dev/null
+++ regress/usr.sbin/vmd/vmd-pass-2.ok
@@ -0,0 +1,2 @@
+size rounded to 1023 megabytes
+configuration OK
diff --git regress/usr.sbin/vmd/vmd-pass-3.conf
regress/usr.sbin/vmd/vmd-pass-3.conf
new file mode 100644
index 00000000000..11587779b06
--- /dev/null
+++ regress/usr.sbin/vmd/vmd-pass-3.conf
@@ -0,0 +1,5 @@
+# $OpenBSD: $
+# Pass on memory (exactly 1MB)
+vm "x" {
+    memory 1048576
+}
diff --git regress/usr.sbin/vmd/vmd-pass-3.ok
regress/usr.sbin/vmd/vmd-pass-3.ok
new file mode 100644
index 00000000000..403d828b763
--- /dev/null
+++ regress/usr.sbin/vmd/vmd-pass-3.ok
@@ -0,0 +1 @@
+configuration OK

Reply via email to