Discussion:
[PATCH 1/2] gprs-ns/test: Re-add return value check for gprs_nsvc_reset
Jacob Erlbeck
2014-10-09 09:07:55 UTC
Permalink
The return value check has been removed in the commit 'Use
gprs_nsvc_reset instead of gprs_ns_tx_reset', because gprs_nsvc_reset
had no return value then. Since a compatible return value has been
added by 'Let gprs_nsvc_reset return a value', the former patch is
partly reverted by this commit.

Sponsored-by: On-Waves ehf
---
tests/gb/gprs_ns_test.c | 9 ++++++++-
tests/gb/gprs_ns_test.ok | 2 ++
2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/tests/gb/gprs_ns_test.c b/tests/gb/gprs_ns_test.c
index 2185ff8..eab71e7 100644
--- a/tests/gb/gprs_ns_test.c
+++ b/tests/gb/gprs_ns_test.c
@@ -592,6 +592,7 @@ static void test_bss_reset_ack()
struct sockaddr_in peer[4] = {{0},};
struct gprs_nsvc *nsvc;
struct sockaddr_in *nse[4];
+ int rc;

peer[0].sin_family = AF_INET;
peer[0].sin_port = htons(1111);
@@ -641,7 +642,13 @@ static void test_bss_reset_ack()
printf("--- Setup VC 2 SGSN -> BSS (hits NSEI 2) ---\n\n");

nsvc = gprs_nsvc_by_nsvci(nsi, 0x2001);
- gprs_nsvc_reset(nsvc, NS_CAUSE_OM_INTERVENTION);
+ rc = gprs_nsvc_reset(nsvc, NS_CAUSE_OM_INTERVENTION);
+ if (rc < 0)
+ printf("Failed to send RESET to %s\n\n", gprs_ns_ll_str(nsvc));
+ else {
+ send_ns_reset_ack(nsi, nse[1], 0x2001, 0x2000);
+ gprs_dump_nsi(nsi);
+ }

printf("--- Setup VC 1 SGSN -> BSS (hits NSEI 1) ---\n\n");

diff --git a/tests/gb/gprs_ns_test.ok b/tests/gb/gprs_ns_test.ok
index 1e0bf7f..d6be1a9 100644
--- a/tests/gb/gprs_ns_test.ok
+++ b/tests/gb/gprs_ns_test.ok
@@ -375,6 +375,8 @@ Current NS-VCIs:

--- Setup VC 2 SGSN -> BSS (hits NSEI 2) ---

+Failed to send RESET to 0.0.0.0:0
+
--- Setup VC 1 SGSN -> BSS (hits NSEI 1) ---

MESSAGE to BSS, msg length 12
--
1.9.1
Jacob Erlbeck
2014-10-09 09:07:56 UTC
Permalink
This patch extends test_sgsn_reset_invalid_state by assertions to check
that nscv->state and nsvc->remote_state have been set as expected.

Sponsored-by: On-Waves ehf
---
tests/gb/gprs_ns_test.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/tests/gb/gprs_ns_test.c b/tests/gb/gprs_ns_test.c
index eab71e7..9c3a3ac 100644
--- a/tests/gb/gprs_ns_test.c
+++ b/tests/gb/gprs_ns_test.c
@@ -847,11 +847,18 @@ static void test_sgsn_reset_invalid_state()
sent_pdu_type = -1;
send_ns_alive(nsi, &sgsn_peer);
OSMO_ASSERT(sent_pdu_type == -1);
+
send_ns_reset_ack(nsi, &sgsn_peer, SGSN_NSEI+1, SGSN_NSEI);
OSMO_ASSERT(sent_pdu_type == NS_PDUT_ALIVE);
+
send_ns_alive_ack(nsi, &sgsn_peer);
+ OSMO_ASSERT(nsvc->state == (NSE_S_ALIVE | NSE_S_BLOCKED));
+ OSMO_ASSERT(nsvc->remote_state == (NSE_S_ALIVE | NSE_S_BLOCKED));
OSMO_ASSERT(sent_pdu_type == NS_PDUT_UNBLOCK);
+
send_ns_unblock_ack(nsi, &sgsn_peer);
+ OSMO_ASSERT(nsvc->state == NSE_S_ALIVE);
+ OSMO_ASSERT(nsvc->remote_state == NSE_S_ALIVE);

send_ns_unitdata(nsi, &sgsn_peer, 0x1234, dummy_sdu, sizeof(dummy_sdu));
--
1.9.1
Loading...