aboutsummaryrefslogtreecommitdiff
path: root/tests/list
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/list
downloadvmm-c235cb62beefd03087e7cfc7f7f55f0c7c6601c9.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/list')
-rw-r--r--tests/list37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/list b/tests/list
new file mode 100644
index 0000000..e62774d
--- /dev/null
+++ b/tests/list
@@ -0,0 +1,37 @@
+# list, status and logs. Read-only verbs that must stay read-only.
+
+"$VMM" create ls1 64M >/dev/null 2>&1
+
+outputs 'ls1' "list shows a VM" list
+outputs 'stopped' "list shows stopped state" list
+exits 1 "list rejects extra arguments" list bogus
+exits 3 "status of a stopped VM exits 3" status ls1
+exits 2 "logs of an unknown VM exits 2" logs nosuchvm
+exits 1 "logs refuses a zero line count" logs -n 00 ls1
+refuses 'invalid line count' "logs refuses a count too big for tail" \
+ logs -n 9999999999 ls1
+
+# A read only listing must never remove a pidfile.
+echo 99999999 > "$VMMDIR/ls1/pid"
+"$VMM" list >/dev/null 2>&1 || :
+"$VMM" status ls1 >/dev/null 2>&1 || :
+holds "list and status never unlink a pidfile" test -f "$VMMDIR/ls1/pid"
+rm -f "$VMMDIR/ls1/pid"
+
+# A live pid running something other than QEMU is stale, not this VM.
+# Use this test shell itself so there is no helper process to leak.
+echo "$$" > "$VMMDIR/ls1/pid"
+state=$("$VMM" list | awk '$1 == "ls1" { print $2 }')
+if [ "$state" = stopped ]; then
+ ok "a live non-QEMU pid reads as stopped"
+else
+ notok "a live non-QEMU pid reads as stopped" "got [$state]"
+fi
+rm -f "$VMMDIR/ls1/pid"
+
+# A pidfile naming a pid that is gone is the common case after a crash,
+# and reading /proc for it must not make the shell complain. The same
+# race happens on every kill.
+echo 999999 > "$VMMDIR/ls1/pid"
+omits cmdline "a pidfile naming a dead process is cleaned quietly" stop ls1
+holds "and the pidfile is cleaned up" test ! -e "$VMMDIR/ls1/pid"