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