diff options
author | Jacob Erlbeck <jerlbeck@sysmocom.de> | 2013-10-09 11:27:04 +0200 |
---|---|---|
committer | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2013-10-11 14:41:40 +0200 |
commit | 34fc4701c7681a4855534c20a6f59d12c4c81521 (patch) | |
tree | a4911e712727211828200038bd1439b7bb0a5069 /tests/gb | |
parent | 2c9168cf34d370b4ea2b21177402d01a7cfffea8 (diff) |
tests/gb: Show invoked signals in test output
Register an osmo signal handler to print a short notice about every
SS_L_NS signal that is generated while processing the tests.
Sponsored-by: On-Waves ehf
Diffstat (limited to 'tests/gb')
-rw-r--r-- | tests/gb/gprs_ns_test.c | 47 | ||||
-rw-r--r-- | tests/gb/gprs_ns_test.ok | 7 |
2 files changed, 53 insertions, 1 deletions
diff --git a/tests/gb/gprs_ns_test.c b/tests/gb/gprs_ns_test.c index d07cc3de..c4fc228a 100644 --- a/tests/gb/gprs_ns_test.c +++ b/tests/gb/gprs_ns_test.c @@ -20,11 +20,11 @@ #include <osmocom/core/utils.h> #include <osmocom/core/logging.h> #include <osmocom/core/talloc.h> +#include <osmocom/core/signal.h> #include <osmocom/gprs/gprs_msgb.h> #include <osmocom/gprs/gprs_ns.h> #include <osmocom/gprs/gprs_bssgp.h> - /* GPRS Network Service, PDU type: NS_RESET, * Cause: O&M intervention, NS VCI: 0x1122, NSEI 0x1122 */ @@ -121,6 +121,50 @@ ssize_t sendto(int sockfd, const void *buf, size_t len, int flags, return len; } +/* Signal handler for signals from NS layer */ +static int test_signal(unsigned int subsys, unsigned int signal, + void *handler_data, void *signal_data) +{ + struct ns_signal_data *nssd = signal_data; + + if (subsys != SS_L_NS) + return 0; + + switch (signal) { + case S_NS_RESET: + printf("==> got signal NS_RESET, NS-VC 0x%04x/%s\n", + nssd->nsvc->nsvci, + gprs_ns_format_peer(nssd->nsvc)); + break; + + case S_NS_ALIVE_EXP: + printf("==> got signal NS_ALIVE_EXP, NS-VC 0x%04x/%s\n", + nssd->nsvc->nsvci, + gprs_ns_format_peer(nssd->nsvc)); + break; + + case S_NS_BLOCK: + printf("==> got signal NS_BLOCK, NS-VC 0x%04x/%s\n", + nssd->nsvc->nsvci, + gprs_ns_format_peer(nssd->nsvc)); + break; + + case S_NS_UNBLOCK: + printf("==> got signal NS_UNBLOCK, NS-VC 0x%04x/%s\n", + nssd->nsvc->nsvci, + gprs_ns_format_peer(nssd->nsvc)); + break; + + default: + printf("==> got signal %d, NS-VC 0x%04x/%s\n", signal, + nssd->nsvc->nsvci, + gprs_ns_format_peer(nssd->nsvc)); + break; + } + + return 0; +} + static int gprs_process_message(struct gprs_ns_inst *nsi, const char *text, struct sockaddr_in *peer, const unsigned char* data, size_t data_len) { struct msgb *msg; @@ -238,6 +282,7 @@ int main(int argc, char **argv) osmo_init_logging(&info); log_set_use_color(osmo_stderr_target, 0); log_set_print_filename(osmo_stderr_target, 0); + osmo_signal_register_handler(SS_L_NS, &test_signal, NULL); printf("===== NS protocol test START\n"); test_ns(); diff --git a/tests/gb/gprs_ns_test.ok b/tests/gb/gprs_ns_test.ok index 578b9054..01b1bc91 100644 --- a/tests/gb/gprs_ns_test.ok +++ b/tests/gb/gprs_ns_test.ok @@ -2,6 +2,7 @@ PROCESSING RESET from 0x01020304:1111 02 00 81 01 01 82 11 22 04 82 11 22 +==> got signal NS_RESET, NS-VC 0x1122/1.2.3.4:1111 RESPONSE, msg length 9 03 01 82 11 22 04 82 11 22 @@ -24,6 +25,7 @@ result (ALIVE) = 1 PROCESSING UNBLOCK from 0x01020304:1111 06 +==> got signal NS_UNBLOCK, NS-VC 0x1122/1.2.3.4:1111 RESPONSE, msg length 1 07 @@ -42,6 +44,7 @@ result (BSSGP RESET) = 0 PROCESSING RESET from 0x01020304:2222 02 00 81 01 01 82 11 22 04 82 11 22 +==> got signal NS_RESET, NS-VC 0x1122/1.2.3.4:2222 RESPONSE, msg length 9 03 01 82 11 22 04 82 11 22 @@ -58,6 +61,7 @@ Current NS-VCIs: PROCESSING RESET from 0x01020304:3333 02 00 81 01 01 82 33 44 04 82 11 22 +==> got signal NS_RESET, NS-VC 0x3344/1.2.3.4:3333 RESPONSE, msg length 9 03 01 82 33 44 04 82 11 22 @@ -75,6 +79,7 @@ Current NS-VCIs: PROCESSING RESET from 0x01020304:4444 02 00 81 01 01 82 11 22 04 82 33 44 +==> got signal NS_RESET, NS-VC 0x1122/1.2.3.4:4444 RESPONSE, msg length 9 03 01 82 11 22 04 82 33 44 @@ -92,6 +97,7 @@ Current NS-VCIs: PROCESSING RESET from 0x01020304:3333 02 00 81 01 01 82 11 22 04 82 11 22 +==> got signal NS_RESET, NS-VC 0x1122/1.2.3.4:3333 RESPONSE, msg length 9 03 01 82 11 22 04 82 11 22 @@ -109,6 +115,7 @@ Current NS-VCIs: PROCESSING RESET from 0x01020304:4444 02 00 81 01 01 82 11 22 04 82 11 22 +==> got signal NS_RESET, NS-VC 0x1122/1.2.3.4:4444 RESPONSE, msg length 9 03 01 82 11 22 04 82 11 22 |