blob: 8668c9c59e211f5da6d42cd9baad463ccd0298b2 [file] [log] [blame]
Louis Yung-Chieh Lo4bbf21e2010-04-21 17:29:05 -07001/* 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 Lo0dce41c2010-05-17 22:45:30 -07005#ifndef VBOOT_REFERENCE_CGPTLIB_TEST_H_
6#define VBOOT_REFERENCE_CGPTLIB_TEST_H_
Louis Yung-Chieh Lo4bbf21e2010-04-21 17:29:05 -07007
8#include <stdio.h>
vbendeb3ecaf772010-06-24 16:19:53 -07009#include "sysincludes.h"
Louis Yung-Chieh Lo4bbf21e2010-04-21 17:29:05 -070010
Louis Yung-Chieh Lo37f6b552010-04-22 21:22:22 -070011enum {
12 TEST_FAIL = -1,
13 TEST_OK = 0,
14};
Louis Yung-Chieh Lo4bbf21e2010-04-21 17:29:05 -070015
Louis Yung-Chieh Lo49fa8e52010-04-30 16:10:48 -070016#define TEST_CASE(func) #func, func
vbendeb3ecaf772010-06-24 16:19:53 -070017typedef int (*test_func)();
Louis Yung-Chieh Lo49fa8e52010-04-30 16:10:48 -070018
19#define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
20
Louis Yung-Chieh Lo4bbf21e2010-04-21 17:29:05 -070021#define EXPECT(expr) \
Louis Yung-Chieh Lo49fa8e52010-04-30 16:10:48 -070022 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)
Louis Yung-Chieh Lo4bbf21e2010-04-21 17:29:05 -070029
Louis Yung-Chieh Lo0dce41c2010-05-17 22:45:30 -070030#endif /* VBOOT_REFERENCE_CGPTLIB_TEST_H_ */