[PATCH] libosmocore[master]: GSUP: don't fail test on first error

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Max gerrit-no-reply at lists.osmocom.org
Mon Jan 22 14:25:53 UTC 2018


Review at  https://gerrit.osmocom.org/5983

GSUP: don't fail test on first error

Instead of forcing test failure via assert on first error encountered,
let it run until completion and print detailed error log. This
simplifies troubleshooting by letting user to see more errors from
single run and more details on each of the errors. Update test output
with explicit test results.

Change-Id: I016a28fe04f7b194e22c15e936095004c5f079d1
---
M tests/gsup/gsup_test.c
M tests/gsup/gsup_test.ok
2 files changed, 30 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/83/5983/1

diff --git a/tests/gsup/gsup_test.c b/tests/gsup/gsup_test.c
index 3b360ac..eddcc92 100644
--- a/tests/gsup/gsup_test.c
+++ b/tests/gsup/gsup_test.c
@@ -212,21 +212,33 @@
 		const struct test *t = &test_messages[test_idx];
 		struct osmo_gsup_message gm = {0};
 		struct msgb *msg = msgb_alloc(4096, "gsup_test");
+		bool passed = true;
 
 		printf("  Testing %s\n", t->name);
 
 		rc = osmo_gsup_decode(t->data, t->data_len, &gm);
-		OSMO_ASSERT(rc >= 0);
+		if (rc < 0)
+			passed = false;
 
 		osmo_gsup_encode(msg, &gm);
 
 		fprintf(stderr, "  generated message: %s\n", msgb_hexdump(msg));
 		fprintf(stderr, "  original message:  %s\n", osmo_hexdump(t->data, t->data_len));
 		fprintf(stderr, "  IMSI:              %s\n", gm.imsi);
-		OSMO_ASSERT(strcmp(gm.imsi, TEST_IMSI_STR) == 0);
-		OSMO_ASSERT(msgb_length(msg) == t->data_len);
-		OSMO_ASSERT(memcmp(msgb_data(msg), t->data, t->data_len) == 0);
 
+		if (strcmp(gm.imsi, TEST_IMSI_STR) != 0 ||
+		    msgb_length(msg) != t->data_len ||
+		    memcmp(msgb_data(msg), t->data, t->data_len) != 0)
+			passed = false;
+
+		if (passed)
+			printf("          %s OK\n", t->name);
+		else
+			printf("          %s FAILED: %d<%s> [%u,%u,%zu,%u]\n",
+			       t->name, rc, strerror(-rc),
+			       strcmp(gm.imsi, TEST_IMSI_STR),
+			       msgb_length(msg), t->data_len,
+			       memcmp(msgb_data(msg), t->data, t->data_len));
 		msgb_free(msg);
 	}
 
diff --git a/tests/gsup/gsup_test.ok b/tests/gsup/gsup_test.ok
index a0b3f35..49a85ba 100644
--- a/tests/gsup/gsup_test.ok
+++ b/tests/gsup/gsup_test.ok
@@ -1,16 +1,30 @@
 Test GSUP message decoding/encoding
   Testing Send Authentication Info Request
+          Send Authentication Info Request OK
   Testing Send Authentication Info Error
+          Send Authentication Info Error OK
   Testing Send Authentication Info Result
+          Send Authentication Info Result OK
   Testing Update Location Request
+          Update Location Request OK
   Testing Update Location Error
+          Update Location Error OK
   Testing Update Location Result
+          Update Location Result OK
   Testing Location Cancellation Request
+          Location Cancellation Request OK
   Testing Location Cancellation Error
+          Location Cancellation Error OK
   Testing Location Cancellation Result
+          Location Cancellation Result OK
   Testing Purge MS Request
+          Purge MS Request OK
   Testing Purge MS Error
+          Purge MS Error OK
   Testing Purge MS Result
+          Purge MS Result OK
   Testing Send Authentication Info Result with IK, CK, AUTN and RES (UMTS)
+          Send Authentication Info Result with IK, CK, AUTN and RES (UMTS) OK
   Testing Send Authentication Info Request with AUTS and RAND (UMTS)
+          Send Authentication Info Request with AUTS and RAND (UMTS) OK
 Done.

-- 
To view, visit https://gerrit.osmocom.org/5983
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I016a28fe04f7b194e22c15e936095004c5f079d1
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>



More information about the gerrit-log mailing list