Server IP : 85.214.239.14 / Your IP : 18.225.56.181 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/3/root/proc/3/root/proc/2/root/usr/share/augeas/lenses/dist/tests/ |
Upload File : |
(* 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" } } (* empty 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" } } (* Test: Shellvars_list.lns Support double-quoted continued lines *) test Shellvars_list.lns get "DAEMON_OPTS=\"-a :6081 \ -T localhost:6082\"\n" = { "DAEMON_OPTS" { "quote" = "\"" } { "value" = "-a" } { "value" = ":6081" } { "value" = "-T" } { "value" = "localhost:6082" } } (* Local Variables: *) (* mode: caml *) (* End: *)