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/.
Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Review at https://gerrit.osmocom.org/5430
ctrl_test.c: replace print_escaped() with new osmo_escape_str()
Change-Id: I12d3828dcc925f97fde11c360f1d60f3bd8cad8b
---
M tests/ctrl/ctrl_test.c
M tests/ctrl/ctrl_test.ok
2 files changed, 28 insertions(+), 60 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/30/5430/1
diff --git a/tests/ctrl/ctrl_test.c b/tests/ctrl/ctrl_test.c
index b8425c7..2bc3128 100644
--- a/tests/ctrl/ctrl_test.c
+++ b/tests/ctrl/ctrl_test.c
@@ -37,45 +37,15 @@
static void *ctx = NULL;
-void print_escaped(const char *str)
-{
- if (!str) {
- printf("NULL");
- return;
- }
-
- printf("'");
- for (;*str; str++) {
- switch (*str) {
- case '\n':
- printf("\\n");
- break;
- case '\r':
- printf("\\r");
- break;
- case '\t':
- printf("\\t");
- break;
- default:
- printf("%c", *str);
- break;
- }
- }
- printf("'");
-}
-
void assert_same_str(const char *label, const char *expect, const char *got)
{
if ((expect == got) || (expect && got && (strcmp(expect, got) == 0))) {
- printf("%s = ", label);
- print_escaped(got);
- printf("\n");
+ printf("%s = '%s'\n", label, osmo_escape_str(got, -1));
return;
}
- printf("MISMATCH for '%s':\ngot: ", label); print_escaped(got);
- printf("\nexpected: "); print_escaped(expect);
- printf("\n");
+ printf("MISMATCH for '%s':\ngot: %s\n", label, osmo_escape_str(got, -1));
+ printf("expected: %s\n", osmo_escape_str(expect, -1));
OSMO_ASSERT(expect == got);
}
@@ -84,9 +54,7 @@
struct ctrl_cmd *cmd;
struct msgb *msg = msgb_from_string(str);
- printf("test parsing: ");
- print_escaped(str);
- printf("\n");
+ printf("test parsing: '%s'\n", osmo_escape_str(str, -1));
cmd = ctrl_cmd_parse(ctx, msg);
OSMO_ASSERT(cmd);
diff --git a/tests/ctrl/ctrl_test.ok b/tests/ctrl/ctrl_test.ok
index 9c8877b..5775eb2 100644
--- a/tests/ctrl/ctrl_test.ok
+++ b/tests/ctrl/ctrl_test.ok
@@ -10,102 +10,102 @@
test parsing: 'GET 1 variable'
id = '1'
variable = 'variable'
-value = NULL
-reply = NULL
+value = '(null)'
+reply = '(null)'
ok
test parsing: 'GET 1 variable\n'
id = '1'
variable = 'variable\n'
-value = NULL
-reply = NULL
+value = '(null)'
+reply = '(null)'
ok
test parsing: 'GET 1 var\ni\nable'
id = '1'
variable = 'var\ni\nable'
-value = NULL
-reply = NULL
+value = '(null)'
+reply = '(null)'
ok
test parsing: 'GET 1 variable value'
id = '1'
variable = 'variable'
-value = NULL
-reply = NULL
+value = '(null)'
+reply = '(null)'
ok
test parsing: 'GET 1 variable value\n'
id = '1'
variable = 'variable'
-value = NULL
-reply = NULL
+value = '(null)'
+reply = '(null)'
ok
test parsing: 'GET 1 variable multiple value tokens'
id = '1'
variable = 'variable'
-value = NULL
-reply = NULL
+value = '(null)'
+reply = '(null)'
ok
test parsing: 'GET 1 variable multiple value tokens\n'
id = '1'
variable = 'variable'
-value = NULL
-reply = NULL
+value = '(null)'
+reply = '(null)'
ok
test parsing: 'SET 1 variable value'
id = '1'
variable = 'variable'
value = 'value'
-reply = NULL
+reply = '(null)'
ok
test parsing: 'SET 1 variable value\n'
id = '1'
variable = 'variable'
value = 'value'
-reply = NULL
+reply = '(null)'
ok
test parsing: 'SET weird_id variable value'
id = 'weird_id'
variable = 'variable'
value = 'value'
-reply = NULL
+reply = '(null)'
ok
test parsing: 'SET weird_id variable value\n'
id = 'weird_id'
variable = 'variable'
value = 'value'
-reply = NULL
+reply = '(null)'
ok
test parsing: 'SET 1 variable multiple value tokens'
id = '1'
variable = 'variable'
value = 'multiple value tokens'
-reply = NULL
+reply = '(null)'
ok
test parsing: 'SET 1 variable multiple value tokens\n'
id = '1'
variable = 'variable'
value = 'multiple value tokens'
-reply = NULL
+reply = '(null)'
ok
test parsing: 'SET 1 variable value_with_trailing_spaces '
id = '1'
variable = 'variable'
value = 'value_with_trailing_spaces '
-reply = NULL
+reply = '(null)'
ok
test parsing: 'SET 1 variable value_with_trailing_spaces \n'
id = '1'
variable = 'variable'
value = 'value_with_trailing_spaces '
-reply = NULL
+reply = '(null)'
ok
test parsing: 'SET \n special_char_id value'
id = '\n'
variable = 'special_char_id'
value = 'value'
-reply = NULL
+reply = '(null)'
ok
test parsing: 'SET \t special_char_id value'
id = '\t'
variable = 'special_char_id'
value = 'value'
-reply = NULL
+reply = '(null)'
ok
--
To view, visit https://gerrit.osmocom.org/5430
To unsubscribe, visit https://gerrit.osmocom.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I12d3828dcc925f97fde11c360f1d60f3bd8cad8b
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>