1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-07-01 14:11:15 +02:00

tests: Add init-shutdown test for nicrealtek

This patch adds a test and mocks for two pci functions that
nicreltek is using.

Main reason for this is to have at least one test for par master
(currently there are none), in preparation for a change like
CB:56103 but for par masters.

BUG=b:181803212
TEST=ninja test

Change-Id: Iaed14fe1d83c8eb45ec185ebd3f1c97cb81941f4
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/56470
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
This commit is contained in:
Anastasia Klimchuk
2021-07-21 14:53:16 +10:00
committed by Edward O'Callaghan
parent 56c82fe623
commit e0ece4a4bb
5 changed files with 34 additions and 0 deletions

View File

@ -89,6 +89,15 @@ void mec1308_init_and_shutdown_test_success(void **state)
#endif
}
void nicrealtek_init_and_shutdown_test_success(void **state)
{
#if CONFIG_NICREALTEK == 1
run_lifecycle(state, &programmer_nicrealtek, "");
#else
skip();
#endif
}
int dediprog_libusb_control_transfer(void *state,
libusb_device_handle *devh,
uint8_t bmRequestType,

View File

@ -37,6 +37,11 @@ typedef struct libusb_device_handle libusb_device_handle;
struct libusb_context;
typedef struct libusb_context libusb_context;
/* Define struct pci_dev to avoid dependency on pci.h */
struct pci_dev {
unsigned int device_id;
};
struct io_mock {
void *state;

View File

@ -26,6 +26,8 @@ mocks = [
'-Wl,--wrap=strdup',
'-Wl,--wrap=physunmap',
'-Wl,--wrap=physmap',
'-Wl,--wrap=pcidev_init',
'-Wl,--wrap=pcidev_readbar',
'-Wl,--wrap=spi_send_command',
'-Wl,--wrap=sio_write',
'-Wl,--wrap=sio_read',

View File

@ -53,6 +53,22 @@ void *__wrap_physmap(const char *descr, uintptr_t phys_addr, size_t len)
return NULL;
}
struct pci_dev mock_pci_dev = {
.device_id = MOCK_HANDLE,
};
struct pci_dev *__wrap_pcidev_init(void *devs, int bar)
{
LOG_ME;
return &mock_pci_dev;
}
uintptr_t __wrap_pcidev_readbar(void *dev, int bar)
{
LOG_ME;
return MOCK_HANDLE;
}
void __wrap_sio_write(uint16_t port, uint8_t reg, uint8_t data)
{
LOG_ME;
@ -230,6 +246,7 @@ int main(void)
const struct CMUnitTest init_shutdown_tests[] = {
cmocka_unit_test(dummy_init_and_shutdown_test_success),
cmocka_unit_test(mec1308_init_and_shutdown_test_success),
cmocka_unit_test(nicrealtek_init_and_shutdown_test_success),
cmocka_unit_test(dediprog_init_and_shutdown_test_success),
cmocka_unit_test(ene_lpc_init_and_shutdown_test_success),
cmocka_unit_test(linux_spi_init_and_shutdown_test_success),

View File

@ -43,6 +43,7 @@ void probe_spi_st95_test_success(void **state); /* spi95.c */
/* init_shutdown.c */
void dummy_init_and_shutdown_test_success(void **state);
void mec1308_init_and_shutdown_test_success(void **state);
void nicrealtek_init_and_shutdown_test_success(void **state);
void dediprog_init_and_shutdown_test_success(void **state);
void ene_lpc_init_and_shutdown_test_success(void **state);
void linux_spi_init_and_shutdown_test_success(void **state);