aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2017-04-29 23:07:55 +0000
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2017-04-29 23:07:55 +0000
commit385e783648e0a477f0957d45791dbb60df67468d (patch)
tree17698e79482339b37aad4e0a0f03fee5e17207b0
parent9c4e4c081521f2c8b7ccc028938fc9a4664df560 (diff)
downloadremote-logon-service-385e783648e0a477f0957d45791dbb60df67468d.tar.gz
remote-logon-service-385e783648e0a477f0957d45791dbb60df67468d.tar.bz2
remote-logon-service-385e783648e0a477f0957d45791dbb60df67468d.zip
Avoid crash during test runs. Don't initialize new NMClient instance during unit tests.
-rw-r--r--src/uccs-server.c24
-rw-r--r--tests/Makefile.am1
2 files changed, 15 insertions, 10 deletions
diff --git a/src/uccs-server.c b/src/uccs-server.c
index c83db35..b045673 100644
--- a/src/uccs-server.c
+++ b/src/uccs-server.c
@@ -112,19 +112,23 @@ uccs_server_init (UccsServer *self)
/* Start as unavailable */
self->parent.state = SERVER_STATE_UNAVAILABLE;
- if (global_client == NULL) {
- global_client = nm_client_new();
+ if (g_strcmp0(g_getenv("DBUS_TEST_RUNNER"), "1")) {
- if (global_client != NULL) {
- g_object_add_weak_pointer(G_OBJECT(global_client), (gpointer *)&global_client);
- self->nm_client = global_client;
+ if (global_client == NULL) {
+ global_client = nm_client_new();
+
+ if (global_client != NULL) {
+ g_object_add_weak_pointer(G_OBJECT(global_client), (gpointer *)&global_client);
+ self->nm_client = global_client;
+ }
+ } else {
+ self->nm_client = g_object_ref(global_client);
+ }
+
+ if (self->nm_client != NULL) {
+ self->nm_signal = g_signal_connect(self->nm_client, "notify::" NM_CLIENT_STATE, G_CALLBACK(nm_state_changed), self);
}
- } else {
- self->nm_client = g_object_ref(global_client);
- }
- if (self->nm_client != NULL) {
- self->nm_signal = g_signal_connect(self->nm_client, "notify::" NM_CLIENT_STATE, G_CALLBACK(nm_state_changed), self);
}
self->verify_server = TRUE;
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9a34654..7927598 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -15,6 +15,7 @@ TESTS = \
SERVER_XML_REPORT = server-test.xml
server-tester: server-test Makefile.am
@echo "#!/bin/bash" > $@
+ @echo export DBUS_TEST_RUNNER=1 >> $@
@echo gtester --verbose -k -o $(SERVER_XML_REPORT) $(abs_builddir)/server-test >> $@
@chmod +x $@