3 efivarfs_mount
=/sys
/firmware
/efi
/efivars
4 test_guid
=210be57c-9849-4fc7-a635-e6382d1aec27
8 local msg
="skip all tests:"
10 if [ $UID != 0 ]; then
11 echo $msg must be run as root
>&2
15 if ! grep -q "^\S\+ $efivarfs_mount efivarfs" /proc
/mounts
; then
16 echo $msg efivarfs is not mounted on
$efivarfs_mount >&2
25 echo "--------------------"
27 echo "--------------------"
29 if [ "$(type -t $test)" = 'function' ]; then
45 local attrs
='\x07\x00\x00\x00'
46 local file=$efivarfs_mount/$FUNCNAME-$test_guid
48 printf "$attrs\x00" > $file
50 if [ ! -e $file ]; then
51 echo "$file couldn't be created" >&2
55 if [ $
(stat
-c %s
$file) -ne 5 ]; then
56 echo "$file has invalid size" >&2
63 local file=$efivarfs_mount/$FUNCNAME-$test_guid
67 if [ ! -e $file ]; then
68 echo "$file can not be created without writing" >&2
75 local file=$efivarfs_mount/$FUNCNAME-$test_guid
81 local attrs
='\x07\x00\x00\x00'
82 local file=$efivarfs_mount/$FUNCNAME-$test_guid
84 printf "$attrs\x00" > $file
86 if [ ! -e $file ]; then
87 echo "$file couldn't be created" >&2
98 echo "$file couldn't be deleted" >&2
104 # test that we can remove a variable by issuing a write with only
105 # attributes specified
106 test_zero_size_delete
()
108 local attrs
='\x07\x00\x00\x00'
109 local file=$efivarfs_mount/$FUNCNAME-$test_guid
111 printf "$attrs\x00" > $file
113 if [ ! -e $file ]; then
114 echo "$file does not exist" >&2
119 printf "$attrs" > $file
121 if [ -e $file ]; then
122 echo "$file should have been deleted" >&2
129 local file=$efivarfs_mount/$FUNCNAME-$test_guid
133 # test that we can create a range of filenames
134 test_valid_filenames
()
136 local attrs
='\x07\x00\x00\x00'
139 local file_list
="abc dump-type0-11-1-1362436005 1234 -"
140 for f
in $file_list; do
141 local file=$efivarfs_mount/$f-$test_guid
143 printf "$attrs\x00" > $file
145 if [ ! -e $file ]; then
146 echo "$file could not be created" >&2
150 if [ $?
-ne 0 ]; then
160 test_invalid_filenames
()
162 local attrs
='\x07\x00\x00\x00'
166 -1234-1234-1234-123456789abc
170 foo-barbazba-foob-foob-foob-foobarbazfoo
171 foo-------------------------------------
172 -12345678-1234-1234-1234-123456789abc
173 a-12345678=1234-1234-1234-123456789abc
174 a-12345678-1234=1234-1234-123456789abc
175 a-12345678-1234-1234=1234-123456789abc
176 a-12345678-1234-1234-1234=123456789abc
177 1112345678-1234-1234-1234-123456789abc"
179 for f
in $file_list; do
180 local file=$efivarfs_mount/$f
182 printf "$attrs\x00" 2>/dev
/null
> $file
184 if [ -e $file ]; then
185 echo "Creating $file should have failed" >&2
187 if [ $?
-ne 0 ]; then
203 run_test test_create_empty
204 run_test test_create_read
206 run_test test_zero_size_delete
207 run_test test_open_unlink
208 run_test test_valid_filenames
209 run_test test_invalid_filenames