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 * Common definitions for test programs. 6 */ 7 8 #ifndef VBOOT_REFERENCE_TLCL_TESTS_H_ 9 #define VBOOT_REFERENCE_TLCL_TESTS_H_ 10 11 /* Standard testing indexes. */ 12 #define INDEX0 0xcafe 13 #define INDEX1 0xcaff 14 15 /* Prints error and returns on failure */ 16 #define TPM_CHECK(tpm_command) TPM_EXPECT(tpm_command, TPM_SUCCESS) 17 18 #define TPM_EXPECT(tpm_command, expected_result) do { \ 19 uint32_t _result = (tpm_command); \ 20 uint32_t _exp = (expected_result); \ 21 if (_result != _exp) { \ 22 printf("TEST FAILED: line %d: " #tpm_command ": %#x" \ 23 " (expecting %#x)\n", __LINE__, _result, _exp); \ 24 return _result; \ 25 } \ 26 } while (0) 27 28 29 /* Executes TlclStartup(), but ignores POSTINIT error if the 30 * TLCL_RESILIENT_STARTUP environment variable is set. 31 */ 32 uint32_t TlclStartupIfNeeded(void); 33 34 #endif /* VBOOT_REFERENCE_TLCL_TESTS_H_ */ 35