Change in libosmocore[master]: tests: ctrl: Test received ERROR messages are handled correctly

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
Mon Jul 16 17:56:26 UTC 2018


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/9984 )

Change subject: tests: ctrl: Test received ERROR messages are handled correctly
......................................................................

tests: ctrl: Test received ERROR messages are handled correctly

Change-Id: I3c8e95aaa1ca222d4cd1395e548f8461bf9d4cd6
---
M tests/ctrl/ctrl_test.c
M tests/ctrl/ctrl_test.ok
2 files changed, 55 insertions(+), 2 deletions(-)

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



diff --git a/tests/ctrl/ctrl_test.c b/tests/ctrl/ctrl_test.c
index 8bb917b..cffb803 100644
--- a/tests/ctrl/ctrl_test.c
+++ b/tests/ctrl/ctrl_test.c
@@ -70,18 +70,23 @@
 static void assert_test(struct ctrl_handle *ctrl, struct ctrl_connection *ccon, const struct one_test *t)
 {
 	struct ctrl_cmd *cmd;
+	bool parse_failed;
 	struct msgb *msg = msgb_from_string(t->cmd_str);
 	int ctx_size_was;
 
 	printf("test: '%s'\n", osmo_escape_str(t->cmd_str, -1));
 	printf("parsing:\n");
 
-	cmd = ctrl_cmd_parse2(ctx, msg);
+	cmd = ctrl_cmd_parse3(ctx, msg, &parse_failed);
 	OSMO_ASSERT(cmd);
 
 	if (t->expect_parsed.type != cmd->type) {
 		printf("type mismatch: got %s\n", get_value_string(ctrl_type_vals, cmd->type));
 		OSMO_ASSERT(t->expect_parsed.type == cmd->type);
+	} else {
+		printf("type = '%s'%s\n", get_value_string(ctrl_type_vals, cmd->type),
+		       cmd->type != CTRL_TYPE_ERROR ? "" :
+		       (parse_failed ? " (parse failure)" : " (error received)"));
 	}
 
 #define ASSERT_SAME_STR(field) \
@@ -310,7 +315,20 @@
 			.reply = "OK",
 		},
 	},
-
+	{ "ERROR 1 some error message",
+		{
+			.type = CTRL_TYPE_ERROR,
+			.id = "1",
+			.reply = "some error message",
+		},
+	},
+	{ "ERROR err some error message",
+		{
+			.type = CTRL_TYPE_ERROR,
+			.id = "err",
+			.reply = "some error message",
+		},
+	},
 };
 
 static void test_messages()
diff --git a/tests/ctrl/ctrl_test.ok b/tests/ctrl/ctrl_test.ok
index 07f4aac..0705d69 100644
--- a/tests/ctrl/ctrl_test.ok
+++ b/tests/ctrl/ctrl_test.ok
@@ -9,6 +9,7 @@
 ctrl type 64 is unknown 0x40 [PARSE FAILED]
 test: 'GET 1 variable'
 parsing:
+type = 'GET'
 id = '1'
 variable = 'variable'
 value = '(null)'
@@ -18,6 +19,7 @@
 ok
 test: 'GET 1 variable\n'
 parsing:
+type = 'GET'
 id = '1'
 variable = 'variable'
 value = '(null)'
@@ -27,6 +29,7 @@
 ok
 test: 'GET 1 var\ni\nable'
 parsing:
+type = 'ERROR' (parse failure)
 id = '1'
 reply = 'GET with trailing characters'
 handling:
@@ -34,6 +37,7 @@
 ok
 test: 'GET 1 var\ti\table'
 parsing:
+type = 'ERROR' (parse failure)
 id = '1'
 reply = 'GET variable contains invalid characters'
 handling:
@@ -41,6 +45,7 @@
 ok
 test: 'GET 1 var\ri\rable'
 parsing:
+type = 'ERROR' (parse failure)
 id = '1'
 reply = 'GET variable contains invalid characters'
 handling:
@@ -48,6 +53,7 @@
 ok
 test: 'GET 1 variable value'
 parsing:
+type = 'ERROR' (parse failure)
 id = '1'
 reply = 'GET with trailing characters'
 handling:
