summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2017-10-11 12:01:21 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2017-10-11 12:01:21 +0000
commit48d3ffbf1f7bac4f7e19cde2febdafb917d1cfa2 (patch)
treee663699323cefd3475d92dd18cc8910a2e1ceb1b
parenta1f9ffd9dd4c6f07e66efc240f0147701f6387df (diff)
Add regression tests for vmd(8) config parsing.
from Carlos Cardenas; OK mlarkin@
-rw-r--r--regress/usr.sbin/vmd/Makefile5
-rw-r--r--regress/usr.sbin/vmd/config/Makefile32
-rw-r--r--regress/usr.sbin/vmd/config/vmd-fail-boot-name-too-long.conf6
-rw-r--r--regress/usr.sbin/vmd/config/vmd-fail-boot-name-too-long.ok1
-rw-r--r--regress/usr.sbin/vmd/config/vmd-fail-disk-path-too-long.conf6
-rw-r--r--regress/usr.sbin/vmd/config/vmd-fail-disk-path-too-long.ok2
-rw-r--r--regress/usr.sbin/vmd/config/vmd-fail-kernel-keyword.conf12
-rw-r--r--regress/usr.sbin/vmd/config/vmd-fail-kernel-keyword.ok1
-rw-r--r--regress/usr.sbin/vmd/config/vmd-fail-too-few-ram.conf5
-rw-r--r--regress/usr.sbin/vmd/config/vmd-fail-too-few-ram.ok2
-rw-r--r--regress/usr.sbin/vmd/config/vmd-fail-too-many-disks.conf9
-rw-r--r--regress/usr.sbin/vmd/config/vmd-fail-too-many-disks.ok2
-rw-r--r--regress/usr.sbin/vmd/config/vmd-fail-too-many-ifs.conf5
-rw-r--r--regress/usr.sbin/vmd/config/vmd-fail-too-many-ifs.ok1
-rw-r--r--regress/usr.sbin/vmd/config/vmd-fail-vm-name-too-long.conf4
-rw-r--r--regress/usr.sbin/vmd/config/vmd-fail-vm-name-too-long.ok1
-rw-r--r--regress/usr.sbin/vmd/config/vmd-pass-boot-keyword.conf12
-rw-r--r--regress/usr.sbin/vmd/config/vmd-pass-boot-keyword.ok1
-rw-r--r--regress/usr.sbin/vmd/config/vmd-pass-memory-just-enough.conf5
-rw-r--r--regress/usr.sbin/vmd/config/vmd-pass-memory-just-enough.ok1
-rw-r--r--regress/usr.sbin/vmd/config/vmd-pass-memory-round.conf5
-rw-r--r--regress/usr.sbin/vmd/config/vmd-pass-memory-round.ok2
22 files changed, 120 insertions, 0 deletions
diff --git a/regress/usr.sbin/vmd/Makefile b/regress/usr.sbin/vmd/Makefile
new file mode 100644
index 00000000000..fbd04d7e483
--- /dev/null
+++ b/regress/usr.sbin/vmd/Makefile
@@ -0,0 +1,5 @@
+# $OpenBSD: Makefile,v 1.1.1.1 2017/10/11 12:01:20 bluhm Exp $
+
+SUBDIR += config
+
+.include <bsd.subdir.mk>
diff --git a/regress/usr.sbin/vmd/config/Makefile b/regress/usr.sbin/vmd/config/Makefile
new file mode 100644
index 00000000000..16a43066415
--- /dev/null
+++ b/regress/usr.sbin/vmd/config/Makefile
@@ -0,0 +1,32 @@
+# $OpenBSD: Makefile,v 1.1.1.1 2017/10/11 12:01:20 bluhm Exp $
+
+VMD ?= /usr/sbin/vmd
+
+VMD_PASS=boot-keyword memory-round memory-just-enough
+VMD_FAIL=kernel-keyword too-few-ram vm-name-too-long too-many-ifs \
+ boot-name-too-long disk-path-too-long too-many-disks
+
+REGRESS_TARGETS=
+
+.for n in ${VMD_PASS}
+REGRESS_TARGETS += vmd-pass-${n}
+
+vmd-pass-${n}:
+ @echo '======== $@ ========'
+ ${VMD} -n -f ${.CURDIR}/vmd-pass-${n}.conf 2>&1 | \
+ diff -u ${.CURDIR}/vmd-pass-${n}.ok /dev/stdin
+.endfor
+
+.for n in ${VMD_FAIL}
+REGRESS_TARGETS += vmd-fail-${n}
+
+vmd-fail-${n}:
+ @echo '======== $@ ========'
+ ${VMD} -n -f ${.CURDIR}/vmd-fail-${n}.conf 2>&1 | \
+ cut -d : -f 2,3,4 | \
+ diff -u ${.CURDIR}/vmd-fail-${n}.ok /dev/stdin
+.endfor
+
+.PHONY: ${REGRESS_TARGETS}
+
+.include <bsd.regress.mk>
diff --git a/regress/usr.sbin/vmd/config/vmd-fail-boot-name-too-long.conf b/regress/usr.sbin/vmd/config/vmd-fail-boot-name-too-long.conf
new file mode 100644
index 00000000000..fffbb360882
--- /dev/null
+++ b/regress/usr.sbin/vmd/config/vmd-fail-boot-name-too-long.conf
@@ -0,0 +1,6 @@
+# $OpenBSD: vmd-fail-boot-name-too-long.conf,v 1.1.1.1 2017/10/11 12:01:20 bluhm Exp $
+# Fail on boot path (> 128)
+ramdisk="/some/absolutepath/somewhere/abcdefghijklmnopqrstuvwxyz0123456789/abcdefghijklmnopqrstuvwxyz0123456789/abcdefghijklmnopqrstuvwxyz0123456789/bsd.rd"
+vm "x" {
+ boot $ramdisk
+}
diff --git a/regress/usr.sbin/vmd/config/vmd-fail-boot-name-too-long.ok b/regress/usr.sbin/vmd/config/vmd-fail-boot-name-too-long.ok
new file mode 100644
index 00000000000..56cb73b98cf
--- /dev/null
+++ b/regress/usr.sbin/vmd/config/vmd-fail-boot-name-too-long.ok
@@ -0,0 +1 @@
+5: kernel name too long
diff --git a/regress/usr.sbin/vmd/config/vmd-fail-disk-path-too-long.conf b/regress/usr.sbin/vmd/config/vmd-fail-disk-path-too-long.conf
new file mode 100644
index 00000000000..402058f55e6
--- /dev/null
+++ b/regress/usr.sbin/vmd/config/vmd-fail-disk-path-too-long.conf
@@ -0,0 +1,6 @@
+# $OpenBSD: vmd-fail-disk-path-too-long.conf,v 1.1.1.1 2017/10/11 12:01:20 bluhm Exp $
+# Fail on disk path (> 128)
+rdisk="/some/absolutepath/somewhere/abcdefghijklmnopqrstuvwxyz0123456789/abcdefghijklmnopqrstuvwxyz0123456789/abcdefghijklmnopqrstuvwxyz0123456789/bsd.img"
+vm "x" {
+ disk $rdisk
+}
diff --git a/regress/usr.sbin/vmd/config/vmd-fail-disk-path-too-long.ok b/regress/usr.sbin/vmd/config/vmd-fail-disk-path-too-long.ok
new file mode 100644
index 00000000000..a384c812362
--- /dev/null
+++ b/regress/usr.sbin/vmd/config/vmd-fail-disk-path-too-long.ok
@@ -0,0 +1,2 @@
+disk path too long
+5: failed to parse disks: /some/absolutepath/somewhere/abcdefghijklmnopqrstuvwxyz0123456789/abcdefghijklmnopqrstuvwxyz0123456789/abcdefghijklmnopqrstuvwxyz0123456789/bsd.img
diff --git a/regress/usr.sbin/vmd/config/vmd-fail-kernel-keyword.conf b/regress/usr.sbin/vmd/config/vmd-fail-kernel-keyword.conf
new file mode 100644
index 00000000000..427e5b2a015
--- /dev/null
+++ b/regress/usr.sbin/vmd/config/vmd-fail-kernel-keyword.conf
@@ -0,0 +1,12 @@
+# $OpenBSD: vmd-fail-kernel-keyword.conf,v 1.1.1.1 2017/10/11 12:01:20 bluhm Exp $
+# Fail on kernel keyword; has been replaced by boot.
+ramdisk="/bsd.rd"
+switch "sw" {
+ add vether0
+}
+vm "x" {
+ kernel $ramdisk
+ memory 1G
+ disable
+ interface { switch "sw" }
+}
diff --git a/regress/usr.sbin/vmd/config/vmd-fail-kernel-keyword.ok b/regress/usr.sbin/vmd/config/vmd-fail-kernel-keyword.ok
new file mode 100644
index 00000000000..348817b1477
--- /dev/null
+++ b/regress/usr.sbin/vmd/config/vmd-fail-kernel-keyword.ok
@@ -0,0 +1 @@
+8: syntax error
diff --git a/regress/usr.sbin/vmd/config/vmd-fail-too-few-ram.conf b/regress/usr.sbin/vmd/config/vmd-fail-too-few-ram.conf
new file mode 100644
index 00000000000..98fb18d9ba0
--- /dev/null
+++ b/regress/usr.sbin/vmd/config/vmd-fail-too-few-ram.conf
@@ -0,0 +1,5 @@
+# $OpenBSD: vmd-fail-too-few-ram.conf,v 1.1.1.1 2017/10/11 12:01:20 bluhm Exp $
+# Fail on memory (less than 1MB)
+vm "x" {
+ memory 1048575
+}
diff --git a/regress/usr.sbin/vmd/config/vmd-fail-too-few-ram.ok b/regress/usr.sbin/vmd/config/vmd-fail-too-few-ram.ok
new file mode 100644
index 00000000000..0cf48a97eaf
--- /dev/null
+++ b/regress/usr.sbin/vmd/config/vmd-fail-too-few-ram.ok
@@ -0,0 +1,2 @@
+size must be at least one megabyte
+4: failed to parse size: 1048575
diff --git a/regress/usr.sbin/vmd/config/vmd-fail-too-many-disks.conf b/regress/usr.sbin/vmd/config/vmd-fail-too-many-disks.conf
new file mode 100644
index 00000000000..913b33f367f
--- /dev/null
+++ b/regress/usr.sbin/vmd/config/vmd-fail-too-many-disks.conf
@@ -0,0 +1,9 @@
+# $OpenBSD: vmd-fail-too-many-disks.conf,v 1.1.1.1 2017/10/11 12:01:20 bluhm Exp $
+# Fail on num disks (> 4)
+vm "x" {
+ disk "disk0.img"
+ disk "disk1.img"
+ disk "disk2.img"
+ disk "disk3.img"
+ disk "disk4.img"
+}
diff --git a/regress/usr.sbin/vmd/config/vmd-fail-too-many-disks.ok b/regress/usr.sbin/vmd/config/vmd-fail-too-many-disks.ok
new file mode 100644
index 00000000000..64794fbf074
--- /dev/null
+++ b/regress/usr.sbin/vmd/config/vmd-fail-too-many-disks.ok
@@ -0,0 +1,2 @@
+too many disks
+8: failed to parse disks: disk4.img
diff --git a/regress/usr.sbin/vmd/config/vmd-fail-too-many-ifs.conf b/regress/usr.sbin/vmd/config/vmd-fail-too-many-ifs.conf
new file mode 100644
index 00000000000..6d07460b9a1
--- /dev/null
+++ b/regress/usr.sbin/vmd/config/vmd-fail-too-many-ifs.conf
@@ -0,0 +1,5 @@
+# $OpenBSD: vmd-fail-too-many-ifs.conf,v 1.1.1.1 2017/10/11 12:01:20 bluhm Exp $
+# Fail on nifs (> 4)
+vm "a" {
+ nifs 5
+}
diff --git a/regress/usr.sbin/vmd/config/vmd-fail-too-many-ifs.ok b/regress/usr.sbin/vmd/config/vmd-fail-too-many-ifs.ok
new file mode 100644
index 00000000000..219cba51f0b
--- /dev/null
+++ b/regress/usr.sbin/vmd/config/vmd-fail-too-many-ifs.ok
@@ -0,0 +1 @@
+4: syntax error
diff --git a/regress/usr.sbin/vmd/config/vmd-fail-vm-name-too-long.conf b/regress/usr.sbin/vmd/config/vmd-fail-vm-name-too-long.conf
new file mode 100644
index 00000000000..348d7977a0b
--- /dev/null
+++ b/regress/usr.sbin/vmd/config/vmd-fail-vm-name-too-long.conf
@@ -0,0 +1,4 @@
+# $OpenBSD: vmd-fail-vm-name-too-long.conf,v 1.1.1.1 2017/10/11 12:01:20 bluhm Exp $
+# Fail on VM name (> 32chars)
+vm "abcdefghijklmnopqrstuvwxyz0123456789" {
+}
diff --git a/regress/usr.sbin/vmd/config/vmd-fail-vm-name-too-long.ok b/regress/usr.sbin/vmd/config/vmd-fail-vm-name-too-long.ok
new file mode 100644
index 00000000000..1b99d3d7810
--- /dev/null
+++ b/regress/usr.sbin/vmd/config/vmd-fail-vm-name-too-long.ok
@@ -0,0 +1 @@
+3: vm name too long
diff --git a/regress/usr.sbin/vmd/config/vmd-pass-boot-keyword.conf b/regress/usr.sbin/vmd/config/vmd-pass-boot-keyword.conf
new file mode 100644
index 00000000000..84124319e1e
--- /dev/null
+++ b/regress/usr.sbin/vmd/config/vmd-pass-boot-keyword.conf
@@ -0,0 +1,12 @@
+# $OpenBSD: vmd-pass-boot-keyword.conf,v 1.1.1.1 2017/10/11 12:01:20 bluhm Exp $
+# Pass on boot keyword as it has replaced the kernel keyword.
+ramdisk="/bsd.rd"
+switch "sw" {
+ add vether0
+}
+vm "x" {
+ boot $ramdisk
+ memory 1G
+ disable
+ interface { switch "sw" }
+}
diff --git a/regress/usr.sbin/vmd/config/vmd-pass-boot-keyword.ok b/regress/usr.sbin/vmd/config/vmd-pass-boot-keyword.ok
new file mode 100644
index 00000000000..403d828b763
--- /dev/null
+++ b/regress/usr.sbin/vmd/config/vmd-pass-boot-keyword.ok
@@ -0,0 +1 @@
+configuration OK
diff --git a/regress/usr.sbin/vmd/config/vmd-pass-memory-just-enough.conf b/regress/usr.sbin/vmd/config/vmd-pass-memory-just-enough.conf
new file mode 100644
index 00000000000..2d8ef79381e
--- /dev/null
+++ b/regress/usr.sbin/vmd/config/vmd-pass-memory-just-enough.conf
@@ -0,0 +1,5 @@
+# $OpenBSD: vmd-pass-memory-just-enough.conf,v 1.1.1.1 2017/10/11 12:01:20 bluhm Exp $
+# Pass on memory (exactly 1MB)
+vm "x" {
+ memory 1048576
+}
diff --git a/regress/usr.sbin/vmd/config/vmd-pass-memory-just-enough.ok b/regress/usr.sbin/vmd/config/vmd-pass-memory-just-enough.ok
new file mode 100644
index 00000000000..403d828b763
--- /dev/null
+++ b/regress/usr.sbin/vmd/config/vmd-pass-memory-just-enough.ok
@@ -0,0 +1 @@
+configuration OK
diff --git a/regress/usr.sbin/vmd/config/vmd-pass-memory-round.conf b/regress/usr.sbin/vmd/config/vmd-pass-memory-round.conf
new file mode 100644
index 00000000000..49aa74d2ca1
--- /dev/null
+++ b/regress/usr.sbin/vmd/config/vmd-pass-memory-round.conf
@@ -0,0 +1,5 @@
+# $OpenBSD: vmd-pass-memory-round.conf,v 1.1.1.1 2017/10/11 12:01:20 bluhm Exp $
+# Pass on memory (rounding to 1023MB)
+vm "x" {
+ memory 1048575K
+}
diff --git a/regress/usr.sbin/vmd/config/vmd-pass-memory-round.ok b/regress/usr.sbin/vmd/config/vmd-pass-memory-round.ok
new file mode 100644
index 00000000000..def650c449e
--- /dev/null
+++ b/regress/usr.sbin/vmd/config/vmd-pass-memory-round.ok
@@ -0,0 +1,2 @@
+size rounded to 1023 megabytes
+configuration OK