Rework pthread_cleanup_* for compatibility kluge.
[libpwmd.git] / tests / move.test
blob9be5b911ff74314bb956111ca063319bde942280
1 #!/bin/bash
2 source common.sh
3 source import-common.sh
5 do_import list
7 cat > config << EOF
8 [global]
9 log_level=9
10 #enable_logging=true
11 [move]
12 passphrase_file=`pwd`/passphrase.key
13 EOF
15 mv -f data/list data/move
16 launch_pwmd move
18 begin_test
19 echo "Test 1. Move src to src (fail)."
20 set +o errexit
21 echo -ne 'MOVE a a' | pwmc $PWMC_ARGS move
22 if [ ${PIPESTATUS[1]} == 0 ]; then
23 echo "The previous command should have failed. Stopping."
24 exit 1
27 set -e
29 echo
30 echo "Test 2. Move non-existant (fail)."
31 set +o errexit
32 echo -ne 'MOVE non-existant a' | pwmc $PWMC_ARGS move
33 if [ ${PIPESTATUS[1]} == 0 ]; then
34 echo "The previous command should have failed. Stopping."
35 exit 1
38 set -e
40 echo
41 echo "Test 3. Move child with target to root of same node."
42 echo -ne 'MOVE a\tb\tc ' | pwmc $PWMC_ARGS move
44 echo
45 echo "Test 4. Move child to sibling child with target."
46 echo -ne 'MOVE a\tc a\tb\tc\td\te' | pwmc $PWMC_ARGS -S move
47 echo -ne 'LIST --recurse' | pwmc $PWMC_ARGS move > result
48 cmp move.result4 result
49 rm -f result
51 echo
52 echo "Test 5. Move child with target to parent sibling."
53 echo -ne 'MOVE a\tb\tc\td\te\tc a' | pwmc $PWMC_ARGS -S move
54 echo -ne 'LIST --recurse' | pwmc $PWMC_ARGS move > result
55 cmp move.result5 result
56 rm -f result
58 echo
59 echo "Test 6. Overwrite existing tree."
60 echo -ne 'MOVE a\tb\tc\td ' | pwmc $PWMC_ARGS -S move
61 echo -ne 'LIST --recurse' | pwmc $PWMC_ARGS move > result
62 cmp move.result6 result
63 rm -f result
65 echo
66 echo "Test 7. Show child elements whose target contains an error."
67 echo -ne 'MOVE d c\te' | pwmc $PWMC_ARGS -S move
68 echo -ne 'LIST --recurse' | pwmc $PWMC_ARGS move > result
69 cmp move.result7 result
70 rm -f result
72 echo
73 echo "Test 8. Move child whos target value is a parent."
74 echo -ne 'MOVE x z' | pwmc $PWMC_ARGS -S move
75 echo -ne 'LIST --recurse' | pwmc $PWMC_ARGS move > result
76 cmp move.result8 result
77 rm -f result
79 echo
80 echo "Test 9. Move child whos target value is a parent."
81 echo -ne 'MOVE z\tx\ty z' | pwmc $PWMC_ARGS -S move
82 echo -ne 'LIST --recurse' | pwmc $PWMC_ARGS move > result
83 cmp move.result9 result
84 rm -f result
86 echo
87 echo "Test 10. Move to non-existant path (create)."
88 echo -ne 'MOVE a\tc c\tf' | pwmc $PWMC_ARGS -S move
89 echo -ne 'LIST --recurse' | pwmc $PWMC_ARGS move > result
90 cmp move.result10 result
91 rm -f result
93 test_success