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_CGPTLIB_TEST_H_ | 5 #ifndef VBOOT_REFERENCE_CGPTLIB_TEST_H_ |
6 #define VBOOT_REFERENCE_CGPTLIB_TEST_H_ | 6 #define VBOOT_REFERENCE_CGPTLIB_TEST_H_ |
7 | 7 |
8 #include <stdio.h> | 8 #include <stdio.h> |
| 9 #include "sysincludes.h" |
9 | 10 |
10 enum { | 11 enum { |
11 TEST_FAIL = -1, | 12 TEST_FAIL = -1, |
12 TEST_OK = 0, | 13 TEST_OK = 0, |
13 }; | 14 }; |
14 | 15 |
15 #define TEST_CASE(func) #func, func | 16 #define TEST_CASE(func) #func, func |
16 typedef int (*test_func)(void); | 17 typedef int (*test_func)(); |
17 | 18 |
18 #define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0])) | 19 #define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0])) |
19 | 20 |
20 /* ANSI Color coding sequences. */ | 21 /* disable MSVC warning on const logical expression (as in } while(0);) */ |
21 #define COL_GREEN "\e[1;32m" | 22 __pragma(warning (disable: 4127)) |
22 #define COL_RED "\e[0;31m" | |
23 #define COL_STOP "\e[m" | |
24 | 23 |
25 #define EXPECT(expr) \ | 24 #define EXPECT(expr) \ |
26 do { \ | 25 do { \ |
27 if (!(expr)) { \ | 26 if (!(expr)) { \ |
28 printf(COL_RED " fail " COL_STOP "in expression %s in %s() line %d\n",\ | 27 printf(COL_RED " fail " COL_STOP "in expression %s in %s() line %d\n",\ |
29 #expr, __FUNCTION__, __LINE__); \ | 28 #expr, __FUNCTION__, __LINE__); \ |
30 return TEST_FAIL; \ | 29 return TEST_FAIL; \ |
31 } \ | 30 } \ |
32 } while (0) | 31 } while (0) |
33 | 32 |
34 #endif /* VBOOT_REFERENCE_CGPTLIB_TEST_H_ */ | 33 #endif /* VBOOT_REFERENCE_CGPTLIB_TEST_H_ */ |
OLD | NEW |