File: | build-scan/../src/test/test-path-util.c |
Warning: | line 362, column 13 Null pointer passed to 1st parameter expecting 'nonnull' |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* SPDX-License-Identifier: LGPL-2.1+ */ | |||
2 | ||||
3 | #include <stdio.h> | |||
4 | #include <unistd.h> | |||
5 | ||||
6 | #include "alloc-util.h" | |||
7 | #include "fd-util.h" | |||
8 | #include "macro.h" | |||
9 | #include "mount-util.h" | |||
10 | #include "path-util.h" | |||
11 | #include "rm-rf.h" | |||
12 | #include "stat-util.h" | |||
13 | #include "string-util.h" | |||
14 | #include "strv.h" | |||
15 | #include "util.h" | |||
16 | ||||
17 | #define test_path_compare(a, b, result){ do { if ((__builtin_expect(!!(!(path_compare(a, b) == result )),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("path_compare(a, b) == result" ), "../src/test/test-path-util.c", 17, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect(!!(!(path_compare(b, a ) == -result)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("path_compare(b, a) == -result"), "../src/test/test-path-util.c" , 17, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(path_equal(a, b) == !result)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("path_equal(a, b) == !result"), "../src/test/test-path-util.c" , 17, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(path_equal(b, a) == !result)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("path_equal(b, a) == !result"), "../src/test/test-path-util.c" , 17, __PRETTY_FUNCTION__); } while (0); } { \ | |||
18 | assert_se(path_compare(a, b) == result)do { if ((__builtin_expect(!!(!(path_compare(a, b) == result) ),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("path_compare(a, b) == result" ), "../src/test/test-path-util.c", 18, __PRETTY_FUNCTION__); } while (0); \ | |||
19 | assert_se(path_compare(b, a) == -result)do { if ((__builtin_expect(!!(!(path_compare(b, a) == -result )),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("path_compare(b, a) == -result" ), "../src/test/test-path-util.c", 19, __PRETTY_FUNCTION__); } while (0); \ | |||
20 | assert_se(path_equal(a, b) == !result)do { if ((__builtin_expect(!!(!(path_equal(a, b) == !result)) ,0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("path_equal(a, b) == !result" ), "../src/test/test-path-util.c", 20, __PRETTY_FUNCTION__); } while (0); \ | |||
21 | assert_se(path_equal(b, a) == !result)do { if ((__builtin_expect(!!(!(path_equal(b, a) == !result)) ,0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("path_equal(b, a) == !result" ), "../src/test/test-path-util.c", 21, __PRETTY_FUNCTION__); } while (0); \ | |||
22 | } | |||
23 | ||||
24 | static void test_path_simplify(const char *in, const char *out, const char *out_dot) { | |||
25 | char *p; | |||
26 | ||||
27 | p = strdupa(in)(__extension__ ({ const char *__old = (in); size_t __len = strlen (__old) + 1; char *__new = (char *) __builtin_alloca (__len) ; (char *) memcpy (__new, __old, __len); })); | |||
28 | assert_se(streq(path_simplify(p, false), out))do { if ((__builtin_expect(!!(!((strcmp((path_simplify(p, 0)) ,(out)) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(path_simplify(p, false), out)"), "../src/test/test-path-util.c" , 28, __PRETTY_FUNCTION__); } while (0); | |||
29 | ||||
30 | p = strdupa(in)(__extension__ ({ const char *__old = (in); size_t __len = strlen (__old) + 1; char *__new = (char *) __builtin_alloca (__len) ; (char *) memcpy (__new, __old, __len); })); | |||
31 | assert_se(streq(path_simplify(p, true), out_dot))do { if ((__builtin_expect(!!(!((strcmp((path_simplify(p, 1)) ,(out_dot)) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(path_simplify(p, true), out_dot)"), "../src/test/test-path-util.c" , 31, __PRETTY_FUNCTION__); } while (0); | |||
32 | } | |||
33 | ||||
34 | static void test_path(void) { | |||
35 | _cleanup_close___attribute__((cleanup(closep))) int fd = -1; | |||
36 | ||||
37 | test_path_compare("/goo", "/goo", 0){ do { if ((__builtin_expect(!!(!(path_compare("/goo", "/goo" ) == 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("path_compare(\"/goo\", \"/goo\") == 0" ), "../src/test/test-path-util.c", 37, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect(!!(!(path_compare("/goo" , "/goo") == -0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("path_compare(\"/goo\", \"/goo\") == -0"), "../src/test/test-path-util.c" , 37, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(path_equal("/goo", "/goo") == !0)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("path_equal(\"/goo\", \"/goo\") == !0"), "../src/test/test-path-util.c", 37, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect(!!(!(path_equal("/goo", "/goo" ) == !0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("path_equal(\"/goo\", \"/goo\") == !0" ), "../src/test/test-path-util.c", 37, __PRETTY_FUNCTION__); } while (0); }; | |||
38 | test_path_compare("/goo", "/goo", 0){ do { if ((__builtin_expect(!!(!(path_compare("/goo", "/goo" ) == 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("path_compare(\"/goo\", \"/goo\") == 0" ), "../src/test/test-path-util.c", 38, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect(!!(!(path_compare("/goo" , "/goo") == -0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("path_compare(\"/goo\", \"/goo\") == -0"), "../src/test/test-path-util.c" , 38, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(path_equal("/goo", "/goo") == !0)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("path_equal(\"/goo\", \"/goo\") == !0"), "../src/test/test-path-util.c", 38, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect(!!(!(path_equal("/goo", "/goo" ) == !0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("path_equal(\"/goo\", \"/goo\") == !0" ), "../src/test/test-path-util.c", 38, __PRETTY_FUNCTION__); } while (0); }; | |||
39 | test_path_compare("//goo", "/goo", 0){ do { if ((__builtin_expect(!!(!(path_compare("//goo", "/goo" ) == 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("path_compare(\"//goo\", \"/goo\") == 0" ), "../src/test/test-path-util.c", 39, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect(!!(!(path_compare("/goo" , "//goo") == -0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("path_compare(\"/goo\", \"//goo\") == -0"), "../src/test/test-path-util.c" , 39, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(path_equal("//goo", "/goo") == !0)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("path_equal(\"//goo\", \"/goo\") == !0") , "../src/test/test-path-util.c", 39, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect(!!(!(path_equal("/goo" , "//goo") == !0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("path_equal(\"/goo\", \"//goo\") == !0"), "../src/test/test-path-util.c" , 39, __PRETTY_FUNCTION__); } while (0); }; | |||
40 | test_path_compare("//goo/////", "/goo", 0){ do { if ((__builtin_expect(!!(!(path_compare("//goo/////", "/goo" ) == 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("path_compare(\"//goo/////\", \"/goo\") == 0" ), "../src/test/test-path-util.c", 40, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect(!!(!(path_compare("/goo" , "//goo/////") == -0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("path_compare(\"/goo\", \"//goo/////\") == -0"), "../src/test/test-path-util.c" , 40, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(path_equal("//goo/////", "/goo") == !0)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("path_equal(\"//goo/////\", \"/goo\") == !0" ), "../src/test/test-path-util.c", 40, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect(!!(!(path_equal("/goo" , "//goo/////") == !0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("path_equal(\"/goo\", \"//goo/////\") == !0"), "../src/test/test-path-util.c" , 40, __PRETTY_FUNCTION__); } while (0); }; | |||
41 | test_path_compare("goo/////", "goo", 0){ do { if ((__builtin_expect(!!(!(path_compare("goo/////", "goo" ) == 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("path_compare(\"goo/////\", \"goo\") == 0" ), "../src/test/test-path-util.c", 41, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect(!!(!(path_compare("goo" , "goo/////") == -0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("path_compare(\"goo\", \"goo/////\") == -0"), "../src/test/test-path-util.c" , 41, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(path_equal("goo/////", "goo") == !0)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("path_equal(\"goo/////\", \"goo\") == !0" ), "../src/test/test-path-util.c", 41, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect(!!(!(path_equal("goo", "goo/////") == !0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("path_equal(\"goo\", \"goo/////\") == !0"), "../src/test/test-path-util.c" , 41, __PRETTY_FUNCTION__); } while (0); }; | |||
42 | ||||
43 | test_path_compare("/goo/boo", "/goo//boo", 0){ do { if ((__builtin_expect(!!(!(path_compare("/goo/boo", "/goo//boo" ) == 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("path_compare(\"/goo/boo\", \"/goo//boo\") == 0" ), "../src/test/test-path-util.c", 43, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect(!!(!(path_compare("/goo//boo" , "/goo/boo") == -0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("path_compare(\"/goo//boo\", \"/goo/boo\") == -0"), "../src/test/test-path-util.c" , 43, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(path_equal("/goo/boo", "/goo//boo") == !0)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("path_equal(\"/goo/boo\", \"/goo//boo\") == !0" ), "../src/test/test-path-util.c", 43, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect(!!(!(path_equal("/goo//boo" , "/goo/boo") == !0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("path_equal(\"/goo//boo\", \"/goo/boo\") == !0"), "../src/test/test-path-util.c" , 43, __PRETTY_FUNCTION__); } while (0); }; | |||
44 | test_path_compare("//goo/boo", "/goo/boo//", 0){ do { if ((__builtin_expect(!!(!(path_compare("//goo/boo", "/goo/boo//" ) == 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("path_compare(\"//goo/boo\", \"/goo/boo//\") == 0" ), "../src/test/test-path-util.c", 44, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect(!!(!(path_compare("/goo/boo//" , "//goo/boo") == -0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("path_compare(\"/goo/boo//\", \"//goo/boo\") == -0"), "../src/test/test-path-util.c" , 44, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(path_equal("//goo/boo", "/goo/boo//") == !0)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("path_equal(\"//goo/boo\", \"/goo/boo//\") == !0" ), "../src/test/test-path-util.c", 44, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect(!!(!(path_equal("/goo/boo//" , "//goo/boo") == !0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("path_equal(\"/goo/boo//\", \"//goo/boo\") == !0"), "../src/test/test-path-util.c" , 44, __PRETTY_FUNCTION__); } while (0); }; | |||
45 | ||||
46 | test_path_compare("/", "///", 0){ do { if ((__builtin_expect(!!(!(path_compare("/", "///") == 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("path_compare(\"/\", \"///\") == 0" ), "../src/test/test-path-util.c", 46, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect(!!(!(path_compare("///" , "/") == -0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("path_compare(\"///\", \"/\") == -0"), "../src/test/test-path-util.c" , 46, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(path_equal("/", "///") == !0)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("path_equal(\"/\", \"///\") == !0"), "../src/test/test-path-util.c" , 46, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(path_equal("///", "/") == !0)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("path_equal(\"///\", \"/\") == !0"), "../src/test/test-path-util.c" , 46, __PRETTY_FUNCTION__); } while (0); }; | |||
47 | ||||
48 | test_path_compare("/x", "x/", 1){ do { if ((__builtin_expect(!!(!(path_compare("/x", "x/") == 1)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("path_compare(\"/x\", \"x/\") == 1" ), "../src/test/test-path-util.c", 48, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect(!!(!(path_compare("x/" , "/x") == -1)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("path_compare(\"x/\", \"/x\") == -1"), "../src/test/test-path-util.c" , 48, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(path_equal("/x", "x/") == !1)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("path_equal(\"/x\", \"x/\") == !1"), "../src/test/test-path-util.c" , 48, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(path_equal("x/", "/x") == !1)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("path_equal(\"x/\", \"/x\") == !1"), "../src/test/test-path-util.c" , 48, __PRETTY_FUNCTION__); } while (0); }; | |||
49 | test_path_compare("x/", "/", -1){ do { if ((__builtin_expect(!!(!(path_compare("x/", "/") == - 1)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("path_compare(\"x/\", \"/\") == -1" ), "../src/test/test-path-util.c", 49, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect(!!(!(path_compare("/", "x/") == - -1)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("path_compare(\"/\", \"x/\") == --1"), "../src/test/test-path-util.c" , 49, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(path_equal("x/", "/") == !-1)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("path_equal(\"x/\", \"/\") == !-1"), "../src/test/test-path-util.c" , 49, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(path_equal("/", "x/") == !-1)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("path_equal(\"/\", \"x/\") == !-1"), "../src/test/test-path-util.c" , 49, __PRETTY_FUNCTION__); } while (0); }; | |||
50 | ||||
51 | test_path_compare("/x/./y", "x/y", 1){ do { if ((__builtin_expect(!!(!(path_compare("/x/./y", "x/y" ) == 1)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("path_compare(\"/x/./y\", \"x/y\") == 1" ), "../src/test/test-path-util.c", 51, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect(!!(!(path_compare("x/y" , "/x/./y") == -1)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("path_compare(\"x/y\", \"/x/./y\") == -1"), "../src/test/test-path-util.c" , 51, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(path_equal("/x/./y", "x/y") == !1)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("path_equal(\"/x/./y\", \"x/y\") == !1") , "../src/test/test-path-util.c", 51, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect(!!(!(path_equal("x/y", "/x/./y") == !1)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("path_equal(\"x/y\", \"/x/./y\") == !1"), "../src/test/test-path-util.c" , 51, __PRETTY_FUNCTION__); } while (0); }; | |||
52 | test_path_compare("x/.y", "x/y", -1){ do { if ((__builtin_expect(!!(!(path_compare("x/.y", "x/y") == -1)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("path_compare(\"x/.y\", \"x/y\") == -1" ), "../src/test/test-path-util.c", 52, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect(!!(!(path_compare("x/y" , "x/.y") == - -1)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("path_compare(\"x/y\", \"x/.y\") == --1"), "../src/test/test-path-util.c" , 52, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(path_equal("x/.y", "x/y") == !-1)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("path_equal(\"x/.y\", \"x/y\") == !-1"), "../src/test/test-path-util.c", 52, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect(!!(!(path_equal("x/y", "x/.y" ) == !-1)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("path_equal(\"x/y\", \"x/.y\") == !-1" ), "../src/test/test-path-util.c", 52, __PRETTY_FUNCTION__); } while (0); }; | |||
53 | ||||
54 | test_path_compare("foo", "/foo", -1){ do { if ((__builtin_expect(!!(!(path_compare("foo", "/foo") == -1)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("path_compare(\"foo\", \"/foo\") == -1" ), "../src/test/test-path-util.c", 54, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect(!!(!(path_compare("/foo" , "foo") == - -1)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("path_compare(\"/foo\", \"foo\") == --1"), "../src/test/test-path-util.c" , 54, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(path_equal("foo", "/foo") == !-1)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("path_equal(\"foo\", \"/foo\") == !-1"), "../src/test/test-path-util.c", 54, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect(!!(!(path_equal("/foo", "foo" ) == !-1)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("path_equal(\"/foo\", \"foo\") == !-1" ), "../src/test/test-path-util.c", 54, __PRETTY_FUNCTION__); } while (0); }; | |||
55 | test_path_compare("/foo", "/foo/bar", -1){ do { if ((__builtin_expect(!!(!(path_compare("/foo", "/foo/bar" ) == -1)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("path_compare(\"/foo\", \"/foo/bar\") == -1" ), "../src/test/test-path-util.c", 55, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect(!!(!(path_compare("/foo/bar" , "/foo") == - -1)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("path_compare(\"/foo/bar\", \"/foo\") == --1"), "../src/test/test-path-util.c" , 55, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(path_equal("/foo", "/foo/bar") == !-1)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("path_equal(\"/foo\", \"/foo/bar\") == !-1" ), "../src/test/test-path-util.c", 55, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect(!!(!(path_equal("/foo/bar" , "/foo") == !-1)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("path_equal(\"/foo/bar\", \"/foo\") == !-1"), "../src/test/test-path-util.c" , 55, __PRETTY_FUNCTION__); } while (0); }; | |||
56 | test_path_compare("/foo/aaa", "/foo/b", -1){ do { if ((__builtin_expect(!!(!(path_compare("/foo/aaa", "/foo/b" ) == -1)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("path_compare(\"/foo/aaa\", \"/foo/b\") == -1" ), "../src/test/test-path-util.c", 56, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect(!!(!(path_compare("/foo/b" , "/foo/aaa") == - -1)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("path_compare(\"/foo/b\", \"/foo/aaa\") == --1"), "../src/test/test-path-util.c" , 56, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(path_equal("/foo/aaa", "/foo/b") == !-1)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("path_equal(\"/foo/aaa\", \"/foo/b\") == !-1" ), "../src/test/test-path-util.c", 56, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect(!!(!(path_equal("/foo/b" , "/foo/aaa") == !-1)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("path_equal(\"/foo/b\", \"/foo/aaa\") == !-1"), "../src/test/test-path-util.c" , 56, __PRETTY_FUNCTION__); } while (0); }; | |||
57 | test_path_compare("/foo/aaa", "/foo/b/a", -1){ do { if ((__builtin_expect(!!(!(path_compare("/foo/aaa", "/foo/b/a" ) == -1)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("path_compare(\"/foo/aaa\", \"/foo/b/a\") == -1" ), "../src/test/test-path-util.c", 57, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect(!!(!(path_compare("/foo/b/a" , "/foo/aaa") == - -1)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("path_compare(\"/foo/b/a\", \"/foo/aaa\") == --1"), "../src/test/test-path-util.c" , 57, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(path_equal("/foo/aaa", "/foo/b/a") == !-1)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("path_equal(\"/foo/aaa\", \"/foo/b/a\") == !-1" ), "../src/test/test-path-util.c", 57, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect(!!(!(path_equal("/foo/b/a" , "/foo/aaa") == !-1)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("path_equal(\"/foo/b/a\", \"/foo/aaa\") == !-1"), "../src/test/test-path-util.c" , 57, __PRETTY_FUNCTION__); } while (0); }; | |||
58 | test_path_compare("/foo/a", "/foo/aaa", -1){ do { if ((__builtin_expect(!!(!(path_compare("/foo/a", "/foo/aaa" ) == -1)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("path_compare(\"/foo/a\", \"/foo/aaa\") == -1" ), "../src/test/test-path-util.c", 58, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect(!!(!(path_compare("/foo/aaa" , "/foo/a") == - -1)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("path_compare(\"/foo/aaa\", \"/foo/a\") == --1"), "../src/test/test-path-util.c" , 58, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(path_equal("/foo/a", "/foo/aaa") == !-1)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("path_equal(\"/foo/a\", \"/foo/aaa\") == !-1" ), "../src/test/test-path-util.c", 58, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect(!!(!(path_equal("/foo/aaa" , "/foo/a") == !-1)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("path_equal(\"/foo/aaa\", \"/foo/a\") == !-1"), "../src/test/test-path-util.c" , 58, __PRETTY_FUNCTION__); } while (0); }; | |||
59 | test_path_compare("/foo/a/b", "/foo/aaa", -1){ do { if ((__builtin_expect(!!(!(path_compare("/foo/a/b", "/foo/aaa" ) == -1)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("path_compare(\"/foo/a/b\", \"/foo/aaa\") == -1" ), "../src/test/test-path-util.c", 59, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect(!!(!(path_compare("/foo/aaa" , "/foo/a/b") == - -1)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("path_compare(\"/foo/aaa\", \"/foo/a/b\") == --1"), "../src/test/test-path-util.c" , 59, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(path_equal("/foo/a/b", "/foo/aaa") == !-1)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("path_equal(\"/foo/a/b\", \"/foo/aaa\") == !-1" ), "../src/test/test-path-util.c", 59, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect(!!(!(path_equal("/foo/aaa" , "/foo/a/b") == !-1)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("path_equal(\"/foo/aaa\", \"/foo/a/b\") == !-1"), "../src/test/test-path-util.c" , 59, __PRETTY_FUNCTION__); } while (0); }; | |||
60 | ||||
61 | assert_se(path_is_absolute("/"))do { if ((__builtin_expect(!!(!(path_is_absolute("/"))),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("path_is_absolute(\"/\")"), "../src/test/test-path-util.c" , 61, __PRETTY_FUNCTION__); } while (0); | |||
62 | assert_se(!path_is_absolute("./"))do { if ((__builtin_expect(!!(!(!path_is_absolute("./"))),0)) ) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("!path_is_absolute(\"./\")" ), "../src/test/test-path-util.c", 62, __PRETTY_FUNCTION__); } while (0); | |||
63 | ||||
64 | assert_se(is_path("/dir"))do { if ((__builtin_expect(!!(!(is_path("/dir"))),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("is_path(\"/dir\")"), "../src/test/test-path-util.c" , 64, __PRETTY_FUNCTION__); } while (0); | |||
65 | assert_se(is_path("a/b"))do { if ((__builtin_expect(!!(!(is_path("a/b"))),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("is_path(\"a/b\")"), "../src/test/test-path-util.c" , 65, __PRETTY_FUNCTION__); } while (0); | |||
66 | assert_se(!is_path("."))do { if ((__builtin_expect(!!(!(!is_path("."))),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("!is_path(\".\")"), "../src/test/test-path-util.c" , 66, __PRETTY_FUNCTION__); } while (0); | |||
67 | ||||
68 | assert_se(streq(basename("./aa/bb/../file.da."), "file.da."))do { if ((__builtin_expect(!!(!((strcmp((basename("./aa/bb/../file.da." )),("file.da.")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(basename(\"./aa/bb/../file.da.\"), \"file.da.\")"), "../src/test/test-path-util.c", 68, __PRETTY_FUNCTION__); } while (0); | |||
69 | assert_se(streq(basename("/aa///.file"), ".file"))do { if ((__builtin_expect(!!(!((strcmp((basename("/aa///.file" )),(".file")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(basename(\"/aa///.file\"), \".file\")"), "../src/test/test-path-util.c" , 69, __PRETTY_FUNCTION__); } while (0); | |||
70 | assert_se(streq(basename("/aa///file..."), "file..."))do { if ((__builtin_expect(!!(!((strcmp((basename("/aa///file..." )),("file...")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(basename(\"/aa///file...\"), \"file...\")"), "../src/test/test-path-util.c" , 70, __PRETTY_FUNCTION__); } while (0); | |||
71 | assert_se(streq(basename("file.../"), ""))do { if ((__builtin_expect(!!(!((strcmp((basename("file.../") ),("")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(basename(\"file.../\"), \"\")"), "../src/test/test-path-util.c" , 71, __PRETTY_FUNCTION__); } while (0); | |||
72 | ||||
73 | fd = open("/", O_RDONLY00|O_CLOEXEC02000000|O_DIRECTORY0200000|O_NOCTTY0400); | |||
74 | assert_se(fd >= 0)do { if ((__builtin_expect(!!(!(fd >= 0)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("fd >= 0"), "../src/test/test-path-util.c" , 74, __PRETTY_FUNCTION__); } while (0); | |||
75 | assert_se(fd_is_mount_point(fd, "/", 0) > 0)do { if ((__builtin_expect(!!(!(fd_is_mount_point(fd, "/", 0) > 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("fd_is_mount_point(fd, \"/\", 0) > 0" ), "../src/test/test-path-util.c", 75, __PRETTY_FUNCTION__); } while (0); | |||
76 | ||||
77 | test_path_simplify("aaa/bbb////ccc", "aaa/bbb/ccc", "aaa/bbb/ccc"); | |||
78 | test_path_simplify("//aaa/.////ccc", "/aaa/./ccc", "/aaa/ccc"); | |||
79 | test_path_simplify("///", "/", "/"); | |||
80 | test_path_simplify("///.//", "/.", "/"); | |||
81 | test_path_simplify("///.//.///", "/./.", "/"); | |||
82 | test_path_simplify("////.././///../.", "/.././../.", "/../.."); | |||
83 | test_path_simplify(".", ".", ""); | |||
84 | test_path_simplify("./", ".", ""); | |||
85 | test_path_simplify(".///.//./.", "./././.", ""); | |||
86 | test_path_simplify(".///.//././/", "./././.", ""); | |||
87 | test_path_simplify("//./aaa///.//./.bbb/..///c.//d.dd///..eeee/.", | |||
88 | "/./aaa/././.bbb/../c./d.dd/..eeee/.", | |||
89 | "/aaa/.bbb/../c./d.dd/..eeee"); | |||
90 | test_path_simplify("//./aaa///.//./.bbb/..///c.//d.dd///..eeee/..", | |||
91 | "/./aaa/././.bbb/../c./d.dd/..eeee/..", | |||
92 | "/aaa/.bbb/../c./d.dd/..eeee/.."); | |||
93 | test_path_simplify(".//./aaa///.//./.bbb/..///c.//d.dd///..eeee/..", | |||
94 | "././aaa/././.bbb/../c./d.dd/..eeee/..", | |||
95 | "aaa/.bbb/../c./d.dd/..eeee/.."); | |||
96 | test_path_simplify("..//./aaa///.//./.bbb/..///c.//d.dd///..eeee/..", | |||
97 | ".././aaa/././.bbb/../c./d.dd/..eeee/..", | |||
98 | "../aaa/.bbb/../c./d.dd/..eeee/.."); | |||
99 | ||||
100 | assert_se(PATH_IN_SET("/bin", "/", "/bin", "/foo"))do { if ((__builtin_expect(!!(!(({ char **s; _Bool _found = 0 ; for ((s) = (((char**) ((const char*[]) { "/", "/bin", "/foo" , ((void*)0) }))); (s) && *(s); (s)++) if (path_equal ("/bin", *s)) { _found = 1; break; } _found; }))),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("PATH_IN_SET(\"/bin\", \"/\", \"/bin\", \"/foo\")" ), "../src/test/test-path-util.c", 100, __PRETTY_FUNCTION__); } while (0); | |||
101 | assert_se(PATH_IN_SET("/bin", "/bin"))do { if ((__builtin_expect(!!(!(({ char **s; _Bool _found = 0 ; for ((s) = (((char**) ((const char*[]) { "/bin", ((void*)0) }))); (s) && *(s); (s)++) if (path_equal("/bin", *s) ) { _found = 1; break; } _found; }))),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("PATH_IN_SET(\"/bin\", \"/bin\")"), "../src/test/test-path-util.c" , 101, __PRETTY_FUNCTION__); } while (0); | |||
102 | assert_se(PATH_IN_SET("/bin", "/foo/bar", "/bin"))do { if ((__builtin_expect(!!(!(({ char **s; _Bool _found = 0 ; for ((s) = (((char**) ((const char*[]) { "/foo/bar", "/bin" , ((void*)0) }))); (s) && *(s); (s)++) if (path_equal ("/bin", *s)) { _found = 1; break; } _found; }))),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("PATH_IN_SET(\"/bin\", \"/foo/bar\", \"/bin\")" ), "../src/test/test-path-util.c", 102, __PRETTY_FUNCTION__); } while (0); | |||
103 | assert_se(PATH_IN_SET("/", "/", "/", "/foo/bar"))do { if ((__builtin_expect(!!(!(({ char **s; _Bool _found = 0 ; for ((s) = (((char**) ((const char*[]) { "/", "/", "/foo/bar" , ((void*)0) }))); (s) && *(s); (s)++) if (path_equal ("/", *s)) { _found = 1; break; } _found; }))),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("PATH_IN_SET(\"/\", \"/\", \"/\", \"/foo/bar\")" ), "../src/test/test-path-util.c", 103, __PRETTY_FUNCTION__); } while (0); | |||
104 | assert_se(!PATH_IN_SET("/", "/abc", "/def"))do { if ((__builtin_expect(!!(!(!({ char **s; _Bool _found = 0 ; for ((s) = (((char**) ((const char*[]) { "/abc", "/def", (( void*)0) }))); (s) && *(s); (s)++) if (path_equal("/" , *s)) { _found = 1; break; } _found; }))),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("!PATH_IN_SET(\"/\", \"/abc\", \"/def\")" ), "../src/test/test-path-util.c", 104, __PRETTY_FUNCTION__); } while (0); | |||
105 | ||||
106 | assert_se(path_equal_ptr(NULL, NULL))do { if ((__builtin_expect(!!(!(path_equal_ptr(((void*)0), (( void*)0)))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ( "path_equal_ptr(NULL, NULL)"), "../src/test/test-path-util.c" , 106, __PRETTY_FUNCTION__); } while (0); | |||
107 | assert_se(path_equal_ptr("/a", "/a"))do { if ((__builtin_expect(!!(!(path_equal_ptr("/a", "/a"))), 0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("path_equal_ptr(\"/a\", \"/a\")" ), "../src/test/test-path-util.c", 107, __PRETTY_FUNCTION__); } while (0); | |||
108 | assert_se(!path_equal_ptr("/a", "/b"))do { if ((__builtin_expect(!!(!(!path_equal_ptr("/a", "/b"))) ,0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("!path_equal_ptr(\"/a\", \"/b\")" ), "../src/test/test-path-util.c", 108, __PRETTY_FUNCTION__); } while (0); | |||
109 | assert_se(!path_equal_ptr("/a", NULL))do { if ((__builtin_expect(!!(!(!path_equal_ptr("/a", ((void* )0)))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("!path_equal_ptr(\"/a\", NULL)" ), "../src/test/test-path-util.c", 109, __PRETTY_FUNCTION__); } while (0); | |||
110 | assert_se(!path_equal_ptr(NULL, "/a"))do { if ((__builtin_expect(!!(!(!path_equal_ptr(((void*)0), "/a" ))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("!path_equal_ptr(NULL, \"/a\")" ), "../src/test/test-path-util.c", 110, __PRETTY_FUNCTION__); } while (0); | |||
111 | } | |||
112 | ||||
113 | static void test_path_equal_root(void) { | |||
114 | /* Nail down the details of how path_equal("/", ...) works. */ | |||
115 | ||||
116 | assert_se(path_equal("/", "/"))do { if ((__builtin_expect(!!(!(path_equal("/", "/"))),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("path_equal(\"/\", \"/\")"), "../src/test/test-path-util.c" , 116, __PRETTY_FUNCTION__); } while (0); | |||
117 | assert_se(path_equal("/", "//"))do { if ((__builtin_expect(!!(!(path_equal("/", "//"))),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("path_equal(\"/\", \"//\")"), "../src/test/test-path-util.c" , 117, __PRETTY_FUNCTION__); } while (0); | |||
118 | ||||
119 | assert_se(!path_equal("/", "/./"))do { if ((__builtin_expect(!!(!(!path_equal("/", "/./"))),0)) ) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("!path_equal(\"/\", \"/./\")" ), "../src/test/test-path-util.c", 119, __PRETTY_FUNCTION__); } while (0); | |||
120 | assert_se(!path_equal("/", "/../"))do { if ((__builtin_expect(!!(!(!path_equal("/", "/../"))),0) )) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("!path_equal(\"/\", \"/../\")" ), "../src/test/test-path-util.c", 120, __PRETTY_FUNCTION__); } while (0); | |||
121 | ||||
122 | assert_se(!path_equal("/", "/.../"))do { if ((__builtin_expect(!!(!(!path_equal("/", "/.../"))),0 ))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("!path_equal(\"/\", \"/.../\")" ), "../src/test/test-path-util.c", 122, __PRETTY_FUNCTION__); } while (0); | |||
123 | ||||
124 | /* Make sure that files_same works as expected. */ | |||
125 | ||||
126 | assert_se(files_same("/", "/", 0) > 0)do { if ((__builtin_expect(!!(!(files_same("/", "/", 0) > 0 )),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("files_same(\"/\", \"/\", 0) > 0" ), "../src/test/test-path-util.c", 126, __PRETTY_FUNCTION__); } while (0); | |||
127 | assert_se(files_same("/", "/", AT_SYMLINK_NOFOLLOW) > 0)do { if ((__builtin_expect(!!(!(files_same("/", "/", 0x100) > 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("files_same(\"/\", \"/\", AT_SYMLINK_NOFOLLOW) > 0" ), "../src/test/test-path-util.c", 127, __PRETTY_FUNCTION__); } while (0); | |||
128 | assert_se(files_same("/", "//", 0) > 0)do { if ((__builtin_expect(!!(!(files_same("/", "//", 0) > 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("files_same(\"/\", \"//\", 0) > 0" ), "../src/test/test-path-util.c", 128, __PRETTY_FUNCTION__); } while (0); | |||
129 | assert_se(files_same("/", "//", AT_SYMLINK_NOFOLLOW) > 0)do { if ((__builtin_expect(!!(!(files_same("/", "//", 0x100) > 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("files_same(\"/\", \"//\", AT_SYMLINK_NOFOLLOW) > 0" ), "../src/test/test-path-util.c", 129, __PRETTY_FUNCTION__); } while (0); | |||
130 | ||||
131 | assert_se(files_same("/", "/./", 0) > 0)do { if ((__builtin_expect(!!(!(files_same("/", "/./", 0) > 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("files_same(\"/\", \"/./\", 0) > 0" ), "../src/test/test-path-util.c", 131, __PRETTY_FUNCTION__); } while (0); | |||
132 | assert_se(files_same("/", "/./", AT_SYMLINK_NOFOLLOW) > 0)do { if ((__builtin_expect(!!(!(files_same("/", "/./", 0x100) > 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("files_same(\"/\", \"/./\", AT_SYMLINK_NOFOLLOW) > 0" ), "../src/test/test-path-util.c", 132, __PRETTY_FUNCTION__); } while (0); | |||
133 | assert_se(files_same("/", "/../", 0) > 0)do { if ((__builtin_expect(!!(!(files_same("/", "/../", 0) > 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("files_same(\"/\", \"/../\", 0) > 0" ), "../src/test/test-path-util.c", 133, __PRETTY_FUNCTION__); } while (0); | |||
134 | assert_se(files_same("/", "/../", AT_SYMLINK_NOFOLLOW) > 0)do { if ((__builtin_expect(!!(!(files_same("/", "/../", 0x100 ) > 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("files_same(\"/\", \"/../\", AT_SYMLINK_NOFOLLOW) > 0" ), "../src/test/test-path-util.c", 134, __PRETTY_FUNCTION__); } while (0); | |||
135 | ||||
136 | assert_se(files_same("/", "/.../", 0) == -ENOENT)do { if ((__builtin_expect(!!(!(files_same("/", "/.../", 0) == -2)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("files_same(\"/\", \"/.../\", 0) == -ENOENT" ), "../src/test/test-path-util.c", 136, __PRETTY_FUNCTION__); } while (0); | |||
137 | assert_se(files_same("/", "/.../", AT_SYMLINK_NOFOLLOW) == -ENOENT)do { if ((__builtin_expect(!!(!(files_same("/", "/.../", 0x100 ) == -2)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("files_same(\"/\", \"/.../\", AT_SYMLINK_NOFOLLOW) == -ENOENT" ), "../src/test/test-path-util.c", 137, __PRETTY_FUNCTION__); } while (0); | |||
138 | ||||
139 | /* The same for path_equal_or_files_same. */ | |||
140 | ||||
141 | assert_se(path_equal_or_files_same("/", "/", 0))do { if ((__builtin_expect(!!(!(path_equal_or_files_same("/", "/", 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("path_equal_or_files_same(\"/\", \"/\", 0)" ), "../src/test/test-path-util.c", 141, __PRETTY_FUNCTION__); } while (0); | |||
142 | assert_se(path_equal_or_files_same("/", "/", AT_SYMLINK_NOFOLLOW))do { if ((__builtin_expect(!!(!(path_equal_or_files_same("/", "/", 0x100))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("path_equal_or_files_same(\"/\", \"/\", AT_SYMLINK_NOFOLLOW)" ), "../src/test/test-path-util.c", 142, __PRETTY_FUNCTION__); } while (0); | |||
143 | assert_se(path_equal_or_files_same("/", "//", 0))do { if ((__builtin_expect(!!(!(path_equal_or_files_same("/", "//", 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ( "path_equal_or_files_same(\"/\", \"//\", 0)"), "../src/test/test-path-util.c" , 143, __PRETTY_FUNCTION__); } while (0); | |||
144 | assert_se(path_equal_or_files_same("/", "//", AT_SYMLINK_NOFOLLOW))do { if ((__builtin_expect(!!(!(path_equal_or_files_same("/", "//", 0x100))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("path_equal_or_files_same(\"/\", \"//\", AT_SYMLINK_NOFOLLOW)" ), "../src/test/test-path-util.c", 144, __PRETTY_FUNCTION__); } while (0); | |||
145 | ||||
146 | assert_se(path_equal_or_files_same("/", "/./", 0))do { if ((__builtin_expect(!!(!(path_equal_or_files_same("/", "/./", 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ( "path_equal_or_files_same(\"/\", \"/./\", 0)"), "../src/test/test-path-util.c" , 146, __PRETTY_FUNCTION__); } while (0); | |||
147 | assert_se(path_equal_or_files_same("/", "/./", AT_SYMLINK_NOFOLLOW))do { if ((__builtin_expect(!!(!(path_equal_or_files_same("/", "/./", 0x100))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("path_equal_or_files_same(\"/\", \"/./\", AT_SYMLINK_NOFOLLOW)" ), "../src/test/test-path-util.c", 147, __PRETTY_FUNCTION__); } while (0); | |||
148 | assert_se(path_equal_or_files_same("/", "/../", 0))do { if ((__builtin_expect(!!(!(path_equal_or_files_same("/", "/../", 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("path_equal_or_files_same(\"/\", \"/../\", 0)"), "../src/test/test-path-util.c" , 148, __PRETTY_FUNCTION__); } while (0); | |||
149 | assert_se(path_equal_or_files_same("/", "/../", AT_SYMLINK_NOFOLLOW))do { if ((__builtin_expect(!!(!(path_equal_or_files_same("/", "/../", 0x100))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("path_equal_or_files_same(\"/\", \"/../\", AT_SYMLINK_NOFOLLOW)" ), "../src/test/test-path-util.c", 149, __PRETTY_FUNCTION__); } while (0); | |||
150 | ||||
151 | assert_se(!path_equal_or_files_same("/", "/.../", 0))do { if ((__builtin_expect(!!(!(!path_equal_or_files_same("/" , "/.../", 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("!path_equal_or_files_same(\"/\", \"/.../\", 0)"), "../src/test/test-path-util.c" , 151, __PRETTY_FUNCTION__); } while (0); | |||
152 | assert_se(!path_equal_or_files_same("/", "/.../", AT_SYMLINK_NOFOLLOW))do { if ((__builtin_expect(!!(!(!path_equal_or_files_same("/" , "/.../", 0x100))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("!path_equal_or_files_same(\"/\", \"/.../\", AT_SYMLINK_NOFOLLOW)" ), "../src/test/test-path-util.c", 152, __PRETTY_FUNCTION__); } while (0); | |||
153 | } | |||
154 | ||||
155 | static void test_find_binary(const char *self) { | |||
156 | char *p; | |||
157 | ||||
158 | assert_se(find_binary("/bin/sh", &p) == 0)do { if ((__builtin_expect(!!(!(find_binary("/bin/sh", &p ) == 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("find_binary(\"/bin/sh\", &p) == 0" ), "../src/test/test-path-util.c", 158, __PRETTY_FUNCTION__); } while (0); | |||
159 | puts(p); | |||
160 | assert_se(path_equal(p, "/bin/sh"))do { if ((__builtin_expect(!!(!(path_equal(p, "/bin/sh"))),0) )) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("path_equal(p, \"/bin/sh\")" ), "../src/test/test-path-util.c", 160, __PRETTY_FUNCTION__); } while (0); | |||
161 | free(p); | |||
162 | ||||
163 | assert_se(find_binary(self, &p) == 0)do { if ((__builtin_expect(!!(!(find_binary(self, &p) == 0 )),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("find_binary(self, &p) == 0" ), "../src/test/test-path-util.c", 163, __PRETTY_FUNCTION__); } while (0); | |||
164 | puts(p); | |||
165 | /* libtool might prefix the binary name with "lt-" */ | |||
166 | assert_se(endswith(p, "/lt-test-path-util") || endswith(p, "/test-path-util"))do { if ((__builtin_expect(!!(!(endswith(p, "/lt-test-path-util" ) || endswith(p, "/test-path-util"))),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("endswith(p, \"/lt-test-path-util\") || endswith(p, \"/test-path-util\")" ), "../src/test/test-path-util.c", 166, __PRETTY_FUNCTION__); } while (0); | |||
167 | assert_se(path_is_absolute(p))do { if ((__builtin_expect(!!(!(path_is_absolute(p))),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("path_is_absolute(p)"), "../src/test/test-path-util.c" , 167, __PRETTY_FUNCTION__); } while (0); | |||
168 | free(p); | |||
169 | ||||
170 | assert_se(find_binary("sh", &p) == 0)do { if ((__builtin_expect(!!(!(find_binary("sh", &p) == 0 )),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("find_binary(\"sh\", &p) == 0" ), "../src/test/test-path-util.c", 170, __PRETTY_FUNCTION__); } while (0); | |||
171 | puts(p); | |||
172 | assert_se(endswith(p, "/sh"))do { if ((__builtin_expect(!!(!(endswith(p, "/sh"))),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("endswith(p, \"/sh\")"), "../src/test/test-path-util.c" , 172, __PRETTY_FUNCTION__); } while (0); | |||
173 | assert_se(path_is_absolute(p))do { if ((__builtin_expect(!!(!(path_is_absolute(p))),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("path_is_absolute(p)"), "../src/test/test-path-util.c" , 173, __PRETTY_FUNCTION__); } while (0); | |||
174 | free(p); | |||
175 | ||||
176 | assert_se(find_binary("xxxx-xxxx", &p) == -ENOENT)do { if ((__builtin_expect(!!(!(find_binary("xxxx-xxxx", & p) == -2)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("find_binary(\"xxxx-xxxx\", &p) == -ENOENT" ), "../src/test/test-path-util.c", 176, __PRETTY_FUNCTION__); } while (0); | |||
177 | assert_se(find_binary("/some/dir/xxxx-xxxx", &p) == -ENOENT)do { if ((__builtin_expect(!!(!(find_binary("/some/dir/xxxx-xxxx" , &p) == -2)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("find_binary(\"/some/dir/xxxx-xxxx\", &p) == -ENOENT") , "../src/test/test-path-util.c", 177, __PRETTY_FUNCTION__); } while (0); | |||
178 | } | |||
179 | ||||
180 | static void test_prefixes(void) { | |||
181 | static const char* values[] = { "/a/b/c/d", "/a/b/c", "/a/b", "/a", "", NULL((void*)0)}; | |||
182 | unsigned i; | |||
183 | char s[PATH_MAX4096]; | |||
184 | bool_Bool b; | |||
185 | ||||
186 | i = 0; | |||
187 | PATH_FOREACH_PREFIX_MORE(s, "/a/b/c/d")for (char *_slash = ({ path_simplify(strcpy(s, "/a/b/c/d"), 0 ); if ((strcmp((s),("/")) == 0)) s[0] = 0; strrchr(s, 0); }); _slash && ((*_slash = 0), 1); _slash = strrchr((s), '/' )) { | |||
188 | log_error("---%s---", s)({ int _level = (((3))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/test/test-path-util.c", 188, __func__, "---%s---", s ) : -abs(_e); }); | |||
189 | assert_se(streq(s, values[i++]))do { if ((__builtin_expect(!!(!((strcmp((s),(values[i++])) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("streq(s, values[i++])" ), "../src/test/test-path-util.c", 189, __PRETTY_FUNCTION__); } while (0); | |||
190 | } | |||
191 | assert_se(values[i] == NULL)do { if ((__builtin_expect(!!(!(values[i] == ((void*)0))),0)) ) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("values[i] == NULL" ), "../src/test/test-path-util.c", 191, __PRETTY_FUNCTION__); } while (0); | |||
192 | ||||
193 | i = 1; | |||
194 | PATH_FOREACH_PREFIX(s, "/a/b/c/d")for (char *_slash = ({ path_simplify(strcpy(s, "/a/b/c/d"), 0 ); (strcmp((s),("/")) == 0) ? ((void*)0) : strrchr(s, '/'); } ); _slash && ((*_slash = 0), 1); _slash = strrchr((s) , '/')) { | |||
195 | log_error("---%s---", s)({ int _level = (((3))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/test/test-path-util.c", 195, __func__, "---%s---", s ) : -abs(_e); }); | |||
196 | assert_se(streq(s, values[i++]))do { if ((__builtin_expect(!!(!((strcmp((s),(values[i++])) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("streq(s, values[i++])" ), "../src/test/test-path-util.c", 196, __PRETTY_FUNCTION__); } while (0); | |||
197 | } | |||
198 | assert_se(values[i] == NULL)do { if ((__builtin_expect(!!(!(values[i] == ((void*)0))),0)) ) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("values[i] == NULL" ), "../src/test/test-path-util.c", 198, __PRETTY_FUNCTION__); } while (0); | |||
199 | ||||
200 | i = 0; | |||
201 | PATH_FOREACH_PREFIX_MORE(s, "////a////b////c///d///////")for (char *_slash = ({ path_simplify(strcpy(s, "////a////b////c///d///////" ), 0); if ((strcmp((s),("/")) == 0)) s[0] = 0; strrchr(s, 0); }); _slash && ((*_slash = 0), 1); _slash = strrchr(( s), '/')) | |||
202 | assert_se(streq(s, values[i++]))do { if ((__builtin_expect(!!(!((strcmp((s),(values[i++])) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("streq(s, values[i++])" ), "../src/test/test-path-util.c", 202, __PRETTY_FUNCTION__); } while (0); | |||
203 | assert_se(values[i] == NULL)do { if ((__builtin_expect(!!(!(values[i] == ((void*)0))),0)) ) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("values[i] == NULL" ), "../src/test/test-path-util.c", 203, __PRETTY_FUNCTION__); } while (0); | |||
204 | ||||
205 | i = 1; | |||
206 | PATH_FOREACH_PREFIX(s, "////a////b////c///d///////")for (char *_slash = ({ path_simplify(strcpy(s, "////a////b////c///d///////" ), 0); (strcmp((s),("/")) == 0) ? ((void*)0) : strrchr(s, '/' ); }); _slash && ((*_slash = 0), 1); _slash = strrchr ((s), '/')) | |||
207 | assert_se(streq(s, values[i++]))do { if ((__builtin_expect(!!(!((strcmp((s),(values[i++])) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("streq(s, values[i++])" ), "../src/test/test-path-util.c", 207, __PRETTY_FUNCTION__); } while (0); | |||
208 | assert_se(values[i] == NULL)do { if ((__builtin_expect(!!(!(values[i] == ((void*)0))),0)) ) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("values[i] == NULL" ), "../src/test/test-path-util.c", 208, __PRETTY_FUNCTION__); } while (0); | |||
209 | ||||
210 | PATH_FOREACH_PREFIX(s, "////")for (char *_slash = ({ path_simplify(strcpy(s, "////"), 0); ( strcmp((s),("/")) == 0) ? ((void*)0) : strrchr(s, '/'); }); _slash && ((*_slash = 0), 1); _slash = strrchr((s), '/')) | |||
211 | assert_not_reached("Wut?")do { log_assert_failed_unreachable_realm(LOG_REALM_SYSTEMD, ( "Wut?"), "../src/test/test-path-util.c", 211, __PRETTY_FUNCTION__ ); } while (0); | |||
212 | ||||
213 | b = false0; | |||
214 | PATH_FOREACH_PREFIX_MORE(s, "////")for (char *_slash = ({ path_simplify(strcpy(s, "////"), 0); if ((strcmp((s),("/")) == 0)) s[0] = 0; strrchr(s, 0); }); _slash && ((*_slash = 0), 1); _slash = strrchr((s), '/')) { | |||
215 | assert_se(!b)do { if ((__builtin_expect(!!(!(!b)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("!b"), "../src/test/test-path-util.c", 215 , __PRETTY_FUNCTION__); } while (0); | |||
216 | assert_se(streq(s, ""))do { if ((__builtin_expect(!!(!((strcmp((s),("")) == 0))),0)) ) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("streq(s, \"\")" ), "../src/test/test-path-util.c", 216, __PRETTY_FUNCTION__); } while (0); | |||
217 | b = true1; | |||
218 | } | |||
219 | assert_se(b)do { if ((__builtin_expect(!!(!(b)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("b"), "../src/test/test-path-util.c", 219 , __PRETTY_FUNCTION__); } while (0); | |||
220 | ||||
221 | PATH_FOREACH_PREFIX(s, "")for (char *_slash = ({ path_simplify(strcpy(s, ""), 0); (strcmp ((s),("/")) == 0) ? ((void*)0) : strrchr(s, '/'); }); _slash && ((*_slash = 0), 1); _slash = strrchr((s), '/')) | |||
222 | assert_not_reached("wut?")do { log_assert_failed_unreachable_realm(LOG_REALM_SYSTEMD, ( "wut?"), "../src/test/test-path-util.c", 222, __PRETTY_FUNCTION__ ); } while (0); | |||
223 | ||||
224 | b = false0; | |||
225 | PATH_FOREACH_PREFIX_MORE(s, "")for (char *_slash = ({ path_simplify(strcpy(s, ""), 0); if (( strcmp((s),("/")) == 0)) s[0] = 0; strrchr(s, 0); }); _slash && ((*_slash = 0), 1); _slash = strrchr((s), '/')) { | |||
226 | assert_se(!b)do { if ((__builtin_expect(!!(!(!b)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("!b"), "../src/test/test-path-util.c", 226 , __PRETTY_FUNCTION__); } while (0); | |||
227 | assert_se(streq(s, ""))do { if ((__builtin_expect(!!(!((strcmp((s),("")) == 0))),0)) ) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("streq(s, \"\")" ), "../src/test/test-path-util.c", 227, __PRETTY_FUNCTION__); } while (0); | |||
228 | b = true1; | |||
229 | } | |||
230 | } | |||
231 | ||||
232 | static void test_path_join(void) { | |||
233 | ||||
234 | #define test_join(root, path, rest, expected){ __attribute__((cleanup(freep))) char *z = ((void*)0); z = path_join (root, path, rest); do { if ((__builtin_expect(!!(!((strcmp(( z),(expected)) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(z, expected)"), "../src/test/test-path-util.c", 234 , __PRETTY_FUNCTION__); } while (0); } { \ | |||
235 | _cleanup_free___attribute__((cleanup(freep))) char *z = NULL((void*)0); \ | |||
236 | z = path_join(root, path, rest); \ | |||
237 | assert_se(streq(z, expected))do { if ((__builtin_expect(!!(!((strcmp((z),(expected)) == 0) )),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("streq(z, expected)" ), "../src/test/test-path-util.c", 237, __PRETTY_FUNCTION__); } while (0); \ | |||
238 | } | |||
239 | ||||
240 | test_join("/root", "/a/b", "/c", "/root/a/b/c"){ __attribute__((cleanup(freep))) char *z = ((void*)0); z = path_join ("/root", "/a/b", "/c"); do { if ((__builtin_expect(!!(!((strcmp ((z),("/root/a/b/c")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(z, \"/root/a/b/c\")"), "../src/test/test-path-util.c" , 240, __PRETTY_FUNCTION__); } while (0); }; | |||
241 | test_join("/root", "a/b", "c", "/root/a/b/c"){ __attribute__((cleanup(freep))) char *z = ((void*)0); z = path_join ("/root", "a/b", "c"); do { if ((__builtin_expect(!!(!((strcmp ((z),("/root/a/b/c")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(z, \"/root/a/b/c\")"), "../src/test/test-path-util.c" , 241, __PRETTY_FUNCTION__); } while (0); }; | |||
242 | test_join("/root", "/a/b", "c", "/root/a/b/c"){ __attribute__((cleanup(freep))) char *z = ((void*)0); z = path_join ("/root", "/a/b", "c"); do { if ((__builtin_expect(!!(!((strcmp ((z),("/root/a/b/c")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(z, \"/root/a/b/c\")"), "../src/test/test-path-util.c" , 242, __PRETTY_FUNCTION__); } while (0); }; | |||
243 | test_join("/root", "/", "c", "/root/c"){ __attribute__((cleanup(freep))) char *z = ((void*)0); z = path_join ("/root", "/", "c"); do { if ((__builtin_expect(!!(!((strcmp( (z),("/root/c")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(z, \"/root/c\")"), "../src/test/test-path-util.c", 243 , __PRETTY_FUNCTION__); } while (0); }; | |||
244 | test_join("/root", "/", NULL, "/root/"){ __attribute__((cleanup(freep))) char *z = ((void*)0); z = path_join ("/root", "/", ((void*)0)); do { if ((__builtin_expect(!!(!(( strcmp((z),("/root/")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(z, \"/root/\")"), "../src/test/test-path-util.c", 244 , __PRETTY_FUNCTION__); } while (0); }; | |||
245 | ||||
246 | test_join(NULL, "/a/b", "/c", "/a/b/c"){ __attribute__((cleanup(freep))) char *z = ((void*)0); z = path_join (((void*)0), "/a/b", "/c"); do { if ((__builtin_expect(!!(!(( strcmp((z),("/a/b/c")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(z, \"/a/b/c\")"), "../src/test/test-path-util.c", 246 , __PRETTY_FUNCTION__); } while (0); }; | |||
247 | test_join(NULL, "a/b", "c", "a/b/c"){ __attribute__((cleanup(freep))) char *z = ((void*)0); z = path_join (((void*)0), "a/b", "c"); do { if ((__builtin_expect(!!(!((strcmp ((z),("a/b/c")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(z, \"a/b/c\")"), "../src/test/test-path-util.c", 247 , __PRETTY_FUNCTION__); } while (0); }; | |||
248 | test_join(NULL, "/a/b", "c", "/a/b/c"){ __attribute__((cleanup(freep))) char *z = ((void*)0); z = path_join (((void*)0), "/a/b", "c"); do { if ((__builtin_expect(!!(!((strcmp ((z),("/a/b/c")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(z, \"/a/b/c\")"), "../src/test/test-path-util.c", 248 , __PRETTY_FUNCTION__); } while (0); }; | |||
249 | test_join(NULL, "/", "c", "/c"){ __attribute__((cleanup(freep))) char *z = ((void*)0); z = path_join (((void*)0), "/", "c"); do { if ((__builtin_expect(!!(!((strcmp ((z),("/c")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(z, \"/c\")"), "../src/test/test-path-util.c", 249, __PRETTY_FUNCTION__ ); } while (0); }; | |||
250 | test_join(NULL, "/", NULL, "/"){ __attribute__((cleanup(freep))) char *z = ((void*)0); z = path_join (((void*)0), "/", ((void*)0)); do { if ((__builtin_expect(!!( !((strcmp((z),("/")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(z, \"/\")"), "../src/test/test-path-util.c", 250, __PRETTY_FUNCTION__ ); } while (0); }; | |||
251 | } | |||
252 | ||||
253 | static void test_fsck_exists(void) { | |||
254 | /* Ensure we use a sane default for PATH. */ | |||
255 | unsetenv("PATH"); | |||
256 | ||||
257 | /* fsck.minix is provided by util-linux and will probably exist. */ | |||
258 | assert_se(fsck_exists("minix") == 1)do { if ((__builtin_expect(!!(!(fsck_exists("minix") == 1)),0 ))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("fsck_exists(\"minix\") == 1" ), "../src/test/test-path-util.c", 258, __PRETTY_FUNCTION__); } while (0); | |||
259 | ||||
260 | assert_se(fsck_exists("AbCdE") == 0)do { if ((__builtin_expect(!!(!(fsck_exists("AbCdE") == 0)),0 ))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("fsck_exists(\"AbCdE\") == 0" ), "../src/test/test-path-util.c", 260, __PRETTY_FUNCTION__); } while (0); | |||
261 | assert_se(fsck_exists("/../bin/") == 0)do { if ((__builtin_expect(!!(!(fsck_exists("/../bin/") == 0) ),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("fsck_exists(\"/../bin/\") == 0" ), "../src/test/test-path-util.c", 261, __PRETTY_FUNCTION__); } while (0); | |||
262 | } | |||
263 | ||||
264 | static void test_make_relative(void) { | |||
265 | char *result; | |||
266 | ||||
267 | assert_se(path_make_relative("some/relative/path", "/some/path", &result) < 0)do { if ((__builtin_expect(!!(!(path_make_relative("some/relative/path" , "/some/path", &result) < 0)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("path_make_relative(\"some/relative/path\", \"/some/path\", &result) < 0" ), "../src/test/test-path-util.c", 267, __PRETTY_FUNCTION__); } while (0); | |||
268 | assert_se(path_make_relative("/some/path", "some/relative/path", &result) < 0)do { if ((__builtin_expect(!!(!(path_make_relative("/some/path" , "some/relative/path", &result) < 0)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("path_make_relative(\"/some/path\", \"some/relative/path\", &result) < 0" ), "../src/test/test-path-util.c", 268, __PRETTY_FUNCTION__); } while (0); | |||
269 | assert_se(path_make_relative("/some/dotdot/../path", "/some/path", &result) < 0)do { if ((__builtin_expect(!!(!(path_make_relative("/some/dotdot/../path" , "/some/path", &result) < 0)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("path_make_relative(\"/some/dotdot/../path\", \"/some/path\", &result) < 0" ), "../src/test/test-path-util.c", 269, __PRETTY_FUNCTION__); } while (0); | |||
270 | ||||
271 | #define test(from_dir, to_path, expected){ __attribute__((cleanup(freep))) char *z = ((void*)0); path_make_relative (from_dir, to_path, &z); do { if ((__builtin_expect(!!(!( (strcmp((z),(expected)) == 0))),0))) log_assert_failed_realm( LOG_REALM_SYSTEMD, ("streq(z, expected)"), "../src/test/test-path-util.c" , 271, __PRETTY_FUNCTION__); } while (0); } { \ | |||
272 | _cleanup_free___attribute__((cleanup(freep))) char *z = NULL((void*)0); \ | |||
273 | path_make_relative(from_dir, to_path, &z); \ | |||
274 | assert_se(streq(z, expected))do { if ((__builtin_expect(!!(!((strcmp((z),(expected)) == 0) )),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("streq(z, expected)" ), "../src/test/test-path-util.c", 274, __PRETTY_FUNCTION__); } while (0); \ | |||
275 | } | |||
276 | ||||
277 | test("/", "/", "."){ __attribute__((cleanup(freep))) char *z = ((void*)0); path_make_relative ("/", "/", &z); do { if ((__builtin_expect(!!(!((strcmp(( z),(".")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(z, \".\")"), "../src/test/test-path-util.c", 277, __PRETTY_FUNCTION__ ); } while (0); }; | |||
278 | test("/", "/some/path", "some/path"){ __attribute__((cleanup(freep))) char *z = ((void*)0); path_make_relative ("/", "/some/path", &z); do { if ((__builtin_expect(!!(!( (strcmp((z),("some/path")) == 0))),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("streq(z, \"some/path\")"), "../src/test/test-path-util.c" , 278, __PRETTY_FUNCTION__); } while (0); }; | |||
279 | test("/some/path", "/some/path", "."){ __attribute__((cleanup(freep))) char *z = ((void*)0); path_make_relative ("/some/path", "/some/path", &z); do { if ((__builtin_expect (!!(!((strcmp((z),(".")) == 0))),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("streq(z, \".\")"), "../src/test/test-path-util.c" , 279, __PRETTY_FUNCTION__); } while (0); }; | |||
280 | test("/some/path", "/some/path/in/subdir", "in/subdir"){ __attribute__((cleanup(freep))) char *z = ((void*)0); path_make_relative ("/some/path", "/some/path/in/subdir", &z); do { if ((__builtin_expect (!!(!((strcmp((z),("in/subdir")) == 0))),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("streq(z, \"in/subdir\")"), "../src/test/test-path-util.c" , 280, __PRETTY_FUNCTION__); } while (0); }; | |||
281 | test("/some/path", "/", "../.."){ __attribute__((cleanup(freep))) char *z = ((void*)0); path_make_relative ("/some/path", "/", &z); do { if ((__builtin_expect(!!(!( (strcmp((z),("../..")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(z, \"../..\")"), "../src/test/test-path-util.c", 281 , __PRETTY_FUNCTION__); } while (0); }; | |||
282 | test("/some/path", "/some/other/path", "../other/path"){ __attribute__((cleanup(freep))) char *z = ((void*)0); path_make_relative ("/some/path", "/some/other/path", &z); do { if ((__builtin_expect (!!(!((strcmp((z),("../other/path")) == 0))),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("streq(z, \"../other/path\")"), "../src/test/test-path-util.c" , 282, __PRETTY_FUNCTION__); } while (0); }; | |||
283 | test("/some/path/./dot", "/some/further/path", "../../further/path"){ __attribute__((cleanup(freep))) char *z = ((void*)0); path_make_relative ("/some/path/./dot", "/some/further/path", &z); do { if ( (__builtin_expect(!!(!((strcmp((z),("../../further/path")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("streq(z, \"../../further/path\")" ), "../src/test/test-path-util.c", 283, __PRETTY_FUNCTION__); } while (0); }; | |||
284 | test("//extra.//.//./.slashes//./won't////fo.ol///anybody//", "/././/extra././/.slashes////ar.e/.just/././.fine///", "../../../ar.e/.just/.fine"){ __attribute__((cleanup(freep))) char *z = ((void*)0); path_make_relative ("//extra.//.//./.slashes//./won't////fo.ol///anybody//", "/././/extra././/.slashes////ar.e/.just/././.fine///" , &z); do { if ((__builtin_expect(!!(!((strcmp((z),("../../../ar.e/.just/.fine" )) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("streq(z, \"../../../ar.e/.just/.fine\")" ), "../src/test/test-path-util.c", 284, __PRETTY_FUNCTION__); } while (0); }; | |||
285 | } | |||
286 | ||||
287 | static void test_strv_resolve(void) { | |||
288 | char tmp_dir[] = "/tmp/test-path-util-XXXXXX"; | |||
289 | _cleanup_strv_free___attribute__((cleanup(strv_freep))) char **search_dirs = NULL((void*)0); | |||
290 | _cleanup_strv_free___attribute__((cleanup(strv_freep))) char **absolute_dirs = NULL((void*)0); | |||
291 | char **d; | |||
292 | ||||
293 | assert_se(mkdtemp(tmp_dir) != NULL)do { if ((__builtin_expect(!!(!(mkdtemp(tmp_dir) != ((void*)0 ))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("mkdtemp(tmp_dir) != NULL" ), "../src/test/test-path-util.c", 293, __PRETTY_FUNCTION__); } while (0); | |||
294 | ||||
295 | search_dirs = strv_new("/dir1", "/dir2", "/dir3", NULL((void*)0)); | |||
296 | assert_se(search_dirs)do { if ((__builtin_expect(!!(!(search_dirs)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("search_dirs"), "../src/test/test-path-util.c" , 296, __PRETTY_FUNCTION__); } while (0); | |||
297 | STRV_FOREACH(d, search_dirs)for ((d) = (search_dirs); (d) && *(d); (d)++) { | |||
298 | char *p = strappend(tmp_dir, *d); | |||
299 | assert_se(p)do { if ((__builtin_expect(!!(!(p)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("p"), "../src/test/test-path-util.c", 299 , __PRETTY_FUNCTION__); } while (0); | |||
300 | assert_se(strv_push(&absolute_dirs, p) == 0)do { if ((__builtin_expect(!!(!(strv_push(&absolute_dirs, p) == 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("strv_push(&absolute_dirs, p) == 0" ), "../src/test/test-path-util.c", 300, __PRETTY_FUNCTION__); } while (0); | |||
301 | } | |||
302 | ||||
303 | assert_se(mkdir(absolute_dirs[0], 0700) == 0)do { if ((__builtin_expect(!!(!(mkdir(absolute_dirs[0], 0700) == 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("mkdir(absolute_dirs[0], 0700) == 0" ), "../src/test/test-path-util.c", 303, __PRETTY_FUNCTION__); } while (0); | |||
304 | assert_se(mkdir(absolute_dirs[1], 0700) == 0)do { if ((__builtin_expect(!!(!(mkdir(absolute_dirs[1], 0700) == 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("mkdir(absolute_dirs[1], 0700) == 0" ), "../src/test/test-path-util.c", 304, __PRETTY_FUNCTION__); } while (0); | |||
305 | assert_se(symlink("dir2", absolute_dirs[2]) == 0)do { if ((__builtin_expect(!!(!(symlink("dir2", absolute_dirs [2]) == 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ( "symlink(\"dir2\", absolute_dirs[2]) == 0"), "../src/test/test-path-util.c" , 305, __PRETTY_FUNCTION__); } while (0); | |||
306 | ||||
307 | path_strv_resolve(search_dirs, tmp_dir); | |||
308 | assert_se(streq(search_dirs[0], "/dir1"))do { if ((__builtin_expect(!!(!((strcmp((search_dirs[0]),("/dir1" )) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("streq(search_dirs[0], \"/dir1\")" ), "../src/test/test-path-util.c", 308, __PRETTY_FUNCTION__); } while (0); | |||
309 | assert_se(streq(search_dirs[1], "/dir2"))do { if ((__builtin_expect(!!(!((strcmp((search_dirs[1]),("/dir2" )) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("streq(search_dirs[1], \"/dir2\")" ), "../src/test/test-path-util.c", 309, __PRETTY_FUNCTION__); } while (0); | |||
310 | assert_se(streq(search_dirs[2], "/dir2"))do { if ((__builtin_expect(!!(!((strcmp((search_dirs[2]),("/dir2" )) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("streq(search_dirs[2], \"/dir2\")" ), "../src/test/test-path-util.c", 310, __PRETTY_FUNCTION__); } while (0); | |||
311 | ||||
312 | assert_se(rm_rf(tmp_dir, REMOVE_ROOT|REMOVE_PHYSICAL) == 0)do { if ((__builtin_expect(!!(!(rm_rf(tmp_dir, REMOVE_ROOT|REMOVE_PHYSICAL ) == 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("rm_rf(tmp_dir, REMOVE_ROOT|REMOVE_PHYSICAL) == 0" ), "../src/test/test-path-util.c", 312, __PRETTY_FUNCTION__); } while (0); | |||
313 | } | |||
314 | ||||
315 | static void test_path_startswith(void) { | |||
316 | const char *p; | |||
317 | ||||
318 | p = path_startswith("/foo/bar/barfoo/", "/foo"); | |||
319 | assert_se(streq_ptr(p, "bar/barfoo/"))do { if ((__builtin_expect(!!(!(streq_ptr(p, "bar/barfoo/"))) ,0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("streq_ptr(p, \"bar/barfoo/\")" ), "../src/test/test-path-util.c", 319, __PRETTY_FUNCTION__); } while (0); | |||
320 | ||||
321 | p = path_startswith("/foo/bar/barfoo/", "/foo/"); | |||
322 | assert_se(streq_ptr(p, "bar/barfoo/"))do { if ((__builtin_expect(!!(!(streq_ptr(p, "bar/barfoo/"))) ,0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("streq_ptr(p, \"bar/barfoo/\")" ), "../src/test/test-path-util.c", 322, __PRETTY_FUNCTION__); } while (0); | |||
323 | ||||
324 | p = path_startswith("/foo/bar/barfoo/", "/"); | |||
325 | assert_se(streq_ptr(p, "foo/bar/barfoo/"))do { if ((__builtin_expect(!!(!(streq_ptr(p, "foo/bar/barfoo/" ))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("streq_ptr(p, \"foo/bar/barfoo/\")" ), "../src/test/test-path-util.c", 325, __PRETTY_FUNCTION__); } while (0); | |||
326 | ||||
327 | p = path_startswith("/foo/bar/barfoo/", "////"); | |||
328 | assert_se(streq_ptr(p, "foo/bar/barfoo/"))do { if ((__builtin_expect(!!(!(streq_ptr(p, "foo/bar/barfoo/" ))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("streq_ptr(p, \"foo/bar/barfoo/\")" ), "../src/test/test-path-util.c", 328, __PRETTY_FUNCTION__); } while (0); | |||
329 | ||||
330 | p = path_startswith("/foo/bar/barfoo/", "/foo//bar/////barfoo///"); | |||
331 | assert_se(streq_ptr(p, ""))do { if ((__builtin_expect(!!(!(streq_ptr(p, ""))),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("streq_ptr(p, \"\")"), "../src/test/test-path-util.c" , 331, __PRETTY_FUNCTION__); } while (0); | |||
332 | ||||
333 | p = path_startswith("/foo/bar/barfoo/", "/foo/bar/barfoo////"); | |||
334 | assert_se(streq_ptr(p, ""))do { if ((__builtin_expect(!!(!(streq_ptr(p, ""))),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("streq_ptr(p, \"\")"), "../src/test/test-path-util.c" , 334, __PRETTY_FUNCTION__); } while (0); | |||
335 | ||||
336 | p = path_startswith("/foo/bar/barfoo/", "/foo/bar///barfoo/"); | |||
337 | assert_se(streq_ptr(p, ""))do { if ((__builtin_expect(!!(!(streq_ptr(p, ""))),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("streq_ptr(p, \"\")"), "../src/test/test-path-util.c" , 337, __PRETTY_FUNCTION__); } while (0); | |||
338 | ||||
339 | p = path_startswith("/foo/bar/barfoo/", "/foo////bar/barfoo/"); | |||
340 | assert_se(streq_ptr(p, ""))do { if ((__builtin_expect(!!(!(streq_ptr(p, ""))),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("streq_ptr(p, \"\")"), "../src/test/test-path-util.c" , 340, __PRETTY_FUNCTION__); } while (0); | |||
341 | ||||
342 | p = path_startswith("/foo/bar/barfoo/", "////foo/bar/barfoo/"); | |||
343 | assert_se(streq_ptr(p, ""))do { if ((__builtin_expect(!!(!(streq_ptr(p, ""))),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("streq_ptr(p, \"\")"), "../src/test/test-path-util.c" , 343, __PRETTY_FUNCTION__); } while (0); | |||
344 | ||||
345 | p = path_startswith("/foo/bar/barfoo/", "/foo/bar/barfoo"); | |||
346 | assert_se(streq_ptr(p, ""))do { if ((__builtin_expect(!!(!(streq_ptr(p, ""))),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("streq_ptr(p, \"\")"), "../src/test/test-path-util.c" , 346, __PRETTY_FUNCTION__); } while (0); | |||
347 | ||||
348 | assert_se(!path_startswith("/foo/bar/barfoo/", "/foo/bar/barfooa/"))do { if ((__builtin_expect(!!(!(!path_startswith("/foo/bar/barfoo/" , "/foo/bar/barfooa/"))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("!path_startswith(\"/foo/bar/barfoo/\", \"/foo/bar/barfooa/\")" ), "../src/test/test-path-util.c", 348, __PRETTY_FUNCTION__); } while (0); | |||
349 | assert_se(!path_startswith("/foo/bar/barfoo/", "/foo/bar/barfooa"))do { if ((__builtin_expect(!!(!(!path_startswith("/foo/bar/barfoo/" , "/foo/bar/barfooa"))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("!path_startswith(\"/foo/bar/barfoo/\", \"/foo/bar/barfooa\")" ), "../src/test/test-path-util.c", 349, __PRETTY_FUNCTION__); } while (0); | |||
350 | assert_se(!path_startswith("/foo/bar/barfoo/", ""))do { if ((__builtin_expect(!!(!(!path_startswith("/foo/bar/barfoo/" , ""))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("!path_startswith(\"/foo/bar/barfoo/\", \"\")" ), "../src/test/test-path-util.c", 350, __PRETTY_FUNCTION__); } while (0); | |||
351 | assert_se(!path_startswith("/foo/bar/barfoo/", "/bar/foo"))do { if ((__builtin_expect(!!(!(!path_startswith("/foo/bar/barfoo/" , "/bar/foo"))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("!path_startswith(\"/foo/bar/barfoo/\", \"/bar/foo\")"), "../src/test/test-path-util.c" , 351, __PRETTY_FUNCTION__); } while (0); | |||
352 | assert_se(!path_startswith("/foo/bar/barfoo/", "/f/b/b/"))do { if ((__builtin_expect(!!(!(!path_startswith("/foo/bar/barfoo/" , "/f/b/b/"))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("!path_startswith(\"/foo/bar/barfoo/\", \"/f/b/b/\")"), "../src/test/test-path-util.c" , 352, __PRETTY_FUNCTION__); } while (0); | |||
353 | } | |||
354 | ||||
355 | static void test_prefix_root_one(const char *r, const char *p, const char *expected) { | |||
356 | _cleanup_free___attribute__((cleanup(freep))) char *s = NULL((void*)0); | |||
357 | const char *t; | |||
358 | ||||
359 | assert_se(s = prefix_root(r, p))do { if ((__builtin_expect(!!(!(s = prefix_root(r, p))),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("s = prefix_root(r, p)"), "../src/test/test-path-util.c" , 359, __PRETTY_FUNCTION__); } while (0); | |||
360 | assert_se(streq_ptr(s, expected))do { if ((__builtin_expect(!!(!(streq_ptr(s, expected))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("streq_ptr(s, expected)" ), "../src/test/test-path-util.c", 360, __PRETTY_FUNCTION__); } while (0); | |||
361 | ||||
362 | t = prefix_roota(r, p)({ const char* _path = (p), *_root = (r), *_ret; char *_p, *_n ; size_t _l; while (_path[0] == '/' && _path[1] == '/' ) _path ++; if (empty_or_root(_root)) _ret = _path; else { _l = strlen(_root) + 1 + strlen(_path) + 1; _n = __builtin_alloca (_l); _p = stpcpy(_n, _root); while (_p > _n && _p [-1] == '/') _p--; if (_path[0] != '/') *(_p++) = '/'; strcpy (_p, _path); _ret = _n; } _ret; }); | |||
| ||||
363 | assert_se(t)do { if ((__builtin_expect(!!(!(t)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("t"), "../src/test/test-path-util.c", 363 , __PRETTY_FUNCTION__); } while (0); | |||
364 | assert_se(streq_ptr(t, expected))do { if ((__builtin_expect(!!(!(streq_ptr(t, expected))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("streq_ptr(t, expected)" ), "../src/test/test-path-util.c", 364, __PRETTY_FUNCTION__); } while (0); | |||
365 | } | |||
366 | ||||
367 | static void test_prefix_root(void) { | |||
368 | test_prefix_root_one("/", "/foo", "/foo"); | |||
369 | test_prefix_root_one(NULL((void*)0), "/foo", "/foo"); | |||
370 | test_prefix_root_one("", "/foo", "/foo"); | |||
371 | test_prefix_root_one("///", "/foo", "/foo"); | |||
372 | test_prefix_root_one("/", "////foo", "/foo"); | |||
373 | test_prefix_root_one(NULL((void*)0), "////foo", "/foo"); | |||
374 | ||||
375 | test_prefix_root_one("/foo", "/bar", "/foo/bar"); | |||
376 | test_prefix_root_one("/foo", "bar", "/foo/bar"); | |||
377 | test_prefix_root_one("foo", "bar", "foo/bar"); | |||
378 | test_prefix_root_one("/foo/", "/bar", "/foo/bar"); | |||
379 | test_prefix_root_one("/foo/", "//bar", "/foo/bar"); | |||
380 | test_prefix_root_one("/foo///", "//bar", "/foo/bar"); | |||
381 | } | |||
382 | ||||
383 | static void test_file_in_same_dir(void) { | |||
384 | char *t; | |||
385 | ||||
386 | t = file_in_same_dir("/", "a"); | |||
387 | assert_se(streq(t, "/a"))do { if ((__builtin_expect(!!(!((strcmp((t),("/a")) == 0))),0 ))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("streq(t, \"/a\")" ), "../src/test/test-path-util.c", 387, __PRETTY_FUNCTION__); } while (0); | |||
388 | free(t); | |||
389 | ||||
390 | t = file_in_same_dir("/", "/a"); | |||
391 | assert_se(streq(t, "/a"))do { if ((__builtin_expect(!!(!((strcmp((t),("/a")) == 0))),0 ))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("streq(t, \"/a\")" ), "../src/test/test-path-util.c", 391, __PRETTY_FUNCTION__); } while (0); | |||
392 | free(t); | |||
393 | ||||
394 | t = file_in_same_dir("", "a"); | |||
395 | assert_se(streq(t, "a"))do { if ((__builtin_expect(!!(!((strcmp((t),("a")) == 0))),0) )) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("streq(t, \"a\")" ), "../src/test/test-path-util.c", 395, __PRETTY_FUNCTION__); } while (0); | |||
396 | free(t); | |||
397 | ||||
398 | t = file_in_same_dir("a/", "a"); | |||
399 | assert_se(streq(t, "a/a"))do { if ((__builtin_expect(!!(!((strcmp((t),("a/a")) == 0))), 0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("streq(t, \"a/a\")" ), "../src/test/test-path-util.c", 399, __PRETTY_FUNCTION__); } while (0); | |||
400 | free(t); | |||
401 | ||||
402 | t = file_in_same_dir("bar/foo", "bar"); | |||
403 | assert_se(streq(t, "bar/bar"))do { if ((__builtin_expect(!!(!((strcmp((t),("bar/bar")) == 0 ))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("streq(t, \"bar/bar\")" ), "../src/test/test-path-util.c", 403, __PRETTY_FUNCTION__); } while (0); | |||
404 | free(t); | |||
405 | } | |||
406 | ||||
407 | static void test_last_path_component(void) { | |||
408 | assert_se(streq(last_path_component("a/b/c"), "c"))do { if ((__builtin_expect(!!(!((strcmp((last_path_component( "a/b/c")),("c")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(last_path_component(\"a/b/c\"), \"c\")"), "../src/test/test-path-util.c" , 408, __PRETTY_FUNCTION__); } while (0); | |||
409 | assert_se(streq(last_path_component("a/b/c/"), "c/"))do { if ((__builtin_expect(!!(!((strcmp((last_path_component( "a/b/c/")),("c/")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(last_path_component(\"a/b/c/\"), \"c/\")"), "../src/test/test-path-util.c" , 409, __PRETTY_FUNCTION__); } while (0); | |||
410 | assert_se(streq(last_path_component("/"), "/"))do { if ((__builtin_expect(!!(!((strcmp((last_path_component( "/")),("/")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(last_path_component(\"/\"), \"/\")"), "../src/test/test-path-util.c" , 410, __PRETTY_FUNCTION__); } while (0); | |||
411 | assert_se(streq(last_path_component("//"), "/"))do { if ((__builtin_expect(!!(!((strcmp((last_path_component( "//")),("/")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(last_path_component(\"//\"), \"/\")"), "../src/test/test-path-util.c" , 411, __PRETTY_FUNCTION__); } while (0); | |||
412 | assert_se(streq(last_path_component("///"), "/"))do { if ((__builtin_expect(!!(!((strcmp((last_path_component( "///")),("/")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(last_path_component(\"///\"), \"/\")"), "../src/test/test-path-util.c" , 412, __PRETTY_FUNCTION__); } while (0); | |||
413 | assert_se(streq(last_path_component("."), "."))do { if ((__builtin_expect(!!(!((strcmp((last_path_component( ".")),(".")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(last_path_component(\".\"), \".\")"), "../src/test/test-path-util.c" , 413, __PRETTY_FUNCTION__); } while (0); | |||
414 | assert_se(streq(last_path_component("./."), "."))do { if ((__builtin_expect(!!(!((strcmp((last_path_component( "./.")),(".")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(last_path_component(\"./.\"), \".\")"), "../src/test/test-path-util.c" , 414, __PRETTY_FUNCTION__); } while (0); | |||
415 | assert_se(streq(last_path_component("././"), "./"))do { if ((__builtin_expect(!!(!((strcmp((last_path_component( "././")),("./")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(last_path_component(\"././\"), \"./\")"), "../src/test/test-path-util.c" , 415, __PRETTY_FUNCTION__); } while (0); | |||
416 | assert_se(streq(last_path_component("././/"), ".//"))do { if ((__builtin_expect(!!(!((strcmp((last_path_component( "././/")),(".//")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(last_path_component(\"././/\"), \".//\")"), "../src/test/test-path-util.c" , 416, __PRETTY_FUNCTION__); } while (0); | |||
417 | assert_se(streq(last_path_component("/foo/a"), "a"))do { if ((__builtin_expect(!!(!((strcmp((last_path_component( "/foo/a")),("a")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(last_path_component(\"/foo/a\"), \"a\")"), "../src/test/test-path-util.c" , 417, __PRETTY_FUNCTION__); } while (0); | |||
418 | assert_se(streq(last_path_component("/foo/a/"), "a/"))do { if ((__builtin_expect(!!(!((strcmp((last_path_component( "/foo/a/")),("a/")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(last_path_component(\"/foo/a/\"), \"a/\")"), "../src/test/test-path-util.c" , 418, __PRETTY_FUNCTION__); } while (0); | |||
419 | assert_se(streq(last_path_component(""), ""))do { if ((__builtin_expect(!!(!((strcmp((last_path_component( "")),("")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(last_path_component(\"\"), \"\")"), "../src/test/test-path-util.c" , 419, __PRETTY_FUNCTION__); } while (0); | |||
420 | assert_se(streq(last_path_component("a"), "a"))do { if ((__builtin_expect(!!(!((strcmp((last_path_component( "a")),("a")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(last_path_component(\"a\"), \"a\")"), "../src/test/test-path-util.c" , 420, __PRETTY_FUNCTION__); } while (0); | |||
421 | assert_se(streq(last_path_component("a/"), "a/"))do { if ((__builtin_expect(!!(!((strcmp((last_path_component( "a/")),("a/")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(last_path_component(\"a/\"), \"a/\")"), "../src/test/test-path-util.c" , 421, __PRETTY_FUNCTION__); } while (0); | |||
422 | assert_se(streq(last_path_component("/a"), "a"))do { if ((__builtin_expect(!!(!((strcmp((last_path_component( "/a")),("a")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(last_path_component(\"/a\"), \"a\")"), "../src/test/test-path-util.c" , 422, __PRETTY_FUNCTION__); } while (0); | |||
423 | assert_se(streq(last_path_component("/a/"), "a/"))do { if ((__builtin_expect(!!(!((strcmp((last_path_component( "/a/")),("a/")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(last_path_component(\"/a/\"), \"a/\")"), "../src/test/test-path-util.c" , 423, __PRETTY_FUNCTION__); } while (0); | |||
424 | } | |||
425 | ||||
426 | static void test_filename_is_valid(void) { | |||
427 | char foo[FILENAME_MAX4096+2]; | |||
428 | int i; | |||
429 | ||||
430 | assert_se(!filename_is_valid(""))do { if ((__builtin_expect(!!(!(!filename_is_valid(""))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("!filename_is_valid(\"\")" ), "../src/test/test-path-util.c", 430, __PRETTY_FUNCTION__); } while (0); | |||
431 | assert_se(!filename_is_valid("/bar/foo"))do { if ((__builtin_expect(!!(!(!filename_is_valid("/bar/foo" ))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("!filename_is_valid(\"/bar/foo\")" ), "../src/test/test-path-util.c", 431, __PRETTY_FUNCTION__); } while (0); | |||
432 | assert_se(!filename_is_valid("/"))do { if ((__builtin_expect(!!(!(!filename_is_valid("/"))),0)) ) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("!filename_is_valid(\"/\")" ), "../src/test/test-path-util.c", 432, __PRETTY_FUNCTION__); } while (0); | |||
433 | assert_se(!filename_is_valid("."))do { if ((__builtin_expect(!!(!(!filename_is_valid("."))),0)) ) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("!filename_is_valid(\".\")" ), "../src/test/test-path-util.c", 433, __PRETTY_FUNCTION__); } while (0); | |||
434 | assert_se(!filename_is_valid(".."))do { if ((__builtin_expect(!!(!(!filename_is_valid(".."))),0) )) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("!filename_is_valid(\"..\")" ), "../src/test/test-path-util.c", 434, __PRETTY_FUNCTION__); } while (0); | |||
435 | ||||
436 | for (i=0; i<FILENAME_MAX4096+1; i++) | |||
437 | foo[i] = 'a'; | |||
438 | foo[FILENAME_MAX4096+1] = '\0'; | |||
439 | ||||
440 | assert_se(!filename_is_valid(foo))do { if ((__builtin_expect(!!(!(!filename_is_valid(foo))),0)) ) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("!filename_is_valid(foo)" ), "../src/test/test-path-util.c", 440, __PRETTY_FUNCTION__); } while (0); | |||
441 | ||||
442 | assert_se(filename_is_valid("foo_bar-333"))do { if ((__builtin_expect(!!(!(filename_is_valid("foo_bar-333" ))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("filename_is_valid(\"foo_bar-333\")" ), "../src/test/test-path-util.c", 442, __PRETTY_FUNCTION__); } while (0); | |||
443 | assert_se(filename_is_valid("o.o"))do { if ((__builtin_expect(!!(!(filename_is_valid("o.o"))),0) )) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("filename_is_valid(\"o.o\")" ), "../src/test/test-path-util.c", 443, __PRETTY_FUNCTION__); } while (0); | |||
444 | } | |||
445 | ||||
446 | static void test_hidden_or_backup_file(void) { | |||
447 | assert_se(hidden_or_backup_file(".hidden"))do { if ((__builtin_expect(!!(!(hidden_or_backup_file(".hidden" ))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("hidden_or_backup_file(\".hidden\")" ), "../src/test/test-path-util.c", 447, __PRETTY_FUNCTION__); } while (0); | |||
448 | assert_se(hidden_or_backup_file("..hidden"))do { if ((__builtin_expect(!!(!(hidden_or_backup_file("..hidden" ))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("hidden_or_backup_file(\"..hidden\")" ), "../src/test/test-path-util.c", 448, __PRETTY_FUNCTION__); } while (0); | |||
449 | assert_se(!hidden_or_backup_file("hidden."))do { if ((__builtin_expect(!!(!(!hidden_or_backup_file("hidden." ))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("!hidden_or_backup_file(\"hidden.\")" ), "../src/test/test-path-util.c", 449, __PRETTY_FUNCTION__); } while (0); | |||
450 | ||||
451 | assert_se(hidden_or_backup_file("backup~"))do { if ((__builtin_expect(!!(!(hidden_or_backup_file("backup~" ))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("hidden_or_backup_file(\"backup~\")" ), "../src/test/test-path-util.c", 451, __PRETTY_FUNCTION__); } while (0); | |||
452 | assert_se(hidden_or_backup_file(".backup~"))do { if ((__builtin_expect(!!(!(hidden_or_backup_file(".backup~" ))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("hidden_or_backup_file(\".backup~\")" ), "../src/test/test-path-util.c", 452, __PRETTY_FUNCTION__); } while (0); | |||
453 | ||||
454 | assert_se(hidden_or_backup_file("lost+found"))do { if ((__builtin_expect(!!(!(hidden_or_backup_file("lost+found" ))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("hidden_or_backup_file(\"lost+found\")" ), "../src/test/test-path-util.c", 454, __PRETTY_FUNCTION__); } while (0); | |||
455 | assert_se(hidden_or_backup_file("aquota.user"))do { if ((__builtin_expect(!!(!(hidden_or_backup_file("aquota.user" ))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("hidden_or_backup_file(\"aquota.user\")" ), "../src/test/test-path-util.c", 455, __PRETTY_FUNCTION__); } while (0); | |||
456 | assert_se(hidden_or_backup_file("aquota.group"))do { if ((__builtin_expect(!!(!(hidden_or_backup_file("aquota.group" ))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("hidden_or_backup_file(\"aquota.group\")" ), "../src/test/test-path-util.c", 456, __PRETTY_FUNCTION__); } while (0); | |||
457 | ||||
458 | assert_se(hidden_or_backup_file("test.rpmnew"))do { if ((__builtin_expect(!!(!(hidden_or_backup_file("test.rpmnew" ))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("hidden_or_backup_file(\"test.rpmnew\")" ), "../src/test/test-path-util.c", 458, __PRETTY_FUNCTION__); } while (0); | |||
459 | assert_se(hidden_or_backup_file("test.dpkg-old"))do { if ((__builtin_expect(!!(!(hidden_or_backup_file("test.dpkg-old" ))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("hidden_or_backup_file(\"test.dpkg-old\")" ), "../src/test/test-path-util.c", 459, __PRETTY_FUNCTION__); } while (0); | |||
460 | assert_se(hidden_or_backup_file("test.dpkg-remove"))do { if ((__builtin_expect(!!(!(hidden_or_backup_file("test.dpkg-remove" ))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("hidden_or_backup_file(\"test.dpkg-remove\")" ), "../src/test/test-path-util.c", 460, __PRETTY_FUNCTION__); } while (0); | |||
461 | assert_se(hidden_or_backup_file("test.swp"))do { if ((__builtin_expect(!!(!(hidden_or_backup_file("test.swp" ))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("hidden_or_backup_file(\"test.swp\")" ), "../src/test/test-path-util.c", 461, __PRETTY_FUNCTION__); } while (0); | |||
462 | ||||
463 | assert_se(!hidden_or_backup_file("test.rpmnew."))do { if ((__builtin_expect(!!(!(!hidden_or_backup_file("test.rpmnew." ))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("!hidden_or_backup_file(\"test.rpmnew.\")" ), "../src/test/test-path-util.c", 463, __PRETTY_FUNCTION__); } while (0); | |||
464 | assert_se(!hidden_or_backup_file("test.dpkg-old.foo"))do { if ((__builtin_expect(!!(!(!hidden_or_backup_file("test.dpkg-old.foo" ))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("!hidden_or_backup_file(\"test.dpkg-old.foo\")" ), "../src/test/test-path-util.c", 464, __PRETTY_FUNCTION__); } while (0); | |||
465 | } | |||
466 | ||||
467 | static void test_systemd_installation_has_version(const char *path) { | |||
468 | int r; | |||
469 | const unsigned versions[] = {0, 231, atoi(PACKAGE_VERSION"239"), 999}; | |||
470 | unsigned i; | |||
471 | ||||
472 | for (i = 0; i < ELEMENTSOF(versions)__extension__ (__builtin_choose_expr( !__builtin_types_compatible_p (typeof(versions), typeof(&*(versions))), sizeof(versions )/sizeof((versions)[0]), ((void)0))); i++) { | |||
473 | r = systemd_installation_has_version(path, versions[i]); | |||
474 | assert_se(r >= 0)do { if ((__builtin_expect(!!(!(r >= 0)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("r >= 0"), "../src/test/test-path-util.c" , 474, __PRETTY_FUNCTION__); } while (0); | |||
475 | log_info("%s has systemd >= %u: %s",({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/test/test-path-util.c", 476, __func__, "%s has systemd >= %u: %s" , path ?: "Current installation", versions[i], yes_no(r)) : - abs(_e); }) | |||
476 | path ?: "Current installation", versions[i], yes_no(r))({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/test/test-path-util.c", 476, __func__, "%s has systemd >= %u: %s" , path ?: "Current installation", versions[i], yes_no(r)) : - abs(_e); }); | |||
477 | } | |||
478 | } | |||
479 | ||||
480 | static void test_skip_dev_prefix(void) { | |||
481 | ||||
482 | assert_se(streq(skip_dev_prefix("/"), "/"))do { if ((__builtin_expect(!!(!((strcmp((skip_dev_prefix("/") ),("/")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(skip_dev_prefix(\"/\"), \"/\")"), "../src/test/test-path-util.c" , 482, __PRETTY_FUNCTION__); } while (0); | |||
483 | assert_se(streq(skip_dev_prefix("/dev"), ""))do { if ((__builtin_expect(!!(!((strcmp((skip_dev_prefix("/dev" )),("")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(skip_dev_prefix(\"/dev\"), \"\")"), "../src/test/test-path-util.c" , 483, __PRETTY_FUNCTION__); } while (0); | |||
484 | assert_se(streq(skip_dev_prefix("/dev/"), ""))do { if ((__builtin_expect(!!(!((strcmp((skip_dev_prefix("/dev/" )),("")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(skip_dev_prefix(\"/dev/\"), \"\")"), "../src/test/test-path-util.c" , 484, __PRETTY_FUNCTION__); } while (0); | |||
485 | assert_se(streq(skip_dev_prefix("/dev/foo"), "foo"))do { if ((__builtin_expect(!!(!((strcmp((skip_dev_prefix("/dev/foo" )),("foo")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(skip_dev_prefix(\"/dev/foo\"), \"foo\")"), "../src/test/test-path-util.c" , 485, __PRETTY_FUNCTION__); } while (0); | |||
486 | assert_se(streq(skip_dev_prefix("/dev/foo/bar"), "foo/bar"))do { if ((__builtin_expect(!!(!((strcmp((skip_dev_prefix("/dev/foo/bar" )),("foo/bar")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(skip_dev_prefix(\"/dev/foo/bar\"), \"foo/bar\")"), "../src/test/test-path-util.c" , 486, __PRETTY_FUNCTION__); } while (0); | |||
487 | assert_se(streq(skip_dev_prefix("//dev"), ""))do { if ((__builtin_expect(!!(!((strcmp((skip_dev_prefix("//dev" )),("")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(skip_dev_prefix(\"//dev\"), \"\")"), "../src/test/test-path-util.c" , 487, __PRETTY_FUNCTION__); } while (0); | |||
488 | assert_se(streq(skip_dev_prefix("//dev//"), ""))do { if ((__builtin_expect(!!(!((strcmp((skip_dev_prefix("//dev//" )),("")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(skip_dev_prefix(\"//dev//\"), \"\")"), "../src/test/test-path-util.c" , 488, __PRETTY_FUNCTION__); } while (0); | |||
489 | assert_se(streq(skip_dev_prefix("/dev///foo"), "foo"))do { if ((__builtin_expect(!!(!((strcmp((skip_dev_prefix("/dev///foo" )),("foo")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(skip_dev_prefix(\"/dev///foo\"), \"foo\")"), "../src/test/test-path-util.c" , 489, __PRETTY_FUNCTION__); } while (0); | |||
490 | assert_se(streq(skip_dev_prefix("///dev///foo///bar"), "foo///bar"))do { if ((__builtin_expect(!!(!((strcmp((skip_dev_prefix("///dev///foo///bar" )),("foo///bar")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(skip_dev_prefix(\"///dev///foo///bar\"), \"foo///bar\")" ), "../src/test/test-path-util.c", 490, __PRETTY_FUNCTION__); } while (0); | |||
491 | assert_se(streq(skip_dev_prefix("//foo"), "//foo"))do { if ((__builtin_expect(!!(!((strcmp((skip_dev_prefix("//foo" )),("//foo")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(skip_dev_prefix(\"//foo\"), \"//foo\")"), "../src/test/test-path-util.c" , 491, __PRETTY_FUNCTION__); } while (0); | |||
492 | assert_se(streq(skip_dev_prefix("foo"), "foo"))do { if ((__builtin_expect(!!(!((strcmp((skip_dev_prefix("foo" )),("foo")) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("streq(skip_dev_prefix(\"foo\"), \"foo\")"), "../src/test/test-path-util.c" , 492, __PRETTY_FUNCTION__); } while (0); | |||
493 | } | |||
494 | ||||
495 | static void test_empty_or_root(void) { | |||
496 | assert_se(empty_or_root(NULL))do { if ((__builtin_expect(!!(!(empty_or_root(((void*)0)))),0 ))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("empty_or_root(NULL)" ), "../src/test/test-path-util.c", 496, __PRETTY_FUNCTION__); } while (0); | |||
497 | assert_se(empty_or_root(""))do { if ((__builtin_expect(!!(!(empty_or_root(""))),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("empty_or_root(\"\")"), "../src/test/test-path-util.c" , 497, __PRETTY_FUNCTION__); } while (0); | |||
498 | assert_se(empty_or_root("/"))do { if ((__builtin_expect(!!(!(empty_or_root("/"))),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("empty_or_root(\"/\")"), "../src/test/test-path-util.c" , 498, __PRETTY_FUNCTION__); } while (0); | |||
499 | assert_se(empty_or_root("//"))do { if ((__builtin_expect(!!(!(empty_or_root("//"))),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("empty_or_root(\"//\")"), "../src/test/test-path-util.c" , 499, __PRETTY_FUNCTION__); } while (0); | |||
500 | assert_se(empty_or_root("///"))do { if ((__builtin_expect(!!(!(empty_or_root("///"))),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("empty_or_root(\"///\")"), "../src/test/test-path-util.c" , 500, __PRETTY_FUNCTION__); } while (0); | |||
501 | assert_se(empty_or_root("/////////////////"))do { if ((__builtin_expect(!!(!(empty_or_root("/////////////////" ))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("empty_or_root(\"/////////////////\")" ), "../src/test/test-path-util.c", 501, __PRETTY_FUNCTION__); } while (0); | |||
502 | assert_se(!empty_or_root("xxx"))do { if ((__builtin_expect(!!(!(!empty_or_root("xxx"))),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("!empty_or_root(\"xxx\")"), "../src/test/test-path-util.c" , 502, __PRETTY_FUNCTION__); } while (0); | |||
503 | assert_se(!empty_or_root("/xxx"))do { if ((__builtin_expect(!!(!(!empty_or_root("/xxx"))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("!empty_or_root(\"/xxx\")" ), "../src/test/test-path-util.c", 503, __PRETTY_FUNCTION__); } while (0); | |||
504 | assert_se(!empty_or_root("/xxx/"))do { if ((__builtin_expect(!!(!(!empty_or_root("/xxx/"))),0)) ) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("!empty_or_root(\"/xxx/\")" ), "../src/test/test-path-util.c", 504, __PRETTY_FUNCTION__); } while (0); | |||
505 | assert_se(!empty_or_root("//yy//"))do { if ((__builtin_expect(!!(!(!empty_or_root("//yy//"))),0) )) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("!empty_or_root(\"//yy//\")" ), "../src/test/test-path-util.c", 505, __PRETTY_FUNCTION__); } while (0); | |||
506 | } | |||
507 | ||||
508 | int main(int argc, char **argv) { | |||
509 | log_set_max_level(LOG_DEBUG)log_set_max_level_realm(LOG_REALM_SYSTEMD, (7)); | |||
510 | log_parse_environment()log_parse_environment_realm(LOG_REALM_SYSTEMD); | |||
511 | log_open(); | |||
512 | ||||
513 | test_path(); | |||
514 | test_path_equal_root(); | |||
515 | test_find_binary(argv[0]); | |||
516 | test_prefixes(); | |||
517 | test_path_join(); | |||
518 | test_fsck_exists(); | |||
519 | test_make_relative(); | |||
520 | test_strv_resolve(); | |||
521 | test_path_startswith(); | |||
522 | test_prefix_root(); | |||
| ||||
523 | test_file_in_same_dir(); | |||
524 | test_last_path_component(); | |||
525 | test_filename_is_valid(); | |||
526 | test_hidden_or_backup_file(); | |||
527 | test_skip_dev_prefix(); | |||
528 | test_empty_or_root(); | |||
529 | ||||
530 | test_systemd_installation_has_version(argv[1]); /* NULL is OK */ | |||
531 | ||||
532 | return 0; | |||
533 | } |