Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: tests/tpm_lite/tlcl_tests.h

Issue 6349091: Improve error messages from tests (Closed) Base URL: http://git.chromium.org/git/vboot_reference.git@master
Patch Set: small improvements Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/tpm_lite/redefine_unowned.c ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 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 2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. 3 * found in the LICENSE file.
4 */ 4 */
5 5
6 /* Common definitions for test programs. 6 /* Common definitions for test programs.
7 */ 7 */
8 8
9 #ifndef TLCL_TESTS_H 9 #ifndef TLCL_TESTS_H
10 #define TLCL_TESTS_H 10 #define TLCL_TESTS_H
11 11
12 /* Standard testing indexes. */ 12 /* Standard testing indexes. */
13 #define INDEX0 0xcafe 13 #define INDEX0 0xcafe
14 #define INDEX1 0xcaff 14 #define INDEX1 0xcaff
15 15
16 #define DO_ON_FAILURE(tpm_command, action) do { \ 16 /* Prints error and returns on failure */
17 uint32_t result; \ 17 #define TPM_CHECK(tpm_command) TPM_EXPECT(tpm_command, TPM_SUCCESS)
18 if ((result = (tpm_command)) != TPM_SUCCESS) { \
19 action; \
20 } \
21 } while (0)
22 18
23 /* Prints error and returns on failure */ 19 #define TPM_EXPECT(tpm_command, expected_result) do { \
24 #define TPM_CHECK(tpm_command) \ 20 uint32_t _result = (tpm_command); \
25 DO_ON_FAILURE(tpm_command, \ 21 uint32_t _exp = (expected_result); \
26 printf("TEST FAILED: line %d: " #tpm_command ": 0x%x\n", \ 22 if (_result != _exp) { \
27 __LINE__, result); return result) 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
28 29
29 /* Executes TlclStartup(), but ignores POSTINIT error if the 30 /* Executes TlclStartup(), but ignores POSTINIT error if the
30 * TLCL_RESILIENT_STARTUP environment variable is set. 31 * TLCL_RESILIENT_STARTUP environment variable is set.
31 */ 32 */
32 uint32_t TlclStartupIfNeeded(void); 33 uint32_t TlclStartupIfNeeded(void);
33 34
34 #endif // TLCL_TESTS_H 35 #endif // TLCL_TESTS_H
OLDNEW
« no previous file with comments | « tests/tpm_lite/redefine_unowned.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698