Commit 0994cc31 authored by Marco Trevisan's avatar Marco Trevisan
Browse files

main: Ensure that a gcov flush happens on SIGTERM

When coverage is enabled fprintd test won't generate any .gcda file and so
apparently no data, this happens because gcov doesn't handle properly the
process termination when SIGTERM is used, and so when in fprintd.py we
terminate the process no coverage data is reported.

To avoid this, quit the main loop cleanly on SIGTERM, so that we will exit
from the main function cleanly, making libc to perform a gcov flush when we
exit the program.
parent 09b1f1f1
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <glib/gi18n.h> #include <glib/gi18n.h>
#include <fprint.h> #include <fprint.h>
#include <glib-object.h> #include <glib-object.h>
#include <glib-unix.h>
#include <gmodule.h> #include <gmodule.h>
#include "fprintd.h" #include "fprintd.h"
...@@ -129,6 +130,14 @@ static const GOptionEntry entries[] = { ...@@ -129,6 +130,14 @@ static const GOptionEntry entries[] = {
{ NULL } { NULL }
}; };
static gboolean sigterm_callback(gpointer data)
{
GMainLoop *loop = data;
g_main_loop_quit (loop);
return FALSE;
}
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
GOptionContext *context; GOptionContext *context;
...@@ -178,6 +187,7 @@ int main(int argc, char **argv) ...@@ -178,6 +187,7 @@ int main(int argc, char **argv)
store.init (); store.init ();
loop = g_main_loop_new(NULL, FALSE); loop = g_main_loop_new(NULL, FALSE);
g_unix_signal_add (SIGTERM, sigterm_callback, loop);
g_debug("Launching FprintObject"); g_debug("Launching FprintObject");
......
...@@ -233,7 +233,7 @@ class FPrintdTest(dbusmock.DBusTestCase): ...@@ -233,7 +233,7 @@ class FPrintdTest(dbusmock.DBusTestCase):
self.daemon.terminate() self.daemon.terminate()
except OSError: except OSError:
pass pass
self.daemon.wait() self.daemon.wait(timeout=2)
self.daemon = None self.daemon = None
self.client = None self.client = None
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment