Fix commit 3c72e54.
[pwmd.git] / tests / list.test
blob13c969b990edb14f1c507b49760d40ec02b471f9
1 #!/bin/sh
3 # Tests for the LIST protocol command.
5 MAX_TESTS=8
7 . $AM_SRCDIR/common.sh
8 . $AM_SRCDIR/import-common.sh
10 init_tests() {
11 do_import list
12 cat >$OUTDIR/config << EOF
13 [global]
14 log_level=9
15 #enable_logging=true
16 [list]
17 passphrase_file=$WDIR/passphrase.key
18 EOF
19 launch_pwmd list
22 test_1() {
23 run_pwmc "list" >result $DEVNULL <<EOF
24 LIST
25 EOF
26 test_result $test_n $? list "List root elements."
29 test_2() {
30 list_recurse list
31 test_result $test_n $? list "List recursive."
34 test_3() {
35 list_recurse list "a b"
36 test_result $test_n $? list "List specific path and verbose with targets."
39 test_4() {
40 list_recurse list "z"
41 test_result $test_n $? list "List specific root path without target."
44 test_5() {
45 list_recurse list "target-loop-a"
46 test_result $test_n $? list "List element with ELOOP target."
49 test_6() {
50 run_pwmc "-S list" $DEVNULL <<EOF
51 ATTR SET _target c d a
52 EOF
53 e=$?
54 if [ $e -eq 0 ]; then
55 run_pwmc "-S list" $DEVNULL <<EOF
56 ATTR SET _target a b c c d b
57 EOF
58 list_recurse list
59 e=$?
61 test_result $test_n $e list "Recursion loop flags."
64 test_7() {
65 run_pwmc "-S list" $DEVNULL <<EOF
66 ATTR SET _target a b c c d
67 EOF
68 list_recurse list
69 test_result $test_n $? list "Recursion loop of target without children."
72 test_8() {
73 run_pwmc "-S list" $DEVNULL <<EOF
74 ATTR SET _target a b c c
75 EOF
76 list_recurse list
77 test_result $test_n $e list "Recursion loop of target that has no target."
80 run_tests $@