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 only type and path *)
84 let short = "A+ /tmp/foo\n"
86 (* Variable: short_tree
92 { "path" = "/tmp/foo" }
95 (* Variable: short_mode
96 Example with only 3 fields *)
97 let short_mode = "c+! /tmp/foo ~0755\n"
99 (* Variable: short_mode_tree
100 Tree for <short_mode> *)
101 let short_mode_tree =
105 { "path" = "/tmp/foo" }
109 (* Variable: short_uid
110 Example with only 4 fields *)
111 let short_uid = "A+ /tmp/foo - 0\n"
113 (* Variable: short_uid_tree
114 Tree for <short_uid> *)
119 { "path" = "/tmp/foo" }
124 (* Variable: short_gid
125 Example with only 5 fields *)
126 let short_gid = "z /tmp/bar/foo -\t- augd\n"
128 (* Variable: short_gid_tree
129 Tree for <short_gid> *)
134 { "path" = "/tmp/bar/foo" }
140 (* Variable: short_age
141 Example with only 6 fields *)
142 let short_age = "H /var/tmp/fooBarFOO - jj jj ~10d\n"
144 (* Variable: short_age_tree
145 Tree for <short_age> *)
150 { "path" = "/var/tmp/fooBarFOO" }
157 (* Variable: complex_arg
158 Complex argument example. That one comes from the manual *)
159 let complex_arg = "t /run/screen - - - - user.name=\"John Smith\" security.SMACK64=screen\n"
161 (* Variable: complex_arg_tree
162 Tree for <complex_arg> *)
163 let complex_arg_tree =
167 { "path" = "/run/screen" }
172 { "argument" = "user.name=\"John Smith\" security.SMACK64=screen" }
175 (* Variable: valid_short_args
176 A short argument value example. *)
177 let valid_short_args = "h /var/log/journal - - - - C\nh /var/log/journal - - - - +C\n"
179 (* Variable: valid_short_args_tree
180 Tree for <valid_short_args> *)
181 let valid_short_args_tree =
185 { "path" = "/var/log/journal" }
195 { "path" = "/var/log/journal" }
200 { "argument" = "+C" }
203 (* Variable: valid_age
204 Example with a complex age. *)
205 let valid_age = "v /var/tmp/js 4221 johnsmith - ~10d12h\n"
207 (* Variable: valid_age_tree
208 Tree for <valid_age> *)
213 { "path" = "/var/tmp/js" }
215 { "uid" = "johnsmith" }
217 { "age" = "~10d12h" }
220 (* Variable: valid_second
221 Example with full age unit *)
222 let valid_second = "p+ /var/tmp - jsmith - 0second\n"
224 (* Variable: valid_second_tree
225 Tree for <valid_second> *)
226 let valid_second_tree =
230 { "path" = "/var/tmp" }
234 { "age" = "0second" }
237 (* Variable: valid_days
238 Example with full age unit (plural) *)
239 let valid_days = "x /var/tmp/manu - jonhsmith - 9days\n"
241 (* Variable: valid_days_tree
242 Tree for <valid_days> *)
243 let valid_days_tree =
247 { "path" = "/var/tmp/manu" }
249 { "uid" = "jonhsmith" }
255 Test with a percent sign *)
256 let percent = "m /var/log/%m 2755 root systemdjournal - -\n"
258 (* Variable: percent_tree
259 Tree for <percent> *)
264 { "path" = "/var/log/%m" }
267 { "gid" = "systemdjournal" }
273 Test with a hyphen in gid *)
274 let hyphen = "L /var/log/journal 2755 root systemd-journal - -\n"
276 (* Variable: hyphen_tree
282 { "path" = "/var/log/journal" }
285 { "gid" = "systemd-journal" }
290 (* Variable: valid_base
291 A valid test to be re-used by the failure cases *)
292 let valid_base = "H /var/tmp/js 0000 jonhsmith 60 1s foo\n"
294 (* Variable: valid_base_tree
295 Tree for <valid_base> *)
296 let valid_base_tree =
300 { "path" = "/var/tmp/js" }
302 { "uid" = "jonhsmith" }
305 { "argument" = "foo" }
309 Mode field example with only three digits *)
310 let mode3 = "c+! /tmp/foo 755\n"
312 (* Variable: mode3_tree
318 { "path" = "/tmp/foo" }
322 (************************************************************************
323 * Group: INVALID EXAMPLES
324 *************************************************************************)
326 (* Variable: invalid_too_short
327 Invalid example that do not contain path *)
328 let invalid_too_short = "H\n"
330 (* Variable: invalid_age
331 Invalid example that contain invalid age *)
332 let invalid_age = "H /var/tmp/js 0000 jonhsmith 60 1sss foo\n"
334 (* Variable: invalid_type
335 Invalid example that contain invalid type (bad letter) *)
336 let invalid_type = "e /var/tmp/js 0000 jonhsmith 60 1s foo\n"
338 (* Variable: invalid_type_num
339 Invalid example that contain invalid type (numeric) *)
340 let invalid_type_num = "1 /var/tmp/js 0000 jonhsmith 60 1s foo\n"
342 (* Variable: invalid_mode
343 Invalid example that contain invalid mode (bad int) *)
344 let invalid_mode = "H /var/tmp/js 8000 jonhsmith 60 1s foo\n"
346 (* Variable: invalid_mode_alpha
347 Invalid example that contain invalid mode (letter) *)
348 let invalid_mode_alpha = "H /var/tmp/js a000 jonhsmith 60 1s foo\n"
350 test Tmpfiles.lns get simple = simple_tree
352 test Tmpfiles.lns get complex = complex_tree
354 test Tmpfiles.lns get trailing_ws = complex_tree
356 test Tmpfiles.lns get empty = {}{}{}
358 test Tmpfiles.lns get exclamation_mark = exclamation_mark_tree
360 test Tmpfiles.lns get short = short_tree
362 test Tmpfiles.lns get short_mode = short_mode_tree
364 test Tmpfiles.lns get short_uid = short_uid_tree
366 test Tmpfiles.lns get short_gid = short_gid_tree
368 test Tmpfiles.lns get short_age = short_age_tree
370 test Tmpfiles.lns get complex_arg = complex_arg_tree
372 test Tmpfiles.lns get valid_short_args = valid_short_args_tree
374 test Tmpfiles.lns get valid_second = valid_second_tree
376 test Tmpfiles.lns get valid_days = valid_days_tree
378 test Tmpfiles.lns get valid_age = valid_age_tree
380 test Tmpfiles.lns get percent = percent_tree
382 test Tmpfiles.lns get hyphen = hyphen_tree
384 test Tmpfiles.lns get valid_base = valid_base_tree
386 test Tmpfiles.lns get mode3 = mode3_tree
391 test Tmpfiles.lns get invalid_too_short = *
393 test Tmpfiles.lns get invalid_age = *
395 test Tmpfiles.lns get invalid_type = *
397 test Tmpfiles.lns get invalid_type_num = *
399 test Tmpfiles.lns get invalid_mode = *
401 test Tmpfiles.lns get invalid_mode_alpha = *
403 (* Local Variables: *)