[MERGED] openbsc[master]: oap_client_test: print test descr to stderr, check stderr

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/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Tue Dec 13 14:54:03 UTC 2016


Harald Welte has submitted this change and it was merged.

Change subject: oap_client_test: print test descr to stderr, check stderr
......................................................................


oap_client_test: print test descr to stderr, check stderr

Related: OS#1592
Change-Id: If1696c8e7bfa696b250f7eac24f08f85f8f492a2
---
M openbsc/tests/oap/Makefile.am
M openbsc/tests/oap/oap_client_test.c
A openbsc/tests/oap/oap_client_test.err
M openbsc/tests/oap/oap_client_test.ok
M openbsc/tests/testsuite.at
5 files changed, 56 insertions(+), 30 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/openbsc/tests/oap/Makefile.am b/openbsc/tests/oap/Makefile.am
index df0a43f..1bb672d 100644
--- a/openbsc/tests/oap/Makefile.am
+++ b/openbsc/tests/oap/Makefile.am
@@ -12,6 +12,7 @@
 
 EXTRA_DIST = \
 	oap_client_test.ok \
+	oap_client_test.err \
 	$(NULL)
 
 if HAVE_LIBGTP
diff --git a/openbsc/tests/oap/oap_client_test.c b/openbsc/tests/oap/oap_client_test.c
index adac911..1473146 100644
--- a/openbsc/tests/oap/oap_client_test.c
+++ b/openbsc/tests/oap/oap_client_test.c
@@ -29,7 +29,7 @@
 
 static void test_oap_api(void)
 {
-	printf("Testing OAP API\n  - Config parsing\n");
+	printf("Testing OAP API\n");
 
 	struct oap_client_config _config;
 	struct oap_client_config *config = &_config;
@@ -43,20 +43,20 @@
 	OSMO_ASSERT(osmo_hexparse("0102030405060708090a0b0c0d0e0f10", config->secret_k, 16) == 16);
 	OSMO_ASSERT(osmo_hexparse("1112131415161718191a1b1c1d1e1f20", config->secret_opc, 16) == 16);
 
-	/* make sure filling with zeros means uninitialized */
+	fprintf(stderr, "- make sure filling with zeros means uninitialized\n");
 	OSMO_ASSERT(state->state == OAP_UNINITIALIZED);
 
-	/* invalid client_id and shared secret */
+	fprintf(stderr, "- invalid client_id and shared secret\n");
 	config->client_id = 0;
 	config->secret_k_present = 0;
 	config->secret_opc_present = 0;
 	OSMO_ASSERT( oap_client_init(config, state) == 0 );
 	OSMO_ASSERT(state->state == OAP_DISABLED);
 
-	/* reset state */
+	fprintf(stderr, "- reset state\n");
 	memset(state, 0, sizeof(*state));
 
-	/* only client_id is invalid */
+	fprintf(stderr, "- only client_id is invalid\n");
 	config->client_id = 0;
 	config->secret_k_present = 1;
 	config->secret_opc_present = 1;
@@ -65,7 +65,7 @@
 
 	memset(state, 0, sizeof(*state));
 
-	/* valid id, but omitted shared_secret (1/2) */
+	fprintf(stderr, "- valid id, but omitted shared_secret (1/2)\n");
 	config->client_id = 12345;
 	config->secret_k_present = 0;
 	config->secret_opc_present = 1;
@@ -74,7 +74,7 @@
 
 	memset(state, 0, sizeof(*state));
 
-	/* valid id, but omitted shared_secret (2/2) */
+	fprintf(stderr, "- valid id, but omitted shared_secret (2/2)\n");
 	config->client_id = 12345;
 	config->secret_k_present = 1;
 	config->secret_opc_present = 0;
@@ -84,7 +84,7 @@
 	memset(state, 0, sizeof(*state));
 
 
-	/* mint configuration */
+	fprintf(stderr, "- mint configuration\n");
 	config->client_id = 12345;
 	config->secret_k_present = 1;
 	config->secret_opc_present = 1;
@@ -92,16 +92,13 @@
 	OSMO_ASSERT( oap_client_init(config, state) == 0 );
 	OSMO_ASSERT(state->state == OAP_INITIALIZED);
 
-	printf("  - AUTN failures\n");
-
 	struct osmo_oap_message oap_rx;
 	struct osmo_oap_message oap_tx;
 	struct msgb *msg_rx;
 	struct msgb *msg_tx;
 
+	fprintf(stderr, "- Missing challenge data\n");
 	memset(&oap_rx, 0, sizeof(oap_rx));
-
-	/* Missing challenge data */
 	oap_rx.message_type = OAP_MSGT_CHALLENGE_REQUEST;
 	oap_rx.rand_present = 0;
 	oap_rx.autn_present = 0;
@@ -110,7 +107,7 @@
 	msgb_free(msg_rx);
 	OSMO_ASSERT(!msg_tx);
 
-	/* AUTN missing */
+	fprintf(stderr, "- AUTN missing\n");
 	osmo_hexparse("0102030405060708090a0b0c0d0e0f10",
 		      oap_rx.rand, 16);
 	oap_rx.rand_present = 1;
@@ -119,7 +116,7 @@
 	msgb_free(msg_rx);
 	OSMO_ASSERT(!msg_tx);
 
-	/* RAND missing */
+	fprintf(stderr, "- RAND missing\n");
 	oap_rx.rand_present = 0;
 	osmo_hexparse("cec4e3848a33000086781158ca40f136",
 		      oap_rx.autn, 16);
@@ -129,7 +126,7 @@
 	msgb_free(msg_rx);
 	OSMO_ASSERT(!msg_tx);
 
-	/* wrong autn (by one bit) */
+	fprintf(stderr, "- wrong autn (by one bit)\n");
 	osmo_hexparse("0102030405060708090a0b0c0d0e0f10",
 		      oap_rx.rand, 16);
 	osmo_hexparse("dec4e3848a33000086781158ca40f136",
@@ -141,12 +138,12 @@
 	msgb_free(msg_rx);
 	OSMO_ASSERT(!msg_tx);
 
-	/* all data correct */
+	fprintf(stderr, "- all data correct\n");
 	osmo_hexparse("cec4e3848a33000086781158ca40f136",
 		      oap_rx.autn, 16);
 	msg_rx = oap_client_encoded(&oap_rx);
 
-	/* but refuse to evaluate in uninitialized state */
+	fprintf(stderr, "- but refuse to evaluate in uninitialized state\n");
 	OSMO_ASSERT(state->state == OAP_INITIALIZED);
 
 	state->state = OAP_UNINITIALIZED;
@@ -159,13 +156,12 @@
 
 	state->state = OAP_INITIALIZED;
 
-	/* now everything is correct */
-	printf("  - AUTN success\n");
+	fprintf(stderr, "- now everything is correct\n");
 	/* a successful return value here indicates correct autn */
 	OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) == 0);
 	msgb_free(msg_rx);
 
