mirror of
https://gitlab.freedesktop.org/libfprint/fprintd.git
synced 2026-02-04 18:50:33 +01:00
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.
This commit is contained in:
parent
09b1f1f1db
commit
0994cc314e
2 changed files with 11 additions and 1 deletions
10
src/main.c
10
src/main.c
|
|
@ -27,6 +27,7 @@
|
|||
#include <glib/gi18n.h>
|
||||
#include <fprint.h>
|
||||
#include <glib-object.h>
|
||||
#include <glib-unix.h>
|
||||
#include <gmodule.h>
|
||||
|
||||
#include "fprintd.h"
|
||||
|
|
@ -129,6 +130,14 @@ static const GOptionEntry entries[] = {
|
|||
{ NULL }
|
||||
};
|
||||
|
||||
static gboolean sigterm_callback(gpointer data)
|
||||
{
|
||||
GMainLoop *loop = data;
|
||||
|
||||
g_main_loop_quit (loop);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GOptionContext *context;
|
||||
|
|
@ -178,6 +187,7 @@ int main(int argc, char **argv)
|
|||
store.init ();
|
||||
|
||||
loop = g_main_loop_new(NULL, FALSE);
|
||||
g_unix_signal_add (SIGTERM, sigterm_callback, loop);
|
||||
|
||||
g_debug("Launching FprintObject");
|
||||
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@ class FPrintdTest(dbusmock.DBusTestCase):
|
|||
self.daemon.terminate()
|
||||
except OSError:
|
||||
pass
|
||||
self.daemon.wait()
|
||||
self.daemon.wait(timeout=2)
|
||||
|
||||
self.daemon = None
|
||||
self.client = None
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue