summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test-util.c41
1 files changed, 31 insertions, 10 deletions
diff --git a/src/test/test-util.c b/src/test/test-util.c
index de6a2a0d89..01b0192c1c 100644
--- a/src/test/test-util.c
+++ b/src/test/test-util.c
@@ -1173,51 +1173,60 @@ static void test_unquote_first_word(void) {
char *t;
p = original = "foobar waldo";
- assert_se(unquote_first_word(&p, &t) > 0);
+ assert_se(unquote_first_word(&p, &t, false) > 0);
assert_se(streq(t, "foobar"));
free(t);
assert_se(p == original + 7);
- assert_se(unquote_first_word(&p, &t) > 0);
+ assert_se(unquote_first_word(&p, &t, false) > 0);
assert_se(streq(t, "waldo"));
free(t);
assert_se(p == original + 12);
- assert_se(unquote_first_word(&p, &t) == 0);
+ assert_se(unquote_first_word(&p, &t, false) == 0);
assert_se(!t);
assert_se(p == original + 12);
p = original = "\"foobar\" \'waldo\'";
- assert_se(unquote_first_word(&p, &t) > 0);
+ assert_se(unquote_first_word(&p, &t, false) > 0);
assert_se(streq(t, "foobar"));
free(t);
assert_se(p == original + 9);
- assert_se(unquote_first_word(&p, &t) > 0);
+ assert_se(unquote_first_word(&p, &t, false) > 0);
assert_se(streq(t, "waldo"));
free(t);
assert_se(p == original + 16);
- assert_se(unquote_first_word(&p, &t) == 0);
+ assert_se(unquote_first_word(&p, &t, false) == 0);
assert_se(!t);
assert_se(p == original + 16);
p = original = "\"";
- assert_se(unquote_first_word(&p, &t) == -EINVAL);
+ assert_se(unquote_first_word(&p, &t, false) == -EINVAL);
assert_se(p == original + 1);
p = original = "\'";
- assert_se(unquote_first_word(&p, &t) == -EINVAL);
+ assert_se(unquote_first_word(&p, &t, false) == -EINVAL);
assert_se(p == original + 1);
+ p = original = "\'fooo";
+ assert_se(unquote_first_word(&p, &t, false) == -EINVAL);
+ assert_se(p == original + 5);
+
+ p = original = "\'fooo";
+ assert_se(unquote_first_word(&p, &t, true) > 0);
+ assert_se(streq(t, "fooo"));
+ assert_se(p == original + 5);
+
p = original = "yay\'foo\'bar";
- assert_se(unquote_first_word(&p, &t) > 0);
+ assert_se(unquote_first_word(&p, &t, false) > 0);
assert_se(streq(t, "yayfoobar"));
free(t);
assert_se(p == original + 11);
p = original = " foobar ";
- assert_se(unquote_first_word(&p, &t) > 0);
+ assert_se(unquote_first_word(&p, &t, false) > 0);
assert_se(streq(t, "foobar"));
free(t);
assert_se(p == original + 12);
@@ -1277,6 +1286,17 @@ static void test_unquote_many_words(void) {
free(a);
}
+static int parse_item(const char *key, const char *value) {
+ assert_se(key);
+
+ log_info("kernel cmdline option <%s> = <%s>", key, strna(value));
+ return 0;
+}
+
+static void test_parse_proc_cmdline(void) {
+ assert_se(parse_proc_cmdline(parse_item) >= 0);
+}
+
int main(int argc, char *argv[]) {
log_parse_environment();
log_open();
@@ -1348,6 +1368,7 @@ int main(int argc, char *argv[]) {
test_execute_directory();
test_unquote_first_word();
test_unquote_many_words();
+ test_parse_proc_cmdline();
return 0;
}