forked from ElektraInitiative/libelektra
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_error.sh
More file actions
executable file
·126 lines (98 loc) · 3.65 KB
/
check_error.sh
File metadata and controls
executable file
·126 lines (98 loc) · 3.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/sh
@INCLUDE_COMMON@
echo
echo ELEKTRA CHECK ERROR
echo
check_version
FILE_SUFFIX=test_error
check_remaining_files $FILE_SUFFIX
ROOT=user:/test/script
ROOT_FILE=${FILE_SUFFIX}_root.ecf
ROOT_MOUNTPOINT=/test/script
if ! is_plugin_available dump || ! is_plugin_available sync; then
echo "Need dump and sync to run test, will abort"
exit 0
fi
"$KDB" mount $ROOT_FILE $ROOT_MOUNTPOINT dump > /dev/null 2>&1
succeed_if "could not mount root: $ROOT_FILE at $ROOT_MOUNTPOINT"
"$KDB" set $ROOT/valueable_data important_unrecoverable_data > /dev/null
succeed_if "cannot set valuable data"
"$KDB" meta-set $ROOT/valueable_data trigger/error "C03100"
succeed_if "cannot set metadata"
TMPFILE="$(mktempfile_elektra)"
cleanup() {
rm -f "$TMPFILE"
}
ERROR_FILE=${FILE_SUFFIX}_error.ecf
#subfolders not supported:
#USER_ERROR_FOLDER=${USER_FOLDER}/subfolder
#SYSTEM_ERROR_FOLDER=${SYSTEM_FOLDER}/subfolder
USER_ERROR_FILE=${USER_FOLDER}/${ERROR_FILE}
SYSTEM_ERROR_FILE=${SYSTEM_FOLDER}/${ERROR_FILE}
ERROR_MOUNTPOINT=/test/script/error
if is_plugin_available error; then
echo "Testing operations on erroneous backends"
"$KDB" mount $ERROR_FILE $ERROR_MOUNTPOINT dump error > /dev/null 2>&1
succeed_if "could not mount error at $ERROR_MOUNTPOINT"
"$KDB" mv $ROOT/valueable_data $ROOT/error/dump > "$TMPFILE" 2>&1
[ $? -ne 0 ]
succeed_if "Was able to move to error plugin"
CONTENT=$(cat "$TMPFILE")
grep "issued the error C03100" "$TMPFILE" > /dev/null
succeed_if "Triggered error did not occur, got $CONTENT"
grep "from error plugin" "$TMPFILE" > /dev/null
succeed_if "Error does not stem from error plugin"
[ "x$("$KDB" ls $ROOT 2> /dev/null)" = "x$ROOT/valueable_data" ]
succeed_if "cant ls $ROOT (may mean that $ROOT folder is not clean)"
[ "x$("$KDB" get $ROOT/valueable_data 2> /dev/null)" = "ximportant_unrecoverable_data" ]
succeed_if "Important data lost"
"$KDB" cp $ROOT/valueable_data $ROOT/error/dump > "$TMPFILE" 2>&1
[ $? -ne 0 ]
succeed_if "Was able to copy to error plugin"
grep "issued the error C03100" "$TMPFILE" > /dev/null
succeed_if "Triggered error did not occur, got $CONTENT"
grep "from error plugin" "$TMPFILE" > /dev/null
succeed_if "Error does not stem from error plugin, got $CONTENT"
[ "x$("$KDB" ls $ROOT 2> /dev/null)" = "x$ROOT/valueable_data" ]
succeed_if "cant ls $ROOT (may mean that $ROOT folder is not clean)"
[ "x$("$KDB" get $ROOT/valueable_data 2> /dev/null)" = "ximportant_unrecoverable_data" ]
succeed_if "data would have been lost"
"$KDB" umount $ERROR_MOUNTPOINT > /dev/null
succeed_if "could not umount $ERROR_MOUNTPOINT"
#Excluded: a bit unclear which behavior is wanted
#echo "Test error plugin when open"
#
#$KDB mount $ERROR_FILE $ERROR_MOUNTPOINT dump error on_open/error=10 > $TMPFILE 2>&1
#[ $? -ne 0 ]
#succeed_if "could mount error at $ERROR_MOUNTPOINT"
#
#CONTENT=`cat $TMPFILE`
#
#grep "[eE]rror (#C03100) occurred!" $TMPFILE > /dev/null
#succeed_if "Error not found in output, got $CONTENT"
#
#$KDB get $ERROR_MOUNTPOINT > /dev/null 2>&1
#[ $? -ne 0 ]
#succeed_if "Was able to get from missing backend"
#
#$KDB get system:$ERROR_MOUNTPOINT > $TMPFILE 2>&1
#[ $? -ne 0 ]
#succeed_if "Was able to get from missing backend"
#
#CONTENT=`cat $TMPFILE`
#
#grep "[eE]rror (#10) occurred!" $TMPFILE > /dev/null
#succeed_if "Error not found in output, got $CONTENT"
#
#
#$KDB umount $ERROR_MOUNTPOINT >/dev/null
#succeed_if "could not umount $ERROR_MOUNTPOINT"
fi
"$KDB" umount $ROOT_MOUNTPOINT > /dev/null
succeed_if "could not umount $ROOT_MOUNTPOINT"
rm -f "$TMPFILE"
rm -f "$USER_FOLDER"/$FILE_SUFFIX*
rm -f "$SYSTEM_FOLDER"/$FILE_SUFFIX*
#rmdir $USER_ERROR_FOLDER
#rmdir $SYSTEM_ERROR_FOLDER
end_script error