-	/* Expect the challenge response in msg_tx */
+	fprintf(stderr, "- Expect the challenge response in msg_tx\n");
 	OSMO_ASSERT(msg_tx);
 	OSMO_ASSERT(osmo_oap_decode(&oap_tx, msg_tx->data, msg_tx->len) == 0);
 	OSMO_ASSERT(oap_tx.message_type == OAP_MSGT_CHALLENGE_RESULT);
@@ -178,14 +174,13 @@
 
 	struct oap_client_state saved_state = _state;
 
-	printf("  - Registration failure\n");
+	fprintf(stderr, "- Receive registration error for the first time.\n");
 
 	memset(&oap_rx, 0, sizeof(oap_rx));
 	oap_rx.message_type = OAP_MSGT_REGISTER_ERROR;
 	oap_rx.cause = GMM_CAUSE_PROTO_ERR_UNSPEC;
 	msg_rx = oap_client_encoded(&oap_rx);
 
-	/* Receive registration error for the first time. */
 	OSMO_ASSERT(state->registration_failures == 0);
 	OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) == 0);
 	OSMO_ASSERT(state->registration_failures == 1);
@@ -196,7 +191,7 @@
 	msgb_free(msg_tx);
 	msg_tx = 0;
 
-	/* Receive registration error for the Nth time. */
+	fprintf(stderr, "- Receive registration error for the Nth time.\n");
 	state->registration_failures = 999;
 	OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) == -11);
 	OSMO_ASSERT(!msg_tx);
