TEST ESYS: Fix error handling.
* Cleanup for TPM objects added in error cases.
* Added initialization for esys handles with ESYS_TR_NONE to check
whether object was allocated before cleanup.
* Moved Handle declarations to the beginning of the file to avoid usage
of uninitialized variables in cleanup.
* Check for optional commands added to skip the test.
* Check for platform authorization added to skip the test if
authorization is not possible.
Signed-off-by: Juergen Repp <Juergen.Repp@sit.fraunhofer.de>
diff --git a/test/integration/esys-pcr-basic.int.c b/test/integration/esys-pcr-basic.int.c
index 877da6f..4721c12 100644
--- a/test/integration/esys-pcr-basic.int.c
+++ b/test/integration/esys-pcr-basic.int.c
@@ -9,6 +9,7 @@
#include "tss2_esys.h"
#include "esys_iutil.h"
+#include "test-esapi.h"
#define LOGMODULE test
#include "util/log.h"
@@ -21,6 +22,7 @@
test_invoke_esapi(ESYS_CONTEXT * esys_context)
{
TSS2_RC r;
+ int failure_return = EXIT_FAILURE;
ESYS_TR pcrHandle_handle = 16;
TPML_DIGEST_VALUES digests
@@ -116,9 +118,10 @@
&sizeNeeded,
&sizeAvailable);
- if (r == (TPM2_RC_BAD_AUTH | TPM2_RC_S | TPM2_RC_1)) {
+ if ((r & (~TPM2_RC_N_MASK & ~TPM2_RC_H & ~TPM2_RC_S & ~TPM2_RC_P)) == TPM2_RC_BAD_AUTH) {
/* Platform authorization not possible test will be skipped */
LOG_WARNING("Platform authorization not possible.");
+ failure_return = EXIT_SKIP;
}
goto_if_error(r, "Error: PCR_Allocate", error);
@@ -126,6 +129,6 @@
return EXIT_SUCCESS;
error:
- return EXIT_FAILURE;
+ return failure_return;
}