activation test: don't crash if AppArmor is built but unavailable
authorSimon McVittie <smcv@debian.org>
Tue, 29 Nov 2016 00:48:14 +0000 (00:48 +0000)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Tue, 29 Nov 2016 12:32:40 +0000 (12:32 +0000)
Also don't try to clean up a process we didn't start.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=98666
Signed-off-by: Simon McVittie <smcv@debian.org>
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
test/sd-activation.c

index 058a247..da63f7d 100644 (file)
@@ -801,9 +801,15 @@ teardown (Fixture *f,
       f->activated = NULL;
     }
 
-  test_kill_pid (f->daemon_pid);
-  g_spawn_close_pid (f->daemon_pid);
-  test_main_context_unref (f->ctx);
+  if (f->daemon_pid != 0)
+    {
+      test_kill_pid (f->daemon_pid);
+      g_spawn_close_pid (f->daemon_pid);
+    }
+
+  if (f->ctx != NULL)
+    test_main_context_unref (f->ctx);
+
   g_free (f->address);
 }