Merge pull request #22934 from poettering/tls-test-fix-root

tests: make test-resolved-stream suceed even when run as root with restrictive access mode on build tree dir
This commit is contained in:
Lennart Poettering
2022-04-01 15:22:43 +02:00
committed by GitHub
2 changed files with 38 additions and 9 deletions
+9 -6
View File
@@ -48,23 +48,26 @@ char* setup_fake_runtime_dir(void) {
static void load_testdata_env(void) {
static bool called = false;
_cleanup_free_ char *s = NULL;
_cleanup_free_ char *envpath = NULL;
_cleanup_free_ char *s = NULL, *d = NULL, *envpath = NULL;
_cleanup_strv_free_ char **pairs = NULL;
int r;
if (called)
return;
called = true;
assert_se(readlink_and_make_absolute("/proc/self/exe", &s) >= 0);
dirname(s);
assert_se(path_extract_directory(s, &d) >= 0);
assert_se(envpath = path_join(d, "systemd-runtest.env"));
envpath = path_join(s, "systemd-runtest.env");
if (load_env_file_pairs(NULL, envpath, &pairs) < 0)
r = load_env_file_pairs(NULL, envpath, &pairs);
if (r < 0) {
log_debug_errno(r, "Reading %s failed: %m", envpath);
return;
}
STRV_FOREACH_PAIR(k, v, pairs)
setenv(*k, *v, 0);
assert_se(setenv(*k, *v, 0) >= 0);
}
int get_testdata_dir(const char *suffix, char **ret) {