From b885ef88c11b5d67f96827abac30a8db75beb5ad Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Thu, 12 Jul 2018 19:29:23 +0200 Subject: tests: ctrl: Test received ERROR messages are handled correctly Change-Id: I3c8e95aaa1ca222d4cd1395e548f8461bf9d4cd6 --- tests/ctrl/ctrl_test.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'tests/ctrl/ctrl_test.c') diff --git a/tests/ctrl/ctrl_test.c b/tests/ctrl/ctrl_test.c index 8bb917b9..cffb8039 100644 --- a/tests/ctrl/ctrl_test.c +++ b/tests/ctrl/ctrl_test.c @@ -70,18 +70,23 @@ void assert_same_str(const char *label, const char *expect, const char *got) 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 @@ static const struct one_test test_messages_list[] = { .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() -- cgit v1.2.3