forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/tools/testing/selftests/efivarfs/efivarfs.sh
....@@ -7,6 +7,12 @@
77 # Kselftest framework requirement - SKIP code is 4.
88 ksft_skip=4
99
10
+file_cleanup()
11
+{
12
+ chattr -i $1
13
+ rm -f $1
14
+}
15
+
1016 check_prereqs()
1117 {
1218 local msg="skip all tests:"
....@@ -58,8 +64,10 @@
5864
5965 if [ $(stat -c %s $file) -ne 5 ]; then
6066 echo "$file has invalid size" >&2
67
+ file_cleanup $file
6168 exit 1
6269 fi
70
+ file_cleanup $file
6371 }
6472
6573 test_create_empty()
....@@ -72,12 +80,14 @@
7280 echo "$file can not be created without writing" >&2
7381 exit 1
7482 fi
83
+ file_cleanup $file
7584 }
7685
7786 test_create_read()
7887 {
7988 local file=$efivarfs_mount/$FUNCNAME-$test_guid
8089 ./create-read $file
90
+ file_cleanup $file
8191 }
8292
8393 test_delete()
....@@ -92,11 +102,7 @@
92102 exit 1
93103 fi
94104
95
- rm $file 2>/dev/null
96
- if [ $? -ne 0 ]; then
97
- chattr -i $file
98
- rm $file
99
- fi
105
+ file_cleanup $file
100106
101107 if [ -e $file ]; then
102108 echo "$file couldn't be deleted" >&2
....@@ -150,11 +156,7 @@
150156 echo "$file could not be created" >&2
151157 ret=1
152158 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
158160 fi
159161 done
160162
....@@ -187,11 +189,7 @@
187189
188190 if [ -e $file ]; then
189191 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
195193 ret=1
196194 fi
197195 done