tests: Check return of list_recurse.
[pwmd.git] / tests / store.test
blob840e98fd9ffb572390a15036e08c7a62478a77f8
1 #!/bin/sh
3 # Tests for the STORE protocol command.
5 MAX_TESTS=10
7 . $AM_SRCDIR/common.sh
8 . $AM_SRCDIR/import-common.sh
10 init_tests() {
11 do_import datafile
12 cat >$OUTDIR/config << EOF
13 [global]
14 log_level=9
15 #enable_logging=true
16 [datafile]
17 passphrase_file=$WDIR/passphrase.key
18 [datafile.tmp]
19 passphrase_file=$WDIR/passphrase.key
20 EOF
21 launch_pwmd datafile
24 test_1() {
25 cp -f data/datafile data/datafile.tmp || bail_out "Could not copy data/datafile."
26 run_pwmc "--inquire STORE --inquire-line 'a a' -S datafile.tmp" $DEVNULL <<EOF
27 EOF
28 e=$?
29 if [ $e -eq 0 ]; then
30 run_pwmc "datafile.tmp" >result $DEVNULL <<EOF
31 GET a
32 EOF
33 e=$?
35 test_result $test_n $e store "Element with same value as element name."
38 test_2() {
39 cp -f data/datafile data/datafile.tmp || bail_out "Could not copy data/datafile."
40 run_pwmc "--inquire STORE --inquire-line 'a ' -S datafile.tmp" $DEVNULL <<EOF
41 EOF
42 e=$?
43 if [ $e -eq 0 ]; then
44 run_pwmc "datafile.tmp" >result $DEVNULL <<EOF
45 GET a
46 EOF
47 e=$?
49 test_failure $test_n $e 536870970 "Remove element content."
52 test_3() {
53 run_pwmc "--inquire STORE --inquire-line 'a b a b value' -S datafile" $DEVNULL <<EOF
54 EOF
55 e=$?
56 if [ $e -eq 0 ]; then
57 run_pwmc "datafile" >result $DEVNULL <<EOF
58 GET a b
59 EOF
60 e=$?
62 test_result $test_n $e store "Write element content."
65 test_4() {
66 run_pwmc "-S datafile" $DEVNULL <<EOF
67 ATTR SET _target b a
68 EOF
69 e=$?
70 if [ $e -eq 0 ]; then
71 run_pwmc "datafile" >result $DEVNULL <<EOF
72 GET b b
73 EOF
74 e=$?
76 test_result $test_n $e store "ATTR: Set root target to root."
79 test_5() {
80 run_pwmc "--inquire STORE --inquire-line 'b b a b value' -S datafile" $DEVNULL <<EOF
81 EOF
82 e=$?
83 if [ $e -eq 0 ]; then
84 run_pwmc "datafile" >result $DEVNULL <<EOF
85 GET b b
86 EOF
87 e=$?
89 test_result $test_n $e store "Overwrite target content."
92 test_6() {
93 cp -f data/datafile data/datafile.tmp || bail_out "Could not copy data/datafile."
94 run_pwmc "-S datafile.tmp" $DEVNULL <<EOF
95 ATTR SET _target a b
96 EOF
97 list_recurse datafile.tmp
98 test_result $test_n $? store "ATTR: Set target to recursion loop."
101 test_7() {
102 run_pwmc "-S datafile.tmp" $DEVNULL <<EOF
103 ATTR SET _target a b a
105 test_failure $test_n $? 536903743 "Fail to set target to parent element."
109 test_8() {
110 cp -f data/datafile data/datafile.tmp || bail_out "Could not copy data/datafile.tmp."
111 run_pwmc "-S datafile.tmp" $DEVNULL <<EOF
112 ATTR SET _target a a b
114 list_recurse datafile.tmp
115 test_result $test_n $? store "ATTR: Set target to child."
118 test_9() {
119 run_pwmc "-S datafile" $DEVNULL <<EOF
120 ATTR SET _target a b b
122 e=$?
123 if [ $e -eq 0 ]; then
124 run_pwmc "--inquire STORE -S datafile" $DEVNULL <<EOF
125 a b c
127 e=$?
129 test_failure $test_n $e 536903743 "Fail to create element at element with recursion loop."
132 test_10() {
133 run_pwmc "--inquire STORE -S datafile" $DEVNULL <<EOF
134 a b content
136 test_failure $test_n $e 536903743 "Fail to create content at element with recursion loop."
139 run_tests $@