1 /* Copyright 2010 The ChromiumOS Authors 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 #ifndef VBOOT_REFERENCE_CGPTLIB_TEST_H_ 7 #define VBOOT_REFERENCE_CGPTLIB_TEST_H_ 8 9 #include <stdio.h> 10 #include "2sysincludes.h" 11 12 enum { 13 TEST_FAIL = -1, 14 TEST_OK = 0, 15 }; 16 17 #define TEST_CASE(func) #func, func 18 typedef int (*test_func)(void); 19 20 #define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0])) 21 22 #define EXPECT(expr) do { \ 23 if (!(expr)) { \ 24 printf(COL_RED " fail " COL_STOP \ 25 "in expression %s in %s() line %d\n", \ 26 #expr, __FUNCTION__, __LINE__); \ 27 return TEST_FAIL; \ 28 } \ 29 } while (0) 30 31 #endif /* VBOOT_REFERENCE_CGPTLIB_TEST_H_ */ 32