diff mbox

[08/15,RESEND] uefirtauthvar: delete authenticated variable test

Message ID 1414146766-9939-1-git-send-email-ivan.hu@canonical.com
State Accepted
Headers show

Commit Message

Ivan Hu Oct. 24, 2014, 10:32 a.m. UTC
This test deletes the test authenticated variable and checks if it still exists.

Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
Acked-by: Colin Ian King <colin.king@canonical.com>
---
 src/uefi/uefirtauthvar/uefirtauthvar.c |   53 ++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)

Comments

Colin Ian King Oct. 24, 2014, 1:58 p.m. UTC | #1
On 24/10/14 11:32, Ivan Hu wrote:
> This test deletes the test authenticated variable and checks if it still exists.
> 
> Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
> Acked-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/uefi/uefirtauthvar/uefirtauthvar.c |   53 ++++++++++++++++++++++++++++++++
>  1 file changed, 53 insertions(+)
> 
> diff --git a/src/uefi/uefirtauthvar/uefirtauthvar.c b/src/uefi/uefirtauthvar/uefirtauthvar.c
> index d41d617..ed851cf 100644
> --- a/src/uefi/uefirtauthvar/uefirtauthvar.c
> +++ b/src/uefi/uefirtauthvar/uefirtauthvar.c
> @@ -464,6 +464,58 @@ static int uefirtauthvar_test6(fwts_framework *fw)
>  	return FWTS_ERROR;
>  }
>  
> +/*
> + * Delete the test authenticated variable.
> + */
> +static int uefirtauthvar_test7(fwts_framework *fw)
> +{
> +	long ioret;
> +	int supcheck;
> +
> +	uint8_t data[getvar_buf_size];
> +	uint64_t getdatasize = sizeof(data);
> +	uint64_t status;
> +	uint32_t attributestest;
> +
> +	ioret = setvar(&gtestguid, attributes, sizeof(AuthVarDel), AuthVarDel, &status);
> +
> +	if (ioret == -1) {
> +		supcheck = check_fw_support(fw, status);
> +		if (supcheck != FWTS_OK)
> +			return supcheck;
> +
> +		fwts_failed(fw, LOG_LEVEL_HIGH,
> +			"UEFIDelAuthVar",
> +			"Failed to delete authenticated variable with UEFI "
> +			"runtime service.");
> +		fwts_uefi_print_status_info(fw, status);
> +		return FWTS_ERROR;
> +	}
> +
> +	ioret = getvar(&gtestguid, &attributestest, &getdatasize, data, &status);
> +	if (ioret == -1) {
> +		if (status == EFI_NOT_FOUND) {
> +			fwts_passed(fw, "Delete authenticated variable tests passed.");
> +			return FWTS_OK;
> +		}
> +
> +		fwts_failed(fw, LOG_LEVEL_MEDIUM,
> +			"UEFIDelAuthVar",
> +			"Failed to get authenticated variable with UEFI "
> +			"runtime service.");
> +		fwts_uefi_print_status_info(fw, status);
> +		return FWTS_ERROR;
> +	}
> +
> +	fwts_failed(fw, LOG_LEVEL_HIGH,
> +		"UEFIDelAuthVar",
> +		"Failed to delete authenticated variable still get the test"
> +		"authenticated variable.");
> +
> +	return FWTS_ERROR;
> +}
> +
> +
>  static fwts_framework_minor_test uefirtauthvar_tests[] = {
>  	{ uefirtauthvar_test1, "Create authenticated variable test." },
>  	{ uefirtauthvar_test2, "Authenticated variable test with the same authenticated variable." },
> @@ -471,6 +523,7 @@ static fwts_framework_minor_test uefirtauthvar_tests[] = {
>  	{ uefirtauthvar_test4, "Append authenticated variable test." },
>  	{ uefirtauthvar_test5, "Update authenticated variable test." },
>  	{ uefirtauthvar_test6, "Authenticated variable test with old authenticated variable." },
> +	{ uefirtauthvar_test7, "Delete authenticated variable test." },
>  	{ NULL, NULL }
>  };
>  
> 
Acked-by: Colin Ian King <colin.king@canonical.com>
Alex Hung Oct. 29, 2014, 3:10 a.m. UTC | #2
On 14-10-24 06:32 PM, Ivan Hu wrote:
> This test deletes the test authenticated variable and checks if it still exists.
>
> Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
> Acked-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/uefi/uefirtauthvar/uefirtauthvar.c |   53 ++++++++++++++++++++++++++++++++
>   1 file changed, 53 insertions(+)
>
> diff --git a/src/uefi/uefirtauthvar/uefirtauthvar.c b/src/uefi/uefirtauthvar/uefirtauthvar.c
> index d41d617..ed851cf 100644
> --- a/src/uefi/uefirtauthvar/uefirtauthvar.c
> +++ b/src/uefi/uefirtauthvar/uefirtauthvar.c
> @@ -464,6 +464,58 @@ static int uefirtauthvar_test6(fwts_framework *fw)
>   	return FWTS_ERROR;
>   }
>   
> +/*
> + * Delete the test authenticated variable.
> + */
> +static int uefirtauthvar_test7(fwts_framework *fw)
> +{
> +	long ioret;
> +	int supcheck;
> +
> +	uint8_t data[getvar_buf_size];
> +	uint64_t getdatasize = sizeof(data);
> +	uint64_t status;
> +	uint32_t attributestest;
> +
> +	ioret = setvar(&gtestguid, attributes, sizeof(AuthVarDel), AuthVarDel, &status);
> +
> +	if (ioret == -1) {
> +		supcheck = check_fw_support(fw, status);
> +		if (supcheck != FWTS_OK)
> +			return supcheck;
> +
> +		fwts_failed(fw, LOG_LEVEL_HIGH,
> +			"UEFIDelAuthVar",
> +			"Failed to delete authenticated variable with UEFI "
> +			"runtime service.");
> +		fwts_uefi_print_status_info(fw, status);
> +		return FWTS_ERROR;
> +	}
> +
> +	ioret = getvar(&gtestguid, &attributestest, &getdatasize, data, &status);
> +	if (ioret == -1) {
> +		if (status == EFI_NOT_FOUND) {
> +			fwts_passed(fw, "Delete authenticated variable tests passed.");
> +			return FWTS_OK;
> +		}
> +
> +		fwts_failed(fw, LOG_LEVEL_MEDIUM,
> +			"UEFIDelAuthVar",
> +			"Failed to get authenticated variable with UEFI "
> +			"runtime service.");
> +		fwts_uefi_print_status_info(fw, status);
> +		return FWTS_ERROR;
> +	}
> +
> +	fwts_failed(fw, LOG_LEVEL_HIGH,
> +		"UEFIDelAuthVar",
> +		"Failed to delete authenticated variable still get the test"
> +		"authenticated variable.");
> +
> +	return FWTS_ERROR;
> +}
> +
> +
>   static fwts_framework_minor_test uefirtauthvar_tests[] = {
>   	{ uefirtauthvar_test1, "Create authenticated variable test." },
>   	{ uefirtauthvar_test2, "Authenticated variable test with the same authenticated variable." },
> @@ -471,6 +523,7 @@ static fwts_framework_minor_test uefirtauthvar_tests[] = {
>   	{ uefirtauthvar_test4, "Append authenticated variable test." },
>   	{ uefirtauthvar_test5, "Update authenticated variable test." },
>   	{ uefirtauthvar_test6, "Authenticated variable test with old authenticated variable." },
> +	{ uefirtauthvar_test7, "Delete authenticated variable test." },
>   	{ NULL, NULL }
>   };
>   
Acked-by: Alex Hung <alex.hung@canonical.com>
diff mbox

Patch

diff --git a/src/uefi/uefirtauthvar/uefirtauthvar.c b/src/uefi/uefirtauthvar/uefirtauthvar.c
index d41d617..ed851cf 100644
--- a/src/uefi/uefirtauthvar/uefirtauthvar.c
+++ b/src/uefi/uefirtauthvar/uefirtauthvar.c
@@ -464,6 +464,58 @@  static int uefirtauthvar_test6(fwts_framework *fw)
 	return FWTS_ERROR;
 }
 
