From 47541722c16a59fcc574397d5413ddc1b4a11cde Mon Sep 17 00:00:00 2001 From: Anastasia Klimchuk Date: Wed, 20 Jul 2022 15:24:51 +1000 Subject: tests: Add basic lifecycle test for parade_lspcon This unit test does not require any additional mocks because init and shutdown of i2c infra was covered in realtek programmer lifecycle. Default mocking of i2c is sufficient to run a basic lifecycle. To run the test, config option for the programmer needs to be enabled explicitly, since by default this programmer is disabled. BUG=b:238816889 TEST=meson configure -Dconfig_parade_lspcon=true ninja test Change-Id: I0dcfae4a58c64b2e8d56ec51b4b050534cbb4cd2 Signed-off-by: Anastasia Klimchuk Reviewed-on: https://review.coreboot.org/c/flashrom/+/66003 Reviewed-by: Edward O'Callaghan Reviewed-by: Felix Singer Reviewed-by: Thomas Heijligen Tested-by: build bot (Jenkins) --- tests/meson.build | 1 + tests/parade_lspcon.c | 36 ++++++++++++++++++++++++++++++++++++ tests/tests.c | 1 + tests/tests.h | 1 + 4 files changed, 39 insertions(+) create mode 100644 tests/parade_lspcon.c (limited to 'tests') diff --git a/tests/meson.build b/tests/meson.build index f6f416f0..ee06b43f 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -25,6 +25,7 @@ srcs = [ 'dediprog.c', 'linux_mtd.c', 'linux_spi.c', + 'parade_lspcon.c', 'realtek_mst_i2c_spi.c', 'layout.c', 'chip.c', diff --git a/tests/parade_lspcon.c b/tests/parade_lspcon.c new file mode 100644 index 00000000..cb9adb43 --- /dev/null +++ b/tests/parade_lspcon.c @@ -0,0 +1,36 @@ +/* + * This file is part of the flashrom project. + * + * Copyright 2022 Google LLC + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include "lifecycle.h" + +#if CONFIG_PARADE_LSPCON == 1 + +void parade_lspcon_basic_lifecycle_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_basic_lifecycle(state, ¶de_lspcon_io, &programmer_parade_lspcon, "bus=254,allow_brick=yes"); +} + +#else + SKIP_TEST(parade_lspcon_basic_lifecycle_test_success) +#endif /* CONFIG_PARADE_LSPCON */ diff --git a/tests/tests.c b/tests/tests.c index 1ad9bb81..f6f3d010 100644 --- a/tests/tests.c +++ b/tests/tests.c @@ -415,6 +415,7 @@ int main(int argc, char *argv[]) cmocka_unit_test(dediprog_basic_lifecycle_test_success), 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(realtek_mst_basic_lifecycle_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 240f33db..c84179c3 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -50,6 +50,7 @@ void raiden_debug_basic_lifecycle_test_success(void **state); 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 realtek_mst_basic_lifecycle_test_success(void **state); /* layout.c */ -- cgit v1.2.3