[PATCH] selftests/efivarfs: clean up test files from test_create*()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Test files created by test_create*() tests will stay in the $efivarfs_mount
directory until next reboot.

When the tester tries to run this efivarfs test again on the same system, the
immutable characteristics in that directory with those previously generated
files will cause some "Permission denied" noises and a false-positive test
result to the test_create_read() test.

Remove those test files in the end of each test to solve this issue.

Link: https://bugs.launchpad.net/bugs/1809704

Signed-off-by: Po-Hsu Lin <po-hsu.lin@xxxxxxxxxxxxx>
---
 tools/testing/selftests/efivarfs/efivarfs.sh | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/tools/testing/selftests/efivarfs/efivarfs.sh b/tools/testing/selftests/efivarfs/efivarfs.sh
index a47029a..ea2e2a0 100755
--- a/tools/testing/selftests/efivarfs/efivarfs.sh
+++ b/tools/testing/selftests/efivarfs/efivarfs.sh
@@ -60,6 +60,12 @@ test_create()
 		echo "$file has invalid size" >&2
 		exit 1
 	fi
+
+        rm $file 2>/dev/null
+        if [ $? -ne 0 ]; then
+                chattr -i $file
+                rm $file
+        fi
 }
 
 test_create_empty()
@@ -72,12 +78,24 @@ test_create_empty()
 		echo "$file can not be created without writing" >&2
 		exit 1
 	fi
+
+        rm $file 2>/dev/null
+        if [ $? -ne 0 ]; then
+                chattr -i $file
+                rm $file
+        fi
 }
 
 test_create_read()
 {
 	local file=$efivarfs_mount/$FUNCNAME-$test_guid
 	./create-read $file
+
+        rm $file 2>/dev/null
+        if [ $? -ne 0 ]; then
+                chattr -i $file
+                rm $file
+        fi
 }
 
 test_delete()
-- 
2.7.4




[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux