tlcl_tests.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
  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. #ifndef TLCL_TESTS_H
  8. #define TLCL_TESTS_H
  9. /* Standard testing indexes. */
  10. #define INDEX0 0xcafe
  11. #define INDEX1 0xcaff
  12. /* Prints error and returns on failure */
  13. #define TPM_CHECK(tpm_command) TPM_EXPECT(tpm_command, TPM_SUCCESS)
  14. #define TPM_EXPECT(tpm_command, expected_result) do { \
  15. uint32_t _result = (tpm_command); \
  16. uint32_t _exp = (expected_result); \
  17. if (_result != _exp) { \
  18. printf("TEST FAILED: line %d: " #tpm_command ": 0x%x" \
  19. " (expecting 0x%x)\n", __LINE__, _result, _exp); \
  20. return _result; \
  21. } \
  22. } while (0)
  23. /* Executes TlclStartup(), but ignores POSTINIT error if the
  24. * TLCL_RESILIENT_STARTUP environment variable is set.
  25. */
  26. uint32_t TlclStartupIfNeeded(void);
  27. #endif // TLCL_TESTS_H