3 Provides unit tests and examples for the <Tmpfiles> lens.
8 (************************************************************************
9 * Group: VALID EXAMPLES
10 *************************************************************************)
12 One line, simple example *)
13 let simple = "d /run/user 0755 root mysql 10d -\n"
15 (* Variable: simple_tree
21 { "path" = "/run/user" }
30 A more complex example, comes from the manual *)
31 let complex = "#Type Path Mode UID GID Age Argument\nd /run/user 0755 root root 10d -\nL /tmp/foobar - - - - /dev/null\n"
33 (* Variable: complex_tree
34 Tree for <complex> and <trailing_ws> *)
36 { "#comment" = "Type Path Mode UID GID Age Argument" }
39 { "path" = "/run/user" }
48 { "path" = "/tmp/foobar" }
53 { "argument" = "/dev/null" }
56 (* Variable: trailing_ws
57 The complex example with extra spaces *)
58 let trailing_ws = " #Type Path Mode UID GID Age Argument \n d /run/user 0755 root root 10d - \t\n L /tmp/foobar - - - - /dev/null\t\n"
64 (* Variable: exclamation_mark
65 Example with an exclamation mark in the type *)
66 let exclamation_mark = "D! /tmp/foo - - - - -\n"
68 (* Variable: exclamation_mark_tree
69 Tree for <exclamation_mark> *)
70 let exclamation_mark_tree =
74 { "path" = "/tmp/foo" }
83 Example with an minus mark in the type *)
84 let minus = "D- /tmp/foo - - - - -\n"
86 (* Variable: minus_tree
87 Tree for <minus_tree> *)
92 { "path" = "/tmp/foo" }
101 Example with an equal sign in the type *)
102 let equal = "d= /tmp/foo 0755 root root - -\n"
104 (* Variable: equal_tree
110 { "path" = "/tmp/foo" }
119 Example with a tilde character in the type *)
120 let tilde = "w~ /tmp/foo 0755 root root - dGVzdAo=\n"
122 (* Variable: tilde_tree
128 { "path" = "/tmp/foo" }
133 { "argument" = "dGVzdAo=" }
137 Example with a caret in the type *)
138 let caret = "f^ /etc/motd.d/50-provision.conf - - - - login.motd\n"
140 (* Variable: caret_tree
146 { "path" = "/etc/motd.d/50-provision.conf" }
151 { "argument" = "login.motd" }
155 Example with only type and path *)
156 let short = "A+ /tmp/foo\n"
158 (* Variable: short_tree
164 { "path" = "/tmp/foo" }
167 (* Variable: short_mode
168 Example with only 3 fields *)
169 let short_mode = "c+! /tmp/foo ~0755\n"
171 (* Variable: short_mode_tree
172 Tree for <short_mode> *)
173 let short_mode_tree =
177 { "path" = "/tmp/foo" }
181 (* Variable: short_uid
182 Example with only 4 fields *)
183 let short_uid = "A+ /tmp/foo - 0\n"
185 (* Variable: short_uid_tree
186 Tree for <short_uid> *)
191 { "path" = "/tmp/foo" }
196 (* Variable: short_gid
197 Example with only 5 fields *)
198 let short_gid = "z /tmp/bar/foo -\t- augd\n"
200 (* Variable: short_gid_tree
201 Tree for <short_gid> *)
206 { "path" = "/tmp/bar/foo" }
212 (* Variable: short_age
213 Example with only 6 fields *)
214 let short_age = "H /var/tmp/fooBarFOO - jj jj ~10d\n"
216 (* Variable: short_age_tree
217 Tree for <short_age> *)
222 { "path" = "/var/tmp/fooBarFOO" }
229 (* Variable: complex_arg
230 Complex argument example. That one comes from the manual *)
231 let complex_arg = "t /run/screen - - - - user.name=\"John Smith\" security.SMACK64=screen\n"
233 (* Variable: complex_arg_tree
234 Tree for <complex_arg> *)
235 let complex_arg_tree =
239 { "path" = "/run/screen" }
244 { "argument" = "user.name=\"John Smith\" security.SMACK64=screen" }
247 (* Variable: valid_short_args
248 A short argument value example. *)
249 let valid_short_args = "h /var/log/journal - - - - C\nh /var/log/journal - - - - +C\n"
251 (* Variable: valid_short_args_tree
252 Tree for <valid_short_args> *)
253 let valid_short_args_tree =
257 { "path" = "/var/log/journal" }
267 { "path" = "/var/log/journal" }
272 { "argument" = "+C" }
275 (* Variable: valid_age
276 Example with a complex age. *)
277 let valid_age = "v /var/tmp/js 4221 johnsmith - ~10d12h\n"
279 (* Variable: valid_age_tree
280 Tree for <valid_age> *)
285 { "path" = "/var/tmp/js" }
287 { "uid" = "johnsmith" }
289 { "age" = "~10d12h" }
292 (* Variable: valid_second
293 Example with full age unit *)
294 let valid_second = "p+ /var/tmp - jsmith - 0second\n"
296 (* Variable: valid_second_tree
297 Tree for <valid_second> *)
298 let valid_second_tree =
302 { "path" = "/var/tmp" }
306 { "age" = "0second" }
309 (* Variable: valid_days
310 Example with full age unit (plural) *)
311 let valid_days = "x /var/tmp/manu - jonhsmith - 9days\n"
313 (* Variable: valid_days_tree
314 Tree for <valid_days> *)
315 let valid_days_tree =
319 { "path" = "/var/tmp/manu" }
321 { "uid" = "jonhsmith" }
327 Test with a percent sign *)
328 let percent = "m /var/log/%m 2755 root systemdjournal - -\n"
330 (* Variable: percent_tree
331 Tree for <percent> *)
336 { "path" = "/var/log/%m" }
339 { "gid" = "systemdjournal" }
345 Test with a hyphen in gid *)
346 let hyphen = "L /var/log/journal 2755 root systemd-journal - -\n"
348 (* Variable: hyphen_tree
354 { "path" = "/var/log/journal" }
357 { "gid" = "systemd-journal" }
362 (* Variable: valid_base
363 A valid test to be re-used by the failure cases *)
364 let valid_base = "H /var/tmp/js 0000 jonhsmith 60 1s foo\n"
366 (* Variable: valid_base_tree
367 Tree for <valid_base> *)
368 let valid_base_tree =
372 { "path" = "/var/tmp/js" }
374 { "uid" = "jonhsmith" }
377 { "argument" = "foo" }
381 Mode field example with only three digits *)
382 let mode3 = "c+! /tmp/foo 755\n"
384 (* Variable: mode3_tree
390 { "path" = "/tmp/foo" }
394 (* Variable: mode_colon
395 Mode field with colon prefix *)
396 let mode_colon = "d- /root :0700 root :root\n"
398 (* Variable: mode_colon_tree
399 Tree for <mode_colon> *)
400 let mode_colon_tree =
410 (************************************************************************
411 * Group: INVALID EXAMPLES
412 *************************************************************************)
414 (* Variable: invalid_too_short
415 Invalid example that do not contain path *)
416 let invalid_too_short = "H\n"
418 (* Variable: invalid_age
419 Invalid example that contain invalid age *)
420 let invalid_age = "H /var/tmp/js 0000 jonhsmith 60 1sss foo\n"
422 (* Variable: invalid_type
423 Invalid example that contain invalid type (bad letter) *)
424 let invalid_type = "i /var/tmp/js 0000 jonhsmith 60 1s foo\n"
426 (* Variable: invalid_type_num
427 Invalid example that contain invalid type (numeric) *)
428 let invalid_type_num = "1 /var/tmp/js 0000 jonhsmith 60 1s foo\n"
430 (* Variable: invalid_mode
431 Invalid example that contain invalid mode (bad int) *)
432 let invalid_mode = "H /var/tmp/js 8000 jonhsmith 60 1s foo\n"
434 (* Variable: invalid_mode_alpha
435 Invalid example that contain invalid mode (letter) *)
436 let invalid_mode_alpha = "H /var/tmp/js a000 jonhsmith 60 1s foo\n"
438 test Tmpfiles.lns get simple = simple_tree
440 test Tmpfiles.lns get complex = complex_tree
442 test Tmpfiles.lns get trailing_ws = complex_tree
444 test Tmpfiles.lns get empty = {}{}{}
446 test Tmpfiles.lns get exclamation_mark = exclamation_mark_tree
448 test Tmpfiles.lns get minus = minus_tree
450 test Tmpfiles.lns get equal = equal_tree
452 test Tmpfiles.lns get tilde = tilde_tree
454 test Tmpfiles.lns get caret = caret_tree
456 test Tmpfiles.lns get short = short_tree
458 test Tmpfiles.lns get short_mode = short_mode_tree
460 test Tmpfiles.lns get short_uid = short_uid_tree
462 test Tmpfiles.lns get short_gid = short_gid_tree
464 test Tmpfiles.lns get short_age = short_age_tree
466 test Tmpfiles.lns get complex_arg = complex_arg_tree
468 test Tmpfiles.lns get valid_short_args = valid_short_args_tree
470 test Tmpfiles.lns get valid_second = valid_second_tree
472 test Tmpfiles.lns get valid_days = valid_days_tree
474 test Tmpfiles.lns get valid_age = valid_age_tree
476 test Tmpfiles.lns get percent = percent_tree
478 test Tmpfiles.lns get hyphen = hyphen_tree
480 test Tmpfiles.lns get valid_base = valid_base_tree
482 test Tmpfiles.lns get mode3 = mode3_tree
484 test Tmpfiles.lns get mode_colon = mode_colon_tree
489 test Tmpfiles.lns get invalid_too_short = *
491 test Tmpfiles.lns get invalid_age = *
493 test Tmpfiles.lns get invalid_type = *
495 test Tmpfiles.lns get invalid_type_num = *
497 test Tmpfiles.lns get invalid_mode = *
499 test Tmpfiles.lns get invalid_mode_alpha = *
501 (* Local Variables: *)