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