]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
b0193f1c | 2 | |
07630cea | 3 | #include <pwd.h> |
b0193f1c LP |
4 | #include <stdio.h> |
5 | #include <stdlib.h> | |
6 | #include <string.h> | |
7 | ||
b5efdb8a | 8 | #include "alloc-util.h" |
57b7a260 | 9 | #include "all-units.h" |
2aaafcf5 | 10 | #include "glob-util.h" |
ca78ad1d | 11 | #include "format-util.h" |
07630cea LP |
12 | #include "hostname-util.h" |
13 | #include "macro.h" | |
1682ff60 | 14 | #include "manager.h" |
07630cea | 15 | #include "path-util.h" |
a04efff8 | 16 | #include "rm-rf.h" |
e5af6e0e | 17 | #include "special.h" |
07630cea LP |
18 | #include "specifier.h" |
19 | #include "string-util.h" | |
20 | #include "test-helper.h" | |
a04efff8 | 21 | #include "tests.h" |
b4152e9b | 22 | #include "unit-def.h" |
b0193f1c | 23 | #include "unit-name.h" |
1682ff60 | 24 | #include "unit-printf.h" |
07630cea | 25 | #include "unit.h" |
79413b67 | 26 | #include "user-util.h" |
b0193f1c LP |
27 | #include "util.h" |
28 | ||
7410616c | 29 | static void test_unit_name_is_valid(void) { |
0682ed5c ZJS |
30 | assert_se( unit_name_is_valid("foo.service", UNIT_NAME_ANY)); |
31 | assert_se( unit_name_is_valid("foo.service", UNIT_NAME_PLAIN)); | |
7410616c LP |
32 | assert_se(!unit_name_is_valid("foo.service", UNIT_NAME_INSTANCE)); |
33 | assert_se(!unit_name_is_valid("foo.service", UNIT_NAME_TEMPLATE)); | |
34 | assert_se(!unit_name_is_valid("foo.service", UNIT_NAME_INSTANCE|UNIT_NAME_TEMPLATE)); | |
35 | ||
0682ed5c | 36 | assert_se( unit_name_is_valid("foo@bar.service", UNIT_NAME_ANY)); |
7410616c | 37 | assert_se(!unit_name_is_valid("foo@bar.service", UNIT_NAME_PLAIN)); |
0682ed5c | 38 | assert_se( unit_name_is_valid("foo@bar.service", UNIT_NAME_INSTANCE)); |
7410616c | 39 | assert_se(!unit_name_is_valid("foo@bar.service", UNIT_NAME_TEMPLATE)); |
0682ed5c | 40 | assert_se( unit_name_is_valid("foo@bar.service", UNIT_NAME_INSTANCE|UNIT_NAME_TEMPLATE)); |
7410616c | 41 | |
0682ed5c ZJS |
42 | assert_se( unit_name_is_valid("foo@bar@bar.service", UNIT_NAME_ANY)); |
43 | assert_se(!unit_name_is_valid("foo@bar@bar.service", UNIT_NAME_PLAIN)); | |
44 | assert_se( unit_name_is_valid("foo@bar@bar.service", UNIT_NAME_INSTANCE)); | |
45 | assert_se(!unit_name_is_valid("foo@bar@bar.service", UNIT_NAME_TEMPLATE)); | |
46 | assert_se( unit_name_is_valid("foo@bar@bar.service", UNIT_NAME_INSTANCE|UNIT_NAME_TEMPLATE)); | |
47 | ||
48 | assert_se( unit_name_is_valid("foo@.service", UNIT_NAME_ANY)); | |
7410616c LP |
49 | assert_se(!unit_name_is_valid("foo@.service", UNIT_NAME_PLAIN)); |
50 | assert_se(!unit_name_is_valid("foo@.service", UNIT_NAME_INSTANCE)); | |
0682ed5c ZJS |
51 | assert_se( unit_name_is_valid("foo@.service", UNIT_NAME_TEMPLATE)); |
52 | assert_se( unit_name_is_valid("foo@.service", UNIT_NAME_INSTANCE|UNIT_NAME_TEMPLATE)); | |
7410616c LP |
53 | |
54 | assert_se(!unit_name_is_valid(".service", UNIT_NAME_ANY)); | |
55 | assert_se(!unit_name_is_valid("", UNIT_NAME_ANY)); | |
56 | assert_se(!unit_name_is_valid("foo.waldo", UNIT_NAME_ANY)); | |
57 | assert_se(!unit_name_is_valid("@.service", UNIT_NAME_ANY)); | |
58 | assert_se(!unit_name_is_valid("@piep.service", UNIT_NAME_ANY)); | |
0682ed5c ZJS |
59 | |
60 | assert_se( unit_name_is_valid("user@1000.slice", UNIT_NAME_ANY)); | |
61 | assert_se( unit_name_is_valid("user@1000.slice", UNIT_NAME_INSTANCE)); | |
62 | assert_se(!unit_name_is_valid("user@1000.slice", UNIT_NAME_TEMPLATE)); | |
7410616c | 63 | } |
3251c0d2 | 64 | |
21868586 | 65 | static void test_unit_name_replace_instance_one(const char *pattern, const char *repl, const char *expected, int ret) { |
7410616c LP |
66 | _cleanup_free_ char *t = NULL; |
67 | assert_se(unit_name_replace_instance(pattern, repl, &t) == ret); | |
68 | puts(strna(t)); | |
69 | assert_se(streq_ptr(t, expected)); | |
70 | } | |
3251c0d2 | 71 | |
21868586 | 72 | static void test_unit_name_replace_instance(void) { |
3251c0d2 | 73 | puts("-------------------------------------------------"); |
21868586 LP |
74 | test_unit_name_replace_instance_one("foo@.service", "waldo", "foo@waldo.service", 0); |
75 | test_unit_name_replace_instance_one("foo@xyz.service", "waldo", "foo@waldo.service", 0); | |
76 | test_unit_name_replace_instance_one("xyz", "waldo", NULL, -EINVAL); | |
77 | test_unit_name_replace_instance_one("", "waldo", NULL, -EINVAL); | |
78 | test_unit_name_replace_instance_one("foo.service", "waldo", NULL, -EINVAL); | |
79 | test_unit_name_replace_instance_one(".service", "waldo", NULL, -EINVAL); | |
80 | test_unit_name_replace_instance_one("foo@", "waldo", NULL, -EINVAL); | |
81 | test_unit_name_replace_instance_one("@bar", "waldo", NULL, -EINVAL); | |
7410616c | 82 | } |
3251c0d2 | 83 | |
21868586 | 84 | static void test_unit_name_from_path_one(const char *path, const char *suffix, const char *expected, int ret) { |
7410616c | 85 | _cleanup_free_ char *t = NULL; |
3251c0d2 | 86 | |
7410616c LP |
87 | assert_se(unit_name_from_path(path, suffix, &t) == ret); |
88 | puts(strna(t)); | |
89 | assert_se(streq_ptr(t, expected)); | |
3251c0d2 | 90 | |
7410616c LP |
91 | if (t) { |
92 | _cleanup_free_ char *k = NULL; | |
93 | assert_se(unit_name_to_path(t, &k) == 0); | |
94 | puts(strna(k)); | |
945403e6 | 95 | assert_se(path_equal(k, empty_to_root(path))); |
7410616c LP |
96 | } |
97 | } | |
3251c0d2 | 98 | |
21868586 | 99 | static void test_unit_name_from_path(void) { |
3251c0d2 | 100 | puts("-------------------------------------------------"); |
21868586 LP |
101 | test_unit_name_from_path_one("/waldo", ".mount", "waldo.mount", 0); |
102 | test_unit_name_from_path_one("/waldo/quuix", ".mount", "waldo-quuix.mount", 0); | |
103 | test_unit_name_from_path_one("/waldo/quuix/", ".mount", "waldo-quuix.mount", 0); | |
104 | test_unit_name_from_path_one("", ".mount", "-.mount", 0); | |
105 | test_unit_name_from_path_one("/", ".mount", "-.mount", 0); | |
106 | test_unit_name_from_path_one("///", ".mount", "-.mount", 0); | |
107 | test_unit_name_from_path_one("/foo/../bar", ".mount", NULL, -EINVAL); | |
108 | test_unit_name_from_path_one("/foo/./bar", ".mount", NULL, -EINVAL); | |
7410616c LP |
109 | } |
110 | ||
21868586 | 111 | static void test_unit_name_from_path_instance_one(const char *pattern, const char *path, const char *suffix, const char *expected, int ret) { |
7410616c LP |
112 | _cleanup_free_ char *t = NULL; |
113 | ||
114 | assert_se(unit_name_from_path_instance(pattern, path, suffix, &t) == ret); | |
115 | puts(strna(t)); | |
116 | assert_se(streq_ptr(t, expected)); | |
117 | ||
118 | if (t) { | |
119 | _cleanup_free_ char *k = NULL, *v = NULL; | |
120 | ||
121 | assert_se(unit_name_to_instance(t, &k) > 0); | |
122 | assert_se(unit_name_path_unescape(k, &v) == 0); | |
945403e6 | 123 | assert_se(path_equal(v, empty_to_root(path))); |
3251c0d2 | 124 | } |
7410616c | 125 | } |
3251c0d2 | 126 | |
21868586 | 127 | static void test_unit_name_from_path_instance(void) { |
7410616c | 128 | puts("-------------------------------------------------"); |
b0193f1c | 129 | |
21868586 LP |
130 | test_unit_name_from_path_instance_one("waldo", "/waldo", ".mount", "waldo@waldo.mount", 0); |
131 | test_unit_name_from_path_instance_one("waldo", "/waldo////quuix////", ".mount", "waldo@waldo-quuix.mount", 0); | |
132 | test_unit_name_from_path_instance_one("waldo", "/", ".mount", "waldo@-.mount", 0); | |
133 | test_unit_name_from_path_instance_one("waldo", "", ".mount", "waldo@-.mount", 0); | |
134 | test_unit_name_from_path_instance_one("waldo", "///", ".mount", "waldo@-.mount", 0); | |
135 | test_unit_name_from_path_instance_one("waldo", "..", ".mount", NULL, -EINVAL); | |
136 | test_unit_name_from_path_instance_one("waldo", "/foo", ".waldi", NULL, -EINVAL); | |
137 | test_unit_name_from_path_instance_one("wa--ldo", "/--", ".mount", "wa--ldo@\\x2d\\x2d.mount", 0); | |
7410616c LP |
138 | } |
139 | ||
21868586 | 140 | static void test_unit_name_to_path_one(const char *unit, const char *path, int ret) { |
7410616c LP |
141 | _cleanup_free_ char *p = NULL; |
142 | ||
143 | assert_se(unit_name_to_path(unit, &p) == ret); | |
144 | assert_se(streq_ptr(path, p)); | |
145 | } | |
146 | ||
21868586 LP |
147 | static void test_unit_name_to_path(void) { |
148 | test_unit_name_to_path_one("home.mount", "/home", 0); | |
149 | test_unit_name_to_path_one("home-lennart.mount", "/home/lennart", 0); | |
150 | test_unit_name_to_path_one("home-lennart-.mount", NULL, -EINVAL); | |
151 | test_unit_name_to_path_one("-home-lennart.mount", NULL, -EINVAL); | |
152 | test_unit_name_to_path_one("-home--lennart.mount", NULL, -EINVAL); | |
153 | test_unit_name_to_path_one("home-..-lennart.mount", NULL, -EINVAL); | |
154 | test_unit_name_to_path_one("", NULL, -EINVAL); | |
155 | test_unit_name_to_path_one("home/foo", NULL, -EINVAL); | |
7410616c LP |
156 | } |
157 | ||
37cbc1d5 | 158 | static void test_unit_name_mangle_one(bool allow_globs, const char *pattern, const char *expect, int ret) { |
7410616c LP |
159 | _cleanup_free_ char *t = NULL; |
160 | ||
37cbc1d5 | 161 | assert_se(unit_name_mangle(pattern, (allow_globs * UNIT_NAME_MANGLE_GLOB) | UNIT_NAME_MANGLE_WARN, &t) == ret); |
7410616c LP |
162 | puts(strna(t)); |
163 | assert_se(streq_ptr(t, expect)); | |
164 | ||
165 | if (t) { | |
166 | _cleanup_free_ char *k = NULL; | |
167 | ||
2aaafcf5 | 168 | assert_se(unit_name_is_valid(t, UNIT_NAME_ANY) || |
37cbc1d5 | 169 | (allow_globs && string_is_glob(t))); |
7410616c | 170 | |
37cbc1d5 | 171 | assert_se(unit_name_mangle(t, (allow_globs * UNIT_NAME_MANGLE_GLOB) | UNIT_NAME_MANGLE_WARN, &k) == 0); |
7410616c LP |
172 | assert_se(streq_ptr(t, k)); |
173 | } | |
174 | } | |
175 | ||
21868586 | 176 | static void test_unit_name_mangle(void) { |
7410616c | 177 | puts("-------------------------------------------------"); |
37cbc1d5 ZJS |
178 | test_unit_name_mangle_one(false, "foo.service", "foo.service", 0); |
179 | test_unit_name_mangle_one(false, "/home", "home.mount", 1); | |
180 | test_unit_name_mangle_one(false, "/dev/sda", "dev-sda.device", 1); | |
181 | test_unit_name_mangle_one(false, "üxknürz.service", "\\xc3\\xbcxkn\\xc3\\xbcrz.service", 1); | |
182 | test_unit_name_mangle_one(false, "foobar-meh...waldi.service", "foobar-meh...waldi.service", 0); | |
183 | test_unit_name_mangle_one(false, "_____####----.....service", "_____\\x23\\x23\\x23\\x23----.....service", 1); | |
184 | test_unit_name_mangle_one(false, "_____##@;;;,,,##----.....service", "_____\\x23\\x23@\\x3b\\x3b\\x3b\\x2c\\x2c\\x2c\\x23\\x23----.....service", 1); | |
185 | test_unit_name_mangle_one(false, "xxx@@@@/////\\\\\\\\\\yyy.service", "xxx@@@@-----\\\\\\\\\\yyy.service", 1); | |
186 | test_unit_name_mangle_one(false, "", NULL, -EINVAL); | |
187 | ||
188 | test_unit_name_mangle_one(true, "foo.service", "foo.service", 0); | |
189 | test_unit_name_mangle_one(true, "foo", "foo.service", 1); | |
190 | test_unit_name_mangle_one(true, "foo*", "foo*", 0); | |
191 | test_unit_name_mangle_one(true, "ü*", "\\xc3\\xbc*", 1); | |
1682ff60 ZJS |
192 | } |
193 | ||
49e5de64 | 194 | static int test_unit_printf(void) { |
b75f0c69 | 195 | _cleanup_free_ char *mid = NULL, *bid = NULL, *host = NULL, *gid = NULL, *group = NULL, *uid = NULL, *user = NULL, *shell = NULL, *home = NULL; |
c70cac54 | 196 | _cleanup_(manager_freep) Manager *m = NULL; |
250e9fad | 197 | Unit *u; |
c5e33bf8 | 198 | int r; |
1682ff60 | 199 | |
19f6d710 LP |
200 | assert_se(specifier_machine_id('m', NULL, NULL, &mid) >= 0 && mid); |
201 | assert_se(specifier_boot_id('b', NULL, NULL, &bid) >= 0 && bid); | |
79413b67 | 202 | assert_se(host = gethostname_malloc()); |
36444d22 | 203 | assert_se(user = uid_to_name(getuid())); |
b75f0c69 | 204 | assert_se(group = gid_to_name(getgid())); |
79413b67 | 205 | assert_se(asprintf(&uid, UID_FMT, getuid())); |
b75f0c69 | 206 | assert_se(asprintf(&gid, UID_FMT, getgid())); |
79413b67 LP |
207 | assert_se(get_home_dir(&home) >= 0); |
208 | assert_se(get_shell(&shell) >= 0); | |
1682ff60 | 209 | |
e0a3da1f | 210 | r = manager_new(UNIT_FILE_USER, MANAGER_TEST_RUN_MINIMAL, &m); |
730d989a ZJS |
211 | if (MANAGER_SKIP_TEST(r)) |
212 | return log_tests_skipped_errno(r, "manager_new"); | |
bdf7026e | 213 | assert_se(r == 0); |
1682ff60 ZJS |
214 | |
215 | #define expect(unit, pattern, expected) \ | |
216 | { \ | |
fa3cd739 | 217 | char *e; \ |
e1ba963f | 218 | _cleanup_free_ char *t = NULL; \ |
19f6d710 | 219 | assert_se(unit_full_printf(unit, pattern, &t) >= 0); \ |
c5e33bf8 | 220 | printf("result: %s\nexpect: %s\n", t, expected); \ |
fa3cd739 | 221 | if ((e = endswith(expected, "*"))) \ |
bdf7026e | 222 | assert_se(strncmp(t, e, e-expected)); \ |
fa3cd739 | 223 | else \ |
bdf7026e | 224 | assert_se(streq(t, expected)); \ |
1682ff60 ZJS |
225 | } |
226 | ||
1682ff60 ZJS |
227 | assert_se(u = unit_new(m, sizeof(Service))); |
228 | assert_se(unit_add_name(u, "blah.service") == 0); | |
229 | assert_se(unit_add_name(u, "blah.service") == 0); | |
230 | ||
231 | /* general tests */ | |
232 | expect(u, "%%", "%"); | |
233 | expect(u, "%%s", "%s"); | |
038492ae FS |
234 | expect(u, "%,", "%,"); |
235 | expect(u, "%", "%"); | |
1682ff60 ZJS |
236 | |
237 | /* normal unit */ | |
238 | expect(u, "%n", "blah.service"); | |
14b0295f | 239 | expect(u, "%f", "/blah"); |
1682ff60 ZJS |
240 | expect(u, "%N", "blah"); |
241 | expect(u, "%p", "blah"); | |
242 | expect(u, "%P", "blah"); | |
243 | expect(u, "%i", ""); | |
250e9fad ZJS |
244 | expect(u, "%I", ""); |
245 | expect(u, "%j", "blah"); | |
246 | expect(u, "%J", "blah"); | |
b75f0c69 DC |
247 | expect(u, "%g", group); |
248 | expect(u, "%G", gid); | |
79413b67 LP |
249 | expect(u, "%u", user); |
250 | expect(u, "%U", uid); | |
251 | expect(u, "%h", home); | |
1682ff60 ZJS |
252 | expect(u, "%m", mid); |
253 | expect(u, "%b", bid); | |
254 | expect(u, "%H", host); | |
fa3cd739 | 255 | expect(u, "%t", "/run/user/*"); |
1682ff60 ZJS |
256 | |
257 | /* templated */ | |
250e9fad ZJS |
258 | assert_se(u = unit_new(m, sizeof(Service))); |
259 | assert_se(unit_add_name(u, "blah@foo-foo.service") == 0); | |
260 | assert_se(unit_add_name(u, "blah@foo-foo.service") == 0); | |
261 | ||
262 | expect(u, "%n", "blah@foo-foo.service"); | |
263 | expect(u, "%N", "blah@foo-foo"); | |
264 | expect(u, "%f", "/foo/foo"); | |
265 | expect(u, "%p", "blah"); | |
266 | expect(u, "%P", "blah"); | |
267 | expect(u, "%i", "foo-foo"); | |
268 | expect(u, "%I", "foo/foo"); | |
269 | expect(u, "%j", "blah"); | |
270 | expect(u, "%J", "blah"); | |
b75f0c69 DC |
271 | expect(u, "%g", group); |
272 | expect(u, "%G", gid); | |
250e9fad ZJS |
273 | expect(u, "%u", user); |
274 | expect(u, "%U", uid); | |
275 | expect(u, "%h", home); | |
276 | expect(u, "%m", mid); | |
277 | expect(u, "%b", bid); | |
278 | expect(u, "%H", host); | |
279 | expect(u, "%t", "/run/user/*"); | |
280 | ||
281 | /* templated with components */ | |
282 | assert_se(u = unit_new(m, sizeof(Slice))); | |
283 | assert_se(unit_add_name(u, "blah-blah\\x2d.slice") == 0); | |
284 | ||
285 | expect(u, "%n", "blah-blah\\x2d.slice"); | |
286 | expect(u, "%N", "blah-blah\\x2d"); | |
287 | expect(u, "%f", "/blah/blah-"); | |
288 | expect(u, "%p", "blah-blah\\x2d"); | |
289 | expect(u, "%P", "blah/blah-"); | |
290 | expect(u, "%i", ""); | |
291 | expect(u, "%I", ""); | |
292 | expect(u, "%j", "blah\\x2d"); | |
293 | expect(u, "%J", "blah-"); | |
294 | ||
fee0a921 | 295 | #undef expect |
b463b813 | 296 | |
49e5de64 | 297 | return 0; |
1682ff60 ZJS |
298 | } |
299 | ||
068ae9fb RC |
300 | static void test_unit_instance_is_valid(void) { |
301 | assert_se(unit_instance_is_valid("fooBar")); | |
302 | assert_se(unit_instance_is_valid("foo-bar")); | |
303 | assert_se(unit_instance_is_valid("foo.stUff")); | |
304 | assert_se(unit_instance_is_valid("fOo123.stuff")); | |
305 | assert_se(unit_instance_is_valid("@f_oo123.Stuff")); | |
306 | ||
307 | assert_se(!unit_instance_is_valid("$¢£")); | |
308 | assert_se(!unit_instance_is_valid("")); | |
309 | assert_se(!unit_instance_is_valid("foo bar")); | |
310 | assert_se(!unit_instance_is_valid("foo/bar")); | |
311 | } | |
312 | ||
313 | static void test_unit_prefix_is_valid(void) { | |
314 | assert_se(unit_prefix_is_valid("fooBar")); | |
315 | assert_se(unit_prefix_is_valid("foo-bar")); | |
316 | assert_se(unit_prefix_is_valid("foo.stUff")); | |
317 | assert_se(unit_prefix_is_valid("fOo123.stuff")); | |
318 | assert_se(unit_prefix_is_valid("foo123.Stuff")); | |
319 | ||
320 | assert_se(!unit_prefix_is_valid("$¢£")); | |
321 | assert_se(!unit_prefix_is_valid("")); | |
322 | assert_se(!unit_prefix_is_valid("foo bar")); | |
323 | assert_se(!unit_prefix_is_valid("foo/bar")); | |
324 | assert_se(!unit_prefix_is_valid("@foo-bar")); | |
325 | } | |
326 | ||
327 | static void test_unit_name_change_suffix(void) { | |
7410616c | 328 | char *t; |
068ae9fb | 329 | |
7410616c LP |
330 | assert_se(unit_name_change_suffix("foo.mount", ".service", &t) == 0); |
331 | assert_se(streq(t, "foo.service")); | |
332 | free(t); | |
068ae9fb | 333 | |
7410616c LP |
334 | assert_se(unit_name_change_suffix("foo@stuff.service", ".socket", &t) == 0); |
335 | assert_se(streq(t, "foo@stuff.socket")); | |
336 | free(t); | |
068ae9fb RC |
337 | } |
338 | ||
339 | static void test_unit_name_build(void) { | |
7410616c | 340 | char *t; |
068ae9fb | 341 | |
7410616c LP |
342 | assert_se(unit_name_build("foo", "bar", ".service", &t) == 0); |
343 | assert_se(streq(t, "foo@bar.service")); | |
344 | free(t); | |
068ae9fb | 345 | |
7410616c LP |
346 | assert_se(unit_name_build("fo0-stUff_b", "bar", ".mount", &t) == 0); |
347 | assert_se(streq(t, "fo0-stUff_b@bar.mount")); | |
348 | free(t); | |
068ae9fb | 349 | |
7410616c LP |
350 | assert_se(unit_name_build("foo", NULL, ".service", &t) == 0); |
351 | assert_se(streq(t, "foo.service")); | |
352 | free(t); | |
068ae9fb RC |
353 | } |
354 | ||
93c47472 | 355 | static void test_slice_name_is_valid(void) { |
0682ed5c ZJS |
356 | assert_se( slice_name_is_valid(SPECIAL_ROOT_SLICE)); |
357 | assert_se( slice_name_is_valid("foo.slice")); | |
358 | assert_se( slice_name_is_valid("foo-bar.slice")); | |
359 | assert_se( slice_name_is_valid("foo-bar-baz.slice")); | |
93c47472 LP |
360 | assert_se(!slice_name_is_valid("-foo-bar-baz.slice")); |
361 | assert_se(!slice_name_is_valid("foo-bar-baz-.slice")); | |
362 | assert_se(!slice_name_is_valid("-foo-bar-baz-.slice")); | |
363 | assert_se(!slice_name_is_valid("foo-bar--baz.slice")); | |
364 | assert_se(!slice_name_is_valid("foo--bar--baz.slice")); | |
365 | assert_se(!slice_name_is_valid(".slice")); | |
366 | assert_se(!slice_name_is_valid("")); | |
367 | assert_se(!slice_name_is_valid("foo.service")); | |
0682ed5c ZJS |
368 | |
369 | assert_se(!slice_name_is_valid("foo@.slice")); | |
370 | assert_se(!slice_name_is_valid("foo@bar.slice")); | |
371 | assert_se(!slice_name_is_valid("foo-bar@baz.slice")); | |
372 | assert_se(!slice_name_is_valid("foo@bar@baz.slice")); | |
373 | assert_se(!slice_name_is_valid("foo@bar-baz.slice")); | |
374 | assert_se(!slice_name_is_valid("-foo-bar-baz@.slice")); | |
375 | assert_se(!slice_name_is_valid("foo-bar-baz@-.slice")); | |
376 | assert_se(!slice_name_is_valid("foo-bar-baz@a--b.slice")); | |
377 | assert_se(!slice_name_is_valid("-foo-bar-baz@-.slice")); | |
378 | assert_se(!slice_name_is_valid("foo-bar--baz@.slice")); | |
379 | assert_se(!slice_name_is_valid("foo--bar--baz@.slice")); | |
380 | assert_se(!slice_name_is_valid("@.slice")); | |
381 | assert_se(!slice_name_is_valid("foo@bar.service")); | |
93c47472 LP |
382 | } |
383 | ||
068ae9fb RC |
384 | static void test_build_subslice(void) { |
385 | char *a; | |
386 | char *b; | |
387 | ||
e5af6e0e | 388 | assert_se(slice_build_subslice(SPECIAL_ROOT_SLICE, "foo", &a) >= 0); |
7410616c | 389 | assert_se(slice_build_subslice(a, "bar", &b) >= 0); |
068ae9fb | 390 | free(a); |
7410616c | 391 | assert_se(slice_build_subslice(b, "barfoo", &a) >= 0); |
068ae9fb | 392 | free(b); |
7410616c | 393 | assert_se(slice_build_subslice(a, "foobar", &b) >= 0); |
068ae9fb RC |
394 | free(a); |
395 | assert_se(streq(b, "foo-bar-barfoo-foobar.slice")); | |
396 | free(b); | |
397 | ||
7410616c LP |
398 | assert_se(slice_build_subslice("foo.service", "bar", &a) < 0); |
399 | assert_se(slice_build_subslice("foo", "bar", &a) < 0); | |
068ae9fb RC |
400 | } |
401 | ||
93c47472 LP |
402 | static void test_build_parent_slice_one(const char *name, const char *expect, int ret) { |
403 | _cleanup_free_ char *s = NULL; | |
404 | ||
405 | assert_se(slice_build_parent_slice(name, &s) == ret); | |
406 | assert_se(streq_ptr(s, expect)); | |
407 | } | |
408 | ||
409 | static void test_build_parent_slice(void) { | |
e5af6e0e ZJS |
410 | test_build_parent_slice_one(SPECIAL_ROOT_SLICE, NULL, 0); |
411 | test_build_parent_slice_one("foo.slice", SPECIAL_ROOT_SLICE, 1); | |
93c47472 LP |
412 | test_build_parent_slice_one("foo-bar.slice", "foo.slice", 1); |
413 | test_build_parent_slice_one("foo-bar-baz.slice", "foo-bar.slice", 1); | |
414 | test_build_parent_slice_one("foo-bar--baz.slice", NULL, -EINVAL); | |
415 | test_build_parent_slice_one("-foo-bar.slice", NULL, -EINVAL); | |
416 | test_build_parent_slice_one("foo-bar-.slice", NULL, -EINVAL); | |
417 | test_build_parent_slice_one("foo-bar.service", NULL, -EINVAL); | |
418 | test_build_parent_slice_one(".slice", NULL, -EINVAL); | |
0682ed5c ZJS |
419 | test_build_parent_slice_one("foo@bar.slice", NULL, -EINVAL); |
420 | test_build_parent_slice_one("foo-bar@baz.slice", NULL, -EINVAL); | |
421 | test_build_parent_slice_one("foo-bar--@baz.slice", NULL, -EINVAL); | |
422 | test_build_parent_slice_one("-foo-bar@bar.slice", NULL, -EINVAL); | |
423 | test_build_parent_slice_one("foo-bar@-.slice", NULL, -EINVAL); | |
424 | test_build_parent_slice_one("foo@bar.service", NULL, -EINVAL); | |
425 | test_build_parent_slice_one("@.slice", NULL, -EINVAL); | |
93c47472 LP |
426 | } |
427 | ||
068ae9fb RC |
428 | static void test_unit_name_to_instance(void) { |
429 | char *instance; | |
430 | int r; | |
431 | ||
432 | r = unit_name_to_instance("foo@bar.service", &instance); | |
433 | assert_se(r >= 0); | |
434 | assert_se(streq(instance, "bar")); | |
435 | free(instance); | |
436 | ||
fee0a921 RC |
437 | r = unit_name_to_instance("foo@.service", &instance); |
438 | assert_se(r >= 0); | |
439 | assert_se(streq(instance, "")); | |
440 | free(instance); | |
441 | ||
7410616c | 442 | r = unit_name_to_instance("fo0-stUff_b@b.service", &instance); |
068ae9fb RC |
443 | assert_se(r >= 0); |
444 | assert_se(streq(instance, "b")); | |
445 | free(instance); | |
446 | ||
7410616c LP |
447 | r = unit_name_to_instance("foo.service", &instance); |
448 | assert_se(r == 0); | |
068ae9fb RC |
449 | assert_se(!instance); |
450 | ||
451 | r = unit_name_to_instance("fooj@unk", &instance); | |
452 | assert_se(r < 0); | |
fee0a921 RC |
453 | |
454 | r = unit_name_to_instance("foo@", &instance); | |
455 | assert_se(r < 0); | |
068ae9fb RC |
456 | } |
457 | ||
458 | static void test_unit_name_escape(void) { | |
459 | _cleanup_free_ char *r; | |
460 | ||
461 | r = unit_name_escape("ab+-c.a/bc@foo.service"); | |
462 | assert_se(r); | |
463 | assert_se(streq(r, "ab\\x2b\\x2dc.a-bc\\x40foo.service")); | |
464 | } | |
465 | ||
7410616c LP |
466 | static void test_u_n_t_one(const char *name, const char *expected, int ret) { |
467 | _cleanup_free_ char *f = NULL; | |
fee0a921 | 468 | |
7410616c LP |
469 | assert_se(unit_name_template(name, &f) == ret); |
470 | printf("got: %s, expected: %s\n", strna(f), strna(expected)); | |
471 | assert_se(streq_ptr(f, expected)); | |
472 | } | |
473 | ||
474 | static void test_unit_name_template(void) { | |
475 | test_u_n_t_one("foo@bar.service", "foo@.service", 0); | |
476 | test_u_n_t_one("foo.mount", NULL, -EINVAL); | |
fee0a921 RC |
477 | } |
478 | ||
93c47472 LP |
479 | static void test_unit_name_path_unescape_one(const char *name, const char *path, int ret) { |
480 | _cleanup_free_ char *p = NULL; | |
481 | ||
482 | assert_se(unit_name_path_unescape(name, &p) == ret); | |
483 | assert_se(streq_ptr(path, p)); | |
484 | } | |
485 | ||
486 | static void test_unit_name_path_unescape(void) { | |
487 | ||
488 | test_unit_name_path_unescape_one("foo", "/foo", 0); | |
489 | test_unit_name_path_unescape_one("foo-bar", "/foo/bar", 0); | |
490 | test_unit_name_path_unescape_one("foo-.bar", "/foo/.bar", 0); | |
491 | test_unit_name_path_unescape_one("foo-bar-baz", "/foo/bar/baz", 0); | |
492 | test_unit_name_path_unescape_one("-", "/", 0); | |
493 | test_unit_name_path_unescape_one("--", NULL, -EINVAL); | |
494 | test_unit_name_path_unescape_one("-foo-bar", NULL, -EINVAL); | |
495 | test_unit_name_path_unescape_one("foo--bar", NULL, -EINVAL); | |
496 | test_unit_name_path_unescape_one("foo-bar-", NULL, -EINVAL); | |
497 | test_unit_name_path_unescape_one(".-bar", NULL, -EINVAL); | |
498 | test_unit_name_path_unescape_one("foo-..", NULL, -EINVAL); | |
499 | test_unit_name_path_unescape_one("", NULL, -EINVAL); | |
500 | } | |
501 | ||
72406c2f LP |
502 | static void test_unit_name_to_prefix_one(const char *input, int ret, const char *output) { |
503 | _cleanup_free_ char *k = NULL; | |
504 | ||
505 | assert_se(unit_name_to_prefix(input, &k) == ret); | |
506 | assert_se(streq_ptr(k, output)); | |
507 | } | |
508 | ||
509 | static void test_unit_name_to_prefix(void) { | |
510 | test_unit_name_to_prefix_one("foobar.service", 0, "foobar"); | |
511 | test_unit_name_to_prefix_one("", -EINVAL, NULL); | |
512 | test_unit_name_to_prefix_one("foobar", -EINVAL, NULL); | |
513 | test_unit_name_to_prefix_one(".service", -EINVAL, NULL); | |
514 | test_unit_name_to_prefix_one("quux.quux", -EINVAL, NULL); | |
515 | test_unit_name_to_prefix_one("quux.mount", 0, "quux"); | |
516 | test_unit_name_to_prefix_one("quux-quux.mount", 0, "quux-quux"); | |
517 | test_unit_name_to_prefix_one("quux@bar.mount", 0, "quux"); | |
518 | test_unit_name_to_prefix_one("quux-@.mount", 0, "quux-"); | |
519 | test_unit_name_to_prefix_one("@.mount", -EINVAL, NULL); | |
520 | } | |
521 | ||
b4152e9b YW |
522 | static void test_unit_name_from_dbus_path_one(const char *input, int ret, const char *output) { |
523 | _cleanup_free_ char *k = NULL; | |
524 | ||
525 | assert_se(unit_name_from_dbus_path(input, &k) == ret); | |
526 | assert_se(streq_ptr(k, output)); | |
527 | } | |
528 | ||
529 | static void test_unit_name_from_dbus_path(void) { | |
530 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dbus_2esocket", 0, "dbus.socket"); | |
531 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/_2d_2emount", 0, "-.mount"); | |
532 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/_2d_2eslice", 0, "-.slice"); | |
533 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/accounts_2ddaemon_2eservice", 0, "accounts-daemon.service"); | |
534 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/auditd_2eservice", 0, "auditd.service"); | |
535 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/basic_2etarget", 0, "basic.target"); | |
536 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/bluetooth_2etarget", 0, "bluetooth.target"); | |
537 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/boot_2eautomount", 0, "boot.automount"); | |
538 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/boot_2emount", 0, "boot.mount"); | |
539 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/btrfs_2emount", 0, "btrfs.mount"); | |
540 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/cryptsetup_2dpre_2etarget", 0, "cryptsetup-pre.target"); | |
541 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/cryptsetup_2etarget", 0, "cryptsetup.target"); | |
542 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dbus_2eservice", 0, "dbus.service"); | |
543 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dbus_2esocket", 0, "dbus.socket"); | |
544 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dcdrom_2edevice", 0, "dev-cdrom.device"); | |
545 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2ddisk_2dby_5cx2did_2data_5cx2dINTEL_5fSSDSA2M120G2GC_5fCVPO044405HH120QGN_2edevice", 0, "dev-disk-by\\x2did-ata\\x2dINTEL_SSDSA2M120G2GC_CVPO044405HH120QGN.device"); | |
546 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2ddisk_2dby_5cx2did_2data_5cx2dINTEL_5fSSDSA2M120G2GC_5fCVPO044405HH120QGN_5cx2dpart1_2edevice", 0, "dev-disk-by\\x2did-ata\\x2dINTEL_SSDSA2M120G2GC_CVPO044405HH120QGN\\x2dpart1.device"); | |
547 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2ddisk_2dby_5cx2did_2data_5cx2dINTEL_5fSSDSA2M160G2GC_5fCVPO951003RY160AGN_2edevice", 0, "dev-disk-by\\x2did-ata\\x2dINTEL_SSDSA2M160G2GC_CVPO951003RY160AGN.device"); | |
548 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2ddisk_2dby_5cx2did_2data_5cx2dINTEL_5fSSDSA2M160G2GC_5fCVPO951003RY160AGN_5cx2dpart1_2edevice", 0, "dev-disk-by\\x2did-ata\\x2dINTEL_SSDSA2M160G2GC_CVPO951003RY160AGN\\x2dpart1.device"); | |
549 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2ddisk_2dby_5cx2did_2data_5cx2dINTEL_5fSSDSA2M160G2GC_5fCVPO951003RY160AGN_5cx2dpart2_2edevice", 0, "dev-disk-by\\x2did-ata\\x2dINTEL_SSDSA2M160G2GC_CVPO951003RY160AGN\\x2dpart2.device"); | |
550 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2ddisk_2dby_5cx2did_2data_5cx2dINTEL_5fSSDSA2M160G2GC_5fCVPO951003RY160AGN_5cx2dpart3_2edevice", 0, "dev-disk-by\\x2did-ata\\x2dINTEL_SSDSA2M160G2GC_CVPO951003RY160AGN\\x2dpart3.device"); | |
551 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2ddisk_2dby_5cx2did_2data_5cx2dTSSTcorp_5fCDDVDW_5fTS_5cx2dL633C_5fR6176GLZB14646_2edevice", 0, "dev-disk-by\\x2did-ata\\x2dTSSTcorp_CDDVDW_TS\\x2dL633C_R6176GLZB14646.device"); | |
552 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2ddisk_2dby_5cx2did_2dwwn_5cx2d0x50015179591245ae_2edevice", 0, "dev-disk-by\\x2did-wwn\\x2d0x50015179591245ae.device"); | |
553 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2ddisk_2dby_5cx2did_2dwwn_5cx2d0x50015179591245ae_5cx2dpart1_2edevice", 0, "dev-disk-by\\x2did-wwn\\x2d0x50015179591245ae\\x2dpart1.device"); | |
554 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2ddisk_2dby_5cx2did_2dwwn_5cx2d0x50015179591245ae_5cx2dpart2_2edevice", 0, "dev-disk-by\\x2did-wwn\\x2d0x50015179591245ae\\x2dpart2.device"); | |
555 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2ddisk_2dby_5cx2did_2dwwn_5cx2d0x50015179591245ae_5cx2dpart3_2edevice", 0, "dev-disk-by\\x2did-wwn\\x2d0x50015179591245ae\\x2dpart3.device"); | |
556 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2ddisk_2dby_5cx2did_2dwwn_5cx2d0x500151795946eab5_2edevice", 0, "dev-disk-by\\x2did-wwn\\x2d0x500151795946eab5.device"); | |
557 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2ddisk_2dby_5cx2did_2dwwn_5cx2d0x500151795946eab5_5cx2dpart1_2edevice", 0, "dev-disk-by\\x2did-wwn\\x2d0x500151795946eab5\\x2dpart1.device"); | |
558 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2ddisk_2dby_5cx2dlabel_2d_5cxe3_5cx82_5cxb7_5cxe3_5cx82_5cxb9_5cxe3_5cx83_5cx86_5cxe3_5cx83_5cxa0_5cxe3_5cx81_5cxa7_5cxe4_5cxba_5cx88_5cxe7_5cxb4_5cx84_5cxe6_5cxb8_5cx88_5cxe3_5cx81_5cxbf_2edevice", 0, "dev-disk-by\\x2dlabel-\\xe3\\x82\\xb7\\xe3\\x82\\xb9\\xe3\\x83\\x86\\xe3\\x83\\xa0\\xe3\\x81\\xa7\\xe4\\xba\\x88\\xe7\\xb4\\x84\\xe6\\xb8\\x88\\xe3\\x81\\xbf.device"); | |
559 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2ddisk_2dby_5cx2dpartuuid_2d59834e50_5cx2d01_2edevice", 0, "dev-disk-by\\x2dpartuuid-59834e50\\x2d01.device"); | |
560 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2ddisk_2dby_5cx2dpartuuid_2d63e2a7b3_5cx2d01_2edevice", 0, "dev-disk-by\\x2dpartuuid-63e2a7b3\\x2d01.device"); | |
561 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2ddisk_2dby_5cx2dpartuuid_2d63e2a7b3_5cx2d02_2edevice", 0, "dev-disk-by\\x2dpartuuid-63e2a7b3\\x2d02.device"); | |
562 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2ddisk_2dby_5cx2dpartuuid_2d63e2a7b3_5cx2d03_2edevice", 0, "dev-disk-by\\x2dpartuuid-63e2a7b3\\x2d03.device"); | |
563 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2ddisk_2dby_5cx2dpath_2dpci_5cx2d0000_3a00_3a1f_2e2_5cx2data_5cx2d1_2edevice", 0, "dev-disk-by\\x2dpath-pci\\x2d0000:00:1f.2\\x2data\\x2d1.device"); | |
564 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2ddisk_2dby_5cx2dpath_2dpci_5cx2d0000_3a00_3a1f_2e2_5cx2data_5cx2d1_5cx2dpart1_2edevice", 0, "dev-disk-by\\x2dpath-pci\\x2d0000:00:1f.2\\x2data\\x2d1\\x2dpart1.device"); | |
565 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2ddisk_2dby_5cx2dpath_2dpci_5cx2d0000_3a00_3a1f_2e2_5cx2data_5cx2d1_5cx2dpart2_2edevice", 0, "dev-disk-by\\x2dpath-pci\\x2d0000:00:1f.2\\x2data\\x2d1\\x2dpart2.device"); | |
566 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2ddisk_2dby_5cx2dpath_2dpci_5cx2d0000_3a00_3a1f_2e2_5cx2data_5cx2d1_5cx2dpart3_2edevice", 0, "dev-disk-by\\x2dpath-pci\\x2d0000:00:1f.2\\x2data\\x2d1\\x2dpart3.device"); | |
567 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2ddisk_2dby_5cx2dpath_2dpci_5cx2d0000_3a00_3a1f_2e2_5cx2data_5cx2d2_2edevice", 0, "dev-disk-by\\x2dpath-pci\\x2d0000:00:1f.2\\x2data\\x2d2.device"); | |
568 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2ddisk_2dby_5cx2dpath_2dpci_5cx2d0000_3a00_3a1f_2e2_5cx2data_5cx2d6_2edevice", 0, "dev-disk-by\\x2dpath-pci\\x2d0000:00:1f.2\\x2data\\x2d6.device"); | |
569 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2ddisk_2dby_5cx2dpath_2dpci_5cx2d0000_3a00_3a1f_2e2_5cx2data_5cx2d6_5cx2dpart1_2edevice", 0, "dev-disk-by\\x2dpath-pci\\x2d0000:00:1f.2\\x2data\\x2d6\\x2dpart1.device"); | |
570 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2ddisk_2dby_5cx2duuid_2d1A34E3F034E3CD37_2edevice", 0, "dev-disk-by\\x2duuid-1A34E3F034E3CD37.device"); | |
571 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2ddisk_2dby_5cx2duuid_2dB670EBFE70EBC2EB_2edevice", 0, "dev-disk-by\\x2duuid-B670EBFE70EBC2EB.device"); | |
572 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2ddisk_2dby_5cx2duuid_2dFCD4F509D4F4C6C4_2edevice", 0, "dev-disk-by\\x2duuid-FCD4F509D4F4C6C4.device"); | |
573 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2ddisk_2dby_5cx2duuid_2db49ead57_5cx2d907c_5cx2d446c_5cx2db405_5cx2d5ca6cd865f5e_2edevice", 0, "dev-disk-by\\x2duuid-b49ead57\\x2d907c\\x2d446c\\x2db405\\x2d5ca6cd865f5e.device"); | |
574 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dhugepages_2emount", 0, "dev-hugepages.mount"); | |
575 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dmqueue_2emount", 0, "dev-mqueue.mount"); | |
576 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2drfkill_2edevice", 0, "dev-rfkill.device"); | |
577 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dsda1_2edevice", 0, "dev-sda1.device"); | |
578 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dsda2_2edevice", 0, "dev-sda2.device"); | |
579 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dsda3_2edevice", 0, "dev-sda3.device"); | |
580 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dsda_2edevice", 0, "dev-sda.device"); | |
581 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dsdb1_2edevice", 0, "dev-sdb1.device"); | |
582 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dsdb_2edevice", 0, "dev-sdb.device"); | |
583 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dsr0_2edevice", 0, "dev-sr0.device"); | |
584 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dttyS0_2edevice", 0, "dev-ttyS0.device"); | |
585 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dttyS10_2edevice", 0, "dev-ttyS10.device"); | |
586 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dttyS11_2edevice", 0, "dev-ttyS11.device"); | |
587 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dttyS12_2edevice", 0, "dev-ttyS12.device"); | |
588 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dttyS13_2edevice", 0, "dev-ttyS13.device"); | |
589 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dttyS14_2edevice", 0, "dev-ttyS14.device"); | |
590 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dttyS15_2edevice", 0, "dev-ttyS15.device"); | |
591 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dttyS16_2edevice", 0, "dev-ttyS16.device"); | |
592 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dttyS17_2edevice", 0, "dev-ttyS17.device"); | |
593 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dttyS18_2edevice", 0, "dev-ttyS18.device"); | |
594 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dttyS19_2edevice", 0, "dev-ttyS19.device"); | |
595 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dttyS1_2edevice", 0, "dev-ttyS1.device"); | |
596 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dttyS20_2edevice", 0, "dev-ttyS20.device"); | |
597 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dttyS21_2edevice", 0, "dev-ttyS21.device"); | |
598 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dttyS22_2edevice", 0, "dev-ttyS22.device"); | |
599 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dttyS23_2edevice", 0, "dev-ttyS23.device"); | |
600 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dttyS24_2edevice", 0, "dev-ttyS24.device"); | |
601 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dttyS25_2edevice", 0, "dev-ttyS25.device"); | |
602 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dttyS26_2edevice", 0, "dev-ttyS26.device"); | |
603 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dttyS27_2edevice", 0, "dev-ttyS27.device"); | |
604 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dttyS28_2edevice", 0, "dev-ttyS28.device"); | |
605 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dttyS29_2edevice", 0, "dev-ttyS29.device"); | |
606 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dttyS2_2edevice", 0, "dev-ttyS2.device"); | |
607 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dttyS30_2edevice", 0, "dev-ttyS30.device"); | |
608 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dttyS31_2edevice", 0, "dev-ttyS31.device"); | |
609 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dttyS3_2edevice", 0, "dev-ttyS3.device"); | |
610 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dttyS4_2edevice", 0, "dev-ttyS4.device"); | |
611 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dttyS5_2edevice", 0, "dev-ttyS5.device"); | |
612 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dttyS6_2edevice", 0, "dev-ttyS6.device"); | |
613 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dttyS7_2edevice", 0, "dev-ttyS7.device"); | |
614 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dttyS8_2edevice", 0, "dev-ttyS8.device"); | |
615 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dev_2dttyS9_2edevice", 0, "dev-ttyS9.device"); | |
616 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dracut_2dcmdline_2eservice", 0, "dracut-cmdline.service"); | |
617 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dracut_2dinitqueue_2eservice", 0, "dracut-initqueue.service"); | |
618 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dracut_2dmount_2eservice", 0, "dracut-mount.service"); | |
619 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dracut_2dpre_2dmount_2eservice", 0, "dracut-pre-mount.service"); | |
620 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dracut_2dpre_2dpivot_2eservice", 0, "dracut-pre-pivot.service"); | |
621 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dracut_2dpre_2dtrigger_2eservice", 0, "dracut-pre-trigger.service"); | |
622 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dracut_2dpre_2dudev_2eservice", 0, "dracut-pre-udev.service"); | |
623 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/dracut_2dshutdown_2eservice", 0, "dracut-shutdown.service"); | |
624 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/ebtables_2eservice", 0, "ebtables.service"); | |
625 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/emergency_2eservice", 0, "emergency.service"); | |
626 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/emergency_2etarget", 0, "emergency.target"); | |
627 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/fedora_2dimport_2dstate_2eservice", 0, "fedora-import-state.service"); | |
628 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/fedora_2dreadonly_2eservice", 0, "fedora-readonly.service"); | |
629 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/firewalld_2eservice", 0, "firewalld.service"); | |
630 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/getty_2dpre_2etarget", 0, "getty-pre.target"); | |
631 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/getty_2etarget", 0, "getty.target"); | |
632 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/getty_40tty1_2eservice", 0, "getty@tty1.service"); | |
633 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/graphical_2etarget", 0, "graphical.target"); | |
634 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/home_2emount", 0, "home.mount"); | |
635 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/init_2escope", 0, "init.scope"); | |
636 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/initrd_2dcleanup_2eservice", 0, "initrd-cleanup.service"); | |
637 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/initrd_2dfs_2etarget", 0, "initrd-fs.target"); | |
638 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/initrd_2dparse_2detc_2eservice", 0, "initrd-parse-etc.service"); | |
639 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/initrd_2droot_2ddevice_2etarget", 0, "initrd-root-device.target"); | |
640 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/initrd_2droot_2dfs_2etarget", 0, "initrd-root-fs.target"); | |
641 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/initrd_2dswitch_2droot_2eservice", 0, "initrd-switch-root.service"); | |
642 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/initrd_2dswitch_2droot_2etarget", 0, "initrd-switch-root.target"); | |
643 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/initrd_2dudevadm_2dcleanup_2ddb_2eservice", 0, "initrd-udevadm-cleanup-db.service"); | |
644 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/initrd_2etarget", 0, "initrd.target"); | |
645 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/ip6tables_2eservice", 0, "ip6tables.service"); | |
646 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/ipset_2eservice", 0, "ipset.service"); | |
647 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/iptables_2eservice", 0, "iptables.service"); | |
648 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/irqbalance_2eservice", 0, "irqbalance.service"); | |
649 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/kmod_2dstatic_2dnodes_2eservice", 0, "kmod-static-nodes.service"); | |
650 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/ldconfig_2eservice", 0, "ldconfig.service"); | |
651 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/lightdm_2eservice", 0, "lightdm.service"); | |
652 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/livesys_2dlate_2eservice", 0, "livesys-late.service"); | |
653 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/lm_5fsensors_2eservice", 0, "lm_sensors.service"); | |
654 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/local_2dfs_2dpre_2etarget", 0, "local-fs-pre.target"); | |
655 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/local_2dfs_2etarget", 0, "local-fs.target"); | |
656 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/machines_2etarget", 0, "machines.target"); | |
657 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/mcelog_2eservice", 0, "mcelog.service"); | |
658 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/multi_2duser_2etarget", 0, "multi-user.target"); | |
659 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/network_2dpre_2etarget", 0, "network-pre.target"); | |
660 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/network_2etarget", 0, "network.target"); | |
661 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/nss_2dlookup_2etarget", 0, "nss-lookup.target"); | |
662 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/nss_2duser_2dlookup_2etarget", 0, "nss-user-lookup.target"); | |
663 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/paths_2etarget", 0, "paths.target"); | |
664 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/plymouth_2dquit_2dwait_2eservice", 0, "plymouth-quit-wait.service"); | |
665 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/plymouth_2dquit_2eservice", 0, "plymouth-quit.service"); | |
666 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/plymouth_2dstart_2eservice", 0, "plymouth-start.service"); | |
667 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/polkit_2eservice", 0, "polkit.service"); | |
668 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/proc_2dsys_2dfs_2dbinfmt_5fmisc_2eautomount", 0, "proc-sys-fs-binfmt_misc.automount"); | |
669 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/proc_2dsys_2dfs_2dbinfmt_5fmisc_2emount", 0, "proc-sys-fs-binfmt_misc.mount"); | |
670 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/rc_2dlocal_2eservice", 0, "rc-local.service"); | |
671 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/remote_2dcryptsetup_2etarget", 0, "remote-cryptsetup.target"); | |
672 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/remote_2dfs_2dpre_2etarget", 0, "remote-fs-pre.target"); | |
673 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/remote_2dfs_2etarget", 0, "remote-fs.target"); | |
674 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/rescue_2eservice", 0, "rescue.service"); | |
675 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/rescue_2etarget", 0, "rescue.target"); | |
676 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/run_2duser_2d1000_2emount", 0, "run-user-1000.mount"); | |
677 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/session_2d2_2escope", 0, "session-2.scope"); | |
678 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/shutdown_2etarget", 0, "shutdown.target"); | |
679 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/slices_2etarget", 0, "slices.target"); | |
680 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/smartd_2eservice", 0, "smartd.service"); | |
681 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sockets_2etarget", 0, "sockets.target"); | |
682 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sound_2etarget", 0, "sound.target"); | |
683 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sshd_2dkeygen_2etarget", 0, "sshd-keygen.target"); | |
684 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sshd_2dkeygen_40ecdsa_2eservice", 0, "sshd-keygen@ecdsa.service"); | |
685 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sshd_2dkeygen_40ed25519_2eservice", 0, "sshd-keygen@ed25519.service"); | |
686 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sshd_2dkeygen_40rsa_2eservice", 0, "sshd-keygen@rsa.service"); | |
687 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sshd_2eservice", 0, "sshd.service"); | |
688 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/swap_2etarget", 0, "swap.target"); | |
689 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dpci0000_3a00_2d0000_3a00_3a02_2e0_2dbacklight_2dacpi_5fvideo0_2edevice", 0, "sys-devices-pci0000:00-0000:00:02.0-backlight-acpi_video0.device"); | |
690 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dpci0000_3a00_2d0000_3a00_3a02_2e0_2ddrm_2dcard0_2dcard0_5cx2dLVDS_5cx2d1_2dintel_5fbacklight_2edevice", 0, "sys-devices-pci0000:00-0000:00:02.0-drm-card0-card0\\x2dLVDS\\x2d1-intel_backlight.device"); | |
691 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dpci0000_3a00_2d0000_3a00_3a1a_2e0_2dusb1_2d1_5cx2d1_2d1_5cx2d1_2e6_2d1_5cx2d1_2e6_3a1_2e0_2dbluetooth_2dhci0_2edevice", 0, "sys-devices-pci0000:00-0000:00:1a.0-usb1-1\\x2d1-1\\x2d1.6-1\\x2d1.6:1.0-bluetooth-hci0.device"); | |
692 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dpci0000_3a00_2d0000_3a00_3a1b_2e0_2dsound_2dcard0_2edevice", 0, "sys-devices-pci0000:00-0000:00:1b.0-sound-card0.device"); | |
693 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dpci0000_3a00_2d0000_3a00_3a1c_2e0_2d0000_3a02_3a00_2e0_2dnet_2dwlp2s0_2edevice", 0, "sys-devices-pci0000:00-0000:00:1c.0-0000:02:00.0-net-wlp2s0.device"); | |
694 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dpci0000_3a00_2d0000_3a00_3a1c_2e2_2d0000_3a04_3a00_2e0_2dnet_2denp4s0_2edevice", 0, "sys-devices-pci0000:00-0000:00:1c.2-0000:04:00.0-net-enp4s0.device"); | |
695 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dpci0000_3a00_2d0000_3a00_3a1f_2e2_2data1_2dhost0_2dtarget0_3a0_3a0_2d0_3a0_3a0_3a0_2dblock_2dsda_2dsda1_2edevice", 0, "sys-devices-pci0000:00-0000:00:1f.2-ata1-host0-target0:0:0-0:0:0:0-block-sda-sda1.device"); | |
696 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dpci0000_3a00_2d0000_3a00_3a1f_2e2_2data1_2dhost0_2dtarget0_3a0_3a0_2d0_3a0_3a0_3a0_2dblock_2dsda_2dsda2_2edevice", 0, "sys-devices-pci0000:00-0000:00:1f.2-ata1-host0-target0:0:0-0:0:0:0-block-sda-sda2.device"); | |
697 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dpci0000_3a00_2d0000_3a00_3a1f_2e2_2data1_2dhost0_2dtarget0_3a0_3a0_2d0_3a0_3a0_3a0_2dblock_2dsda_2dsda3_2edevice", 0, "sys-devices-pci0000:00-0000:00:1f.2-ata1-host0-target0:0:0-0:0:0:0-block-sda-sda3.device"); | |
698 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dpci0000_3a00_2d0000_3a00_3a1f_2e2_2data1_2dhost0_2dtarget0_3a0_3a0_2d0_3a0_3a0_3a0_2dblock_2dsda_2edevice", 0, "sys-devices-pci0000:00-0000:00:1f.2-ata1-host0-target0:0:0-0:0:0:0-block-sda.device"); | |
699 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dpci0000_3a00_2d0000_3a00_3a1f_2e2_2data2_2dhost1_2dtarget1_3a0_3a0_2d1_3a0_3a0_3a0_2dblock_2dsr0_2edevice", 0, "sys-devices-pci0000:00-0000:00:1f.2-ata2-host1-target1:0:0-1:0:0:0-block-sr0.device"); | |
700 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dpci0000_3a00_2d0000_3a00_3a1f_2e2_2data6_2dhost5_2dtarget5_3a0_3a0_2d5_3a0_3a0_3a0_2dblock_2dsdb_2dsdb1_2edevice", 0, "sys-devices-pci0000:00-0000:00:1f.2-ata6-host5-target5:0:0-5:0:0:0-block-sdb-sdb1.device"); | |
701 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dpci0000_3a00_2d0000_3a00_3a1f_2e2_2data6_2dhost5_2dtarget5_3a0_3a0_2d5_3a0_3a0_3a0_2dblock_2dsdb_2edevice", 0, "sys-devices-pci0000:00-0000:00:1f.2-ata6-host5-target5:0:0-5:0:0:0-block-sdb.device"); | |
702 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dplatform_2dserial8250_2dtty_2dttyS0_2edevice", 0, "sys-devices-platform-serial8250-tty-ttyS0.device"); | |
703 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dplatform_2dserial8250_2dtty_2dttyS10_2edevice", 0, "sys-devices-platform-serial8250-tty-ttyS10.device"); | |
704 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dplatform_2dserial8250_2dtty_2dttyS11_2edevice", 0, "sys-devices-platform-serial8250-tty-ttyS11.device"); | |
705 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dplatform_2dserial8250_2dtty_2dttyS12_2edevice", 0, "sys-devices-platform-serial8250-tty-ttyS12.device"); | |
706 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dplatform_2dserial8250_2dtty_2dttyS13_2edevice", 0, "sys-devices-platform-serial8250-tty-ttyS13.device"); | |
707 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dplatform_2dserial8250_2dtty_2dttyS14_2edevice", 0, "sys-devices-platform-serial8250-tty-ttyS14.device"); | |
708 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dplatform_2dserial8250_2dtty_2dttyS15_2edevice", 0, "sys-devices-platform-serial8250-tty-ttyS15.device"); | |
709 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dplatform_2dserial8250_2dtty_2dttyS16_2edevice", 0, "sys-devices-platform-serial8250-tty-ttyS16.device"); | |
710 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dplatform_2dserial8250_2dtty_2dttyS17_2edevice", 0, "sys-devices-platform-serial8250-tty-ttyS17.device"); | |
711 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dplatform_2dserial8250_2dtty_2dttyS18_2edevice", 0, "sys-devices-platform-serial8250-tty-ttyS18.device"); | |
712 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dplatform_2dserial8250_2dtty_2dttyS19_2edevice", 0, "sys-devices-platform-serial8250-tty-ttyS19.device"); | |
713 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dplatform_2dserial8250_2dtty_2dttyS1_2edevice", 0, "sys-devices-platform-serial8250-tty-ttyS1.device"); | |
714 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dplatform_2dserial8250_2dtty_2dttyS20_2edevice", 0, "sys-devices-platform-serial8250-tty-ttyS20.device"); | |
715 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dplatform_2dserial8250_2dtty_2dttyS21_2edevice", 0, "sys-devices-platform-serial8250-tty-ttyS21.device"); | |
716 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dplatform_2dserial8250_2dtty_2dttyS22_2edevice", 0, "sys-devices-platform-serial8250-tty-ttyS22.device"); | |
717 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dplatform_2dserial8250_2dtty_2dttyS23_2edevice", 0, "sys-devices-platform-serial8250-tty-ttyS23.device"); | |
718 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dplatform_2dserial8250_2dtty_2dttyS24_2edevice", 0, "sys-devices-platform-serial8250-tty-ttyS24.device"); | |
719 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dplatform_2dserial8250_2dtty_2dttyS25_2edevice", 0, "sys-devices-platform-serial8250-tty-ttyS25.device"); | |
720 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dplatform_2dserial8250_2dtty_2dttyS26_2edevice", 0, "sys-devices-platform-serial8250-tty-ttyS26.device"); | |
721 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dplatform_2dserial8250_2dtty_2dttyS27_2edevice", 0, "sys-devices-platform-serial8250-tty-ttyS27.device"); | |
722 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dplatform_2dserial8250_2dtty_2dttyS28_2edevice", 0, "sys-devices-platform-serial8250-tty-ttyS28.device"); | |
723 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dplatform_2dserial8250_2dtty_2dttyS29_2edevice", 0, "sys-devices-platform-serial8250-tty-ttyS29.device"); | |
724 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dplatform_2dserial8250_2dtty_2dttyS2_2edevice", 0, "sys-devices-platform-serial8250-tty-ttyS2.device"); | |
725 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dplatform_2dserial8250_2dtty_2dttyS30_2edevice", 0, "sys-devices-platform-serial8250-tty-ttyS30.device"); | |
726 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dplatform_2dserial8250_2dtty_2dttyS31_2edevice", 0, "sys-devices-platform-serial8250-tty-ttyS31.device"); | |
727 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dplatform_2dserial8250_2dtty_2dttyS3_2edevice", 0, "sys-devices-platform-serial8250-tty-ttyS3.device"); | |
728 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dplatform_2dserial8250_2dtty_2dttyS4_2edevice", 0, "sys-devices-platform-serial8250-tty-ttyS4.device"); | |
729 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dplatform_2dserial8250_2dtty_2dttyS5_2edevice", 0, "sys-devices-platform-serial8250-tty-ttyS5.device"); | |
730 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dplatform_2dserial8250_2dtty_2dttyS6_2edevice", 0, "sys-devices-platform-serial8250-tty-ttyS6.device"); | |
731 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dplatform_2dserial8250_2dtty_2dttyS7_2edevice", 0, "sys-devices-platform-serial8250-tty-ttyS7.device"); | |
732 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dplatform_2dserial8250_2dtty_2dttyS8_2edevice", 0, "sys-devices-platform-serial8250-tty-ttyS8.device"); | |
733 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dplatform_2dserial8250_2dtty_2dttyS9_2edevice", 0, "sys-devices-platform-serial8250-tty-ttyS9.device"); | |
734 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2ddevices_2dvirtual_2dmisc_2drfkill_2edevice", 0, "sys-devices-virtual-misc-rfkill.device"); | |
735 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2dfs_2dfuse_2dconnections_2emount", 0, "sys-fs-fuse-connections.mount"); | |
736 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2dkernel_2dconfig_2emount", 0, "sys-kernel-config.mount"); | |
737 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2dkernel_2ddebug_2emount", 0, "sys-kernel-debug.mount"); | |
738 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2dmodule_2dconfigfs_2edevice", 0, "sys-module-configfs.device"); | |
739 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2dsubsystem_2dbluetooth_2ddevices_2dhci0_2edevice", 0, "sys-subsystem-bluetooth-devices-hci0.device"); | |
740 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2dsubsystem_2dnet_2ddevices_2denp4s0_2edevice", 0, "sys-subsystem-net-devices-enp4s0.device"); | |
741 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sys_2dsubsystem_2dnet_2ddevices_2dwlp2s0_2edevice", 0, "sys-subsystem-net-devices-wlp2s0.device"); | |
742 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sysinit_2etarget", 0, "sysinit.target"); | |
743 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/syslog_2eservice", 0, "syslog.service"); | |
744 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/syslog_2esocket", 0, "syslog.socket"); | |
745 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/syslog_2etarget", 0, "syslog.target"); | |
746 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/sysroot_2emount", 0, "sysroot.mount"); | |
747 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/system_2dgetty_2eslice", 0, "system-getty.slice"); | |
748 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/system_2dsshd_5cx2dkeygen_2eslice", 0, "system-sshd\\x2dkeygen.slice"); | |
749 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/system_2dsystemd_5cx2dbacklight_2eslice", 0, "system-systemd\\x2dbacklight.slice"); | |
750 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/system_2dsystemd_5cx2dcoredump_2eslice", 0, "system-systemd\\x2dcoredump.slice"); | |
751 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/system_2duser_5cx2druntime_5cx2ddir_2eslice", 0, "system-user\\x2druntime\\x2ddir.slice"); | |
752 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/system_2eslice", 0, "system.slice"); | |
753 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2dask_2dpassword_2dconsole_2epath", 0, "systemd-ask-password-console.path"); | |
754 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2dask_2dpassword_2dconsole_2eservice", 0, "systemd-ask-password-console.service"); | |
755 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2dask_2dpassword_2dwall_2epath", 0, "systemd-ask-password-wall.path"); | |
756 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2dask_2dpassword_2dwall_2eservice", 0, "systemd-ask-password-wall.service"); | |
757 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2dbacklight_40backlight_3aacpi_5fvideo0_2eservice", 0, "systemd-backlight@backlight:acpi_video0.service"); | |
758 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2dbacklight_40backlight_3aintel_5fbacklight_2eservice", 0, "systemd-backlight@backlight:intel_backlight.service"); | |
759 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2dbinfmt_2eservice", 0, "systemd-binfmt.service"); | |
760 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2dcoredump_2esocket", 0, "systemd-coredump.socket"); | |
761 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2dcoredump_400_2eservice", 0, "systemd-coredump@0.service"); | |
762 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2dfirstboot_2eservice", 0, "systemd-firstboot.service"); | |
5ff8da10 | 763 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2dfsck_2droot_2eservice", 0, SPECIAL_FSCK_ROOT_SERVICE); |
b4152e9b YW |
764 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2dhwdb_2dupdate_2eservice", 0, "systemd-hwdb-update.service"); |
765 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2dinitctl_2eservice", 0, "systemd-initctl.service"); | |
766 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2dinitctl_2esocket", 0, "systemd-initctl.socket"); | |
767 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2djournal_2dcatalog_2dupdate_2eservice", 0, "systemd-journal-catalog-update.service"); | |
768 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2djournal_2dflush_2eservice", 0, "systemd-journal-flush.service"); | |
769 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2djournald_2daudit_2esocket", 0, "systemd-journald-audit.socket"); | |
770 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2djournald_2ddev_2dlog_2esocket", 0, "systemd-journald-dev-log.socket"); | |
771 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2djournald_2eservice", 0, "systemd-journald.service"); | |
772 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2djournald_2esocket", 0, "systemd-journald.socket"); | |
773 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2dlogind_2eservice", 0, "systemd-logind.service"); | |
774 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2dmachine_2did_2dcommit_2eservice", 0, "systemd-machine-id-commit.service"); | |
775 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2dmodules_2dload_2eservice", 0, "systemd-modules-load.service"); | |
776 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2dnetworkd_2eservice", 0, "systemd-networkd.service"); | |
777 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2dnetworkd_2esocket", 0, "systemd-networkd.socket"); | |
778 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2drandom_2dseed_2eservice", 0, "systemd-random-seed.service"); | |
779 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2dremount_2dfs_2eservice", 0, "systemd-remount-fs.service"); | |
780 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2dresolved_2eservice", 0, "systemd-resolved.service"); | |
781 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2drfkill_2eservice", 0, "systemd-rfkill.service"); | |
782 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2drfkill_2esocket", 0, "systemd-rfkill.socket"); | |
783 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2dsysctl_2eservice", 0, "systemd-sysctl.service"); | |
784 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2dsysusers_2eservice", 0, "systemd-sysusers.service"); | |
785 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2dtimesyncd_2eservice", 0, "systemd-timesyncd.service"); | |
786 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2dtmpfiles_2dclean_2eservice", 0, "systemd-tmpfiles-clean.service"); | |
787 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2dtmpfiles_2dclean_2etimer", 0, "systemd-tmpfiles-clean.timer"); | |
788 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2dtmpfiles_2dsetup_2ddev_2eservice", 0, "systemd-tmpfiles-setup-dev.service"); | |
789 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2dtmpfiles_2dsetup_2eservice", 0, "systemd-tmpfiles-setup.service"); | |
790 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2dudev_2dtrigger_2eservice", 0, "systemd-udev-trigger.service"); | |
791 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2dudevd_2dcontrol_2esocket", 0, "systemd-udevd-control.socket"); | |
792 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2dudevd_2dkernel_2esocket", 0, "systemd-udevd-kernel.socket"); | |
793 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2dudevd_2eservice", 0, "systemd-udevd.service"); | |
794 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2dupdate_2ddone_2eservice", 0, "systemd-update-done.service"); | |
795 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2dupdate_2dutmp_2drunlevel_2eservice", 0, "systemd-update-utmp-runlevel.service"); | |
796 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2dupdate_2dutmp_2eservice", 0, "systemd-update-utmp.service"); | |
797 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2duser_2dsessions_2eservice", 0, "systemd-user-sessions.service"); | |
798 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/systemd_2dvconsole_2dsetup_2eservice", 0, "systemd-vconsole-setup.service"); | |
799 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/time_2dsync_2etarget", 0, "time-sync.target"); | |
800 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/timers_2etarget", 0, "timers.target"); | |
801 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/tmp_2emount", 0, "tmp.mount"); | |
802 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/umount_2etarget", 0, "umount.target"); | |
803 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/unbound_2danchor_2eservice", 0, "unbound-anchor.service"); | |
804 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/unbound_2danchor_2etimer", 0, "unbound-anchor.timer"); | |
805 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/upower_2eservice", 0, "upower.service"); | |
806 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/user_2d1000_2eslice", 0, "user-1000.slice"); | |
807 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/user_2druntime_2ddir_401000_2eservice", 0, "user-runtime-dir@1000.service"); | |
808 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/user_2eslice", 0, "user.slice"); | |
809 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/user_401000_2eservice", 0, "user@1000.service"); | |
810 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/usr_2dlocal_2dtexlive_2emount", 0, "usr-local-texlive.mount"); | |
811 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/var_2dlib_2dmachines_2emount", 0, "var-lib-machines.mount"); | |
812 | test_unit_name_from_dbus_path_one("/org/freedesktop/systemd1/unit/wpa_5fsupplicant_2eservice", 0, "wpa_supplicant.service"); | |
813 | } | |
814 | ||
1682ff60 | 815 | int main(int argc, char* argv[]) { |
a04efff8 | 816 | _cleanup_(rm_rf_physical_and_freep) char *runtime_dir = NULL; |
651d47d1 | 817 | int r, rc = 0; |
a04efff8 | 818 | |
6d7c4033 | 819 | test_setup_logging(LOG_INFO); |
a04efff8 | 820 | |
651d47d1 | 821 | r = enter_cgroup_subroot(); |
317bb217 ZJS |
822 | if (r == -ENOMEDIUM) |
823 | return log_tests_skipped("cgroupfs not available"); | |
8c759b33 | 824 | |
a04efff8 YW |
825 | assert_se(runtime_dir = setup_fake_runtime_dir()); |
826 | ||
7410616c | 827 | test_unit_name_is_valid(); |
21868586 LP |
828 | test_unit_name_replace_instance(); |
829 | test_unit_name_from_path(); | |
830 | test_unit_name_from_path_instance(); | |
831 | test_unit_name_mangle(); | |
832 | test_unit_name_to_path(); | |
143bfdaf | 833 | TEST_REQ_RUNNING_SYSTEMD(rc = test_unit_printf()); |
068ae9fb RC |
834 | test_unit_instance_is_valid(); |
835 | test_unit_prefix_is_valid(); | |
836 | test_unit_name_change_suffix(); | |
837 | test_unit_name_build(); | |
93c47472 | 838 | test_slice_name_is_valid(); |
068ae9fb | 839 | test_build_subslice(); |
93c47472 | 840 | test_build_parent_slice(); |
068ae9fb RC |
841 | test_unit_name_to_instance(); |
842 | test_unit_name_escape(); | |
fee0a921 | 843 | test_unit_name_template(); |
93c47472 | 844 | test_unit_name_path_unescape(); |
72406c2f | 845 | test_unit_name_to_prefix(); |
b4152e9b | 846 | test_unit_name_from_dbus_path(); |
068ae9fb | 847 | |
143bfdaf | 848 | return rc; |
b0193f1c | 849 | } |