diff options
author | Lennart Poettering <lennart@poettering.net> | 2020-09-11 17:43:05 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2020-09-14 12:26:41 +0200 |
commit | df8b14b59119c61f660037710bbb3899db441ef7 (patch) | |
tree | e70d3c0b75b34db655811f69ebe92fad098a8935 /src/test/test-fileio.c | |
parent | 55f99c26c678b4bf4fb697a57d540b0266aa3f49 (diff) | |
download | systemd-df8b14b59119c61f660037710bbb3899db441ef7.tar.gz |
test-fileio: test test strings with shell, too
Diffstat (limited to 'src/test/test-fileio.c')
-rw-r--r-- | src/test/test-fileio.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c index 3e6413ec47..9c0b3533c2 100644 --- a/src/test/test-fileio.c +++ b/src/test/test-fileio.c @@ -151,6 +151,18 @@ static void test_parse_env_file(void) { assert_se(r >= 0); } +static void test_one_shell_var(const char *file, const char *variable, const char *value) { + _cleanup_free_ char *cmd = NULL, *from_shell = NULL; + _cleanup_fclose_ FILE *f = NULL; + size_t sz; + + assert_se(cmd = strjoin(". ", file, " && /bin/echo -n \"$", variable, "\"")); + assert_se(f = popen(cmd, "re")); + assert_se(read_full_stream(f, &from_shell, &sz) >= 0); + assert_se(sz == strlen(value)); + assert_se(streq(from_shell, value)); +} + static void test_parse_multiline_env_file(void) { _cleanup_(unlink_tempfilep) char t[] = "/tmp/test-fileio-in-XXXXXX", @@ -176,6 +188,10 @@ static void test_parse_multiline_env_file(void) { assert_se(fflush_and_check(f) >= 0); fclose(f); + test_one_shell_var(t, "one", "BAR VAR\tGAR"); + test_one_shell_var(t, "two", "bar var\tgar"); + test_one_shell_var(t, "tri", "bar var \tgar "); + r = load_env_file(NULL, t, &a); assert_se(r >= 0); |