Fix build.
[libpwmd.git] / tests / copy.test
blobb282d259df71deed2062210b566fdd45c7d0e19e
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 [copy]
12 passphrase_file=`pwd`/passphrase.key
13 EOF
15 set -e
16 mv -f data/list data/copy
17 launch_pwmd copy
19 begin_test
20 echo "Test 1. Copy element to self (fail)."
21 set +o errexit
22 echo -ne 'COPY a a' | pwmc $PWMC_ARGS -S copy
23 if [ ${PIPESTATUS[1]} == 0 ]; then
24 echo "The previous command should have failed. Stopping."
25 exit 1
28 set -e
30 echo
31 echo "Test 2. Copy element to new root."
32 echo -ne 'COPY a new' | pwmc $PWMC_ARGS -S copy
33 echo -ne 'LIST --recurse' | pwmc $PWMC_ARGS copy > result
34 cmp copy.result2 result
35 rm -f result
37 echo
38 echo "Test 3. Copy element to new child."
39 echo -ne 'COPY new a\tnew' | pwmc $PWMC_ARGS -S copy
40 echo -ne 'LIST --recurse' | pwmc $PWMC_ARGS copy > result
41 cmp copy.result3 result
42 rm -f result
44 echo
45 echo "Test 4. Copy element to root and overwrite."
46 echo -ne 'COPY new a' | pwmc $PWMC_ARGS -S copy
47 echo -ne 'LIST --recurse' | pwmc $PWMC_ARGS copy > result
48 cmp copy.result4 result
49 rm -f result
51 echo
52 echo "Test 5. Copy element to child and overwrite."
53 echo -ne 'COPY new a\tb' | pwmc $PWMC_ARGS -S copy
54 echo -ne 'LIST --recurse' | pwmc $PWMC_ARGS copy > result
55 cmp copy.result5 result
56 rm -f result
58 echo
59 echo "Test 6. Copy element to target."
60 echo -ne 'COPY new b' | pwmc $PWMC_ARGS -S copy
61 echo -ne 'LIST --recurse' | pwmc $PWMC_ARGS copy > result
62 cmp copy.result6 result
63 rm -f result
65 test_success