From 1d25a753a35245af0f98897c4e999ec428b97134 Mon Sep 17 00:00:00 2001 From: Hsin-Te Yuan Date: Mon, 11 Jul 2022 15:55:11 +0800 Subject: tests/common/tests.h: rename test_common.h to common/tests.h Create tests/common/ to put some common files. BUG=none BRANCH=none TEST=make runtests Signed-off-by: Hsin-Te Yuan Change-Id: I8918b7a1e62d47fca6074ef123e2de6f46f1aa00 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3754814 Reviewed-by: Hsuan Ting Chen Reviewed-by: Yu-Ping Wu --- Makefile | 8 +- tests/cgptlib_test.c | 2 +- tests/chromeos_config_tests.c | 2 +- tests/common/tests.c | 217 ++++++++++++++++++++++++++++++ tests/common/tests.h | 167 +++++++++++++++++++++++ tests/common/timer_utils.c | 24 ++++ tests/common/timer_utils.h | 26 ++++ tests/crc32_test.c | 2 +- tests/futility/test_file_types.c | 2 +- tests/futility/test_not_really.c | 2 +- tests/gpt_misc_tests.c | 2 +- tests/hmac_test.c | 2 +- tests/sha_benchmark.c | 2 +- tests/subprocess_tests.c | 2 +- tests/test_common.c | 217 ------------------------------ tests/test_common.h | 167 ----------------------- tests/timer_utils.c | 24 ---- tests/timer_utils.h | 26 ---- tests/tlcl_tests.c | 2 +- tests/tpm_lite/tpmtest_fastenable.c | 2 +- tests/tpm_lite/tpmtest_globallock.c | 2 +- tests/tpm_lite/tpmtest_redefine_unowned.c | 2 +- tests/tpm_lite/tpmtest_spaceperm.c | 2 +- tests/tpm_lite/tpmtest_writelimit.c | 2 +- tests/vb20_api_kernel_tests.c | 2 +- tests/vb20_kernel_tests.c | 2 +- tests/vb20_rsa_padding_tests.c | 2 +- tests/vb21_host_common2_tests.c | 2 +- tests/vb21_host_common_tests.c | 2 +- tests/vb21_host_key_tests.c | 2 +- tests/vb21_host_misc_tests.c | 2 +- tests/vb21_host_sig_tests.c | 2 +- tests/vb2_api_tests.c | 2 +- tests/vb2_auxfw_sync_tests.c | 2 +- tests/vb2_common2_tests.c | 2 +- tests/vb2_common3_tests.c | 2 +- tests/vb2_common_tests.c | 2 +- tests/vb2_crypto_tests.c | 2 +- tests/vb2_ec_sync_tests.c | 2 +- tests/vb2_firmware_tests.c | 2 +- tests/vb2_gbb_tests.c | 2 +- tests/vb2_host_flashrom_tests.c | 2 +- tests/vb2_host_key_tests.c | 2 +- tests/vb2_host_nvdata_flashrom_tests.c | 2 +- tests/vb2_kernel2_tests.c | 2 +- tests/vb2_kernel_tests.c | 2 +- tests/vb2_misc2_tests.c | 2 +- tests/vb2_misc_tests.c | 2 +- tests/vb2_nvstorage_tests.c | 2 +- tests/vb2_recovery_reasons_tests.c | 2 +- tests/vb2_rsa_utility_tests.c | 2 +- tests/vb2_secdata_firmware_tests.c | 2 +- tests/vb2_secdata_fwmp_tests.c | 2 +- tests/vb2_secdata_kernel_tests.c | 2 +- tests/vb2_sha256_x86_tests.c | 2 +- tests/vb2_sha_api_tests.c | 2 +- tests/vb2_sha_tests.c | 2 +- tests/vboot_api_kernel_tests.c | 2 +- tests/vboot_kernel2_tests.c | 2 +- tests/vboot_kernel_tests.c | 2 +- 60 files changed, 489 insertions(+), 489 deletions(-) create mode 100644 tests/common/tests.c create mode 100644 tests/common/tests.h create mode 100644 tests/common/timer_utils.c create mode 100644 tests/common/timer_utils.h delete mode 100644 tests/test_common.c delete mode 100644 tests/test_common.h delete mode 100644 tests/timer_utils.c delete mode 100644 tests/timer_utils.h diff --git a/Makefile b/Makefile index a3566d46..e1569516 100644 --- a/Makefile +++ b/Makefile @@ -698,10 +698,10 @@ ALL_OBJS += ${FUTIL_OBJS} # Library of handy test functions. TESTLIB = ${BUILD}/tests/test.a -TESTLIB_SRCS += \ - tests/test_common.c \ - tests/timer_utils.c \ - tests/crc32_test.c +TEST_COMMON_DIR = tests/common + +TESTLIB_SRCS += $(wildcard $(TEST_COMMON_DIR)/*.c) +TESTLIB_SRCS += tests/crc32_test.c TESTLIB_OBJS = ${TESTLIB_SRCS:%.c=${BUILD}/%.o} TEST_OBJS += ${TESTLIB_OBJS} diff --git a/tests/cgptlib_test.c b/tests/cgptlib_test.c index 6fd7c322..f614977b 100644 --- a/tests/cgptlib_test.c +++ b/tests/cgptlib_test.c @@ -9,10 +9,10 @@ #include "../cgpt/cgpt.h" #include "cgptlib_internal.h" #include "cgptlib_test.h" +#include "common/tests.h" #include "crc32.h" #include "crc32_test.h" #include "gpt.h" -#include "test_common.h" /* * Testing partition layout (sector_bytes=512) diff --git a/tests/chromeos_config_tests.c b/tests/chromeos_config_tests.c index 2408d8ce..6b24a331 100644 --- a/tests/chromeos_config_tests.c +++ b/tests/chromeos_config_tests.c @@ -11,8 +11,8 @@ #include "2common.h" #include "2return_codes.h" #include "chromeos_config.h" +#include "common/tests.h" #include "host_misc.h" -#include "test_common.h" static struct { const char *path; diff --git a/tests/common/tests.c b/tests/common/tests.c new file mode 100644 index 00000000..7df16134 --- /dev/null +++ b/tests/common/tests.c @@ -0,0 +1,217 @@ +/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * Common functions used by tests. + */ + +#include +#include +#include + +#include "2common.h" +#include "common/tests.h" + +/* Global test success flag. */ +int gTestSuccess = 1; +int gTestAbortArmed = 0; +jmp_buf gTestJmpEnv; + +static void print_passed(const char *preamble, const char *desc, + const char *comment) +{ + fprintf(stderr, "%s: %s ... " COL_GREEN "PASSED\n" COL_STOP, + preamble, comment ? comment : desc); +} + +static void print_failed(const char *preamble, const char *desc, + const char *comment) +{ + fprintf(stderr, "%s: %s ... " COL_RED "FAILED\n" COL_STOP, + preamble, comment ? comment : desc); +} + +int test_eq(int result, int expected, + const char *preamble, const char *desc, const char *comment) +{ + if (result == expected) { + print_passed(preamble, desc, comment); + return 1; + } else { + print_failed(preamble, desc, comment); + fprintf(stderr, " Expected: %#x (%d), got: %#x (%d)\n", + expected, expected, result, result); + gTestSuccess = 0; + return 0; + } +} + +int test_neq(int result, int not_expected, + const char *preamble, const char *desc, const char *comment) +{ + if (result != not_expected) { + print_passed(preamble, desc, comment); + return 1; + } else { + print_failed(preamble, desc, comment); + fprintf(stderr, " Didn't expect %#x (%d), but got it.\n", + not_expected, not_expected); + gTestSuccess = 0; + return 0; + } +} + +int test_ptr_eq(const void* result, const void* expected, + const char *preamble, const char *desc, const char *comment) +{ + if (result == expected) { + print_passed(preamble, desc, comment); + return 1; + } else { + print_failed(preamble, desc, comment); + fprintf(stderr, " Expected: %#lx, got: %#lx\n", + (long)expected, (long)result); + gTestSuccess = 0; + return 0; + } +} + +int test_ptr_neq(const void* result, const void* not_expected, + const char *preamble, const char *desc, const char *comment) +{ + if (result != not_expected) { + print_passed(preamble, desc, comment); + return 1; + } else { + print_failed(preamble, desc, comment); + fprintf(stderr, " Didn't expect %#lx, but got it\n", + (long)not_expected); + gTestSuccess = 0; + return 0; + } +} + +int test_str_eq(const char* result, const char* expected, + const char *preamble, const char *desc, const char *comment) +{ + if (!result || !expected) { + print_failed(preamble, desc, comment); + fprintf(stderr, " String compare with NULL\n"); + gTestSuccess = 0; + return 0; + } else if (!strcmp(result, expected)) { + print_passed(preamble, desc, comment); + return 1; + } else { + print_failed(preamble, desc, comment); + fprintf(stderr, " Expected: \"%s\", got: \"%s\"\n", + expected, result); + gTestSuccess = 0; + return 0; + } +} + +int test_str_neq(const char* result, const char* not_expected, + const char *preamble, const char *desc, const char *comment) +{ + if (!result || !not_expected) { + print_failed(preamble, desc, comment); + fprintf(stderr, " String compare with NULL\n"); + gTestSuccess = 0; + return 0; + } else if (strcmp(result, not_expected)) { + print_passed(preamble, desc, comment); + fprintf(stderr, "%s: %s, %s ... " COL_GREEN "PASSED\n" COL_STOP, + preamble, desc, comment); + return 1; + } else { + print_failed(preamble, desc, comment); + fprintf(stderr, " Didn't expect: \"%s\", but got it\n", + not_expected); + gTestSuccess = 0; + return 0; + } +} + +int test_succ(int result, + const char *preamble, const char *desc, const char *comment) +{ + if (result == 0) { + print_passed(preamble, desc, comment); + } else { + print_failed(preamble, desc, comment); + fprintf(stderr, " Expected SUCCESS, got: %#x (%d)\n", + result, result); + gTestSuccess = 0; + } + return !result; +} + +int test_fail(int result, + const char *preamble, const char *desc, const char *comment) +{ + if (result != 0) { + print_passed(preamble, desc, comment); + } else { + print_failed(preamble, desc, comment); + fprintf(stderr, + " Didn't expect SUCCESS (0), but got it\n"); + gTestSuccess = 0; + } + return result; +} + +int test_true(int result, + const char *preamble, const char *desc, const char *comment) +{ + if (result) { + print_passed(preamble, desc, comment); + } else { + print_failed(preamble, desc, comment); + fprintf(stderr, " Expected TRUE, got 0\n"); + gTestSuccess = 0; + } + return result; +} + +int test_false(int result, + const char *preamble, const char *desc, const char *comment) +{ + if (!result) { + print_passed(preamble, desc, comment); + } else { + print_failed(preamble, desc, comment); + fprintf(stderr, " Expected FALSE, got: %#lx\n", + (long)result); + gTestSuccess = 0; + } + return !result; +} + +int test_abort(int aborted, + const char *preamble, const char *desc, const char *comment) +{ + if (aborted) { + print_passed(preamble, desc, comment); + } else { + print_failed(preamble, desc, comment); + fprintf(stderr, " Expected ABORT, but did not get it\n"); + gTestSuccess = 0; + } + return aborted; +} + +void vb2ex_abort(void) +{ + /* + * If expecting an abort call, jump back to TEST_ABORT macro. + * Otherwise, force exit to ensure the test fails. + */ + if (gTestAbortArmed) { + longjmp(gTestJmpEnv, 1); + } else { + fprintf(stderr, COL_RED "Unexpected ABORT encountered, " + "exiting\n" COL_STOP); + exit(1); + } +} diff --git a/tests/common/tests.h b/tests/common/tests.h new file mode 100644 index 00000000..656e2d91 --- /dev/null +++ b/tests/common/tests.h @@ -0,0 +1,167 @@ +/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef VBOOT_REFERENCE_COMMON_TESTS_H_ +#define VBOOT_REFERENCE_COMMON_TESTS_H_ + +#include +#include + +/* Used to get a line number as a constant string. Need to stringify it twice */ +#define STRINGIFY(x) #x +#define TOSTRING(x) STRINGIFY(x) + +extern int gTestSuccess; +extern int gTestAbortArmed; +extern jmp_buf gTestJmpEnv; + +/* Return 1 if result is equal to expected_result, else return 0. + * Also update the global gTestSuccess flag if test fails. */ +int test_eq(int result, int expected, + const char *preamble, const char *desc, const char *comment); + +#define TEST_EQ(result, expected, comment) \ + test_eq(result, expected, \ + __FILE__ ":" TOSTRING(__LINE__), \ + #result " == " #expected, \ + comment) + +#define TEST_EQ_S(result, expected) TEST_EQ(result, expected, NULL); + +/* Return 0 if result is equal to not_expected_result, else return 1. + * Also update the global gTestSuccess flag if test fails. */ +int test_neq(int result, int not_expected, + const char *preamble, const char *desc, const char *comment); + +#define TEST_NEQ(result, not_expected, comment) \ + test_neq(result, not_expected, \ + __FILE__ ":" TOSTRING(__LINE__), \ + #result " != " #not_expected, \ + comment) + +/* Return 1 if result pointer is equal to expected_result pointer, + * else return 0. Does not check pointer contents, only the pointer + * itself. Also update the global gTestSuccess flag if test fails. */ +int test_ptr_eq(const void* result, const void* expected, + const char *preamble, const char *desc, const char *comment); + +#define TEST_PTR_EQ(result, expected, comment) \ + test_ptr_eq(result, expected, \ + __FILE__ ":" TOSTRING(__LINE__), \ + #result " == " #expected, \ + comment) + +/* Return 1 if result pointer is not equal to expected_result pointer, + * else return 0. Does not check pointer contents, only the pointer + * itself. Also update the global gTestSuccess flag if test fails. */ +int test_ptr_neq(const void* result, const void* not_expected, + const char *preamble, const char *desc, const char *comment); + +#define TEST_PTR_NEQ(result, not_expected, comment) \ + test_ptr_neq(result, not_expected, \ + __FILE__ ":" TOSTRING(__LINE__), \ + #result " != " #not_expected, \ + comment) + +/* Return 1 if result string is equal to expected_result string, + * else return 0. Also update the global gTestSuccess flag if test fails. */ +int test_str_eq(const char* result, const char* expected, + const char *preamble, const char *desc, const char *comment); + +#define TEST_STR_EQ(result, expected, comment) \ + test_str_eq(result, expected, \ + __FILE__ ":" TOSTRING(__LINE__), \ + #result " == " #expected, \ + comment) + +/* Return 1 if result string is not equal to not_expected string, + * else return 0. Also update the global gTestSuccess flag if test fails. */ +int test_str_neq(const char* result, const char* not_expected, + const char *preamble, const char *desc, const char *comment); + +#define TEST_STR_NEQ(result, not_expected, comment) \ + test_str_neq(result, not_expected, \ + __FILE__ ":" TOSTRING(__LINE__), \ + #result " != " #not_expected, \ + comment) + +/* Return 1 if the result is true, else return 0. + * Also update the global gTestSuccess flag if test fails. */ +int test_true(int result, + const char *preamble, const char *desc, const char *comment); + +#define TEST_TRUE(result, comment) \ + test_true(result, \ + __FILE__ ":" TOSTRING(__LINE__), \ + #result " == true", \ + comment) + +/* Return 1 if the result is false, else return 0. + * Also update the global gTestSuccess flag if test fails. */ +int test_false(int result, + const char *preamble, const char *desc, const char *comment); + +#define TEST_FALSE(result, comment) \ + test_false(result, \ + __FILE__ ":" TOSTRING(__LINE__), \ + #result " == false", \ + comment) + +/* Return 1 if result is 0 (VB2_SUCCESS or other), else return 0. + * Also update the global gTestSuccess flag if test fails. */ +int test_succ(int result, + const char *preamble, const char *desc, const char *comment); + +#define TEST_SUCC(result, comment) \ + test_succ(result, \ + __FILE__ ":" TOSTRING(__LINE__), \ + #result " == 0", \ + comment) + +/* Return 1 if result is not 0 (VB2_SUCCESS or other), else return 1. + * Also update the global gTestSuccess flag if test fails. */ +int test_fail(int result, + const char *preamble, const char *desc, const char *comment); + +#define TEST_FAIL(result, comment) \ + test_fail(result, \ + __FILE__ ":" TOSTRING(__LINE__), \ + #result " != 0", \ + comment) + +/* Return 1 if vb2ex_abort() was called, else return 0. + * Also update the global gTestSuccess flag if test fails. */ +int test_abort(int aborted, + const char *preamble, const char *desc, const char *comment); + +#define TEST_ABORT(call, comment) do { \ + gTestAbortArmed = 1; \ + int jumped = setjmp(gTestJmpEnv); \ + if (!jumped) \ + call; \ + gTestAbortArmed = 0; \ + test_abort(jumped, \ + __FILE__ ":" TOSTRING(__LINE__), \ + #call " causes abort", \ + comment); \ +} while (0) + +/* ANSI Color coding sequences. + * + * Don't use \e as MSC does not recognize it as a valid escape sequence. + */ +#define COL_GREEN "\x1b[1;32m" +#define COL_YELLOW "\x1b[1;33m" +#define COL_RED "\x1b[0;31m" +#define COL_STOP "\x1b[m" + +/* Abort if asprintf fails. */ +#define xasprintf(...) \ + do { \ + if (asprintf(__VA_ARGS__) < 0) \ + abort(); \ + } while (0) + +#endif /* VBOOT_REFERENCE_COMMON_TESTS_H_ */ diff --git a/tests/common/timer_utils.c b/tests/common/timer_utils.c new file mode 100644 index 00000000..25e7503c --- /dev/null +++ b/tests/common/timer_utils.c @@ -0,0 +1,24 @@ +/* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "timer_utils.h" + +void StartTimer(ClockTimerState* ct) { + clock_gettime(CLOCK_REALTIME, &ct->start_time); +} + +void StopTimer(ClockTimerState* ct) { + clock_gettime(CLOCK_REALTIME, &ct->end_time); +} + +uint32_t GetDurationMsecs(ClockTimerState* ct) { + uint64_t start = ((uint64_t) ct->start_time.tv_sec * 1000000000 + + (uint64_t) ct->start_time.tv_nsec); + uint64_t end = ((uint64_t) ct->end_time.tv_sec * 1000000000 + + (uint64_t) ct->end_time.tv_nsec); + uint64_t duration_msecs = (end - start) / 1000000U; /* Nanoseconds -> + * Milliseconds. */ + return (uint32_t) duration_msecs; +} diff --git a/tests/common/timer_utils.h b/tests/common/timer_utils.h new file mode 100644 index 00000000..b2a424a5 --- /dev/null +++ b/tests/common/timer_utils.h @@ -0,0 +1,26 @@ + /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef VBOOT_REFERENCE_COMMON_TIMER_UTILS_H_ +#define VBOOT_REFERENCE_COMMON_TIMER_UTILS_H_ + +#include +#include + +typedef struct ClockTimer { + struct timespec start_time; + struct timespec end_time; +} ClockTimerState; + +/* Start timer and update [ct]. */ +void StartTimer(ClockTimerState* ct); + +/* Stop timer and update [ct]. */ +void StopTimer(ClockTimerState* ct); + +/* Get duration in milliseconds. */ +uint32_t GetDurationMsecs(ClockTimerState* ct); + +#endif /* VBOOT_REFERENCE_COMMON_TIMER_UTILS_H_ */ diff --git a/tests/crc32_test.c b/tests/crc32_test.c index 1d1d8cd3..ee60cc0a 100644 --- a/tests/crc32_test.c +++ b/tests/crc32_test.c @@ -4,9 +4,9 @@ */ #include "cgptlib_test.h" +#include "common/tests.h" #include "crc32.h" #include "crc32_test.h" -#include "test_common.h" #define MAX_VECTOR_LEN 256 diff --git a/tests/futility/test_file_types.c b/tests/futility/test_file_types.c index 17388cfd..ee433bab 100644 --- a/tests/futility/test_file_types.c +++ b/tests/futility/test_file_types.c @@ -10,7 +10,7 @@ #include "file_type.h" #include "futility.h" -#include "test_common.h" +#include "common/tests.h" /* * Files that exemplify each type. diff --git a/tests/futility/test_not_really.c b/tests/futility/test_not_really.c index 3cfc3ed6..9bffb1a1 100644 --- a/tests/futility/test_not_really.c +++ b/tests/futility/test_not_really.c @@ -6,7 +6,7 @@ #include #include "2struct.h" -#include "test_common.h" +#include "common/tests.h" int main(int argc, char *argv[]) { diff --git a/tests/gpt_misc_tests.c b/tests/gpt_misc_tests.c index e0a8d56e..30632991 100644 --- a/tests/gpt_misc_tests.c +++ b/tests/gpt_misc_tests.c @@ -8,8 +8,8 @@ #include "2api.h" #include "cgptlib.h" #include "cgptlib_internal.h" +#include "common/tests.h" #include "gpt.h" -#include "test_common.h" #define LOGCALL(fmt, args...) sprintf(call_log + strlen(call_log), fmt, ##args) #define TEST_CALLS(expect_log) TEST_STR_EQ(call_log, expect_log, " calls") diff --git a/tests/hmac_test.c b/tests/hmac_test.c index ed77d7bb..708711fd 100644 --- a/tests/hmac_test.c +++ b/tests/hmac_test.c @@ -10,7 +10,7 @@ #include "2sha.h" #include "2hmac.h" -#include "test_common.h" +#include "common/tests.h" const char short_key[] = "key"; const char message[] = "The quick brown fox jumps over the lazy dog"; diff --git a/tests/sha_benchmark.c b/tests/sha_benchmark.c index 27b1c101..d7ba31ab 100644 --- a/tests/sha_benchmark.c +++ b/tests/sha_benchmark.c @@ -10,8 +10,8 @@ #include "2common.h" #include "2sha.h" #include "2sysincludes.h" +#include "common/timer_utils.h" #include "host_common.h" -#include "timer_utils.h" #define TEST_BUFFER_SIZE 4000000 diff --git a/tests/subprocess_tests.c b/tests/subprocess_tests.c index 75d6e493..d65618f4 100644 --- a/tests/subprocess_tests.c +++ b/tests/subprocess_tests.c @@ -7,7 +7,7 @@ #include #include "subprocess.h" -#include "test_common.h" +#include "common/tests.h" #define TEST_STRING "hello world" #define TEST_STRING_LN TEST_STRING "\n" diff --git a/tests/test_common.c b/tests/test_common.c deleted file mode 100644 index 2ce3a5da..00000000 --- a/tests/test_common.c +++ /dev/null @@ -1,217 +0,0 @@ -/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Common functions used by tests. - */ - -#include -#include -#include - -#include "2common.h" -#include "test_common.h" - -/* Global test success flag. */ -int gTestSuccess = 1; -int gTestAbortArmed = 0; -jmp_buf gTestJmpEnv; - -static void print_passed(const char *preamble, const char *desc, - const char *comment) -{ - fprintf(stderr, "%s: %s ... " COL_GREEN "PASSED\n" COL_STOP, - preamble, comment ? comment : desc); -} - -static void print_failed(const char *preamble, const char *desc, - const char *comment) -{ - fprintf(stderr, "%s: %s ... " COL_RED "FAILED\n" COL_STOP, - preamble, comment ? comment : desc); -} - -int test_eq(int result, int expected, - const char *preamble, const char *desc, const char *comment) -{ - if (result == expected) { - print_passed(preamble, desc, comment); - return 1; - } else { - print_failed(preamble, desc, comment); - fprintf(stderr, " Expected: %#x (%d), got: %#x (%d)\n", - expected, expected, result, result); - gTestSuccess = 0; - return 0; - } -} - -int test_neq(int result, int not_expected, - const char *preamble, const char *desc, const char *comment) -{ - if (result != not_expected) { - print_passed(preamble, desc, comment); - return 1; - } else { - print_failed(preamble, desc, comment); - fprintf(stderr, " Didn't expect %#x (%d), but got it.\n", - not_expected, not_expected); - gTestSuccess = 0; - return 0; - } -} - -int test_ptr_eq(const void* result, const void* expected, - const char *preamble, const char *desc, const char *comment) -{ - if (result == expected) { - print_passed(preamble, desc, comment); - return 1; - } else { - print_failed(preamble, desc, comment); - fprintf(stderr, " Expected: %#lx, got: %#lx\n", - (long)expected, (long)result); - gTestSuccess = 0; - return 0; - } -} - -int test_ptr_neq(const void* result, const void* not_expected, - const char *preamble, const char *desc, const char *comment) -{ - if (result != not_expected) { - print_passed(preamble, desc, comment); - return 1; - } else { - print_failed(preamble, desc, comment); - fprintf(stderr, " Didn't expect %#lx, but got it\n", - (long)not_expected); - gTestSuccess = 0; - return 0; - } -} - -int test_str_eq(const char* result, const char* expected, - const char *preamble, const char *desc, const char *comment) -{ - if (!result || !expected) { - print_failed(preamble, desc, comment); - fprintf(stderr, " String compare with NULL\n"); - gTestSuccess = 0; - return 0; - } else if (!strcmp(result, expected)) { - print_passed(preamble, desc, comment); - return 1; - } else { - print_failed(preamble, desc, comment); - fprintf(stderr, " Expected: \"%s\", got: \"%s\"\n", - expected, result); - gTestSuccess = 0; - return 0; - } -} - -int test_str_neq(const char* result, const char* not_expected, - const char *preamble, const char *desc, const char *comment) -{ - if (!result || !not_expected) { - print_failed(preamble, desc, comment); - fprintf(stderr, " String compare with NULL\n"); - gTestSuccess = 0; - return 0; - } else if (strcmp(result, not_expected)) { - print_passed(preamble, desc, comment); - fprintf(stderr, "%s: %s, %s ... " COL_GREEN "PASSED\n" COL_STOP, - preamble, desc, comment); - return 1; - } else { - print_failed(preamble, desc, comment); - fprintf(stderr, " Didn't expect: \"%s\", but got it\n", - not_expected); - gTestSuccess = 0; - return 0; - } -} - -int test_succ(int result, - const char *preamble, const char *desc, const char *comment) -{ - if (result == 0) { - print_passed(preamble, desc, comment); - } else { - print_failed(preamble, desc, comment); - fprintf(stderr, " Expected SUCCESS, got: %#x (%d)\n", - result, result); - gTestSuccess = 0; - } - return !result; -} - -int test_fail(int result, - const char *preamble, const char *desc, const char *comment) -{ - if (result != 0) { - print_passed(preamble, desc, comment); - } else { - print_failed(preamble, desc, comment); - fprintf(stderr, - " Didn't expect SUCCESS (0), but got it\n"); - gTestSuccess = 0; - } - return result; -} - -int test_true(int result, - const char *preamble, const char *desc, const char *comment) -{ - if (result) { - print_passed(preamble, desc, comment); - } else { - print_failed(preamble, desc, comment); - fprintf(stderr, " Expected TRUE, got 0\n"); - gTestSuccess = 0; - } - return result; -} - -int test_false(int result, - const char *preamble, const char *desc, const char *comment) -{ - if (!result) { - print_passed(preamble, desc, comment); - } else { - print_failed(preamble, desc, comment); - fprintf(stderr, " Expected FALSE, got: %#lx\n", - (long)result); - gTestSuccess = 0; - } - return !result; -} - -int test_abort(int aborted, - const char *preamble, const char *desc, const char *comment) -{ - if (aborted) { - print_passed(preamble, desc, comment); - } else { - print_failed(preamble, desc, comment); - fprintf(stderr, " Expected ABORT, but did not get it\n"); - gTestSuccess = 0; - } - return aborted; -} - -void vb2ex_abort(void) -{ - /* - * If expecting an abort call, jump back to TEST_ABORT macro. - * Otherwise, force exit to ensure the test fails. - */ - if (gTestAbortArmed) { - longjmp(gTestJmpEnv, 1); - } else { - fprintf(stderr, COL_RED "Unexpected ABORT encountered, " - "exiting\n" COL_STOP); - exit(1); - } -} diff --git a/tests/test_common.h b/tests/test_common.h deleted file mode 100644 index c3da8805..00000000 --- a/tests/test_common.h +++ /dev/null @@ -1,167 +0,0 @@ -/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef VBOOT_REFERENCE_TEST_COMMON_H_ -#define VBOOT_REFERENCE_TEST_COMMON_H_ - -#include -#include - -/* Used to get a line number as a constant string. Need to stringify it twice */ -#define STRINGIFY(x) #x -#define TOSTRING(x) STRINGIFY(x) - -extern int gTestSuccess; -extern int gTestAbortArmed; -extern jmp_buf gTestJmpEnv; - -/* Return 1 if result is equal to expected_result, else return 0. - * Also update the global gTestSuccess flag if test fails. */ -int test_eq(int result, int expected, - const char *preamble, const char *desc, const char *comment); - -#define TEST_EQ(result, expected, comment) \ - test_eq(result, expected, \ - __FILE__ ":" TOSTRING(__LINE__), \ - #result " == " #expected, \ - comment) - -#define TEST_EQ_S(result, expected) TEST_EQ(result, expected, NULL); - -/* Return 0 if result is equal to not_expected_result, else return 1. - * Also update the global gTestSuccess flag if test fails. */ -int test_neq(int result, int not_expected, - const char *preamble, const char *desc, const char *comment); - -#define TEST_NEQ(result, not_expected, comment) \ - test_neq(result, not_expected, \ - __FILE__ ":" TOSTRING(__LINE__), \ - #result " != " #not_expected, \ - comment) - -/* Return 1 if result pointer is equal to expected_result pointer, - * else return 0. Does not check pointer contents, only the pointer - * itself. Also update the global gTestSuccess flag if test fails. */ -int test_ptr_eq(const void* result, const void* expected, - const char *preamble, const char *desc, const char *comment); - -#define TEST_PTR_EQ(result, expected, comment) \ - test_ptr_eq(result, expected, \ - __FILE__ ":" TOSTRING(__LINE__), \ - #result " == " #expected, \ - comment) - -/* Return 1 if result pointer is not equal to expected_result pointer, - * else return 0. Does not check pointer contents, only the pointer - * itself. Also update the global gTestSuccess flag if test fails. */ -int test_ptr_neq(const void* result, const void* not_expected, - const char *preamble, const char *desc, const char *comment); - -#define TEST_PTR_NEQ(result, not_expected, comment) \ - test_ptr_neq(result, not_expected, \ - __FILE__ ":" TOSTRING(__LINE__), \ - #result " != " #not_expected, \ - comment) - -/* Return 1 if result string is equal to expected_result string, - * else return 0. Also update the global gTestSuccess flag if test fails. */ -int test_str_eq(const char* result, const char* expected, - const char *preamble, const char *desc, const char *comment); - -#define TEST_STR_EQ(result, expected, comment) \ - test_str_eq(result, expected, \ - __FILE__ ":" TOSTRING(__LINE__), \ - #result " == " #expected, \ - comment) - -/* Return 1 if result string is not equal to not_expected string, - * else return 0. Also update the global gTestSuccess flag if test fails. */ -int test_str_neq(const char* result, const char* not_expected, - const char *preamble, const char *desc, const char *comment); - -#define TEST_STR_NEQ(result, not_expected, comment) \ - test_str_neq(result, not_expected, \ - __FILE__ ":" TOSTRING(__LINE__), \ - #result " != " #not_expected, \ - comment) - -/* Return 1 if the result is true, else return 0. - * Also update the global gTestSuccess flag if test fails. */ -int test_true(int result, - const char *preamble, const char *desc, const char *comment); - -#define TEST_TRUE(result, comment) \ - test_true(result, \ - __FILE__ ":" TOSTRING(__LINE__), \ - #result " == true", \ - comment) - -/* Return 1 if the result is false, else return 0. - * Also update the global gTestSuccess flag if test fails. */ -int test_false(int result, - const char *preamble, const char *desc, const char *comment); - -#define TEST_FALSE(result, comment) \ - test_false(result, \ - __FILE__ ":" TOSTRING(__LINE__), \ - #result " == false", \ - comment) - -/* Return 1 if result is 0 (VB2_SUCCESS or other), else return 0. - * Also update the global gTestSuccess flag if test fails. */ -int test_succ(int result, - const char *preamble, const char *desc, const char *comment); - -#define TEST_SUCC(result, comment) \ - test_succ(result, \ - __FILE__ ":" TOSTRING(__LINE__), \ - #result " == 0", \ - comment) - -/* Return 1 if result is not 0 (VB2_SUCCESS or other), else return 1. - * Also update the global gTestSuccess flag if test fails. */ -int test_fail(int result, - const char *preamble, const char *desc, const char *comment); - -#define TEST_FAIL(result, comment) \ - test_fail(result, \ - __FILE__ ":" TOSTRING(__LINE__), \ - #result " != 0", \ - comment) - -/* Return 1 if vb2ex_abort() was called, else return 0. - * Also update the global gTestSuccess flag if test fails. */ -int test_abort(int aborted, - const char *preamble, const char *desc, const char *comment); - -#define TEST_ABORT(call, comment) do { \ - gTestAbortArmed = 1; \ - int jumped = setjmp(gTestJmpEnv); \ - if (!jumped) \ - call; \ - gTestAbortArmed = 0; \ - test_abort(jumped, \ - __FILE__ ":" TOSTRING(__LINE__), \ - #call " causes abort", \ - comment); \ -} while (0) - -/* ANSI Color coding sequences. - * - * Don't use \e as MSC does not recognize it as a valid escape sequence. - */ -#define COL_GREEN "\x1b[1;32m" -#define COL_YELLOW "\x1b[1;33m" -#define COL_RED "\x1b[0;31m" -#define COL_STOP "\x1b[m" - -/* Abort if asprintf fails. */ -#define xasprintf(...) \ - do { \ - if (asprintf(__VA_ARGS__) < 0) \ - abort(); \ - } while (0) - -#endif /* VBOOT_REFERENCE_TEST_COMMON_H_ */ diff --git a/tests/timer_utils.c b/tests/timer_utils.c deleted file mode 100644 index 25e7503c..00000000 --- a/tests/timer_utils.c +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "timer_utils.h" - -void StartTimer(ClockTimerState* ct) { - clock_gettime(CLOCK_REALTIME, &ct->start_time); -} - -void StopTimer(ClockTimerState* ct) { - clock_gettime(CLOCK_REALTIME, &ct->end_time); -} - -uint32_t GetDurationMsecs(ClockTimerState* ct) { - uint64_t start = ((uint64_t) ct->start_time.tv_sec * 1000000000 + - (uint64_t) ct->start_time.tv_nsec); - uint64_t end = ((uint64_t) ct->end_time.tv_sec * 1000000000 + - (uint64_t) ct->end_time.tv_nsec); - uint64_t duration_msecs = (end - start) / 1000000U; /* Nanoseconds -> - * Milliseconds. */ - return (uint32_t) duration_msecs; -} diff --git a/tests/timer_utils.h b/tests/timer_utils.h deleted file mode 100644 index 8cafdf91..00000000 --- a/tests/timer_utils.h +++ /dev/null @@ -1,26 +0,0 @@ - /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef VBOOT_REFERENCE_TIMER_UTILS_H_ -#define VBOOT_REFERENCE_TIMER_UTILS_H_ - -#include -#include - -typedef struct ClockTimer { - struct timespec start_time; - struct timespec end_time; -} ClockTimerState; - -/* Start timer and update [ct]. */ -void StartTimer(ClockTimerState* ct); - -/* Stop timer and update [ct]. */ -void StopTimer(ClockTimerState* ct); - -/* Get duration in milliseconds. */ -uint32_t GetDurationMsecs(ClockTimerState* ct); - -#endif /* VBOOT_REFERENCE_TIMER_UTILS_H_ */ diff --git a/tests/tlcl_tests.c b/tests/tlcl_tests.c index 328abbed..62d34afc 100644 --- a/tests/tlcl_tests.c +++ b/tests/tlcl_tests.c @@ -11,8 +11,8 @@ #include #include "2api.h" +#include "common/tests.h" #include "host_common.h" -#include "test_common.h" #include "tlcl.h" #include "tlcl_internal.h" diff --git a/tests/tpm_lite/tpmtest_fastenable.c b/tests/tpm_lite/tpmtest_fastenable.c index a93dfd77..226a41f2 100644 --- a/tests/tpm_lite/tpmtest_fastenable.c +++ b/tests/tpm_lite/tpmtest_fastenable.c @@ -15,7 +15,7 @@ #include #include "host_common.h" -#include "test_common.h" +#include "common/tests.h" #include "tlcl.h" #include "tlcl_tests.h" diff --git a/tests/tpm_lite/tpmtest_globallock.c b/tests/tpm_lite/tpmtest_globallock.c index 14f16de0..52f7c8ea 100644 --- a/tests/tpm_lite/tpmtest_globallock.c +++ b/tests/tpm_lite/tpmtest_globallock.c @@ -11,7 +11,7 @@ #include #include "host_common.h" -#include "test_common.h" +#include "common/tests.h" #include "tlcl.h" #include "tlcl_tests.h" diff --git a/tests/tpm_lite/tpmtest_redefine_unowned.c b/tests/tpm_lite/tpmtest_redefine_unowned.c index 0f89870d..45bcd933 100644 --- a/tests/tpm_lite/tpmtest_redefine_unowned.c +++ b/tests/tpm_lite/tpmtest_redefine_unowned.c @@ -11,7 +11,7 @@ #include #include "host_common.h" -#include "test_common.h" +#include "common/tests.h" #include "tlcl.h" #include "tlcl_tests.h" diff --git a/tests/tpm_lite/tpmtest_spaceperm.c b/tests/tpm_lite/tpmtest_spaceperm.c index 8c9232b2..70f2b992 100644 --- a/tests/tpm_lite/tpmtest_spaceperm.c +++ b/tests/tpm_lite/tpmtest_spaceperm.c @@ -11,7 +11,7 @@ #include #include "host_common.h" -#include "test_common.h" +#include "common/tests.h" #include "tlcl.h" #include "tlcl_tests.h" diff --git a/tests/tpm_lite/tpmtest_writelimit.c b/tests/tpm_lite/tpmtest_writelimit.c index 05e4a178..71562b06 100644 --- a/tests/tpm_lite/tpmtest_writelimit.c +++ b/tests/tpm_lite/tpmtest_writelimit.c @@ -12,7 +12,7 @@ #include "2common.h" #include "host_common.h" -#include "test_common.h" +#include "common/tests.h" #include "tlcl.h" #include "tlcl_tests.h" diff --git a/tests/vb20_api_kernel_tests.c b/tests/vb20_api_kernel_tests.c index b835251f..bc585b48 100644 --- a/tests/vb20_api_kernel_tests.c +++ b/tests/vb20_api_kernel_tests.c @@ -14,7 +14,7 @@ #include "2rsa.h" #include "2secdata.h" #include "2sysincludes.h" -#include "test_common.h" +#include "common/tests.h" #include "vboot_struct.h" /* Common context for tests */ diff --git a/tests/vb20_kernel_tests.c b/tests/vb20_kernel_tests.c index 8766114a..05f21ab6 100644 --- a/tests/vb20_kernel_tests.c +++ b/tests/vb20_kernel_tests.c @@ -14,7 +14,7 @@ #include "2rsa.h" #include "2secdata.h" #include "2sysincludes.h" -#include "test_common.h" +#include "common/tests.h" /* Common context for tests */ static uint8_t workbuf[VB2_KERNEL_WORKBUF_RECOMMENDED_SIZE] diff --git a/tests/vb20_rsa_padding_tests.c b/tests/vb20_rsa_padding_tests.c index 90ff42ae..68c32a9a 100644 --- a/tests/vb20_rsa_padding_tests.c +++ b/tests/vb20_rsa_padding_tests.c @@ -9,10 +9,10 @@ #include "2common.h" #include "2rsa.h" #include "2sysincludes.h" +#include "common/tests.h" #include "file_keys.h" #include "host_key.h" #include "rsa_padding_test.h" -#include "test_common.h" vb2_error_t hwcrypto_modexp_return_value = VB2_SUCCESS; vb2_error_t vb2ex_hwcrypto_modexp(const struct vb2_public_key *key, diff --git a/tests/vb21_host_common2_tests.c b/tests/vb21_host_common2_tests.c index b2ceb95f..61ba9866 100644 --- a/tests/vb21_host_common2_tests.c +++ b/tests/vb21_host_common2_tests.c @@ -12,11 +12,11 @@ #include "2common.h" #include "2rsa.h" #include "2sysincludes.h" +#include "common/tests.h" #include "host_common.h" #include "host_common21.h" #include "host_key21.h" #include "host_signature21.h" -#include "test_common.h" #include "util_misc.h" static const uint8_t test_data[] = "This is some test data to sign."; diff --git a/tests/vb21_host_common_tests.c b/tests/vb21_host_common_tests.c index 3ab5dbc3..385a0c2c 100644 --- a/tests/vb21_host_common_tests.c +++ b/tests/vb21_host_common_tests.c @@ -8,10 +8,10 @@ #include "2common.h" #include "2rsa.h" #include "2sysincludes.h" +#include "common/tests.h" #include "host_common21.h" #include "host_key21.h" #include "host_signature21.h" -#include "test_common.h" static const uint8_t test_data[] = "This is some test data to sign."; diff --git a/tests/vb21_host_key_tests.c b/tests/vb21_host_key_tests.c index e8eef9b3..e0a11055 100644 --- a/tests/vb21_host_key_tests.c +++ b/tests/vb21_host_key_tests.c @@ -11,10 +11,10 @@ #include "2common.h" #include "2rsa.h" #include "2sysincludes.h" +#include "common/tests.h" #include "host_common.h" #include "host_common21.h" #include "host_key21.h" -#include "test_common.h" /* Test only the algorithms we use */ struct alg_combo { diff --git a/tests/vb21_host_misc_tests.c b/tests/vb21_host_misc_tests.c index f437803c..dbf12e0c 100644 --- a/tests/vb21_host_misc_tests.c +++ b/tests/vb21_host_misc_tests.c @@ -10,10 +10,10 @@ #include "2common.h" #include "2sysincludes.h" +#include "common/tests.h" #include "host_common.h" #include "host_common21.h" #include "host_misc.h" -#include "test_common.h" static void misc_tests(void) { diff --git a/tests/vb21_host_sig_tests.c b/tests/vb21_host_sig_tests.c index f337eaa4..4a9abffa 100644 --- a/tests/vb21_host_sig_tests.c +++ b/tests/vb21_host_sig_tests.c @@ -11,11 +11,11 @@ #include "2common.h" #include "2rsa.h" #include "2sysincludes.h" +#include "common/tests.h" #include "host_common.h" #include "host_common21.h" #include "host_key21.h" #include "host_signature21.h" -#include "test_common.h" /* Test only the algorithms we use */ struct alg_combo { diff --git a/tests/vb2_api_tests.c b/tests/vb2_api_tests.c index ff7fa18c..ca2f7e93 100644 --- a/tests/vb2_api_tests.c +++ b/tests/vb2_api_tests.c @@ -14,7 +14,7 @@ #include "2rsa.h" #include "2secdata.h" #include "2sysincludes.h" -#include "test_common.h" +#include "common/tests.h" /* Common context for tests */ diff --git a/tests/vb2_auxfw_sync_tests.c b/tests/vb2_auxfw_sync_tests.c index 9cd4999d..bb236be8 100644 --- a/tests/vb2_auxfw_sync_tests.c +++ b/tests/vb2_auxfw_sync_tests.c @@ -13,9 +13,9 @@ #include "2misc.h" #include "2nvstorage.h" #include "2sysincludes.h" +#include "common/tests.h" #include "host_common.h" #include "load_kernel_fw.h" -#include "test_common.h" #include "vboot_struct.h" /* Mock data */ diff --git a/tests/vb2_common2_tests.c b/tests/vb2_common2_tests.c index 5f065f8f..e793e57a 100644 --- a/tests/vb2_common2_tests.c +++ b/tests/vb2_common2_tests.c @@ -12,10 +12,10 @@ #include "2common.h" #include "2rsa.h" #include "2sysincludes.h" +#include "common/tests.h" #include "file_keys.h" #include "host_common.h" #include "host_key21.h" -#include "test_common.h" static const uint8_t test_data[] = "This is some test data to sign."; static const uint32_t test_size = sizeof(test_data); diff --git a/tests/vb2_common3_tests.c b/tests/vb2_common3_tests.c index 58052040..8e7a20c6 100644 --- a/tests/vb2_common3_tests.c +++ b/tests/vb2_common3_tests.c @@ -10,12 +10,12 @@ #include "2common.h" #include "2rsa.h" #include "2sysincludes.h" +#include "common/tests.h" #include "file_keys.h" #include "host_common.h" #include "host_keyblock.h" #include "host_key.h" #include "host_signature.h" -#include "test_common.h" static void resign_keyblock(struct vb2_keyblock *h, const struct vb2_private_key *key) diff --git a/tests/vb2_common_tests.c b/tests/vb2_common_tests.c index d76c4023..beb84610 100644 --- a/tests/vb2_common_tests.c +++ b/tests/vb2_common_tests.c @@ -7,7 +7,7 @@ #include "2common.h" #include "2sysincludes.h" -#include "test_common.h" +#include "common/tests.h" #include "vboot_struct.h" /* For old struct sizes */ /* Mock data */ diff --git a/tests/vb2_crypto_tests.c b/tests/vb2_crypto_tests.c index c7d66760..6696feb2 100644 --- a/tests/vb2_crypto_tests.c +++ b/tests/vb2_crypto_tests.c @@ -12,7 +12,7 @@ #include "2rsa.h" #include "2sha.h" #include "2sysincludes.h" -#include "test_common.h" +#include "common/tests.h" #include "vboot_host.h" static void hash_algorithm_name_tests(void) diff --git a/tests/vb2_ec_sync_tests.c b/tests/vb2_ec_sync_tests.c index f4631b7f..4afc5ef0 100644 --- a/tests/vb2_ec_sync_tests.c +++ b/tests/vb2_ec_sync_tests.c @@ -10,9 +10,9 @@ #include "2nvstorage.h" #include "2secdata.h" #include "2sysincludes.h" +#include "common/tests.h" #include "host_common.h" #include "load_kernel_fw.h" -#include "test_common.h" #include "vboot_struct.h" /* Mock data */ diff --git a/tests/vb2_firmware_tests.c b/tests/vb2_firmware_tests.c index 681e5d67..933f6085 100644 --- a/tests/vb2_firmware_tests.c +++ b/tests/vb2_firmware_tests.c @@ -14,7 +14,7 @@ #include "2rsa.h" #include "2secdata.h" #include "2sysincludes.h" -#include "test_common.h" +#include "common/tests.h" /* Common context for tests */ static uint8_t workbuf[VB2_FIRMWARE_WORKBUF_RECOMMENDED_SIZE] diff --git a/tests/vb2_gbb_tests.c b/tests/vb2_gbb_tests.c index 047fa423..51ebcf6a 100644 --- a/tests/vb2_gbb_tests.c +++ b/tests/vb2_gbb_tests.c @@ -7,7 +7,7 @@ #include "2common.h" #include "2misc.h" -#include "test_common.h" +#include "common/tests.h" /* Mock data */ static char gbb_data[4096 + sizeof(struct vb2_gbb_header)]; diff --git a/tests/vb2_host_flashrom_tests.c b/tests/vb2_host_flashrom_tests.c index 815657d4..7cebc5ed 100644 --- a/tests/vb2_host_flashrom_tests.c +++ b/tests/vb2_host_flashrom_tests.c @@ -18,10 +18,10 @@ #include "2common.h" #include "2return_codes.h" +#include "common/tests.h" #include "host_misc.h" #include "flashrom.h" #include "subprocess.h" -#include "test_common.h" #define MOCK_TMPFILE_NAME "/tmp/vb2_unittest" #define MOCK_ROM_CONTENTS "bloop123" diff --git a/tests/vb2_host_key_tests.c b/tests/vb2_host_key_tests.c index 82dd3572..9c6fe284 100644 --- a/tests/vb2_host_key_tests.c +++ b/tests/vb2_host_key_tests.c @@ -6,8 +6,8 @@ */ #include "2common.h" +#include "common/tests.h" #include "host_common.h" -#include "test_common.h" /* Public key utility functions */ static void public_key_tests(void) diff --git a/tests/vb2_host_nvdata_flashrom_tests.c b/tests/vb2_host_nvdata_flashrom_tests.c index 068b23a4..719f1d19 100644 --- a/tests/vb2_host_nvdata_flashrom_tests.c +++ b/tests/vb2_host_nvdata_flashrom_tests.c @@ -17,9 +17,9 @@ #include "2constants.h" #include "2nvstorage.h" #include "2return_codes.h" +#include "common/tests.h" #include "crossystem_vbnv.h" #include "flashrom.h" -#include "test_common.h" /* Mocked flashrom only supports host programmer, and RW_NVRAM region. */ diff --git a/tests/vb2_kernel2_tests.c b/tests/vb2_kernel2_tests.c index f42c0f78..b3477411 100644 --- a/tests/vb2_kernel2_tests.c +++ b/tests/vb2_kernel2_tests.c @@ -11,9 +11,9 @@ #include "2nvstorage.h" #include "2secdata.h" #include "2sysincludes.h" +#include "common/tests.h" #include "host_common.h" #include "load_kernel_fw.h" -#include "test_common.h" #include "tlcl.h" #include "tss_constants.h" #include "vboot_struct.h" diff --git a/tests/vb2_kernel_tests.c b/tests/vb2_kernel_tests.c index d5e6b55a..5d857e4e 100644 --- a/tests/vb2_kernel_tests.c +++ b/tests/vb2_kernel_tests.c @@ -12,7 +12,7 @@ #include "2rsa.h" #include "2secdata.h" #include "2sysincludes.h" -#include "test_common.h" +#include "common/tests.h" #include "vboot_struct.h" #include "vboot_api.h" diff --git a/tests/vb2_misc2_tests.c b/tests/vb2_misc2_tests.c index a4ed5789..403e2f6f 100644 --- a/tests/vb2_misc2_tests.c +++ b/tests/vb2_misc2_tests.c @@ -9,7 +9,7 @@ #include "2common.h" #include "2misc.h" #include "2nvstorage.h" -#include "test_common.h" +#include "common/tests.h" /* Mock data */ diff --git a/tests/vb2_misc_tests.c b/tests/vb2_misc_tests.c index 99f8bae4..d882743f 100644 --- a/tests/vb2_misc_tests.c +++ b/tests/vb2_misc_tests.c @@ -11,7 +11,7 @@ #include "2nvstorage.h" #include "2secdata.h" #include "2sysincludes.h" -#include "test_common.h" +#include "common/tests.h" /* Common context for tests */ static uint8_t workbuf[VB2_FIRMWARE_WORKBUF_RECOMMENDED_SIZE] diff --git a/tests/vb2_nvstorage_tests.c b/tests/vb2_nvstorage_tests.c index 94bcfcab..8734f72f 100644 --- a/tests/vb2_nvstorage_tests.c +++ b/tests/vb2_nvstorage_tests.c @@ -16,7 +16,7 @@ #include "2nvstorage_fields.h" #include "2nvstorage.h" #include "2sysincludes.h" -#include "test_common.h" +#include "common/tests.h" /* Single NV storage field to test */ struct nv_field { diff --git a/tests/vb2_recovery_reasons_tests.c b/tests/vb2_recovery_reasons_tests.c index 5def4d21..8d05862b 100644 --- a/tests/vb2_recovery_reasons_tests.c +++ b/tests/vb2_recovery_reasons_tests.c @@ -6,7 +6,7 @@ */ #include "2recovery_reasons.h" -#include "test_common.h" +#include "common/tests.h" static void get_recovery_reason_string_tests(void) { diff --git a/tests/vb2_rsa_utility_tests.c b/tests/vb2_rsa_utility_tests.c index 18347348..057b4b09 100644 --- a/tests/vb2_rsa_utility_tests.c +++ b/tests/vb2_rsa_utility_tests.c @@ -10,9 +10,9 @@ #include "2rsa.h" #include "2rsa_private.h" #include "2sysincludes.h" +#include "common/tests.h" #include "file_keys.h" #include "rsa_padding_test.h" -#include "test_common.h" #include "vboot_api.h" /** diff --git a/tests/vb2_secdata_firmware_tests.c b/tests/vb2_secdata_firmware_tests.c index c1b0a73f..0520cc0f 100644 --- a/tests/vb2_secdata_firmware_tests.c +++ b/tests/vb2_secdata_firmware_tests.c @@ -12,7 +12,7 @@ #include "2secdata.h" #include "2secdata_struct.h" #include "2sysincludes.h" -#include "test_common.h" +#include "common/tests.h" static uint8_t workbuf[VB2_FIRMWARE_WORKBUF_RECOMMENDED_SIZE] __attribute__((aligned(VB2_WORKBUF_ALIGN))); diff --git a/tests/vb2_secdata_fwmp_tests.c b/tests/vb2_secdata_fwmp_tests.c index 79b0f55f..eabe671c 100644 --- a/tests/vb2_secdata_fwmp_tests.c +++ b/tests/vb2_secdata_fwmp_tests.c @@ -9,7 +9,7 @@ #include "2misc.h" #include "2secdata.h" #include "2secdata_struct.h" -#include "test_common.h" +#include "common/tests.h" static uint8_t workbuf[VB2_FIRMWARE_WORKBUF_RECOMMENDED_SIZE] __attribute__((aligned(VB2_WORKBUF_ALIGN))); diff --git a/tests/vb2_secdata_kernel_tests.c b/tests/vb2_secdata_kernel_tests.c index 5ac63ee5..a84e04e1 100644 --- a/tests/vb2_secdata_kernel_tests.c +++ b/tests/vb2_secdata_kernel_tests.c @@ -12,7 +12,7 @@ #include "2secdata.h" #include "2secdata_struct.h" #include "2sysincludes.h" -#include "test_common.h" +#include "common/tests.h" static uint8_t workbuf[VB2_FIRMWARE_WORKBUF_RECOMMENDED_SIZE] __attribute__((aligned(VB2_WORKBUF_ALIGN))); diff --git a/tests/vb2_sha256_x86_tests.c b/tests/vb2_sha256_x86_tests.c index 06ba12e1..e17d3951 100644 --- a/tests/vb2_sha256_x86_tests.c +++ b/tests/vb2_sha256_x86_tests.c @@ -10,8 +10,8 @@ #include "2api.h" #include "2sha.h" +#include "common/tests.h" #include "sha_test_vectors.h" -#include "test_common.h" vb2_error_t vb2_digest_buffer(const uint8_t *buf, uint32_t size, enum vb2_hash_algorithm hash_alg, uint8_t *digest, diff --git a/tests/vb2_sha_api_tests.c b/tests/vb2_sha_api_tests.c index cb58f7bc..6ed0b74b 100644 --- a/tests/vb2_sha_api_tests.c +++ b/tests/vb2_sha_api_tests.c @@ -8,7 +8,7 @@ #include "2return_codes.h" #include "2sha.h" #include "2sysincludes.h" -#include "test_common.h" +#include "common/tests.h" uint8_t mock_sha1[] = {0x1, 0x3, 0x5, 0x2, 0x4, 0x6, 0xa, 0xb, 0xc, 0xd, 0xd, 0xe, 0xa, 0xd, 0xb, 0xe, 0xe, 0xf, 0x0, 0xf0}; diff --git a/tests/vb2_sha_tests.c b/tests/vb2_sha_tests.c index a14af65c..40cf42f5 100644 --- a/tests/vb2_sha_tests.c +++ b/tests/vb2_sha_tests.c @@ -11,8 +11,8 @@ #include "2rsa.h" #include "2sha.h" #include "2sysincludes.h" +#include "common/tests.h" #include "sha_test_vectors.h" -#include "test_common.h" static void sha1_tests(void) { diff --git a/tests/vboot_api_kernel_tests.c b/tests/vboot_api_kernel_tests.c index f885cd86..5c1d0182 100644 --- a/tests/vboot_api_kernel_tests.c +++ b/tests/vboot_api_kernel_tests.c @@ -9,8 +9,8 @@ #include "2misc.h" #include "2nvstorage.h" #include "2sysincludes.h" +#include "common/tests.h" #include "load_kernel_fw.h" -#include "test_common.h" #include "vboot_api.h" #define MAX_TEST_DISKS 10 diff --git a/tests/vboot_kernel2_tests.c b/tests/vboot_kernel2_tests.c index bbebf386..d402969c 100644 --- a/tests/vboot_kernel2_tests.c +++ b/tests/vboot_kernel2_tests.c @@ -10,8 +10,8 @@ #include "2misc.h" #include "2nvstorage.h" #include "2secdata.h" +#include "common/tests.h" #include "load_kernel_fw.h" -#include "test_common.h" #include "vboot_api.h" #define MAX_MOCK_KERNELS 10 diff --git a/tests/vboot_kernel_tests.c b/tests/vboot_kernel_tests.c index 1f77cc5c..afeb08d7 100644 --- a/tests/vboot_kernel_tests.c +++ b/tests/vboot_kernel_tests.c @@ -13,9 +13,9 @@ #include "2secdata_struct.h" #include "cgptlib.h" #include "cgptlib_internal.h" +#include "common/tests.h" #include "gpt.h" #include "load_kernel_fw.h" -#include "test_common.h" #include "vboot_api.h" /* Mock kernel partition */ -- cgit v1.2.1