# 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"