Re: [PATCH] add initial set of regress tests for vmd

2017-08-28 Thread Carlos Cardenas
On Sun, Aug 27, 2017 at 11:44 PM, Mike Larkin  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 000..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 
diff --git regress/usr.sbin/vmd/vmd-fail-1.conf
regress/usr.sbin/vmd/vmd-fail-1.conf
new file mode 100644
index 000..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 000..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 000..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 000..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 000..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 000..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 000..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 000..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 000..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 000..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 

Re: [PATCH] add initial set of regress tests for vmd

2017-08-28 Thread Mike Larkin
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?

> +--+
> Carlos
> 
> diff --git regress/usr.sbin/vmd/Makefile regress/usr.sbin/vmd/Makefile
> new file mode 100644
> index 000..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 
> diff --git regress/usr.sbin/vmd/vmd-fail-1.conf
> regress/usr.sbin/vmd/vmd-fail-1.conf
> new file mode 100644
> index 000..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 000..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 000..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 000..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 000..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 000..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 000..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 000..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 000..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 

Re: [PATCH] add initial set of regress tests for vmd

2017-08-27 Thread Mike Larkin
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?
> 

Thanks, I'll give this a test.

-ml

> +--+
> Carlos
> 
> diff --git regress/usr.sbin/vmd/Makefile regress/usr.sbin/vmd/Makefile
> new file mode 100644
> index 000..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 
> diff --git regress/usr.sbin/vmd/vmd-fail-1.conf
> regress/usr.sbin/vmd/vmd-fail-1.conf
> new file mode 100644
> index 000..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 000..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 000..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 000..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 000..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 000..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 000..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 000..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 000..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 000..f17303c6838
> --- /dev/null
> +++