diff options
author | Thomas Huth <thuth@redhat.com> | 2017-05-22 17:40:54 +0200 |
---|---|---|
committer | Michael Tokarev <mjt@tls.msk.ru> | 2017-06-04 18:42:55 +0300 |
commit | 7c933ad61b8f3f5133757c8cbaedd712e5be6f78 (patch) | |
tree | e2424db0e9d0daa847372ceb98a448795110c9da /tests/libqtest.c | |
parent | 7a0bbd55e5a1844996896fea5c006e3263c345e2 (diff) |
tests/libqtest: Print error instead of aborting when env variable is missing
When you currently try to run a test directly from the command line
without setting the QTEST_QEMU_BINARY environment variable first,
you are presented with an unhelpful assertion message like this:
ERROR:tests/libqtest.c:163:qtest_init_without_qmp_handshake:
assertion failed: (qemu_binary != NULL)
Aborted (core dumped)
Let's replace the assert() with a more user friendly error message
instead.
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Diffstat (limited to 'tests/libqtest.c')
-rw-r--r-- | tests/libqtest.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/tests/libqtest.c b/tests/libqtest.c index 84ecbd2bd8..4a5492a603 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -160,7 +160,10 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args) const char *qemu_binary; qemu_binary = getenv("QTEST_QEMU_BINARY"); - g_assert(qemu_binary != NULL); + if (!qemu_binary) { + fprintf(stderr, "Environment variable QTEST_QEMU_BINARY required\n"); + exit(1); + } s = g_malloc(sizeof(*s)); |