Felix Held has submitted this change. ( https://review.coreboot.org/c/coreboot/+/63643 )
Change subject: test/lib: Add non-existent DIMMs test case in spd_cache-test ......................................................................
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 --- M tests/lib/spd_cache-test.c 1 file changed, 41 insertions(+), 0 deletions(-)
Approvals: build bot (Jenkins): Verified Paul Menzel: Looks good to me, but someone else must approve Tim Wawrzynczak: Looks good to me, but someone else must approve Jakub Czapiga: Looks good to me, approved
diff --git a/tests/lib/spd_cache-test.c b/tests/lib/spd_cache-test.c index 48f06e3..b949d1b 100644 --- a/tests/lib/spd_cache-test.c +++ b/tests/lib/spd_cache-test.c @@ -230,6 +230,25 @@ 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 @@ 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 };