[PATCH 2/3] uefirtvariable: add checking the EFI_UNSUPPORTED return code
Ivan Hu
ivan.hu at canonical.com
Tue Jun 11 10:18:56 UTC 2019
The UEFI spec 2.8(Matis 1961) adds EFI_UNSUPPORTED as a return code to most
UEFI runtime services for those embeded devices such as specified by the
ARM EBBR specification which are impractical or impossible to implement
in such a way that they can be used at runtime.
Add checking the EFI_UNSUPPORTED return code and skip the test for those
unsupported runtime services.
Signed-off-by: Ivan Hu <ivan.hu at canonical.com>
---
src/uefi/uefirtvariable/uefirtvariable.c | 86 ++++++++++++++++++++++++++++++--
1 file changed, 83 insertions(+), 3 deletions(-)
diff --git a/src/uefi/uefirtvariable/uefirtvariable.c b/src/uefi/uefirtvariable/uefirtvariable.c
index 6aa44d3..9dffcab 100644
--- a/src/uefi/uefirtvariable/uefirtvariable.c
+++ b/src/uefi/uefirtvariable/uefirtvariable.c
@@ -156,6 +156,11 @@ static int getvariable_test(
ioret = ioctl(fd, EFI_RUNTIME_SET_VARIABLE, &setvariable);
if (ioret == -1) {
+ if (status == EFI_UNSUPPORTED) {
+ fwts_skipped(fw, "Skipping test, SetVariable runtime "
+ "service is not supported on this platform.");
+ return FWTS_SKIP;
+ }
if (status == EFI_OUT_OF_RESOURCES) {
fwts_uefi_print_status_info(fw, status);
fwts_skipped(fw,
@@ -231,6 +236,11 @@ static int getvariable_test(
ioret = ioctl(fd, EFI_RUNTIME_SET_VARIABLE, &setvariable);
if (ioret == -1) {
+ if (status == EFI_UNSUPPORTED) {
+ fwts_skipped(fw, "Skipping test, SetVariable runtime "
+ "service is not supported on this platform.");
+ return FWTS_SKIP;
+ }
fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeSetVariable",
"Failed to delete variable with UEFI runtime service.");
fwts_uefi_print_status_info(fw, status);
@@ -247,6 +257,11 @@ err_restore_env:
ioret = ioctl(fd, EFI_RUNTIME_SET_VARIABLE, &setvariable);
if (ioret == -1) {
+ if (status == EFI_UNSUPPORTED) {
+ fwts_skipped(fw, "Skipping test, SetVariable runtime "
+ "service is not supported on this platform.");
+ return FWTS_SKIP;
+ }
fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeSetVariable",
"Failed to delete variable with UEFI runtime service.");
fwts_uefi_print_status_info(fw, status);
@@ -323,6 +338,11 @@ static int getnextvariable_test1(fwts_framework *fw)
ioret = ioctl(fd, EFI_RUNTIME_SET_VARIABLE, &setvariable);
if (ioret == -1) {
+ if (status == EFI_UNSUPPORTED) {
+ fwts_skipped(fw, "Skipping test, SetVariable runtime "
+ "service is not supported on this platform.");
+ return FWTS_SKIP;
+ }
if (status == EFI_OUT_OF_RESOURCES) {
fwts_uefi_print_status_info(fw, status);
fwts_skipped(fw,
@@ -362,7 +382,11 @@ static int getnextvariable_test1(fwts_framework *fw)
ioret = ioctl(fd, EFI_RUNTIME_GET_NEXTVARIABLENAME, &getnextvariablename);
if (ioret == -1) {
-
+ if (status == EFI_UNSUPPORTED) {
+ fwts_skipped(fw, "Skipping test, GetNextVariable runtime "
+ "service is not supported on this platform.");
+ return FWTS_SKIP;
+ }
/* no next variable was found*/
if (*getnextvariablename.status == EFI_NOT_FOUND)
break;
@@ -429,6 +453,11 @@ static int getnextvariable_test1(fwts_framework *fw)
ioret = ioctl(fd, EFI_RUNTIME_SET_VARIABLE, &setvariable);
if (ioret == -1) {
+ if (status == EFI_UNSUPPORTED) {
+ fwts_skipped(fw, "Skipping test, SetVariable runtime "
+ "service is not supported on this platform.");
+ return FWTS_SKIP;
+ }
fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeSetVariable",
"Failed to delete variable with UEFI runtime service.");
fwts_uefi_print_status_info(fw, status);
@@ -445,6 +474,11 @@ err_restore_env:
ioret = ioctl(fd, EFI_RUNTIME_SET_VARIABLE, &setvariable);
if (ioret == -1) {
+ if (status == EFI_UNSUPPORTED) {
+ fwts_skipped(fw, "Skipping test, SetVariable runtime "
+ "service is not supported on this platform.");
+ return FWTS_SKIP;
+ }
fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeSetVariable",
"Failed to delete variable with UEFI runtime service.");
fwts_uefi_print_status_info(fw, status);
@@ -512,7 +546,11 @@ static int getnextvariable_test2(fwts_framework *fw)
ioret = ioctl(fd, EFI_RUNTIME_GET_NEXTVARIABLENAME, &getnextvariablename);
if (ioret == -1) {
-
+ if (status == EFI_UNSUPPORTED) {
+ fwts_skipped(fw, "Skipping test, SetVariable runtime "
+ "service is not supported on this platform.");
+ return FWTS_SKIP;
+ }
/* no next variable was found*/
if (*getnextvariablename.status == EFI_NOT_FOUND)
break;
@@ -673,7 +711,11 @@ static int getnextvariable_test3(fwts_framework *fw)
ioret = ioctl(fd, EFI_RUNTIME_GET_NEXTVARIABLENAME, &getnextvariablename);
if (ioret == -1) {
-
+ if (status == EFI_UNSUPPORTED) {
+ fwts_skipped(fw, "Skipping test, SetVariable runtime "
+ "service is not supported on this platform.");
+ return FWTS_SKIP;
+ }
/* no next variable was found*/
if (*getnextvariablename.status == EFI_NOT_FOUND)
break;
@@ -789,6 +831,12 @@ static int getnextvariable_test4(fwts_framework *fw)
ioret = ioctl(fd, EFI_RUNTIME_GET_NEXTVARIABLENAME, &getnextvariablename);
+ if (status == EFI_UNSUPPORTED) {
+ fwts_skipped(fw, "Skipping test, GetNextVaiable runtime "
+ "service is not supported on this platform.");
+ return FWTS_SKIP;
+ }
+
if (ioret != -1 || status != EFI_INVALID_PARAMETER) {
fwts_failed(fw, LOG_LEVEL_HIGH,
"UEFIRuntimeGetNextVariableName",
@@ -898,6 +946,12 @@ static int setvariable_insertvariable(
setvariable.status = &status;
ioret = ioctl(fd, EFI_RUNTIME_SET_VARIABLE, &setvariable);
+ if (status == EFI_UNSUPPORTED) {
+ fwts_skipped(fw, "Skipping test, SetVariable runtime "
+ "service is not supported on this platform.");
+ return FWTS_SKIP;
+ }
+
if (ioret == -1) {
if ((status == EFI_INVALID_PARAMETER) &&
((attributes & FWTS_UEFI_VARIABLE_ENHANCED_AUTHENTICATED_ACCESS) ||
@@ -966,6 +1020,11 @@ static int setvariable_checkvariable(
ioret = ioctl(fd, EFI_RUNTIME_GET_VARIABLE, &getvariable);
if (ioret == -1) {
+ if (status == EFI_UNSUPPORTED) {
+ fwts_skipped(fw, "Skipping test, GetVariable runtime "
+ "service is not supported on this platform.");
+ return FWTS_SKIP;
+ }
fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeGetVariable",
"Failed to get variable with UEFI runtime service.");
fwts_uefi_print_status_info(fw, status);
@@ -1021,6 +1080,11 @@ static int setvariable_checkvariable_notfound(
ioret = ioctl(fd, EFI_RUNTIME_GET_VARIABLE, &getvariable);
+ if (status == EFI_UNSUPPORTED) {
+ fwts_skipped(fw, "Skipping test, GetVariable runtime "
+ "service is not supported on this platform.");
+ return FWTS_SKIP;
+ }
/* expect the uefi runtime interface return EFI_NOT_FOUND */
if (ioret == -1) {
if (*getvariable.status == EFI_NOT_FOUND)
@@ -1059,6 +1123,12 @@ static int setvariable_invalidattr(
ioret = ioctl(fd, EFI_RUNTIME_SET_VARIABLE, &setvariable);
+ if (status == EFI_UNSUPPORTED) {
+ fwts_skipped(fw, "Skipping test, SetVariable runtime "
+ "service is not supported on this platform.");
+ return FWTS_SKIP;
+ }
+
if ((status == EFI_SUCCESS) && (ioret != -1)) {
if ((attributes & FWTS_UEFI_VARIABLE_ENHANCED_AUTHENTICATED_ACCESS) &&
(attributes & FWTS_UEFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) &&
@@ -1838,6 +1908,11 @@ static void getvariable_test_invalid(
*(getvariable->status) = ~0ULL;
ioret = ioctl(fd, EFI_RUNTIME_GET_VARIABLE, getvariable);
+ if (*(getvariable->status) == EFI_UNSUPPORTED) {
+ fwts_skipped(fw, "Skipping test, GetVariable runtime "
+ "service is not supported on this platform.");
+ return;
+ }
if (ioret == -1) {
if (*(getvariable->status) == EFI_INVALID_PARAMETER) {
fwts_passed(fw, "GetVariable with %s returned error "
@@ -1882,6 +1957,11 @@ static int uefirtvariable_test8(fwts_framework *fw)
setvariable.status = &status;
ioret = ioctl(fd, EFI_RUNTIME_SET_VARIABLE, &setvariable);
+ if (status == EFI_UNSUPPORTED) {
+ fwts_skipped(fw, "Skipping test, SetVariable runtime "
+ "service is not supported on this platform.");
+ return FWTS_OK;
+ }
if (ioret == -1) {
if (status == EFI_OUT_OF_RESOURCES) {
fwts_uefi_print_status_info(fw, status);
--
2.7.4
More information about the fwts-devel
mailing list