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