aboutsummaryrefslogtreecommitdiff
path: root/tests/viewer
diff options
context:
space:
mode:
authorLena <lena@omega>2026-08-01 00:00:00 +0000
committerLena <lena@omega>2026-08-01 00:00:00 +0000
commitc235cb62beefd03087e7cfc7f7f55f0c7c6601c9 (patch)
tree2776f86d9226d55c78e3d735764fcd9ecbe5e08e /tests/viewer
downloadvmm-master.tar.gz
Enter vmmHEADmaster
A QEMU/KVM virtual machine manager in one POSIX shell script. Each VM is a directory of plain files under $VMMDIR, configured by a hand-edited KEY=VALUE file that is parsed rather than sourced, so nothing in it can inject a raw QEMU argument. Control is a QMP FIFO pair inside that directory, guarded by its permissions alone; nothing binds a TCP port. The tests are TAP without a framework and boot real guests where the host allows.
Diffstat (limited to 'tests/viewer')
-rw-r--r--tests/viewer44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/viewer b/tests/viewer
new file mode 100644
index 0000000..f0357f0
--- /dev/null
+++ b/tests/viewer
@@ -0,0 +1,44 @@
+# The URI is the whole of what viewer decides, and VIEWER=echo reports
+# it without a client anywhere. The guests here are emulated.
+
+"$VMM" create vw1 64M >/dev/null 2>&1
+
+exits 2 "viewer of an unknown VM exits 2" viewer nosuchvm
+exits 3 "viewer of a stopped VM exits 3" viewer vw1
+
+cfg vw1 <<EOF
+MEM=256
+CPUS=1
+HWACCEL=no
+EOF
+if "$VMM" start vw1 >/dev/null 2>&1; then
+ refuses 'has no display' "GRAPHICS=no leaves nothing to view" viewer vw1
+ "$VMM" kill vw1 >/dev/null 2>&1 || :
+else
+ skip 1 "vw1 did not start"
+fi
+
+# The URI names the socket that is really there, not what the config
+# says, so a display that failed to appear is an error rather than a
+# client left dialling nothing.
+for g in vnc spice; do
+ cfg vw1 <<EOF
+MEM=256
+CPUS=1
+HWACCEL=no
+GRAPHICS=$g
+EOF
+ if ! "$VMM" start vw1 >/dev/null 2>&1; then
+ skip 2 "this qemu cannot do GRAPHICS=$g"
+ continue
+ fi
+ out=$(env VIEWER=echo "$VMM" viewer vw1 2>&1) && got=0 || got=$?
+ if [ "$got" = 0 ] && [ "$out" = "$g+unix://$VMMDIR/vw1/$g.sock" ]; then
+ ok "$g is handed to the client as $g+unix"
+ else
+ notok "$g is handed to the client as $g+unix" \
+ "exit $got, wanted $g+unix://$VMMDIR/vw1/$g.sock" "got: $out"
+ fi
+ "$VMM" kill vw1 >/dev/null 2>&1 || :
+ exits 3 "and the killed $g guest has nothing to view" viewer vw1
+done