diff options
author | Anastasia Klimchuk <aklm@chromium.org> | 2022-08-08 10:42:39 +1000 |
---|---|---|
committer | Anastasia Klimchuk <aklm@chromium.org> | 2022-08-10 23:53:11 +0000 |
commit | e18a528c6b399d4a330e77657ba64a72b09fcf23 (patch) | |
tree | 5fe3e770ffa91e663108a439dcf3b016d7a307ed | |
parent | 4adfd99d782ab825042f9225df05d360476f8e19 (diff) | |
download | flashrom-e18a528c6b399d4a330e77657ba64a72b09fcf23.tar.gz flashrom-e18a528c6b399d4a330e77657ba64a72b09fcf23.tar.bz2 flashrom-e18a528c6b399d4a330e77657ba64a72b09fcf23.zip |
tests: Test allow_brick is required for i2c programmers init
Add tests for i2c programmers that assert that initialisation fails
when allow_brick parameter is not provided.
Example of logs from test run:
[ RUN ] parade_lspcon_no_allow_brick_test_success
Testing init error path for programmer=parade_lspcon with params: bus=254 ...
... init failed with error code -1 as expected
[ OK ] parade_lspcon_no_allow_brick_test_success
BUG=b:181803212
TEST=ninja test
Change-Id: I382f563016502f3342131d5f9c0de41dc665b03a
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66508
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Felix Singer <felixsinger@posteo.net>
Reviewed-by: Thomas Heijligen <src@posteo.de>
-rw-r--r-- | tests/mediatek_i2c_spi.c | 16 | ||||
-rw-r--r-- | tests/parade_lspcon.c | 16 | ||||
-rw-r--r-- | tests/realtek_mst_i2c_spi.c | 16 | ||||
-rw-r--r-- | tests/tests.c | 3 | ||||
-rw-r--r-- | tests/tests.h | 3 |
5 files changed, 54 insertions, 0 deletions
diff --git a/tests/mediatek_i2c_spi.c b/tests/mediatek_i2c_spi.c index caf69808..d2780bc9 100644 --- a/tests/mediatek_i2c_spi.c +++ b/tests/mediatek_i2c_spi.c @@ -31,6 +31,22 @@ void mediatek_i2c_spi_basic_lifecycle_test_success(void **state) run_basic_lifecycle(state, &mediatek_i2c_spi_io, &programmer_mediatek_i2c_spi, "bus=254,allow_brick=yes"); } +void mediatek_i2c_no_allow_brick_test_success(void **state) +{ + struct io_mock_fallback_open_state mediatek_i2c_spi_fallback_open_state = { + .noc = 0, + .paths = { "/dev/i2c-254", NULL }, + .flags = { O_RDWR }, + }; + const struct io_mock mediatek_i2c_spi_io = { + .fallback_open_state = &mediatek_i2c_spi_fallback_open_state, + }; + + run_init_error_path(state, &mediatek_i2c_spi_io, &programmer_mediatek_i2c_spi, + "bus=254", SPI_GENERIC_ERROR); +} + #else SKIP_TEST(mediatek_i2c_spi_basic_lifecycle_test_success) + SKIP_TEST(mediatek_i2c_no_allow_brick_test_success) #endif /* CONFIG_MEDIATEK_I2C_SPI */ diff --git a/tests/parade_lspcon.c b/tests/parade_lspcon.c index cb9adb43..478e296d 100644 --- a/tests/parade_lspcon.c +++ b/tests/parade_lspcon.c @@ -31,6 +31,22 @@ void parade_lspcon_basic_lifecycle_test_success(void **state) run_basic_lifecycle(state, ¶de_lspcon_io, &programmer_parade_lspcon, "bus=254,allow_brick=yes"); } +void parade_lspcon_no_allow_brick_test_success(void **state) +{ + struct io_mock_fallback_open_state parade_lspcon_fallback_open_state = { + .noc = 0, + .paths = { "/dev/i2c-254", NULL }, + .flags = { O_RDWR }, + }; + const struct io_mock parade_lspcon_io = { + .fallback_open_state = ¶de_lspcon_fallback_open_state, + }; + + run_init_error_path(state, ¶de_lspcon_io, &programmer_parade_lspcon, + "bus=254", SPI_GENERIC_ERROR); +} + #else SKIP_TEST(parade_lspcon_basic_lifecycle_test_success) + SKIP_TEST(parade_lspcon_no_allow_brick_test_success) #endif /* CONFIG_PARADE_LSPCON */ diff --git a/tests/realtek_mst_i2c_spi.c b/tests/realtek_mst_i2c_spi.c index 85ebc13c..50512abb 100644 --- a/tests/realtek_mst_i2c_spi.c +++ b/tests/realtek_mst_i2c_spi.c @@ -58,6 +58,22 @@ void realtek_mst_basic_lifecycle_test_success(void **state) run_basic_lifecycle(state, &realtek_mst_io, &programmer_realtek_mst_i2c_spi, "bus=254,enter_isp=0,allow_brick=yes"); } + +void realtek_mst_no_allow_brick_test_success(void **state) +{ + struct io_mock_fallback_open_state realtek_mst_fallback_open_state = { + .noc = 0, + .paths = { "/dev/i2c-254", NULL }, + .flags = { O_RDWR }, + }; + const struct io_mock realtek_mst_io = { + .fallback_open_state = &realtek_mst_fallback_open_state, + }; + + run_init_error_path(state, &realtek_mst_io, &programmer_realtek_mst_i2c_spi, + "bus=254,enter_isp=0", SPI_GENERIC_ERROR); +} #else SKIP_TEST(realtek_mst_basic_lifecycle_test_success) + SKIP_TEST(realtek_mst_no_allow_brick_test_success) #endif /* CONFIG_REALTEK_I2C_SPI */ diff --git a/tests/tests.c b/tests/tests.c index 2a54aab3..2994c022 100644 --- a/tests/tests.c +++ b/tests/tests.c @@ -416,8 +416,11 @@ int main(int argc, char *argv[]) cmocka_unit_test(linux_mtd_probe_lifecycle_test_success), cmocka_unit_test(linux_spi_probe_lifecycle_test_success), cmocka_unit_test(parade_lspcon_basic_lifecycle_test_success), + cmocka_unit_test(parade_lspcon_no_allow_brick_test_success), cmocka_unit_test(mediatek_i2c_spi_basic_lifecycle_test_success), + cmocka_unit_test(mediatek_i2c_no_allow_brick_test_success), cmocka_unit_test(realtek_mst_basic_lifecycle_test_success), + cmocka_unit_test(realtek_mst_no_allow_brick_test_success), }; ret |= cmocka_run_group_tests_name("lifecycle.c tests", lifecycle_tests, NULL, NULL); diff --git a/tests/tests.h b/tests/tests.h index c279be90..4808b58b 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -51,8 +51,11 @@ void dediprog_basic_lifecycle_test_success(void **state); void linux_mtd_probe_lifecycle_test_success(void **state); void linux_spi_probe_lifecycle_test_success(void **state); void parade_lspcon_basic_lifecycle_test_success(void **state); +void parade_lspcon_no_allow_brick_test_success(void **state); void mediatek_i2c_spi_basic_lifecycle_test_success(void **state); +void mediatek_i2c_no_allow_brick_test_success(void **state); void realtek_mst_basic_lifecycle_test_success(void **state); +void realtek_mst_no_allow_brick_test_success(void **state); /* layout.c */ void included_regions_dont_overlap_test_success(void **state); |