[v3,2/2] efi_selftest: fix variables test for GetNextVariableName()

Message ID 20190121114314.15741-3-xypron.glpk@gmx.de
State New
Headers show
Series
  • [v3,1/2] efi_loader: implement GetNextVariableName()
Related show

Commit Message

Heinrich Schuchardt Jan. 21, 2019, 11:43 a.m.
From: AKASHI Takahiro <takahiro.akashi@linaro.org>

There is a bug in efi variables test.
Fix it with some cosmetic improvements.

Please note that efi variables test still fails at QueryVariableInfo()
and GetVariable(), but this is not due to a change in this patch.
  ==8<==
  Testing EFI API implementation

  Selected test: 'variables'

  Setting up 'variables'
  Setting up 'variables' succeeded

  Executing 'variables'
  .../u-boot/lib/efi_selftest/efi_selftest_variables.c(60):
  TODO: QueryVariableInfo failed
  .../u-boot/lib/efi_selftest/efi_selftest_variables.c(131):
  TODO: GetVariable returned wrong length 7
  .../u-boot/lib/efi_selftest/efi_selftest_variables.c(133):
  TODO: GetVariable returned wrong value
  Executing 'variables' succeeded

  Boot services terminated

  Summary: 0 failures
  ==>8==

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
v3
	no change
v2
	no change
---
 lib/efi_selftest/efi_selftest_variables.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

Comments

Alexander Graf Jan. 22, 2019, 9:24 a.m. | #1
On 21.01.19 12:43, Heinrich Schuchardt wrote:
> From: AKASHI Takahiro <takahiro.akashi@linaro.org>
> 
> There is a bug in efi variables test.
> Fix it with some cosmetic improvements.
> 
> Please note that efi variables test still fails at QueryVariableInfo()
> and GetVariable(), but this is not due to a change in this patch.
>   ==8<==
>   Testing EFI API implementation
> 
>   Selected test: 'variables'
> 
>   Setting up 'variables'
>   Setting up 'variables' succeeded
> 
>   Executing 'variables'
>   .../u-boot/lib/efi_selftest/efi_selftest_variables.c(60):
>   TODO: QueryVariableInfo failed
>   .../u-boot/lib/efi_selftest/efi_selftest_variables.c(131):
>   TODO: GetVariable returned wrong length 7
>   .../u-boot/lib/efi_selftest/efi_selftest_variables.c(133):
>   TODO: GetVariable returned wrong value
>   Executing 'variables' succeeded
> 
>   Boot services terminated
> 
>   Summary: 0 failures
>   ==>8==
> 
> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

This fails in Travis for me on the qemu-x86_64 target:

/home/travis/build/agraf/u-boot/lib/efi_selftest/efi_selftest_variables.c(145):
ERROR: GetNextVariableName failed (2)
/home/travis/build/agraf/u-boot/lib/efi_selftest/efi_selftest.c(110):
ERROR: Executing 'variables' failed


Alex

Patch

diff --git a/lib/efi_selftest/efi_selftest_variables.c b/lib/efi_selftest/efi_selftest_variables.c
index ffc8cad329..47a8e7fb95 100644
--- a/lib/efi_selftest/efi_selftest_variables.c
+++ b/lib/efi_selftest/efi_selftest_variables.c
@@ -141,19 +141,22 @@  static int execute(void)
 		if (ret == EFI_NOT_FOUND)
 			break;
 		if (ret != EFI_SUCCESS) {
-			efi_st_todo("GetNextVariableName failed\n");
-			break;
+			efi_st_error("GetNextVariableName failed (%u)\n",
+				     (unsigned int)ret);
+			return EFI_ST_FAILURE;
 		}
 		if (!efi_st_memcmp(&guid, &guid_vendor0, sizeof(efi_guid_t)) &&
 		    !efi_st_strcmp_16_8(varname, "efi_st_var0"))
-			flag |= 2;
+			flag |= 1;
 		if (!efi_st_memcmp(&guid, &guid_vendor1, sizeof(efi_guid_t)) &&
 		    !efi_st_strcmp_16_8(varname, "efi_st_var1"))
 			flag |= 2;
 	}
-	if (flag != 3)
-		efi_st_todo(
+	if (flag != 3) {
+		efi_st_error(
 			"GetNextVariableName did not return all variables\n");
+		return EFI_ST_FAILURE;
+	}
 	/* Delete variable 1 */
 	ret = runtime->set_variable(L"efi_st_var1", &guid_vendor1,
 				    0, 0, NULL);