summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEvgeny Vereshchagin <evvers@ya.ru>2015-11-07 18:54:12 +0000
committerFilipe Brandenburger <filbranden@google.com>2015-11-11 07:55:23 -0800
commit4ad4beec7f927d1d592d85bba6af2f7ba106ad8b (patch)
tree8cceb845a1fb7a7b89d9a1d1c424b07fa5987c6b /src
parentb4c14404b3e8753c41bac0b1d49369230a15c544 (diff)
tests: add test for config_parse_pass_environ
Diffstat (limited to 'src')
-rw-r--r--src/test/test-unit-file.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/test/test-unit-file.c b/src/test/test-unit-file.c
index 3648ec9c58..a8e5b6feee 100644
--- a/src/test/test-unit-file.c
+++ b/src/test/test-unit-file.c
@@ -741,6 +741,44 @@ static void test_config_parse_rlimit(void) {
rl[RLIMIT_RTTIME] = mfree(rl[RLIMIT_RTTIME]);
}
+static void test_config_parse_pass_environ(void) {
+ /* int config_parse_pass_environ(
+ const char *unit,
+ const char *filename,
+ unsigned line,
+ const char *section,
+ unsigned section_line,
+ const char *lvalue,
+ int ltype,
+ const char *rvalue,
+ void *data,
+ void *userdata) */
+ int r;
+ _cleanup_strv_free_ char **passenv = NULL;
+
+ r = config_parse_pass_environ(NULL, "fake", 1, "section", 1,
+ "PassEnvironment", 0, "A B",
+ &passenv, NULL);
+ assert_se(r >= 0);
+ assert_se(strv_length(passenv) == 2);
+ assert_se(streq(passenv[0], "A"));
+ assert_se(streq(passenv[1], "B"));
+
+ r = config_parse_pass_environ(NULL, "fake", 1, "section", 1,
+ "PassEnvironment", 0, "",
+ &passenv, NULL);
+ assert_se(r >= 0);
+ assert_se(strv_isempty(passenv));
+
+ r = config_parse_pass_environ(NULL, "fake", 1, "section", 1,
+ "PassEnvironment", 0, "'invalid name' 'normal_name' A=1 \\",
+ &passenv, NULL);
+ assert_se(r >= 0);
+ assert_se(strv_length(passenv) == 1);
+ assert_se(streq(passenv[0], "normal_name"));
+
+}
+
int main(int argc, char *argv[]) {
int r;
@@ -751,6 +789,7 @@ int main(int argc, char *argv[]) {
test_config_parse_exec();
test_config_parse_bounding_set();
test_config_parse_rlimit();
+ test_config_parse_pass_environ();
test_load_env_file_1();
test_load_env_file_2();
test_load_env_file_3();