@@ -206,7 +201,7 @@
 
 	msgb_free(msg_rx);
 
-	printf("  - Registration success\n");
+	fprintf(stderr, "- Registration success\n");
 
 	_state = saved_state;
 	memset(&oap_rx, 0, sizeof(oap_rx));
@@ -236,6 +231,12 @@
 	msgb_talloc_ctx_init(NULL, 0);
 	osmo_init_logging(&info);
 
+	OSMO_ASSERT(osmo_stderr_target);
+	osmo_stderr_target->use_color = 0;
+	osmo_stderr_target->print_timestamp = 0;
+	osmo_stderr_target->print_filename = 0;
+	osmo_stderr_target->print_category = 1;
+
 	test_oap_api();
 	printf("Done\n");
 
diff --git a/openbsc/tests/oap/oap_client_test.err b/openbsc/tests/oap/oap_client_test.err
new file mode 100644
index 0000000..3272237
--- /dev/null
+++ b/openbsc/tests/oap/oap_client_test.err
@@ -0,0 +1,28 @@
+- make sure filling with zeros means uninitialized
+- invalid client_id and shared secret
+- reset state
+- only client_id is invalid
+- valid id, but omitted shared_secret (1/2)
+DGPRS OAP: client ID set, but secret K missing.
+- valid id, but omitted shared_secret (2/2)
+DGPRS OAP: client ID set, but secret OPC missing.
+- mint configuration
+- Missing challenge data
+DGPRS OAP challenge incomplete (rand_present: 0, autn_present: 0)
+- AUTN missing
+DGPRS OAP challenge incomplete (rand_present: 1, autn_present: 0)
+- RAND missing
+DGPRS OAP challenge incomplete (rand_present: 0, autn_present: 1)
+- wrong autn (by one bit)
+DGPRS OAP: AUTN mismatch!
+DGPRS OAP: AUTN from server: dec4e3848a33000086781158ca40f136
+DGPRS OAP: AUTN expected:    cec4e3848a33000086781158ca40f136
+- all data correct
+- but refuse to evaluate in uninitialized state
+- now everything is correct
+- Expect the challenge response in msg_tx
+- Receive registration error for the first time.
+DGPRS OAP registration failed
+- Receive registration error for the Nth time.
+DGPRS OAP registration failed
+- Registration success
diff --git a/openbsc/tests/oap/oap_client_test.ok b/openbsc/tests/oap/oap_client_test.ok
index 2e9ecf0..59108a7 100644
--- a/openbsc/tests/oap/oap_client_test.ok
+++ b/openbsc/tests/oap/oap_client_test.ok
@@ -1,7 +1,2 @@
 Testing OAP API
-  - Config parsing
-  - AUTN failures
-  - AUTN success
-  - Registration failure
-  - Registration success
 Done
diff --git a/openbsc/tests/testsuite.at b/openbsc/tests/testsuite.at
index 0765c76..01737a3 100644
--- a/openbsc/tests/testsuite.at
+++ b/openbsc/tests/testsuite.at
@@ -108,7 +108,8 @@
 AT_KEYWORDS([oap])
 AT_CHECK([test "$enable_oap_test" != no || exit 77])
 cat $abs_srcdir/oap/oap_client_test.ok > expout
-AT_CHECK([$abs_top_builddir/tests/oap/oap_client_test], [], [expout], [ignore])
+cat $abs_srcdir/oap/oap_client_test.err > experr
+AT_CHECK([$abs_top_builddir/tests/oap/oap_client_test], [], [expout], [experr])
 AT_CLEANUP
 
 AT_SETUP([gtphub])

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

Gerrit-MessageType: merged
Gerrit-Change-Id: If1696c8e7bfa696b250f7eac24f08f85f8f492a2
Gerrit-PatchSet: 3
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list