Reset save key id's at SAVE start.
[libpwmd.git] / tests / move.test
blobf59174c5f3ab0366e5dd9da6d523c968f122859c
1 #!/bin/bash
3 # Most checks should be done by the client. For example, recursion loop
4 # checking is not done after the element has been moved.
6 source common.sh
7 source import-common.sh
9 do_import list
11 cat > config << EOF
12 [global]
13 log_level=9
14 #enable_logging=true
15 [move]
16 passphrase_file=`pwd`/list.key
17 EOF
19 mv -f data/list data/move
20 launch_pwmd move
22 begin_test
23 echo "Test 1. Move src to src (fail)."
24 set +o errexit
25 echo -ne 'MOVE !a !a' | pwmc $PWMC_ARGS move
26 if [ ${PIPESTATUS[1]} == 0 ]; then
27 echo "The previous command should have failed. Stopping."
28 exit 1
31 set -e
33 echo
34 echo "Test 2. Move non-existant (fail)."
35 set +o errexit
36 echo -ne 'MOVE non-existant !a' | pwmc $PWMC_ARGS move
37 if [ ${PIPESTATUS[1]} == 0 ]; then
38 echo "The previous command should have failed. Stopping."
39 exit 1
42 set -e
44 echo
45 echo "Test 3. Move child with target to root."
46 echo -ne 'MOVE !a\t!b\tc ' | pwmc $PWMC_ARGS move
48 echo
49 echo "Test 4. Move child to sibling child with target."
50 echo -ne 'MOVE !a\tc !a\tb\tc\td\te' | pwmc $PWMC_ARGS -S move
51 echo -ne 'LIST --all --with-target' | pwmc $PWMC_ARGS move > result
52 cmp move.result4 result
53 rm -f result
55 echo
56 echo "Test 5. Move child with target to parent sibling."
57 echo -ne 'MOVE !a\tb\tc\td\te\tc !a' | pwmc $PWMC_ARGS -S move
58 echo -ne 'LIST --all --with-target' | pwmc $PWMC_ARGS move > result
59 cmp move.result5 result
60 rm -f result
62 echo
63 echo "Test 6. Overwrite existing tree."
64 echo -ne 'MOVE !a\tb\tc\t!d ' | pwmc $PWMC_ARGS -S move
65 echo -ne 'LIST --all --with-target' | pwmc $PWMC_ARGS move > result
66 cmp move.result6 result
67 rm -f result
69 echo
70 echo "Test 7. Show child elements whose target contains an error."
71 echo -ne 'MOVE !d c\te' | pwmc $PWMC_ARGS -S move
72 echo -ne 'LIST --all --with-target' | pwmc $PWMC_ARGS move > result
73 cmp move.result7 result
74 rm -f result
76 echo
77 echo "Test 8. Move child whos target value is a parent."
78 echo -ne 'MOVE !x z' | pwmc $PWMC_ARGS -S move
79 echo -ne 'LIST --all --with-target' | pwmc $PWMC_ARGS move > result
80 cmp move.result8 result
81 rm -f result
83 echo
84 echo "Test 9. Move child whos target value is a parent."
85 echo -ne 'MOVE z\tx\t!y z' | pwmc $PWMC_ARGS -S move
86 echo -ne 'LIST --all --with-target' | pwmc $PWMC_ARGS move > result
87 cmp move.result9 result
88 rm -f result
90 test_success