Randall Spangler | 1f5d53f | 2011-08-24 12:07:43 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
Gaurav Shah | ce0cc30 | 2010-03-24 13:48:55 -0700 | [diff] [blame] | 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 | |
| 7 | #ifndef VBOOT_REFERENCE_TEST_COMMON_H_ |
| 8 | #define VBOOT_REFERENCE_TEST_COMMON_H_ |
| 9 | |
Gaurav Shah | ce0cc30 | 2010-03-24 13:48:55 -0700 | [diff] [blame] | 10 | extern int gTestSuccess; |
Gaurav Shah | bcd8f4a | 2010-05-26 13:19:00 -0700 | [diff] [blame] | 11 | |
Gaurav Shah | 3199eed | 2010-03-25 13:04:45 -0700 | [diff] [blame] | 12 | /* Return 1 if result is equal to expected_result, else return 0. |
| 13 | * Also update the global gTestSuccess flag if test fails. */ |
Randall Spangler | 6c6babc | 2011-08-31 11:34:29 -0700 | [diff] [blame] | 14 | int TEST_EQ(int result, int expected_result, const char* testname); |
Randall Spangler | 1f5d53f | 2011-08-24 12:07:43 -0700 | [diff] [blame] | 15 | |
Gaurav Shah | bcd8f4a | 2010-05-26 13:19:00 -0700 | [diff] [blame] | 16 | /* Return 0 if result is equal to not_expected_result, else return 1. |
| 17 | * Also update the global gTestSuccess flag if test fails. */ |
Randall Spangler | 6c6babc | 2011-08-31 11:34:29 -0700 | [diff] [blame] | 18 | int TEST_NEQ(int result, int not_expected_result, const char* testname); |
Gaurav Shah | 3199eed | 2010-03-25 13:04:45 -0700 | [diff] [blame] | 19 | |
Randall Spangler | cb3313e | 2011-08-26 12:53:16 -0700 | [diff] [blame] | 20 | /* 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 Spangler | 1f5d53f | 2011-08-24 12:07:43 -0700 | [diff] [blame] | 23 | int TEST_PTR_EQ(const void* result, const void* expected_result, |
Randall Spangler | 6c6babc | 2011-08-31 11:34:29 -0700 | [diff] [blame] | 24 | const char* testname); |
Randall Spangler | 1f5d53f | 2011-08-24 12:07:43 -0700 | [diff] [blame] | 25 | |
Randall Spangler | 9c9606b | 2011-08-30 16:44:44 -0700 | [diff] [blame] | 26 | /* 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. */ |
| 29 | int TEST_PTR_NEQ(const void* result, const void* expected_result, |
Randall Spangler | 6c6babc | 2011-08-31 11:34:29 -0700 | [diff] [blame] | 30 | const char* testname); |
Randall Spangler | 9c9606b | 2011-08-30 16:44:44 -0700 | [diff] [blame] | 31 | |
Randall Spangler | cb3313e | 2011-08-26 12:53:16 -0700 | [diff] [blame] | 32 | /* Return 1 if result string is equal to expected_result string, |
| 33 | * else return 0. Also update the global gTestSuccess flag if test fails. */ |
| 34 | int TEST_STR_EQ(const char* result, const char* expected_result, |
Randall Spangler | 6c6babc | 2011-08-31 11:34:29 -0700 | [diff] [blame] | 35 | const char* testname); |
Randall Spangler | cb3313e | 2011-08-26 12:53:16 -0700 | [diff] [blame] | 36 | |
Bill Richardson | 94d7034 | 2011-10-04 08:36:09 -0700 | [diff] [blame] | 37 | /* Return 1 if the result is true, else return 0. |
| 38 | * Also update the global gTestSuccess flag if test fails. */ |
| 39 | int TEST_TRUE(int result, const char* testname); |
| 40 | |
| 41 | /* Return 1 if the result is false, else return 0. |
| 42 | * Also update the global gTestSuccess flag if test fails. */ |
| 43 | int TEST_FALSE(int result, const char* testname); |
| 44 | |
Randall Spangler | b9be536 | 2014-06-05 13:32:11 -0700 | [diff] [blame] | 45 | /* Return 1 if result is 0 (VB_ERROR_SUCCESS / VB2_SUCCESS), else return 0. |
| 46 | * Also update the global gTestSuccess flag if test fails. */ |
| 47 | int TEST_SUCC(int result, const char* testname); |
| 48 | |
vbendeb | 3ecaf77 | 2010-06-24 16:19:53 -0700 | [diff] [blame] | 49 | /* ANSI Color coding sequences. |
| 50 | * |
| 51 | * Don't use \e as MSC does not recognize it as a valid escape sequence. |
| 52 | */ |
| 53 | #define COL_GREEN "\x1b[1;32m" |
| 54 | #define COL_RED "\x1b[0;31m" |
| 55 | #define COL_STOP "\x1b[m" |
| 56 | |
Simon Glass | 2500185 | 2013-08-16 02:47:57 -0600 | [diff] [blame] | 57 | /* Check that all memory allocations were freed */ |
| 58 | int vboot_api_stub_check_memory(void); |
| 59 | |
Gaurav Shah | ce0cc30 | 2010-03-24 13:48:55 -0700 | [diff] [blame] | 60 | #endif /* VBOOT_REFERENCE_TEST_COMMON_H_ */ |