tests: Make test-fail-on-null-core-interface an automated test

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@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
This commit is contained in:
Frediano Ziglio 2017-09-03 08:26:47 +01:00
parent 544f5d7ed3
commit 0905a95d3a
2 changed files with 21 additions and 6 deletions

View File

@ -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 \

View File

@ -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);
return 0;
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 g_test_run();
}