vboot: remove vboot1 version of ARRAY_SIZE macro

Macro already exists in vboot2-style 2common.h.
Relocate tests accordingly.

BUG=b:124141368
TEST=make clean && make runtests
BRANCH=none

Change-Id: I6b96627a05e8c05ff49b8780fe4472890c2a2043
Signed-off-by: Joel Kitching <kitching@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1675869
Reviewed-by: Joel Kitching <kitching@chromium.org>
Tested-by: Joel Kitching <kitching@chromium.org>
Commit-Queue: Joel Kitching <kitching@chromium.org>
This commit is contained in:
Joel Kitching 2019-06-25 16:11:45 +08:00 committed by Commit Bot
parent 9e9619fd4a
commit 98b00ae762
5 changed files with 17 additions and 18 deletions

View File

@ -11,10 +11,6 @@
#include "2api.h"
#include "vboot_struct.h"
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(array) (sizeof(array)/sizeof(array[0]))
#endif
/* Test an important condition at compile time, not run time */
#ifndef BUILD_ASSERT
#define _BA1_(cond, line) \

View File

@ -18,6 +18,7 @@
#include "2sysincludes.h"
#include "2api.h"
#include "2common.h"
#include "2nvstorage.h"
#include "host_common.h"
@ -26,7 +27,6 @@
#include "crossystem_arch.h"
#include "crossystem_vbnv.h"
#include "utility.h"
#include "vboot_common.h"
#include "vboot_struct.h"
/* Filename for kernel command line */

View File

@ -10,6 +10,20 @@
#include "test_common.h"
#include "vboot_struct.h" /* For old struct sizes */
/*
* Test array size macro.
*/
static void test_array_size(void)
{
uint8_t arr1[12];
uint32_t arr2[7];
uint64_t arr3[9];
TEST_EQ(ARRAY_SIZE(arr1), 12, "ARRAYSIZE(uint8_t)");
TEST_EQ(ARRAY_SIZE(arr2), 7, "ARRAYSIZE(uint32_t)");
TEST_EQ(ARRAY_SIZE(arr3), 9, "ARRAYSIZE(uint64_t)");
}
/*
* Test struct packing for vboot_struct.h structs which are passed between
* firmware and OS, or passed between different phases of firmware.
@ -218,6 +232,7 @@ static void test_helper_functions(void)
int main(int argc, char* argv[])
{
test_array_size();
test_struct_packing();
test_memcmp();
test_align();

View File

@ -11,6 +11,7 @@
#include "2sysincludes.h"
#include "2api.h"
#include "2common.h"
#include "2misc.h"
#include "2nvstorage.h"
#include "ec_sync.h"

View File

@ -40,18 +40,6 @@ static void StructPackingTest(void)
"sizeof(VbSharedDataHeader) V2");
}
/* Test array size macro */
static void ArraySizeTest(void)
{
uint8_t arr1[12];
uint32_t arr2[7];
uint64_t arr3[9];
TEST_EQ(ARRAY_SIZE(arr1), 12, "ARRAYSIZE(uint8_t)");
TEST_EQ(ARRAY_SIZE(arr2), 7, "ARRAYSIZE(uint32_t)");
TEST_EQ(ARRAY_SIZE(arr3), 9, "ARRAYSIZE(uint64_t)");
}
/* Helper functions not dependent on specific key sizes */
static void VerifyHelperFunctions(void)
{
@ -222,7 +210,6 @@ static void VbSharedDataTest(void)
int main(int argc, char* argv[])
{
StructPackingTest();
ArraySizeTest();
VerifyHelperFunctions();
PublicKeyTest();
VbSharedDataTest();