@@ -55,6 +61,7 @@
 ok
 test: 'GET 1 variable value\n'
 parsing:
+type = 'ERROR' (parse failure)
 id = '1'
 reply = 'GET with trailing characters'
 handling:
@@ -62,6 +69,7 @@
 ok
 test: 'GET 1 variable multiple value tokens'
 parsing:
+type = 'ERROR' (parse failure)
 id = '1'
 reply = 'GET with trailing characters'
 handling:
@@ -69,6 +77,7 @@
 ok
 test: 'GET 1 variable multiple value tokens\n'
 parsing:
+type = 'ERROR' (parse failure)
 id = '1'
 reply = 'GET with trailing characters'
 handling:
@@ -76,6 +85,7 @@
 ok
 test: 'SET 1 variable value'
 parsing:
+type = 'SET'
 id = '1'
 variable = 'variable'
 value = 'value'
@@ -85,6 +95,7 @@
 ok
 test: 'SET 1 variable value\n'
 parsing:
+type = 'SET'
 id = '1'
 variable = 'variable'
 value = 'value'
@@ -94,6 +105,7 @@
 ok
 test: 'SET weird_id variable value'
 parsing:
+type = 'ERROR' (parse failure)
 id = 'err'
 reply = 'Invalid message ID number'
 handling:
@@ -101,6 +113,7 @@
 ok
 test: 'SET weird_id variable value\n'
 parsing:
+type = 'ERROR' (parse failure)
 id = 'err'
 reply = 'Invalid message ID number'
 handling:
@@ -108,6 +121,7 @@
 ok
 test: 'SET 1 variable multiple value tokens'
 parsing:
+type = 'SET'
 id = '1'
 variable = 'variable'
 value = 'multiple value tokens'
@@ -117,6 +131,7 @@
 ok
 test: 'SET 1 variable multiple value tokens\n'
 parsing:
+type = 'SET'
 id = '1'
 variable = 'variable'
 value = 'multiple value tokens'
@@ -126,6 +141,7 @@
 ok
 test: 'SET 1 variable value_with_trailing_spaces  '
 parsing:
+type = 'SET'
 id = '1'
 variable = 'variable'
 value = 'value_with_trailing_spaces  '
@@ -135,6 +151,7 @@
 ok
 test: 'SET 1 variable value_with_trailing_spaces  \n'
 parsing:
+type = 'SET'
 id = '1'
 variable = 'variable'
 value = 'value_with_trailing_spaces  '
@@ -144,6 +161,7 @@
 ok
 test: 'SET \n special_char_id value'
 parsing:
+type = 'ERROR' (parse failure)
 id = 'err'
 reply = 'Invalid message ID number'
 handling:
@@ -151,6 +169,7 @@
 ok
 test: 'SET \t special_char_id value'
 parsing:
+type = 'ERROR' (parse failure)
 id = 'err'
 reply = 'Invalid message ID number'
 handling:
@@ -158,6 +177,7 @@
 ok
 test: 'GET_REPLY 1 variable OK'
 parsing:
+type = 'GET_REPLY'
 id = '1'
 variable = 'variable'
 value = '(null)'
@@ -166,12 +186,27 @@
 ok
 test: 'SET_REPLY 1 variable OK'
 parsing:
+type = 'SET_REPLY'
 id = '1'
 variable = 'variable'
 value = '(null)'
 reply = 'OK'
 handling:
 ok
+test: 'ERROR 1 some error message'
+parsing:
+type = 'ERROR' (error received)
+id = '1'
+reply = 'some error message'
+handling:
+ok
+test: 'ERROR err some error message'
+parsing:
+type = 'ERROR' (error received)
+id = 'err'
+reply = 'some error message'
+handling:
+ok
 
 test_deferred_cmd
 get_test_defer called

-- 
To view, visit https://gerrit.osmocom.org/9984
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I3c8e95aaa1ca222d4cd1395e548f8461bf9d4cd6
Gerrit-Change-Number: 9984
Gerrit-PatchSet: 2
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180716/15b8fa47/attachment.htm>


More information about the gerrit-log mailing list