[Spice-devel] [PATCH spice-server 12/16] tests: Make test-fail-on-null-core-interface an automated test
Frediano Ziglio
fziglio at redhat.com
Mon Sep 4 10:57:20 UTC 2017
Update to Glib style to catch warning.
Initialize properly the structure (invalid) provided.
Check results of spice_server_init.
Remove leaks.
Enable as check.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
server/tests/Makefile.am | 3 ++-
server/tests/test-fail-on-null-core-interface.c | 22 ++++++++++++++++++----
2 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/server/tests/Makefile.am b/server/tests/Makefile.am
index b64add5f..c35038a8 100644
--- a/server/tests/Makefile.am
+++ b/server/tests/Makefile.am
@@ -55,13 +55,13 @@ check_PROGRAMS = \
test-stat-file \
test-leaks \
test-vdagent \
+ test-fail-on-null-core-interface \
$(NULL)
noinst_PROGRAMS = \
test-display-no-ssl \
test-display-streaming \
test-empty-success \
- test-fail-on-null-core-interface \
test-just-sockets-no-ssl \
test-playback \
test-display-resolution-changes \
@@ -137,6 +137,7 @@ test_vdagent_CPPFLAGS = \
$(NULL)
test_codecs_parsing_CPPFLAGS = $(test_vdagent_CPPFLAGS)
test_qxl_parsing_CPPFLAGS = $(test_vdagent_CPPFLAGS)
+test_fail_on_null_core_interface_CPPFLAGS = $(test_vdagent_CPPFLAGS)
if HAVE_GSTREAMER
test_gst_SOURCES = test-gst.c \
diff --git a/server/tests/test-fail-on-null-core-interface.c b/server/tests/test-fail-on-null-core-interface.c
index 48e92db0..ca96ea01 100644
--- a/server/tests/test-fail-on-null-core-interface.c
+++ b/server/tests/test-fail-on-null-core-interface.c
@@ -18,13 +18,27 @@
#include <config.h>
#include <spice.h>
-int main(void)
+#include "test-glib-compat.h"
+
+static SpiceCoreInterface core;
+
+static void empty_core(void)
{
SpiceServer *server = spice_server_new();
- SpiceCoreInterface core;
- spice_server_init(server, &core);
+ g_test_expect_message(G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
+ "*bad core interface*");
+ int result = spice_server_init(server, &core);
+ g_assert_cmpint(result, ==, -1);
spice_server_set_port(server, 5911);
+ spice_server_destroy(server);
+}
+
+int main(int argc, char *argv[])
+{
+ g_test_init(&argc, &argv, NULL);
+
+ g_test_add_func("/server/empty core", empty_core);
- return 0;
+ return g_test_run();
}
--
2.13.5
More information about the Spice-devel
mailing list