xref: /aosp_15_r20/external/vboot_reference/tests/tpm_lite/tlcl_tests.c (revision 8617a60d3594060b7ecbd21bc622a7c14f3cf2bc)
1 /* Copyright 2010 The ChromiumOS Authors
2  * Use of this source code is governed by a BSD-style license that can be
3  * found in the LICENSE file.
4  */
5 
6 /* Shared code for tests.
7  */
8 
9 #include "2sysincludes.h"
10 
11 #include "tlcl.h"
12 #include "tlcl_tests.h"
13 
14 const char* resilient_startup = NULL;
15 
TlclStartupIfNeeded(void)16 uint32_t TlclStartupIfNeeded(void) {
17 	static const char* null_getenv = "some string";  /* a unique address */
18 	uint32_t result = TlclStartup();
19 	if (resilient_startup == NULL) {
20 		resilient_startup = getenv("TLCL_RESILIENT_STARTUP");
21 		if (resilient_startup == NULL) {
22 			resilient_startup = null_getenv;
23 		}
24 	}
25 	if (resilient_startup == null_getenv) {
26 		return result;
27 	}
28 	return result == TPM_E_INVALID_POSTINIT ? TPM_SUCCESS : result;
29 }
30