+/*
+ * Delete the test authenticated variable.
+ */
+static int uefirtauthvar_test7(fwts_framework *fw)
+{
+	long ioret;
+	int supcheck;
+
+	uint8_t data[getvar_buf_size];
+	uint64_t getdatasize = sizeof(data);
+	uint64_t status;
+	uint32_t attributestest;
+
+	ioret = setvar(&gtestguid, attributes, sizeof(AuthVarDel), AuthVarDel, &status);
+
+	if (ioret == -1) {
+		supcheck = check_fw_support(fw, status);
+		if (supcheck != FWTS_OK)
+			return supcheck;
+
+		fwts_failed(fw, LOG_LEVEL_HIGH,
+			"UEFIDelAuthVar",
+			"Failed to delete authenticated variable with UEFI "
+			"runtime service.");
+		fwts_uefi_print_status_info(fw, status);
+		return FWTS_ERROR;
+	}
+
+	ioret = getvar(&gtestguid, &attributestest, &getdatasize, data, &status);
+	if (ioret == -1) {
+		if (status == EFI_NOT_FOUND) {
+			fwts_passed(fw, "Delete authenticated variable tests passed.");
+			return FWTS_OK;
+		}
+
+		fwts_failed(fw, LOG_LEVEL_MEDIUM,
+			"UEFIDelAuthVar",
+			"Failed to get authenticated variable with UEFI "
+			"runtime service.");
+		fwts_uefi_print_status_info(fw, status);
+		return FWTS_ERROR;
+	}
+
+	fwts_failed(fw, LOG_LEVEL_HIGH,
+		"UEFIDelAuthVar",
+		"Failed to delete authenticated variable still get the test"
+		"authenticated variable.");
+
+	return FWTS_ERROR;
+}
+
+
 static fwts_framework_minor_test uefirtauthvar_tests[] = {
 	{ uefirtauthvar_test1, "Create authenticated variable test." },
 	{ uefirtauthvar_test2, "Authenticated variable test with the same authenticated variable." },
@@ -471,6 +523,7 @@  static fwts_framework_minor_test uefirtauthvar_tests[] = {
 	{ uefirtauthvar_test4, "Append authenticated variable test." },
 	{ uefirtauthvar_test5, "Update authenticated variable test." },
 	{ uefirtauthvar_test6, "Authenticated variable test with old authenticated variable." },
+	{ uefirtauthvar_test7, "Delete authenticated variable test." },
 	{ NULL, NULL }
 };