tests: e1inp_ipa_*_test: add signal handling for process termination

This patch adds signal handling to release memory in the exit
path of the tests. This is good to check what memory we are
leaking in the exist path of the tests.
diff --git a/tests/e1inp_ipa_bts_test.c b/tests/e1inp_ipa_bts_test.c
index 1b9a2db..f885c5c 100644
--- a/tests/e1inp_ipa_bts_test.c
+++ b/tests/e1inp_ipa_bts_test.c
@@ -1,4 +1,5 @@
 #include <stdio.h>
+#include <signal.h>
 #include <osmocom/core/talloc.h>
 #include <string.h>
 #include <unistd.h>
@@ -236,6 +237,14 @@
 	return 0;
 }
 
+static struct e1inp_line *line;
+
+static void sighandler(int foo)
+{
+	e1inp_line_put(line);
+	exit(EXIT_SUCCESS);
+}
+
 int main(void)
 {
 	struct ipaccess_unit bts_dev_info = {
@@ -250,7 +259,6 @@
 		.location2	= "testBTS",
 		.serno		= "",
 	};
-	struct e1inp_line *line;
 
 	tall_test = talloc_named_const(NULL, 1, "e1inp_test");
 	libosmo_abis_init(tall_test);
@@ -272,6 +280,12 @@
 
 #define LINENR 0
 
+	if (signal(SIGINT, sighandler) == SIG_ERR ||
+	    signal(SIGTERM, sighandler) == SIG_ERR) {
+		perror("Cannot set sighandler");
+		exit(EXIT_FAILURE);
+	}
+
 	line = e1inp_line_create(LINENR, "ipa");
 	if (line == NULL) {
 		LOGP(DBTSTEST, LOGL_ERROR, "problem enabling E1 line\n");