.. | .. |
---|
7 | 7 | # Kselftest framework requirement - SKIP code is 4. |
---|
8 | 8 | ksft_skip=4 |
---|
9 | 9 | |
---|
| 10 | +file_cleanup() |
---|
| 11 | +{ |
---|
| 12 | + chattr -i $1 |
---|
| 13 | + rm -f $1 |
---|
| 14 | +} |
---|
| 15 | + |
---|
10 | 16 | check_prereqs() |
---|
11 | 17 | { |
---|
12 | 18 | local msg="skip all tests:" |
---|
.. | .. |
---|
58 | 64 | |
---|
59 | 65 | if [ $(stat -c %s $file) -ne 5 ]; then |
---|
60 | 66 | echo "$file has invalid size" >&2 |
---|
| 67 | + file_cleanup $file |
---|
61 | 68 | exit 1 |
---|
62 | 69 | fi |
---|
| 70 | + file_cleanup $file |
---|
63 | 71 | } |
---|
64 | 72 | |
---|
65 | 73 | test_create_empty() |
---|
.. | .. |
---|
72 | 80 | echo "$file can not be created without writing" >&2 |
---|
73 | 81 | exit 1 |
---|
74 | 82 | fi |
---|
| 83 | + file_cleanup $file |
---|
75 | 84 | } |
---|
76 | 85 | |
---|
77 | 86 | test_create_read() |
---|
78 | 87 | { |
---|
79 | 88 | local file=$efivarfs_mount/$FUNCNAME-$test_guid |
---|
80 | 89 | ./create-read $file |
---|
| 90 | + file_cleanup $file |
---|
81 | 91 | } |
---|
82 | 92 | |
---|
83 | 93 | test_delete() |
---|
.. | .. |
---|
92 | 102 | exit 1 |
---|
93 | 103 | fi |
---|
94 | 104 | |
---|
95 | | - rm $file 2>/dev/null |
---|
96 | | - if [ $? -ne 0 ]; then |
---|
97 | | - chattr -i $file |
---|
98 | | - rm $file |
---|
99 | | - fi |
---|
| 105 | + file_cleanup $file |
---|
100 | 106 | |
---|
101 | 107 | if [ -e $file ]; then |
---|
102 | 108 | echo "$file couldn't be deleted" >&2 |
---|
.. | .. |
---|
150 | 156 | echo "$file could not be created" >&2 |
---|
151 | 157 | ret=1 |
---|
152 | 158 | else |
---|
153 | | - rm $file 2>/dev/null |
---|
154 | | - if [ $? -ne 0 ]; then |
---|
155 | | - chattr -i $file |
---|
156 | | - rm $file |
---|
157 | | - fi |
---|
| 159 | + file_cleanup $file |
---|
158 | 160 | fi |
---|
159 | 161 | done |
---|
160 | 162 | |
---|
.. | .. |
---|
187 | 189 | |
---|
188 | 190 | if [ -e $file ]; then |
---|
189 | 191 | echo "Creating $file should have failed" >&2 |
---|
190 | | - rm $file 2>/dev/null |
---|
191 | | - if [ $? -ne 0 ]; then |
---|
192 | | - chattr -i $file |
---|
193 | | - rm $file |
---|
194 | | - fi |
---|
| 192 | + file_cleanup $file |
---|
195 | 193 | ret=1 |
---|
196 | 194 | fi |
---|
197 | 195 | done |
---|