blob: 6f594f93674ba60acbcfa8cac02558d12e59702f [file] [log] [blame]
Randall Spangler1f5d53f2011-08-24 12:07:43 -07001/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
Gaurav Shahce0cc302010-03-24 13:48:55 -07002 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
4 *
5 */
6
7#ifndef VBOOT_REFERENCE_TEST_COMMON_H_
8#define VBOOT_REFERENCE_TEST_COMMON_H_
9
Gaurav Shahce0cc302010-03-24 13:48:55 -070010extern int gTestSuccess;
Gaurav Shahbcd8f4a2010-05-26 13:19:00 -070011
Gaurav Shah3199eed2010-03-25 13:04:45 -070012/* Return 1 if result is equal to expected_result, else return 0.
13 * Also update the global gTestSuccess flag if test fails. */
Randall Spangler6c6babc2011-08-31 11:34:29 -070014int TEST_EQ(int result, int expected_result, const char* testname);
Randall Spangler1f5d53f2011-08-24 12:07:43 -070015
Gaurav Shahbcd8f4a2010-05-26 13:19:00 -070016/* Return 0 if result is equal to not_expected_result, else return 1.
17 * Also update the global gTestSuccess flag if test fails. */
Randall Spangler6c6babc2011-08-31 11:34:29 -070018int TEST_NEQ(int result, int not_expected_result, const char* testname);
Gaurav Shah3199eed2010-03-25 13:04:45 -070019
Randall Spanglercb3313e2011-08-26 12:53:16 -070020/* Return 1 if result pointer is equal to expected_result pointer,
21 * else return 0. Does not check pointer contents, only the pointer
22 * itself. Also update the global gTestSuccess flag if test fails. */
Randall Spangler1f5d53f2011-08-24 12:07:43 -070023int TEST_PTR_EQ(const void* result, const void* expected_result,
Randall Spangler6c6babc2011-08-31 11:34:29 -070024 const char* testname);
Randall Spangler1f5d53f2011-08-24 12:07:43 -070025
Randall Spangler9c9606b2011-08-30 16:44:44 -070026/* Return 1 if result pointer is not equal to expected_result pointer,
27 * else return 0. Does not check pointer contents, only the pointer
28 * itself. Also update the global gTestSuccess flag if test fails. */
29int TEST_PTR_NEQ(const void* result, const void* expected_result,
Randall Spangler6c6babc2011-08-31 11:34:29 -070030 const char* testname);
Randall Spangler9c9606b2011-08-30 16:44:44 -070031
Randall Spanglercb3313e2011-08-26 12:53:16 -070032/* Return 1 if result string is equal to expected_result string,
33 * else return 0. Also update the global gTestSuccess flag if test fails. */
34int TEST_STR_EQ(const char* result, const char* expected_result,
Randall Spangler6c6babc2011-08-31 11:34:29 -070035 const char* testname);
Randall Spanglercb3313e2011-08-26 12:53:16 -070036
vbendeb3ecaf772010-06-24 16:19:53 -070037/* ANSI Color coding sequences.
38 *
39 * Don't use \e as MSC does not recognize it as a valid escape sequence.
40 */
41#define COL_GREEN "\x1b[1;32m"
42#define COL_RED "\x1b[0;31m"
43#define COL_STOP "\x1b[m"
44
Gaurav Shahce0cc302010-03-24 13:48:55 -070045#endif /* VBOOT_REFERENCE_TEST_COMMON_H_ */