Louis Yung-Chieh Lo | 4bbf21e | 2010-04-21 17:29:05 -0700 | [diff] [blame] | 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 | */ |
Louis Yung-Chieh Lo | 0dce41c | 2010-05-17 22:45:30 -0700 | [diff] [blame] | 5 | #ifndef VBOOT_REFERENCE_CGPTLIB_TEST_H_ |
| 6 | #define VBOOT_REFERENCE_CGPTLIB_TEST_H_ |
Louis Yung-Chieh Lo | 4bbf21e | 2010-04-21 17:29:05 -0700 | [diff] [blame] | 7 | |
| 8 | #include <stdio.h> |
vbendeb | 3ecaf77 | 2010-06-24 16:19:53 -0700 | [diff] [blame] | 9 | #include "sysincludes.h" |
Louis Yung-Chieh Lo | 4bbf21e | 2010-04-21 17:29:05 -0700 | [diff] [blame] | 10 | |
Louis Yung-Chieh Lo | 37f6b55 | 2010-04-22 21:22:22 -0700 | [diff] [blame] | 11 | enum { |
| 12 | TEST_FAIL = -1, |
| 13 | TEST_OK = 0, |
| 14 | }; |
Louis Yung-Chieh Lo | 4bbf21e | 2010-04-21 17:29:05 -0700 | [diff] [blame] | 15 | |
Louis Yung-Chieh Lo | 49fa8e5 | 2010-04-30 16:10:48 -0700 | [diff] [blame] | 16 | #define TEST_CASE(func) #func, func |
vbendeb | 3ecaf77 | 2010-06-24 16:19:53 -0700 | [diff] [blame] | 17 | typedef int (*test_func)(); |
Louis Yung-Chieh Lo | 49fa8e5 | 2010-04-30 16:10:48 -0700 | [diff] [blame] | 18 | |
| 19 | #define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0])) |
| 20 | |
vbendeb | 3ecaf77 | 2010-06-24 16:19:53 -0700 | [diff] [blame] | 21 | /* disable MSVC warning on const logical expression (as in } while(0);) */ |
| 22 | __pragma(warning (disable: 4127)) |
Louis Yung-Chieh Lo | 4bbf21e | 2010-04-21 17:29:05 -0700 | [diff] [blame] | 23 | |
| 24 | #define EXPECT(expr) \ |
Louis Yung-Chieh Lo | 49fa8e5 | 2010-04-30 16:10:48 -0700 | [diff] [blame] | 25 | do { \ |
| 26 | if (!(expr)) { \ |
| 27 | printf(COL_RED " fail " COL_STOP "in expression %s in %s() line %d\n",\ |
| 28 | #expr, __FUNCTION__, __LINE__); \ |
| 29 | return TEST_FAIL; \ |
| 30 | } \ |
| 31 | } while (0) |
Louis Yung-Chieh Lo | 4bbf21e | 2010-04-21 17:29:05 -0700 | [diff] [blame] | 32 | |
Louis Yung-Chieh Lo | 0dce41c | 2010-05-17 22:45:30 -0700 | [diff] [blame] | 33 | #endif /* VBOOT_REFERENCE_CGPTLIB_TEST_H_ */ |