/usr/share/augeas/lenses/dist/tests/test_shellvars_list.aug is in augeas-lenses 1.2.0-0ubuntu1.3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | (* Test for shell list handling lens *)
module Test_shellvars_list =
let list_vals = "# Some comment
MODULES_LOADED_ON_BOOT=\"ipv6 sunrpc\"
DEFAULT_APPEND=\"showopts noresume console=tty0 console=ttyS0,115200n8 ro\"
LOADER_TYPE=\"grub\"
"
test Shellvars_list.lns get list_vals =
{ "#comment" = "Some comment" }
{ "MODULES_LOADED_ON_BOOT"
{ "quote" = "\"" }
{ "value" = "ipv6" }
{ "value" = "sunrpc" } }
{ }
{ "DEFAULT_APPEND"
{ "quote" = "\"" }
{ "value" = "showopts" }
{ "value" = "noresume" }
{ "value" = "console=tty0" }
{ "value" = "console=ttyS0,115200n8" }
{ "value" = "ro" } }
{ }
{ "LOADER_TYPE"
{ "quote" = "\"" }
{ "value" = "grub" } }
(* append a value *)
test Shellvars_list.lns put "VAR=\"test1\t \ntest2\"\n" after
set "VAR/value[last()+1]" "test3"
= "VAR=\"test1\t \ntest2 test3\"\n"
(* in double quoted lists, single quotes and escaped values are allowed *)
test Shellvars_list.lns get "VAR=\"test'1 test2 a\ \\\"longer\\\"\ test\"\n" =
{ "VAR"
{ "quote" = "\"" }
{ "value" = "test'1" }
{ "value" = "test2" }
{ "value" = "a\ \\\"longer\\\"\ test" } }
(* add new value, delete one and append something *)
test Shellvars_list.lns put list_vals after
set "FAILSAVE_APPEND/quote" "\"" ;
set "FAILSAVE_APPEND/value[last()+1]" "console=ttyS0" ;
rm "LOADER_TYPE" ;
rm "MODULES_LOADED_ON_BOOT/value[1]" ;
set "DEFAULT_APPEND/value[last()+1]" "teststring"
= "# Some comment
MODULES_LOADED_ON_BOOT=\"sunrpc\"
DEFAULT_APPEND=\"showopts noresume console=tty0 console=ttyS0,115200n8 ro teststring\"
FAILSAVE_APPEND=\"console=ttyS0\"
"
(* test of single quotes (leading/trailing whitespaces are kept *)
(* leading/trailing) *)
test Shellvars_list.lns put "VAR=' \t test1\t \ntest2 '\n" after
set "VAR/value[last()+1]" "test3"
= "VAR=' \t test1\t \ntest2 test3 '\n"
(* change quotes (leading/trailing whitespaces are lost *)
test Shellvars_list.lns put "VAR=' \t test1\t \ntest2 '\n" after
set "VAR/quote" "\""
= "VAR=\"test1\t \ntest2\"\n"
(* double quotes are allowed in single quoted lists *)
test Shellvars_list.lns get "VAR='test\"1 test2'\n" =
{ "VAR"
{ "quote" = "'" }
{ "value" = "test\"1" }
{ "value" = "test2" } }
(* emtpy list with quotes *)
test Shellvars_list.lns get "VAR=''\n" =
{ "VAR"
{ "quote" = "'" } }
(* unquoted value *)
test Shellvars_list.lns get "VAR=test\n" =
{ "VAR"
{ "quote" = "" }
{ "value" = "test" } }
(* uquoted value with escaped space etc. *)
test Shellvars_list.lns get "VAR=a\\ \\\"long\\\"\\ test\n" =
{ "VAR"
{ "quote" = "" }
{ "value" = "a\\ \\\"long\\\"\\ test" } }
(* append to unquoted value *)
test Shellvars_list.lns put "VAR=test1\n" after
set "VAR/quote" "\"";
set "VAR/value[last()+1]" "test2"
= "VAR=\"test1 test2\"\n"
(* empty entry *)
test Shellvars_list.lns get "VAR=\n" =
{ "VAR"
{ "quote" = "" } }
(* set value w/o quotes to empty value... *)
test Shellvars_list.lns put "VAR=\n" after
set "VAR/value[last()+1]" "test"
= "VAR=test\n"
(* ... or no value *)
test Shellvars_list.lns put "" after
set "VAR/quote" "";
set "VAR/value[1]" "test"
= "VAR=test\n"
(* Ticket #368 - backticks *)
test Shellvars_list.lns get "GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`\n" =
{ "GRUB_DISTRIBUTOR"
{ "quote" = "" }
{ "value" = "`lsb_release -i -s 2> /dev/null || echo Debian`" } }
(* Test: Shellvars_list.lns
Ticket #342: end-of-line comments *)
test Shellvars_list.lns get "service_ping=\"ping/icmp\" #ping\n" =
{ "service_ping"
{ "quote" = "\"" }
{ "value" = "ping/icmp" }
{ "#comment" = "ping" } }
(* Local Variables: *)
(* mode: caml *)
(* End: *)
|