Revert "Add thread mutex deadlock checker script to tests/."
[pwmd.git] / tests / copy.test
blobd8d6804f923c70d2253e813f0dcc23f5f8738b0d
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`/list.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."
21 echo -ne 'COPY !a !a' | pwmc $PWMC_ARGS -S copy
22 echo -ne 'LIST --all --with-target' | pwmc $PWMC_ARGS copy > result
23 cmp copy.result1 result
24 rm -f result
26 echo
27 echo "Test 2. Copy element to new root."
28 echo -ne 'COPY !a !new' | pwmc $PWMC_ARGS -S copy
29 echo -ne 'LIST --all --with-target' | pwmc $PWMC_ARGS copy > result
30 cmp copy.result2 result
31 rm -f result
33 echo
34 echo "Test 3. Copy element to new child."
35 echo -ne 'COPY new !a\tnew' | pwmc $PWMC_ARGS -S copy
36 echo -ne 'LIST --all --with-target' | pwmc $PWMC_ARGS copy > result
37 cmp copy.result3 result
38 rm -f result
40 echo
41 echo "Test 4. Copy element to root and overwrite."
42 echo -ne 'COPY new !a' | pwmc $PWMC_ARGS -S copy
43 echo -ne 'LIST --all --with-target' | pwmc $PWMC_ARGS copy > result
44 cmp copy.result4 result
45 rm -f result
47 echo
48 echo "Test 5. Copy element to child and overwrite."
49 echo -ne 'COPY new !a\tb' | pwmc $PWMC_ARGS -S copy
50 echo -ne 'LIST --all --with-target' | pwmc $PWMC_ARGS copy > result
51 cmp copy.result5 result
52 rm -f result
54 echo
55 echo "Test 6. Copy element to target."
56 echo -ne 'COPY new b' | pwmc $PWMC_ARGS -S copy
57 echo -ne 'LIST --all --with-target' | pwmc $PWMC_ARGS copy > result
58 cmp copy.result6 result
59 rm -f result
61 test_success