]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/test/test-path-util.c
test-condition: make function return void
[thirdparty/systemd.git] / src / test / test-path-util.c
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
76877b46 2
a696dbef 3#include <stdio.h>
07630cea 4#include <unistd.h>
a696dbef 5
b5efdb8a 6#include "alloc-util.h"
3ffd4af2 7#include "fd-util.h"
76877b46 8#include "macro.h"
4349cd7c 9#include "mount-util.h"
07630cea 10#include "path-util.h"
c6878637 11#include "rm-rf.h"
84e72b5e 12#include "stat-util.h"
07630cea
LP
13#include "string-util.h"
14#include "strv.h"
15#include "util.h"
76877b46 16
2230852b
MS
17#define test_path_compare(a, b, result) { \
18 assert_se(path_compare(a, b) == result); \
19 assert_se(path_compare(b, a) == -result); \
20 assert_se(path_equal(a, b) == !result); \
21 assert_se(path_equal(b, a) == !result); \
22 }
76877b46 23
858d36c1
YW
24static void test_path_simplify(const char *in, const char *out, const char *out_dot) {
25 char *p;
26
27 p = strdupa(in);
28 assert_se(streq(path_simplify(p, false), out));
29
30 p = strdupa(in);
31 assert_se(streq(path_simplify(p, true), out_dot));
32}
33
76877b46 34static void test_path(void) {
3f72b427
LP
35 _cleanup_close_ int fd = -1;
36
2230852b
MS
37 test_path_compare("/goo", "/goo", 0);
38 test_path_compare("/goo", "/goo", 0);
39 test_path_compare("//goo", "/goo", 0);
40 test_path_compare("//goo/////", "/goo", 0);
41 test_path_compare("goo/////", "goo", 0);
76877b46 42
2230852b
MS
43 test_path_compare("/goo/boo", "/goo//boo", 0);
44 test_path_compare("//goo/boo", "/goo/boo//", 0);
76877b46 45
2230852b 46 test_path_compare("/", "///", 0);
76877b46 47
2230852b
MS
48 test_path_compare("/x", "x/", 1);
49 test_path_compare("x/", "/", -1);
76877b46 50
2230852b
MS
51 test_path_compare("/x/./y", "x/y", 1);
52 test_path_compare("x/.y", "x/y", -1);
53
54 test_path_compare("foo", "/foo", -1);
55 test_path_compare("/foo", "/foo/bar", -1);
56 test_path_compare("/foo/aaa", "/foo/b", -1);
57 test_path_compare("/foo/aaa", "/foo/b/a", -1);
58 test_path_compare("/foo/a", "/foo/aaa", -1);
59 test_path_compare("/foo/a/b", "/foo/aaa", -1);
76877b46
ZJS
60
61 assert_se(path_is_absolute("/"));
62 assert_se(!path_is_absolute("./"));
63
64 assert_se(is_path("/dir"));
65 assert_se(is_path("a/b"));
66 assert_se(!is_path("."));
67
2b6bf07d
ZJS
68 assert_se(streq(basename("./aa/bb/../file.da."), "file.da."));
69 assert_se(streq(basename("/aa///.file"), ".file"));
70 assert_se(streq(basename("/aa///file..."), "file..."));
71 assert_se(streq(basename("file.../"), ""));
76877b46 72
3f72b427
LP
73 fd = open("/", O_RDONLY|O_CLOEXEC|O_DIRECTORY|O_NOCTTY);
74 assert_se(fd >= 0);
5d409034 75 assert_se(fd_is_mount_point(fd, "/", 0) > 0);
76877b46 76
858d36c1
YW
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/..");
3ae5990c
ZJS
99
100 assert_se(PATH_IN_SET("/bin", "/", "/bin", "/foo"));
101 assert_se(PATH_IN_SET("/bin", "/bin"));
102 assert_se(PATH_IN_SET("/bin", "/foo/bar", "/bin"));
103 assert_se(PATH_IN_SET("/", "/", "/", "/foo/bar"));
104 assert_se(!PATH_IN_SET("/", "/abc", "/def"));
24737c29
ZJS
105
106 assert_se(path_equal_ptr(NULL, NULL));
107 assert_se(path_equal_ptr("/a", "/a"));
108 assert_se(!path_equal_ptr("/a", "/b"));
109 assert_se(!path_equal_ptr("/a", NULL));
110 assert_se(!path_equal_ptr(NULL, "/a"));
76877b46
ZJS
111}
112
84e72b5e
ZJS
113static void test_path_equal_root(void) {
114 /* Nail down the details of how path_equal("/", ...) works. */
115
116 assert_se(path_equal("/", "/"));
117 assert_se(path_equal("/", "//"));
118
119 assert_se(!path_equal("/", "/./"));
120 assert_se(!path_equal("/", "/../"));
121
122 assert_se(!path_equal("/", "/.../"));
123
124 /* Make sure that files_same works as expected. */
125
e3f791a2
ZJS
126 assert_se(files_same("/", "/", 0) > 0);
127 assert_se(files_same("/", "/", AT_SYMLINK_NOFOLLOW) > 0);
128 assert_se(files_same("/", "//", 0) > 0);
129 assert_se(files_same("/", "//", AT_SYMLINK_NOFOLLOW) > 0);
84e72b5e 130
e3f791a2
ZJS
131 assert_se(files_same("/", "/./", 0) > 0);
132 assert_se(files_same("/", "/./", AT_SYMLINK_NOFOLLOW) > 0);
133 assert_se(files_same("/", "/../", 0) > 0);
134 assert_se(files_same("/", "/../", AT_SYMLINK_NOFOLLOW) > 0);
84e72b5e 135
e3f791a2
ZJS
136 assert_se(files_same("/", "/.../", 0) == -ENOENT);
137 assert_se(files_same("/", "/.../", AT_SYMLINK_NOFOLLOW) == -ENOENT);
84e72b5e
ZJS
138
139 /* The same for path_equal_or_files_same. */
140
e3f791a2
ZJS
141 assert_se(path_equal_or_files_same("/", "/", 0));
142 assert_se(path_equal_or_files_same("/", "/", AT_SYMLINK_NOFOLLOW));
143 assert_se(path_equal_or_files_same("/", "//", 0));
144 assert_se(path_equal_or_files_same("/", "//", AT_SYMLINK_NOFOLLOW));
84e72b5e 145
e3f791a2
ZJS
146 assert_se(path_equal_or_files_same("/", "/./", 0));
147 assert_se(path_equal_or_files_same("/", "/./", AT_SYMLINK_NOFOLLOW));
148 assert_se(path_equal_or_files_same("/", "/../", 0));
149 assert_se(path_equal_or_files_same("/", "/../", AT_SYMLINK_NOFOLLOW));
84e72b5e 150
e3f791a2
ZJS
151 assert_se(!path_equal_or_files_same("/", "/.../", 0));
152 assert_se(!path_equal_or_files_same("/", "/.../", AT_SYMLINK_NOFOLLOW));
84e72b5e
ZJS
153}
154
85eca92e 155static void test_find_binary(const char *self) {
c9d954b2
ZJS
156 char *p;
157
85eca92e 158 assert_se(find_binary("/bin/sh", &p) == 0);
c9d954b2 159 puts(p);
85eca92e 160 assert_se(path_equal(p, "/bin/sh"));
c9d954b2
ZJS
161 free(p);
162
85eca92e 163 assert_se(find_binary(self, &p) == 0);
c9d954b2 164 puts(p);
6d1e2ddd
MG
165 /* libtool might prefix the binary name with "lt-" */
166 assert_se(endswith(p, "/lt-test-path-util") || endswith(p, "/test-path-util"));
8d95631e 167 assert_se(path_is_absolute(p));
c9d954b2
ZJS
168 free(p);
169
85eca92e 170 assert_se(find_binary("sh", &p) == 0);
c9d954b2 171 puts(p);
8d95631e
FB
172 assert_se(endswith(p, "/sh"));
173 assert_se(path_is_absolute(p));
c9d954b2
ZJS
174 free(p);
175
85eca92e
LP
176 assert_se(find_binary("xxxx-xxxx", &p) == -ENOENT);
177 assert_se(find_binary("/some/dir/xxxx-xxxx", &p) == -ENOENT);
c9d954b2
ZJS
178}
179
fecffe5d 180static void test_prefixes(void) {
e203f7c3
LP
181 static const char* values[] = { "/a/b/c/d", "/a/b/c", "/a/b", "/a", "", NULL};
182 unsigned i;
fecffe5d 183 char s[PATH_MAX];
e203f7c3 184 bool b;
fecffe5d 185
e203f7c3
LP
186 i = 0;
187 PATH_FOREACH_PREFIX_MORE(s, "/a/b/c/d") {
fecffe5d
LP
188 log_error("---%s---", s);
189 assert_se(streq(s, values[i++]));
190 }
e203f7c3 191 assert_se(values[i] == NULL);
fecffe5d 192
e203f7c3
LP
193 i = 1;
194 PATH_FOREACH_PREFIX(s, "/a/b/c/d") {
195 log_error("---%s---", s);
196 assert_se(streq(s, values[i++]));
197 }
fecffe5d
LP
198 assert_se(values[i] == NULL);
199
200 i = 0;
e203f7c3 201 PATH_FOREACH_PREFIX_MORE(s, "////a////b////c///d///////")
fecffe5d 202 assert_se(streq(s, values[i++]));
e203f7c3 203 assert_se(values[i] == NULL);
fecffe5d 204
e203f7c3
LP
205 i = 1;
206 PATH_FOREACH_PREFIX(s, "////a////b////c///d///////")
207 assert_se(streq(s, values[i++]));
fecffe5d
LP
208 assert_se(values[i] == NULL);
209
210 PATH_FOREACH_PREFIX(s, "////")
e203f7c3
LP
211 assert_not_reached("Wut?");
212
213 b = false;
214 PATH_FOREACH_PREFIX_MORE(s, "////") {
215 assert_se(!b);
fecffe5d 216 assert_se(streq(s, ""));
e203f7c3
LP
217 b = true;
218 }
219 assert_se(b);
fecffe5d
LP
220
221 PATH_FOREACH_PREFIX(s, "")
222 assert_not_reached("wut?");
223
e203f7c3
LP
224 b = false;
225 PATH_FOREACH_PREFIX_MORE(s, "") {
8d95631e
FB
226 assert_se(!b);
227 assert_se(streq(s, ""));
e203f7c3
LP
228 b = true;
229 }
fecffe5d
LP
230}
231
0c6ea3a4 232static void test_path_join(void) {
59ae3a95
TA
233
234#define test_join(root, path, rest, expected) { \
235 _cleanup_free_ char *z = NULL; \
236 z = path_join(root, path, rest); \
237 assert_se(streq(z, expected)); \
238 }
239
240 test_join("/root", "/a/b", "/c", "/root/a/b/c");
241 test_join("/root", "a/b", "c", "/root/a/b/c");
242 test_join("/root", "/a/b", "c", "/root/a/b/c");
bc854dc7 243 test_join("/root", "/", "c", "/root/c");
59ae3a95
TA
244 test_join("/root", "/", NULL, "/root/");
245
246 test_join(NULL, "/a/b", "/c", "/a/b/c");
247 test_join(NULL, "a/b", "c", "a/b/c");
248 test_join(NULL, "/a/b", "c", "/a/b/c");
bc854dc7 249 test_join(NULL, "/", "c", "/c");
59ae3a95 250 test_join(NULL, "/", NULL, "/");
0c6ea3a4
ZJS
251}
252
eb66db55
MG
253static 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. */
85eca92e 258 assert_se(fsck_exists("minix") == 1);
eb66db55 259
85eca92e
LP
260 assert_se(fsck_exists("AbCdE") == 0);
261 assert_se(fsck_exists("/../bin/") == 0);
eb66db55
MG
262}
263
6b56a651
TK
264static void test_make_relative(void) {
265 char *result;
266
267 assert_se(path_make_relative("some/relative/path", "/some/path", &result) < 0);
268 assert_se(path_make_relative("/some/path", "some/relative/path", &result) < 0);
2a5beb66 269 assert_se(path_make_relative("/some/dotdot/../path", "/some/path", &result) < 0);
6b56a651 270
59ae3a95
TA
271#define test(from_dir, to_path, expected) { \
272 _cleanup_free_ char *z = NULL; \
273 path_make_relative(from_dir, to_path, &z); \
274 assert_se(streq(z, expected)); \
6b56a651
TK
275 }
276
277 test("/", "/", ".");
278 test("/", "/some/path", "some/path");
279 test("/some/path", "/some/path", ".");
280 test("/some/path", "/some/path/in/subdir", "in/subdir");
281 test("/some/path", "/", "../..");
282 test("/some/path", "/some/other/path", "../other/path");
2a5beb66 283 test("/some/path/./dot", "/some/further/path", "../../further/path");
48054262 284 test("//extra.//.//./.slashes//./won't////fo.ol///anybody//", "/././/extra././/.slashes////ar.e/.just/././.fine///", "../../../ar.e/.just/.fine");
6b56a651
TK
285}
286
3e8a78c8
MM
287static void test_strv_resolve(void) {
288 char tmp_dir[] = "/tmp/test-path-util-XXXXXX";
289 _cleanup_strv_free_ char **search_dirs = NULL;
290 _cleanup_strv_free_ char **absolute_dirs = NULL;
291 char **d;
292
293 assert_se(mkdtemp(tmp_dir) != NULL);
294
295 search_dirs = strv_new("/dir1", "/dir2", "/dir3", NULL);
296 assert_se(search_dirs);
297 STRV_FOREACH(d, search_dirs) {
298 char *p = strappend(tmp_dir, *d);
299 assert_se(p);
300 assert_se(strv_push(&absolute_dirs, p) == 0);
301 }
302
303 assert_se(mkdir(absolute_dirs[0], 0700) == 0);
304 assert_se(mkdir(absolute_dirs[1], 0700) == 0);
305 assert_se(symlink("dir2", absolute_dirs[2]) == 0);
306
307 path_strv_resolve(search_dirs, tmp_dir);
308 assert_se(streq(search_dirs[0], "/dir1"));
309 assert_se(streq(search_dirs[1], "/dir2"));
310 assert_se(streq(search_dirs[2], "/dir2"));
311
c6878637 312 assert_se(rm_rf(tmp_dir, REMOVE_ROOT|REMOVE_PHYSICAL) == 0);
3e8a78c8
MM
313}
314
5895b62f 315static void test_path_startswith(void) {
0470289b
ZJS
316 const char *p;
317
318 p = path_startswith("/foo/bar/barfoo/", "/foo");
319 assert_se(streq_ptr(p, "bar/barfoo/"));
320
321 p = path_startswith("/foo/bar/barfoo/", "/foo/");
322 assert_se(streq_ptr(p, "bar/barfoo/"));
323
324 p = path_startswith("/foo/bar/barfoo/", "/");
325 assert_se(streq_ptr(p, "foo/bar/barfoo/"));
326
327 p = path_startswith("/foo/bar/barfoo/", "////");
328 assert_se(streq_ptr(p, "foo/bar/barfoo/"));
329
330 p = path_startswith("/foo/bar/barfoo/", "/foo//bar/////barfoo///");
331 assert_se(streq_ptr(p, ""));
332
333 p = path_startswith("/foo/bar/barfoo/", "/foo/bar/barfoo////");
334 assert_se(streq_ptr(p, ""));
335
336 p = path_startswith("/foo/bar/barfoo/", "/foo/bar///barfoo/");
337 assert_se(streq_ptr(p, ""));
338
339 p = path_startswith("/foo/bar/barfoo/", "/foo////bar/barfoo/");
340 assert_se(streq_ptr(p, ""));
341
342 p = path_startswith("/foo/bar/barfoo/", "////foo/bar/barfoo/");
343 assert_se(streq_ptr(p, ""));
344
345 p = path_startswith("/foo/bar/barfoo/", "/foo/bar/barfoo");
346 assert_se(streq_ptr(p, ""));
5895b62f
RC
347
348 assert_se(!path_startswith("/foo/bar/barfoo/", "/foo/bar/barfooa/"));
349 assert_se(!path_startswith("/foo/bar/barfoo/", "/foo/bar/barfooa"));
350 assert_se(!path_startswith("/foo/bar/barfoo/", ""));
351 assert_se(!path_startswith("/foo/bar/barfoo/", "/bar/foo"));
352 assert_se(!path_startswith("/foo/bar/barfoo/", "/f/b/b/"));
353}
354
1d13f648
LP
355static void test_prefix_root_one(const char *r, const char *p, const char *expected) {
356 _cleanup_free_ char *s = NULL;
357 const char *t;
358
359 assert_se(s = prefix_root(r, p));
360 assert_se(streq_ptr(s, expected));
361
362 t = prefix_roota(r, p);
363 assert_se(t);
364 assert_se(streq_ptr(t, expected));
365}
366
367static void test_prefix_root(void) {
368 test_prefix_root_one("/", "/foo", "/foo");
369 test_prefix_root_one(NULL, "/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, "////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
63292663
RC
383static void test_file_in_same_dir(void) {
384 char *t;
385
386 t = file_in_same_dir("/", "a");
387 assert_se(streq(t, "/a"));
388 free(t);
389
390 t = file_in_same_dir("/", "/a");
391 assert_se(streq(t, "/a"));
392 free(t);
393
394 t = file_in_same_dir("", "a");
395 assert_se(streq(t, "a"));
396 free(t);
397
398 t = file_in_same_dir("a/", "a");
399 assert_se(streq(t, "a/a"));
400 free(t);
401
402 t = file_in_same_dir("bar/foo", "bar");
403 assert_se(streq(t, "bar/bar"));
404 free(t);
405}
406
b12d25a8
ZJS
407static void test_last_path_component(void) {
408 assert_se(streq(last_path_component("a/b/c"), "c"));
409 assert_se(streq(last_path_component("a/b/c/"), "c/"));
410 assert_se(streq(last_path_component("/"), "/"));
411 assert_se(streq(last_path_component("//"), "/"));
412 assert_se(streq(last_path_component("///"), "/"));
413 assert_se(streq(last_path_component("."), "."));
414 assert_se(streq(last_path_component("./."), "."));
415 assert_se(streq(last_path_component("././"), "./"));
416 assert_se(streq(last_path_component("././/"), ".//"));
417 assert_se(streq(last_path_component("/foo/a"), "a"));
418 assert_se(streq(last_path_component("/foo/a/"), "a/"));
69f9ccf1 419 assert_se(streq(last_path_component(""), ""));
8460289f
LP
420 assert_se(streq(last_path_component("a"), "a"));
421 assert_se(streq(last_path_component("a/"), "a/"));
422 assert_se(streq(last_path_component("/a"), "a"));
423 assert_se(streq(last_path_component("/a/"), "a/"));
b12d25a8
ZJS
424}
425
63292663
RC
426static void test_filename_is_valid(void) {
427 char foo[FILENAME_MAX+2];
428 int i;
429
430 assert_se(!filename_is_valid(""));
431 assert_se(!filename_is_valid("/bar/foo"));
432 assert_se(!filename_is_valid("/"));
433 assert_se(!filename_is_valid("."));
434 assert_se(!filename_is_valid(".."));
435
436 for (i=0; i<FILENAME_MAX+1; i++)
437 foo[i] = 'a';
438 foo[FILENAME_MAX+1] = '\0';
439
440 assert_se(!filename_is_valid(foo));
441
442 assert_se(filename_is_valid("foo_bar-333"));
443 assert_se(filename_is_valid("o.o"));
444}
445
b05b9cde
ZJS
446static void test_hidden_or_backup_file(void) {
447 assert_se(hidden_or_backup_file(".hidden"));
448 assert_se(hidden_or_backup_file("..hidden"));
449 assert_se(!hidden_or_backup_file("hidden."));
450
451 assert_se(hidden_or_backup_file("backup~"));
452 assert_se(hidden_or_backup_file(".backup~"));
453
454 assert_se(hidden_or_backup_file("lost+found"));
455 assert_se(hidden_or_backup_file("aquota.user"));
456 assert_se(hidden_or_backup_file("aquota.group"));
457
458 assert_se(hidden_or_backup_file("test.rpmnew"));
459 assert_se(hidden_or_backup_file("test.dpkg-old"));
460 assert_se(hidden_or_backup_file("test.dpkg-remove"));
461 assert_se(hidden_or_backup_file("test.swp"));
462
463 assert_se(!hidden_or_backup_file("test.rpmnew."));
464 assert_se(!hidden_or_backup_file("test.dpkg-old.foo"));
465}
466
5a46d55f
ZJS
467static void test_systemd_installation_has_version(const char *path) {
468 int r;
469 const unsigned versions[] = {0, 231, atoi(PACKAGE_VERSION), 999};
470 unsigned i;
471
472 for (i = 0; i < ELEMENTSOF(versions); i++) {
473 r = systemd_installation_has_version(path, versions[i]);
474 assert_se(r >= 0);
475 log_info("%s has systemd >= %u: %s",
476 path ?: "Current installation", versions[i], yes_no(r));
477 }
478}
479
a119ec7c
LP
480static void test_skip_dev_prefix(void) {
481
482 assert_se(streq(skip_dev_prefix("/"), "/"));
483 assert_se(streq(skip_dev_prefix("/dev"), ""));
484 assert_se(streq(skip_dev_prefix("/dev/"), ""));
485 assert_se(streq(skip_dev_prefix("/dev/foo"), "foo"));
486 assert_se(streq(skip_dev_prefix("/dev/foo/bar"), "foo/bar"));
487 assert_se(streq(skip_dev_prefix("//dev"), ""));
488 assert_se(streq(skip_dev_prefix("//dev//"), ""));
489 assert_se(streq(skip_dev_prefix("/dev///foo"), "foo"));
490 assert_se(streq(skip_dev_prefix("///dev///foo///bar"), "foo///bar"));
491 assert_se(streq(skip_dev_prefix("//foo"), "//foo"));
492 assert_se(streq(skip_dev_prefix("foo"), "foo"));
493}
494
57ea45e1
LP
495static void test_empty_or_root(void) {
496 assert_se(empty_or_root(NULL));
497 assert_se(empty_or_root(""));
498 assert_se(empty_or_root("/"));
499 assert_se(empty_or_root("//"));
500 assert_se(empty_or_root("///"));
501 assert_se(empty_or_root("/////////////////"));
502 assert_se(!empty_or_root("xxx"));
503 assert_se(!empty_or_root("/xxx"));
504 assert_se(!empty_or_root("/xxx/"));
505 assert_se(!empty_or_root("//yy//"));
506}
507
7f076504 508int main(int argc, char **argv) {
5a46d55f
ZJS
509 log_set_max_level(LOG_DEBUG);
510 log_parse_environment();
511 log_open();
512
76877b46 513 test_path();
84e72b5e 514 test_path_equal_root();
85eca92e 515 test_find_binary(argv[0]);
fecffe5d 516 test_prefixes();
0c6ea3a4 517 test_path_join();
eb66db55 518 test_fsck_exists();
6b56a651 519 test_make_relative();
3e8a78c8 520 test_strv_resolve();
5895b62f 521 test_path_startswith();
1d13f648 522 test_prefix_root();
63292663 523 test_file_in_same_dir();
b12d25a8 524 test_last_path_component();
63292663 525 test_filename_is_valid();
b05b9cde 526 test_hidden_or_backup_file();
a119ec7c 527 test_skip_dev_prefix();
57ea45e1 528 test_empty_or_root();
5895b62f 529
5a46d55f
ZJS
530 test_systemd_installation_has_version(argv[1]); /* NULL is OK */
531
76877b46
ZJS
532 return 0;
533}