Re: [PATCH] selftests: Add tests for efivarfs

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

 



On 01/18/2013 05:19 PM, Jeremy Kerr wrote:
> This change adds a few initial efivarfs tests to the
> tools/testing/selftests directory.
> 

Nice idea. I might add a few look test cases or try some fs testsuites
on efivarfs.

> +	# the open-unlink test relies on deleting the Lang variable at
> +	# present; we don't want to do this on an actual machine.

It seems open-unlink already goes to delete a custom variable.

> +	if ! grep -q 'model name.* QEMU' /proc/cpuinfo; then
> +		echo $msg efivarfs tests should only be run on a VM >&2
> +		exit 0
> +	fi

This won't allow me to test. I use qemu-kvm -cpu host, /proc/cpuinfo
doesn't have the string "QEMU".

How about grep -q OVMF /sys/firmware/acpi/tables/DSDT? Or add a prompt
if it can't be determined?

> +# test that we can remove a variable by issuing a write with only
> +# attributes specified
> +test_zero_size_delete()
> +{
> +	local attrs='\x07\x00\x00\x00'
> +	local file=$efivarfs_mount/test.3-$test_guid
> +
> +	printf "$attrs\x00" > $file
> +
> +	if [ ! -e $file ]; then
> +		echo "$file does not exist" >&2
> +		exit 1
> +	fi
> +

test_zero_size_delete can't reproduce the file lingering bug on unpatched
3.8-rc4.

A remount is required to reproduce the bug for newly created variable, here:

        umount $efivarfs_mount
        mount -t efivarfs - $efivarfs_mount

If a variable exists at boot time, then no remount is required. This is why
I choosed RTC-$GUID. With this remount, I can verify the bug is fixed by
efivarfs: Delete dentry from dcache in efivarfs_file_write().

> +	/* create a test variable */
> +	fd = open(path, O_WRONLY | O_CREAT);
> +	if (fd < 0) {
> +		perror("open(O_WRONLY)");
> +		return EXIT_FAILURE;
> +	}
> +
> +	rc = write(fd, buf, sizeof(buf));
> +	if (rc != sizeof(buf)) {
> +		perror("write");
> +		return EXIT_FAILURE;
> +	}
> +
> +	close(fd);
> +

Likewise, we might want to test this with remount after file creation.

> +	fd = open(path, O_RDONLY);
> +	if (fd < 0) {
> +		perror("open");
> +		return EXIT_FAILURE;
> +	}

--
Lingzhu Xiang
--
To unsubscribe from this list: send the line "unsubscribe linux-efi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux