test-env-replace.c revision 9b5d6bd909855543cba75a4469bff6f82845cf0d
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2010 Lennart Poettering
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <unistd.h>
#include <string.h>
#include "util.h"
#include "strv.h"
#include "env-util.h"
static void test_strv_env_delete(void) {
assert_se(a);
assert_se(b);
assert_se(c);
d = strv_env_delete(a, 2, b, c);
assert_se(d);
}
static void test_strv_env_unset(void) {
_cleanup_strv_free_ char **l = NULL;
assert_se(l);
}
static void test_strv_env_set(void) {
assert_se(l);
r = strv_env_set(l, "WALDO=WALDO");
assert_se(r);
}
static void test_strv_env_merge(void) {
assert_se(a);
assert_se(b);
r = strv_env_merge(2, a, b);
assert_se(r);
assert_se(strv_env_clean(r) == r);
}
static void test_replace_env_arg(void) {
const char *env[] = {
"FOO=BAR BAR",
"BAR=waldo",
};
const char *line[] = {
"FOO$FOO",
"FOO$FOOFOO",
"FOO${FOO}$FOO",
"FOO${FOO}",
"${FOO}",
"$FOO",
"$FOO$FOO",
"${FOO}${BAR}",
"${FOO",
};
_cleanup_strv_free_ char **r = NULL;
assert_se(r);
}
_cleanup_free_ char *t;
assert_se(t);
}
static void test_normalize_env_assignment(void) {
}
static void test_env_clean(void) {
_cleanup_strv_free_ char **e;
e = strv_new("FOOBAR=WALDO",
"FOOBAR=WALDO",
"FOOBAR",
"F",
"X=",
"F=F",
"=",
"=F",
"",
"0000=000",
"äöüß=abcd",
"abcd=äöüß",
"xyz\n=xyz",
"xyz=xyz\n",
"another=one",
"another=final one",
NULL);
assert_se(e);
assert_se(!strv_env_is_valid(e));
assert_se(strv_env_clean(e) == e);
}
return 0;
}