summaryrefslogtreecommitdiff
path: root/tests/tpm_lite/tlcl_tests.c
blob: 353b16c6972ba52f11ca7b1cda917c002f1cc66c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

/* Shared code for tests.
 */

#include "sysincludes.h"

#include "tlcl.h"
#include "tlcl_tests.h"

const char* resilient_startup = NULL;

uint32_t TlclStartupIfNeeded(void) {
	static const char* null_getenv = "some string";  /* a unique address */
	uint32_t result = TlclStartup();
	if (resilient_startup == NULL) {
		resilient_startup = getenv("TLCL_RESILIENT_STARTUP");
		if (resilient_startup == NULL) {
			resilient_startup = null_getenv;
		}
	}
	if (resilient_startup == null_getenv) {
		return result;
	}
	return result == TPM_E_INVALID_POSTINIT ? TPM_SUCCESS : result;
}