| .. | .. |
|---|
| 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 | + if [ $? -ne 0 ]; then |
|---|
| 91 | + echo "create and read $file failed" |
|---|
| 92 | + file_cleanup $file |
|---|
| 93 | + exit 1 |
|---|
| 94 | + fi |
|---|
| 95 | + file_cleanup $file |
|---|
| 81 | 96 | } |
|---|
| 82 | 97 | |
|---|
| 83 | 98 | test_delete() |
|---|
| .. | .. |
|---|
| 92 | 107 | exit 1 |
|---|
| 93 | 108 | fi |
|---|
| 94 | 109 | |
|---|
| 95 | | - rm $file 2>/dev/null |
|---|
| 96 | | - if [ $? -ne 0 ]; then |
|---|
| 97 | | - chattr -i $file |
|---|
| 98 | | - rm $file |
|---|
| 99 | | - fi |
|---|
| 110 | + file_cleanup $file |
|---|
| 100 | 111 | |
|---|
| 101 | 112 | if [ -e $file ]; then |
|---|
| 102 | 113 | echo "$file couldn't be deleted" >&2 |
|---|
| .. | .. |
|---|
| 150 | 161 | echo "$file could not be created" >&2 |
|---|
| 151 | 162 | ret=1 |
|---|
| 152 | 163 | else |
|---|
| 153 | | - rm $file 2>/dev/null |
|---|
| 154 | | - if [ $? -ne 0 ]; then |
|---|
| 155 | | - chattr -i $file |
|---|
| 156 | | - rm $file |
|---|
| 157 | | - fi |
|---|
| 164 | + file_cleanup $file |
|---|
| 158 | 165 | fi |
|---|
| 159 | 166 | done |
|---|
| 160 | 167 | |
|---|
| .. | .. |
|---|
| 187 | 194 | |
|---|
| 188 | 195 | if [ -e $file ]; then |
|---|
| 189 | 196 | 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 |
|---|
| 197 | + file_cleanup $file |
|---|
| 195 | 198 | ret=1 |
|---|
| 196 | 199 | fi |
|---|
| 197 | 200 | done |
|---|