diff options
author | Eric Lai <eric_lai@quanta.corp-partner.google.com> | 2022-04-15 11:20:38 +0800 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2022-11-03 13:00:15 +0000 |
commit | 01590227f2281c106008ad923bb4cdc5d4249fd5 (patch) | |
tree | 87e2f00d546bcd9a0b3ea98557c98574c54f7d9d /tests | |
parent | 29bc20f996a63cd1ccf9a422bafffa4bab66e317 (diff) |
test/lib: Add non-existent DIMMs test case in spd_cache-test
Add non-existent DIMMs test case in spd_cache-test.
BUG=b:213964936
TEST=make unit-tests PASSED
Signed-off-by: Eric Lai <eric_lai@quanta.corp-partner.google.com>
Change-Id: I3c8aa92ee0cfd5908399f4bbd305f8f306571d40
Reviewed-on: https://review.coreboot.org/c/coreboot/+/63643
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Paul Menzel <paulepanter@mailbox.org>
Reviewed-by: Tim Wawrzynczak <inforichland@gmail.com>
Reviewed-by: Jakub Czapiga <jacz@semihalf.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/spd_cache-test.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/lib/spd_cache-test.c b/tests/lib/spd_cache-test.c index 48f06e3883..b949d1b297 100644 --- a/tests/lib/spd_cache-test.c +++ b/tests/lib/spd_cache-test.c @@ -230,6 +230,25 @@ __attribute__((unused)) static void test_check_if_dimm_changed_sn_changed(void * assert_true(check_if_dimm_changed(spd_cache, &blk)); } +__attribute__((unused)) static void test_check_if_dimm_changed_with_nonexistent(void **state) +{ + uint8_t *spd_cache; + size_t spd_cache_sz; + struct spd_block blk = {.addr_map = {0x50, 0, 0, 0}, + .spd_array = {0}, .len = 0}; + + assert_int_equal(CB_SUCCESS, load_spd_cache(&spd_cache, &spd_cache_sz)); + memcpy(spd_cache, spd_data_ddr4_1, spd_data_ddr4_1_sz); + memset(spd_cache + spd_data_ddr4_1_sz, 0xff, spd_cache_sz - spd_data_ddr4_1_sz); + calc_spd_cache_crc(spd_cache); + assert_int_equal(CB_SUCCESS, spd_fill_from_cache(spd_cache, &blk)); + + get_sn_from_spd_cache(spd_cache, get_spd_sn_ret_sn); + get_spd_sn_ret_sn_idx = 0; + will_return_always(get_spd_sn, CB_SUCCESS); + assert_false(check_if_dimm_changed(spd_cache, &blk)); +} + int main(void) { const struct CMUnitTest tests[] = { @@ -247,6 +266,8 @@ int main(void) setup_spd_cache_test), cmocka_unit_test_setup(test_check_if_dimm_changed_sn_changed, setup_spd_cache_test), + cmocka_unit_test_setup(test_check_if_dimm_changed_with_nonexistent, + setup_spd_cache_test), #endif }; |