diff options
author | Pablo Neira Ayuso <pablo@gnumonks.org> | 2012-08-23 23:26:19 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2012-08-30 21:50:32 +0200 |
commit | 1fd93bbc6edbf1c297d71739242e8f35aa499787 (patch) | |
tree | 1b8dba2e07b15132b97f61a40220963aa0395f86 /tests/e1inp_ipa_bsc_test.c | |
parent | 7723b4e9a3fd51cec28fb48423472479cd41d95e (diff) |
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.
Diffstat (limited to 'tests/e1inp_ipa_bsc_test.c')
-rw-r--r-- | tests/e1inp_ipa_bsc_test.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/tests/e1inp_ipa_bsc_test.c b/tests/e1inp_ipa_bsc_test.c index a0e5653..b447893 100644 --- a/tests/e1inp_ipa_bsc_test.c +++ b/tests/e1inp_ipa_bsc_test.c @@ -1,4 +1,5 @@ #include <stdio.h> +#include <signal.h> #include <osmocom/core/talloc.h> #include <osmocom/abis/abis.h> #include <osmocom/abis/e1_input.h> @@ -199,10 +200,16 @@ const struct log_info bsc_test_log_info = { .num_cat = ARRAY_SIZE(bsc_test_cat), }; -int main(void) +static struct e1inp_line *line; + +static void sighandler(int foo) { - struct e1inp_line *line; + e1inp_line_put(line); + exit(EXIT_SUCCESS); +} +int main(void) +{ tall_test = talloc_named_const(NULL, 1, "e1inp_test"); libosmo_abis_init(tall_test); @@ -220,6 +227,12 @@ int main(void) .sign_link = sign_link, }; + if (signal(SIGINT, sighandler) == SIG_ERR || + signal(SIGTERM, sighandler) == SIG_ERR) { + perror("Cannot set sighandler"); + exit(EXIT_FAILURE); + } + #define LINENR 0 line = e1inp_line_create(LINENR, "ipa"); |