]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/test/test-fileio.c
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 This file is part of systemd.
6 Copyright 2013 Lennart Poettering
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
30 static void test_parse_env_file(void) {
31 char t
[] = "/tmp/test-parse-env-file-XXXXXX";
34 _cleanup_free_
char *one
= NULL
, *two
= NULL
, *three
= NULL
, *four
= NULL
, *five
= NULL
, *six
= NULL
, *seven
= NULL
;
35 _cleanup_strv_free_
char **a
= NULL
;
38 fd
= mkostemp(t
, O_CLOEXEC
);
51 "four = \'44\\\"44\'\n"
52 "five = \'55\\\'55\' \"FIVE\" cinco \n"
53 "six = seis sechs\\\n"
73 log_info("one=[%s]", strna(one
));
74 log_info("two=[%s]", strna(two
));
75 log_info("three=[%s]", strna(three
));
76 log_info("four=[%s]", strna(four
));
77 log_info("five=[%s]", strna(five
));
78 log_info("six=[%s]", strna(six
));
79 log_info("seven=[%s]", strna(seven
));
81 assert_se(streq(one
, "BAR"));
82 assert_se(streq(two
, "bar"));
83 assert_se(streq(three
, "333\nxxxx"));
84 assert_se(streq(four
, "44\"44"));
85 assert_se(streq(five
, "55\'55FIVEcinco"));
86 assert_se(streq(six
, "seis sechs sis"));
87 assert_se(seven
== NULL
);
89 r
= load_env_file(t
, NULL
, &a
);
93 log_info("Got: %s", *i
);
98 int main(int argc
, char *argv
[]) {
99 test_parse_env_file();