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 attrs='\x07\x00\x00\x00'
76 local file=$efivarfs_mount/$FUNCNAME-$test_guid
78 printf "$attrs\x00" > $file
80 if [ ! -e $file ]; then
81 echo "$file couldn't be created" >&2
88 echo "$file couldn't be deleted" >&2
94 # test that we can remove a variable by issuing a write with only
95 # attributes specified
96 test_zero_size_delete()
98 local attrs='\x07\x00\x00\x00'
99 local file=$efivarfs_mount/$FUNCNAME-$test_guid
101 printf "$attrs\x00" > $file
103 if [ ! -e $file ]; then
104 echo "$file does not exist" >&2
108 printf "$attrs" > $file
110 if [ -e $file ]; then
111 echo "$file should have been deleted" >&2
118 local file=$efivarfs_mount/$FUNCNAME-$test_guid
127 run_test test_create_empty
129 run_test test_zero_size_delete
130 run_test test_open_unlink