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>
This commit is contained in:
		@@ -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));
 | 
						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)
 | 
					int main(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	const struct CMUnitTest tests[] = {
 | 
						const struct CMUnitTest tests[] = {
 | 
				
			||||||
@@ -247,6 +266,8 @@ int main(void)
 | 
				
			|||||||
				       setup_spd_cache_test),
 | 
									       setup_spd_cache_test),
 | 
				
			||||||
		cmocka_unit_test_setup(test_check_if_dimm_changed_sn_changed,
 | 
							cmocka_unit_test_setup(test_check_if_dimm_changed_sn_changed,
 | 
				
			||||||
				       setup_spd_cache_test),
 | 
									       setup_spd_cache_test),
 | 
				
			||||||
 | 
							cmocka_unit_test_setup(test_check_if_dimm_changed_with_nonexistent,
 | 
				
			||||||
 | 
									       setup_spd_cache_test),
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user