OLD | NEW |
---|---|
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 #ifndef VBOOT_REFERENCE_CGPT_TEST_H_ | 5 #ifndef VBOOT_REFERENCE_CGPT_TEST_H_ |
6 #define VBOOT_REFERENCE_CGPT_TEST_H_ | 6 #define VBOOT_REFERENCE_CGPT_TEST_H_ |
Bill Richardson
2010/05/17 15:15:03
Should change the #define to match the new file na
Louis
2010/05/18 08:18:02
Done.
| |
7 | 7 |
8 #include <stdio.h> | 8 #include <stdio.h> |
9 | 9 |
10 enum { | 10 enum { |
11 TEST_FAIL = -1, | 11 TEST_FAIL = -1, |
12 TEST_OK = 0, | 12 TEST_OK = 0, |
13 }; | 13 }; |
14 | 14 |
15 #define TEST_CASE(func) #func, func | 15 #define TEST_CASE(func) #func, func |
16 typedef int (*test_func)(void); | 16 typedef int (*test_func)(void); |
17 | 17 |
18 #define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0])) | 18 #define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0])) |
19 | 19 |
20 /* ANSI Color coding sequences. */ | 20 /* ANSI Color coding sequences. */ |
21 #define COL_GREEN "\e[1;32m" | 21 #define COL_GREEN "\e[1;32m" |
22 #define COL_RED "\e[0;31m" | 22 #define COL_RED "\e[0;31m" |
23 #define COL_STOP "\e[m" | 23 #define COL_STOP "\e[m" |
24 | 24 |
25 #define EXPECT(expr) \ | 25 #define EXPECT(expr) \ |
26 do { \ | 26 do { \ |
27 if (!(expr)) { \ | 27 if (!(expr)) { \ |
28 printf(COL_RED " fail " COL_STOP "in expression %s in %s() line %d\n",\ | 28 printf(COL_RED " fail " COL_STOP "in expression %s in %s() line %d\n",\ |
29 #expr, __FUNCTION__, __LINE__); \ | 29 #expr, __FUNCTION__, __LINE__); \ |
30 return TEST_FAIL; \ | 30 return TEST_FAIL; \ |
31 } \ | 31 } \ |
32 } while (0) | 32 } while (0) |
33 | 33 |
34 #endif /* VBOOT_REFERENCE_CGPT_TEST_H_ */ | 34 #endif /* VBOOT_REFERENCE_CGPT_TEST_H_ */ |
OLD | NEW |