]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/test/test-path-lookup.c
Merge pull request #12593 from AdrianBunk/master
[thirdparty/systemd.git] / src / test / test-path-lookup.c
index 0541033d77470a796c7516b5908fa6fd573d5344..f20855935866a94118023e2985135f14f1a5e41f 100644 (file)
@@ -1,22 +1,4 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
-/***
-  This file is part of systemd.
-
-  Copyright 2014 Zbigniew JÄ™drzejewski-Szmek
-
-  systemd is free software; you can redistribute it and/or modify it
-  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 <stdlib.h>
 #include <sys/stat.h>
 #include "rm-rf.h"
 #include "string-util.h"
 #include "strv.h"
+#include "tests.h"
 
 static void test_paths(UnitFileScope scope) {
         char template[] = "/tmp/test-path-lookup.XXXXXXX";
 
-        _cleanup_lookup_paths_free_ LookupPaths lp_without_env = {};
-        _cleanup_lookup_paths_free_ LookupPaths lp_with_env = {};
+        _cleanup_(lookup_paths_free) LookupPaths lp_without_env = {};
+        _cleanup_(lookup_paths_free) LookupPaths lp_with_env = {};
         char *systemd_unit_path;
 
         assert_se(mkdtemp(template));
@@ -53,11 +36,13 @@ static void test_paths(UnitFileScope scope) {
 }
 
 static void test_user_and_global_paths(void) {
-        _cleanup_lookup_paths_free_ LookupPaths lp_global = {}, lp_user = {};
+        _cleanup_(lookup_paths_free) LookupPaths lp_global = {}, lp_user = {};
         char **u, **g, **p;
         unsigned k = 0;
 
         assert_se(unsetenv("SYSTEMD_UNIT_PATH") == 0);
+        assert_se(unsetenv("XDG_DATA_DIRS") == 0);
+        assert_se(unsetenv("XDG_CONFIG_DIRS") == 0);
 
         assert_se(lookup_paths_init(&lp_global, UNIT_FILE_GLOBAL, 0, NULL) == 0);
         assert_se(lookup_paths_init(&lp_user, UNIT_FILE_USER, 0, NULL) == 0);
@@ -94,9 +79,7 @@ static void print_generator_binary_paths(UnitFileScope scope) {
 }
 
 int main(int argc, char **argv) {
-        log_set_max_level(LOG_DEBUG);
-        log_parse_environment();
-        log_open();
+        test_setup_logging(LOG_DEBUG);
 
         test_paths(UNIT_FILE_SYSTEM);
         test_paths(UNIT_FILE_USER);