[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 3/3] libqtest: add more exit status checks
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PATCH v4 3/3] libqtest: add more exit status checks |
Date: |
Thu, 24 May 2018 21:25:28 +0300 |
Add more checks on how did QEMU exit.
Legal ways to exit right now:
- exit(0) or return from main
- kill(SIGTERM) - sent by testing infrastructure
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
tests/libqtest.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/tests/libqtest.c b/tests/libqtest.c
index f869854..36ca859 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -109,9 +109,19 @@ static void kill_qemu(QTestState *s)
kill(s->qemu_pid, SIGTERM);
pid = waitpid(s->qemu_pid, &wstatus, 0);
- if (pid == s->qemu_pid && WIFSIGNALED(wstatus)) {
+ /* waitpid returns child PID on success */
+ assert(pid == s->qemu_pid);
+
+ /* If exited on signal - check the reason: core dump is never OK */
+ if (WIFSIGNALED(wstatus)) {
assert(!WCOREDUMP(wstatus));
}
+ /* If exited normally - check exit status */
+ if (WIFEXITED(wstatus)) {
+ assert(!WEXITSTATUS(wstatus));
+ }
+ /* Valid ways to exit: right now only return from main or exit */
+ assert(WIFEXITED(wstatus));
}
}
--
MST