aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xtools/testing/selftests/efivarfs/efivarfs.sh32
1 files changed, 13 insertions, 19 deletions
diff --git a/tools/testing/selftests/efivarfs/efivarfs.sh b/tools/testing/selftests/efivarfs/efivarfs.sh
index d3866100e884..a90f394f9aa9 100755
--- a/tools/testing/selftests/efivarfs/efivarfs.sh
+++ b/tools/testing/selftests/efivarfs/efivarfs.sh
@@ -7,6 +7,12 @@ test_guid=210be57c-9849-4fc7-a635-e6382d1aec27
7# Kselftest framework requirement - SKIP code is 4. 7# Kselftest framework requirement - SKIP code is 4.
8ksft_skip=4 8ksft_skip=4
9 9
10file_cleanup()
11{
12 chattr -i $1
13 rm -f $1
14}
15
10check_prereqs() 16check_prereqs()
11{ 17{
12 local msg="skip all tests:" 18 local msg="skip all tests:"
@@ -58,8 +64,10 @@ test_create()
58 64
59 if [ $(stat -c %s $file) -ne 5 ]; then 65 if [ $(stat -c %s $file) -ne 5 ]; then
60 echo "$file has invalid size" >&2 66 echo "$file has invalid size" >&2
67 file_cleanup $file
61 exit 1 68 exit 1
62 fi 69 fi
70 file_cleanup $file
63} 71}
64 72
65test_create_empty() 73test_create_empty()
@@ -72,16 +80,14 @@ test_create_empty()
72 echo "$file can not be created without writing" >&2 80 echo "$file can not be created without writing" >&2
73 exit 1 81 exit 1
74 fi 82 fi
83 file_cleanup $file
75} 84}
76 85
77test_create_read() 86test_create_read()
78{ 87{
79 local file=$efivarfs_mount/$FUNCNAME-$test_guid 88 local file=$efivarfs_mount/$FUNCNAME-$test_guid
80 if [ -f $file]; then
81 chattr -i $file
82 rm -rf $file
83 fi
84 ./create-read $file 89 ./create-read $file
90 file_cleanup $file
85} 91}
86 92
87test_delete() 93test_delete()
@@ -96,11 +102,7 @@ test_delete()
96 exit 1 102 exit 1
97 fi 103 fi
98 104
99 rm $file 2>/dev/null 105 file_cleanup $file
100 if [ $? -ne 0 ]; then
101 chattr -i $file
102 rm $file
103 fi
104 106
105 if [ -e $file ]; then 107 if [ -e $file ]; then
106 echo "$file couldn't be deleted" >&2 108 echo "$file couldn't be deleted" >&2
@@ -154,11 +156,7 @@ test_valid_filenames()
154 echo "$file could not be created" >&2 156 echo "$file could not be created" >&2
155 ret=1 157 ret=1
156 else 158 else
157 rm $file 2>/dev/null 159 file_cleanup $file
158 if [ $? -ne 0 ]; then
159 chattr -i $file
160 rm $file
161 fi
162 fi 160 fi
163 done 161 done
164 162
@@ -191,11 +189,7 @@ test_invalid_filenames()
191 189
192 if [ -e $file ]; then 190 if [ -e $file ]; then
193 echo "Creating $file should have failed" >&2 191 echo "Creating $file should have failed" >&2
194 rm $file 2>/dev/null 192 file_cleanup $file
195 if [ $? -ne 0 ]; then
196 chattr -i $file
197 rm $file
198 fi
199 ret=1 193 ret=1
200 fi 194 fi
201 done 195 done