diff options
author | Daisuke Nojiri <dnojiri@chromium.org> | 2020-08-13 10:07:09 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-08-14 05:45:45 +0000 |
commit | 89d7fa59ea9674d8f7d561739f81cdb3d9c80774 (patch) | |
tree | 57cb96c69a2ee08353eb85b080f0d4d8ee8a7dff | |
parent | 41cfc8b01c3ea457e2b24349684c675f21ba9d6e (diff) | |
download | chrome-ec-89d7fa59ea9674d8f7d561739f81cdb3d9c80774.tar.gz |
CBI: Make test fail if a tag is missing from unit test
This patch adds a check in the unit test which fails if there is a tag
missing from test_all_tags. This will force developers to pay attension
to the unit test when adding a new tag.
BUG=none
BRANCH=none
TEST=buildall
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Change-Id: I34d054493e16454c3662b289eaa6d4de362a26f4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2354200
-rw-r--r-- | test/cbi.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/cbi.c b/test/cbi.c index 936dc204b8..f0fe68f162 100644 --- a/test/cbi.c +++ b/test/cbi.c @@ -8,6 +8,7 @@ #include "common.h" #include "console.h" #include "cros_board_info.h" +#include "ec_commands.h" #include "gpio.h" #include "i2c.h" #include "test_util.h" @@ -125,29 +126,60 @@ static int test_all_tags(void) { uint8_t d8; uint32_t d32; + const char string[] = "abc"; + uint8_t buf[32]; + uint8_t size; + int count = 0; /* Populate all data and read out */ d8 = 0x12; TEST_ASSERT(cbi_set_board_info(CBI_TAG_BOARD_VERSION, &d8, sizeof(d8)) == EC_SUCCESS); + count++; TEST_ASSERT(cbi_set_board_info(CBI_TAG_OEM_ID, &d8, sizeof(d8)) == EC_SUCCESS); + count++; TEST_ASSERT(cbi_set_board_info(CBI_TAG_SKU_ID, &d8, sizeof(d8)) == EC_SUCCESS); + count++; + TEST_ASSERT(cbi_set_board_info(CBI_TAG_DRAM_PART_NUM, + string, sizeof(string)) + == EC_SUCCESS); + count++; + TEST_ASSERT(cbi_set_board_info(CBI_TAG_OEM_NAME, + string, sizeof(string)) + == EC_SUCCESS); + count++; TEST_ASSERT(cbi_set_board_info(CBI_TAG_MODEL_ID, &d8, sizeof(d8)) == EC_SUCCESS); + count++; TEST_ASSERT(cbi_set_board_info(CBI_TAG_FW_CONFIG, &d8, sizeof(d8)) == EC_SUCCESS); + count++; TEST_ASSERT(cbi_set_board_info(CBI_TAG_PCB_SUPPLIER, &d8, sizeof(d8)) == EC_SUCCESS); + count++; TEST_ASSERT(cbi_set_board_info(CBI_TAG_SSFC, &d8, sizeof(d8)) == EC_SUCCESS); + count++; + + /* Read out all */ TEST_ASSERT(cbi_get_board_version(&d32) == EC_SUCCESS); TEST_EQ(d32, d8, "0x%x"); TEST_ASSERT(cbi_get_oem_id(&d32) == EC_SUCCESS); TEST_EQ(d32, d8, "0x%x"); TEST_ASSERT(cbi_get_sku_id(&d32) == EC_SUCCESS); TEST_EQ(d32, d8, "0x%x"); + size = sizeof(buf); + TEST_ASSERT(cbi_get_board_info(CBI_TAG_DRAM_PART_NUM, buf, &size) + == EC_SUCCESS); + TEST_ASSERT(strncmp(buf, string, sizeof(string)) == 0); + TEST_EQ((size_t)size - 1, strlen(buf), "%zu"); + size = sizeof(buf); + TEST_ASSERT(cbi_get_board_info(CBI_TAG_OEM_NAME, buf, &size) + == EC_SUCCESS); + TEST_ASSERT(strncmp(buf, string, sizeof(string)) == 0); + TEST_EQ((size_t)size - 1, strlen(buf), "%zu"); TEST_ASSERT(cbi_get_model_id(&d32) == EC_SUCCESS); TEST_EQ(d32, d8, "0x%x"); TEST_ASSERT(cbi_get_fw_config(&d32) == EC_SUCCESS); @@ -157,6 +189,9 @@ static int test_all_tags(void) TEST_ASSERT(cbi_get_ssfc(&d32) == EC_SUCCESS); TEST_EQ(d32, d8, "0x%x"); + /* Fail if a (new) tag is missing from the unit test. */ + TEST_EQ(count, CBI_TAG_COUNT, "%d"); + /* Write protect */ gpio_set_level(GPIO_WP, 1); TEST_ASSERT(cbi_write() == EC_ERROR_ACCESS_DENIED); |