3 # Blank lines and lines starting with '#' are ignored. This file is
4 # processed by test-run.c
6 # The syntax for a test specification is
7 # test NAME RESULT ERRCODE
14 # NAME - the name printed to identify the test
15 # RESULT - an integer that is compared against the return code
17 # ERRCODE - one of the error codes defined in enum errcode_t in augeas.h
18 # without the AUG_ prefix, i.e. NOERROR, EMMATCH etc. If ERRCODE
19 # is omitted, it defaults to NOERROR
20 # MODULE - the name of a module that should be loaded before the test
21 # COMMANDS - the commands to hand to aug_srun; can be multiple lines,
22 # which are passed as one string.
23 # OUTPUT - the string that aug_srun should print on the OUT file stream
25 # The prints keyword and OUTPUT are optional; if they are not provided, the
26 # output of aug_srun must be empty
28 # Leading spaces are stripped from COMMANDS and OUTPUT; a leading or trailing
29 # ':' is also stripped, but the rest of the line is used verbatim.
31 # A test passes when RESULT and ERRCODE agree with what aug_srun given
32 # COMMANDS produces, and OUTPUT coincides with what aug_srun prints on its
35 # The test is run against a tree initialized with AUG_NO_STDINC|AUG_NO_LOAD
36 # and file system root /dev/null. The Hosts module is loaded
40 # Various corner cases
60 /augeas/root = /dev/null/
76 test get_wspace_between 1
81 test unknown-cmd -1 ECMDRUN
97 test ls-bad-pathx -1 EPATHX
114 test match-root-star 1
120 test match-bad-pathx -1 EPATHX
132 rm /augeas/version/save
134 rm : /augeas/version/save 5
136 test rm-bad-pathx -1 EPATHX
143 mv /augeas/version /files
145 test mv-not-there -1 ENOMATCH
148 test mv-to-not-there 1
151 test mv-into-descendant -1 EMVDESC
152 mv /augeas /augeas/version
154 test mv-into-self -1 EMVDESC
157 test mv-into-multiple -1 EMMATCH
158 mv /files /augeas/version/save/*
160 test mv-multiple -1 EMMATCH
161 mv /augeas/version/save/* /files
166 print /*[ label() != 'augeas' and label() != 'files']
175 print /*[ label() != 'augeas' and label() != 'files']
184 print /*[ label() != 'augeas' and label() != 'files']
191 test mv-tree4 -1 EMVDESC
194 print /*[ label() != 'augeas' and label() != 'files']
199 print /*[ label() != 'augeas' and label() != 'files']
208 print /*[ label() != 'augeas' and label() != 'files']
219 rename /augeas/version version2
221 rename : /augeas/version to version2 1
223 test rename-into-self 1
224 rename /augeas augeas
226 rename : /augeas to augeas 1
231 print /*[ label() != 'augeas' and label() != 'files']
233 rename : /a/b/c to x 1
242 print /*[ label() != 'augeas' and label() != 'files']
244 rename : /a/b/c to x 1
250 test rename-multiple 4
254 print /*[ label() != 'augeas' and label() != 'files']
263 test rename-slash -1 ELABEL
282 test set-trailing-slash 2
288 test set-bad-pathx -1 EPATHX
291 test set-multiple -1 EMMATCH
292 set /augeas/version/save/mode value
302 test clear-not-there 2
308 test clear-existing 2
314 test clear-bad-pathx -1 EPATHX
317 test clear-multiple -1 EMMATCH
318 clear /augeas/version/save/mode
320 test clear-args -1 ECMDRUN
327 get /augeas/version/save/mode[1]
329 /augeas/version/save/mode[1] = backup
331 test get-too-many -1 EMMATCH
339 test get-bad-pathx -1 EPATHX
346 transform Test incl /tmp/bar
347 get /augeas/load/Test/lens
348 get /augeas/load/Test/incl
350 /augeas/load/Test/lens = Test.lns
351 /augeas/load/Test/incl = /tmp/bar
354 transform Bar incl /tmp/foo/*
355 transform Bar incl /tmp/bar/*
356 transform Bar excl /tmp/foo/baz
357 print /augeas/load/Bar
360 /augeas/load/Bar/lens = "Bar.lns"
361 /augeas/load/Bar/incl[1] = "/tmp/foo/*"
362 /augeas/load/Bar/incl[2] = "/tmp/bar/*"
363 /augeas/load/Bar/excl = "/tmp/foo/baz"
366 transform Bar.lns incl /tmp/foo/*
367 print /augeas/load/Bar
370 /augeas/load/Bar/lens = "Bar.lns"
371 /augeas/load/Bar/incl = "/tmp/foo/*"
377 print /augeas/version/save
380 /augeas/version/save/mode[1] = "backup"
381 /augeas/version/save/mode[2] = "newfile"
382 /augeas/version/save/mode[3] = "noop"
383 /augeas/version/save/mode[4] = "overwrite"
389 # test set/get parsing with quoting, whitespace and escaping
391 test set-single-quotes 2
392 set /files 'a test value'
395 /files = a test value
397 test set-double-quotes 2
398 set /files "a test value"
401 /files = a test value
403 test set-mixed-quotes1 2
404 set /files "a 'mixed quotes' test"
407 /files = a 'mixed quotes' test
409 test set-mixed-quotes2 2
410 set /files 'a "mixed quotes" test'
413 /files = a "mixed quotes" test
415 test set-mixed-quotes-expr 2
417 print "/*[ label() != 'augeas' and label() != 'files']"
421 test set-quote-concat 2
427 test set-escaped-quotes 2
433 test set-escaped-path 2
434 set /white\ space\ tab value
435 get /white\ space\ tab
437 /white space tab = value
439 test set-escaped-path-bracket 2
440 set /white\ space/\[section value
441 print /white\ space/\[section
443 /white\ space/\[section = "value"
445 test set-squote-escaped-bracket 2
446 set '/augeas/\[section' value
447 print '/augeas/\[section'
449 /augeas/\[section = "value"
451 test set-squote-escaped-path 2
452 set '/white\ space' value
455 /white\ space = value
457 test set-dquote-escaped-path 2
458 set "/white\ space" value
461 /white\ space = value
464 set /files newl\ntab\tend
470 test set-tabnline-squote 2
471 set /files 'newl\ntab\tend'
477 test set-tabnline-dquote 2
478 set /files "newl\ntab\tend"
484 # Combinations of quotes in values, some unmatched
485 # Tests from David Schmitt (Puppet bug #12199)
486 test quot_sq -1 ECMDRUN
489 test quot_sq_sq -1 ECMDRUN
516 test quot_sqsqsq -1 ECMDRUN
519 test quot_sqsqsq_sq -1 ECMDRUN
522 test quot_sqsqsq_dq 2
534 test quot_sqsqsqsq_sq 2
540 test quot_sqsqsqsq_dq 2
546 test quot_dq -1 ECMDRUN
555 test quot_dq_dq -1 ECMDRUN
576 test quot_dqdqdq -1 ECMDRUN
579 test quot_dqdqdq_sq 2
585 test quot_dqdqdq_dq -1 ECMDRUN
594 test quot_dqdqdqdq_sq 2
600 test quot_dqdqdqdq_dq 2
606 test quot_truncated_dq 2
612 test quot_truncated_dq_sq 2
613 set /test '"s"bc"d"ef'
618 test quot_truncated_dq_dq 2
619 set /test ""s"bc"d"ef"
624 test quot_truncated_sq 2
630 test quot_truncated_sq_sq 2
631 set /test ''s'bc'd'ef'
636 test quot_truncated_sq_dq 2
637 set /test "'s'bc'd'ef"
642 test quot_truncated_dq_mix 2
648 test quot_truncated_dq_mix_sq 2
649 set /test '"s"bc'd'ef'
654 test quot_truncated_dq_mix_dq 2
655 set /test ""s"bc'd'ef"
660 test quot_truncated_sq_mix 2
666 test quot_truncated_sq_mix_sq 2
667 set /test ''s'bc"d"ef'
672 test quot_truncated_sq_mix_dq 2
673 set /test "'s'bc"d"ef"
678 test quot_truncated_space -1 ECMDRUN
679 set /test before after
681 test quot_truncated_space_sq 2
682 set /test 'before after'
687 test quot_truncated_space_dq 2
688 set /test "before after"
693 test quot_mix -1 ECMDRUN
696 test quot_mix_sq -1 ECMDRUN
697 set /test 'a"b'c"d'e'
699 test quot_mix_dq -1 ECMDRUN
700 set /test "a"b'c"d'e"
703 # Tests for aug_text_store
707 set /text/in/t1 "192.168.0.1 rtr.example.com foo\n"
708 store Hosts.lns /text/in/t1 /text/tree/t1
713 /text/tree/t1/1/ipaddr = "192.168.0.1"
714 /text/tree/t1/1/canonical = "rtr.example.com"
715 /text/tree/t1/1/alias = "foo"
717 test store_nolens -1 ENOLENS
718 set /text/in/t1 "192.168.0.1 rtr.example.com foo\n"
719 store Nomodule.lns /text/in/t1 /text/tree/t1
721 test store_epathx_node -1 EPATHX
723 store Hosts.lns [garbage] /text/tree/t1
725 test store_epathx_path -1 EPATHX
727 store Hosts.lns /text/in/t1 [garbage]
729 test store_null_text -1 ENOMATCH
731 store Hosts.lns /text/in/t1 /text/tree/t1
735 set /text/in/t1 "not a hosts file entry"
736 store Hosts.lns /text/in/t1 /text/tree/t1
737 match /augeas/text/text/tree/t1/error
739 /augeas/text/text/tree/t1/error = parse_failed
741 # Bug #283; /text is actually NULL
742 test store_null -1 ENOMATCH
744 set /text/1 "192.168.0.1 toto\n"
745 store Hosts.lns /text /hosts
748 # Tests for aug_text_retrieve
750 test retrieve_hosts 5
752 set /text/in/t1 "192.168.0.1 rtr.example.com foo\n"
753 store Hosts.lns /text/in/t1 /text/tree/t1
754 set /text/tree/t1/1/alias[1] bar
755 retrieve Hosts.lns /text/in/t1 /text/tree/t1 /text/out/t1
758 /text/out/t1 = "192.168.0.1 rtr.example.com bar\n"
760 test retrieve_nolens -1 ENOLENS
761 set /text/in/t1 "192.168.0.1 rtr.example.com foo\n"
762 store Hosts.lns /text/in/t1 /text/tree/t1
763 retrieve Nomodule.lns /text/in/t1 /text/tree/t1 /text/out/t1
765 test retrieve_epathx_node_in -1 EPATHX
767 retrieve Hosts.lns [garbage] /text/tree/t1 /text/out/t1
769 test retrieve_epathx_path -1 EPATHX
771 retrieve Hosts.lns /text/in/t1 [garbage] /text/out/t1
773 test retrieve_epathx_node_out -1 EPATHX
775 set /text/in/t1 "192.168.0.1 rtr.example.com foo\n"
776 retrieve Hosts.lns /text/in/t1 /text/tree/t1 [garbage]
778 test retrieve_no_node_in -1 ENOMATCH
780 retrieve Hosts.lns /text/in/t1 /text/tree/t1 /text/out/t1
782 test retrieve_no_tree 3
784 set /text/in/t1 "192.168.0.1 rtr.example.com foo\n"
785 retrieve Hosts.lns /text/in/t1 /text/tree/t1 /text/out/t1
790 test retrieve_esyntax 5
792 set /text/in/t1 "192.168.0.1 rtr.example.com foo\n"
793 store Hosts.lns /text/in/t1 /text/tree/t1
794 set /text/in/t1 "not a hosts file entry"
795 retrieve Hosts.lns /text/in/t1 /text/tree/t1 /text/out/t1
798 /augeas/text/text/tree/t1/error = parse_skel_failed
800 # Bug #283; /text is actually NULL
801 test retrieve_null -1 ENOMATCH
803 set /text/1 "192.168.0.1 toto\n"
804 retrieve Hosts.lns /text /hosts /out
806 # Change 'var=val' to 'variable=value' and check that the span gets updated
807 test span_updates_lv 9
809 store Cron.lns /in /cron
812 mv /cron/var /cron/variable
813 set /cron/variable value
814 retrieve Cron.lns /in /cron /out
818 /cron label=(0:3) value=(4:7) span=(0,8)
819 /cron label=(0:0) value=(0:0) span=(0,8)
820 /cron label=(0:8) value=(9:14) span=(0,15)
821 /cron label=(0:0) value=(0:0) span=(0,15)
823 # Make a change and check that the parents' span gets updated
824 test span_updates_parent 8
825 set /in "10.0.0.1 gw.example.com\n"
826 store Hosts.lns /in /host
829 set /host/1/canonical gateway.example.com
830 retrieve Hosts.lns /in /host /out
834 /host label=(0:0) value=(0:0) span=(0,24)
835 /host label=(0:0) value=(0:0) span=(0,24)
836 /host label=(0:0) value=(0:0) span=(0,29)
837 /host label=(0:0) value=(0:0) span=(0,29)
839 # Check that creating nodes sets spans
840 test span_updates_on_create 5
843 retrieve Cron.lns /in /cron /out
847 /cron label=(0:3) value=(4:7) span=(0,8)
848 /cron label=(0:0) value=(0:0) span=(0,8)