aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnastasia Klimchuk <aklm@chromium.org>2022-07-29 16:16:25 +1000
committerAnastasia Klimchuk <aklm@chromium.org>2022-08-08 03:15:22 +0000
commit5c5b0a8fab59ec5b2daaac8caa6a0cb1343db0fe (patch)
tree789ec1954b3416c71e42b8fe3b98e0fdc610f098
parent47541722c16a59fcc574397d5413ddc1b4a11cde (diff)
downloadflashrom-5c5b0a8fab59ec5b2daaac8caa6a0cb1343db0fe.tar.gz
flashrom-5c5b0a8fab59ec5b2daaac8caa6a0cb1343db0fe.tar.bz2
flashrom-5c5b0a8fab59ec5b2daaac8caa6a0cb1343db0fe.zip
tests: Add basic lifecycle test for mediatek_i2c_spi
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:238816884 TEST=meson configure -Dconfig_mediatek_i2c_spi=true ninja test Change-Id: I98a12067d165c90013d33ffc45d20dab5c364c83 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/66261 Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Felix Singer <felixsinger@posteo.net> Reviewed-by: Thomas Heijligen <src@posteo.de> Reviewed-by: Alexander Goncharov <chat@joursoir.net> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
-rw-r--r--tests/mediatek_i2c_spi.c36
-rw-r--r--tests/meson.build1
-rw-r--r--tests/tests.c1
-rw-r--r--tests/tests.h1
4 files changed, 39 insertions, 0 deletions
diff --git a/tests/mediatek_i2c_spi.c b/tests/mediatek_i2c_spi.c
new file mode 100644
index 00000000..caf69808
--- /dev/null
+++ b/tests/mediatek_i2c_spi.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_MEDIATEK_I2C_SPI == 1
+
+void mediatek_i2c_spi_basic_lifecycle_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_basic_lifecycle(state, &mediatek_i2c_spi_io, &programmer_mediatek_i2c_spi, "bus=254,allow_brick=yes");
+}
+
+#else
+ SKIP_TEST(mediatek_i2c_spi_basic_lifecycle_test_success)
+#endif /* CONFIG_MEDIATEK_I2C_SPI */
diff --git a/tests/meson.build b/tests/meson.build
index ee06b43f..96ca5a68 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -26,6 +26,7 @@ srcs = [
'linux_mtd.c',
'linux_spi.c',
'parade_lspcon.c',
+ 'mediatek_i2c_spi.c',
'realtek_mst_i2c_spi.c',
'layout.c',
'chip.c',
diff --git a/tests/tests.c b/tests/tests.c
index f6f3d010..2a54aab3 100644
--- a/tests/tests.c
+++ b/tests/tests.c
@@ -416,6 +416,7 @@ 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(mediatek_i2c_spi_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 c84179c3..c279be90 100644
--- a/tests/tests.h
+++ b/tests/tests.h
@@ -51,6 +51,7 @@ 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 mediatek_i2c_spi_basic_lifecycle_test_success(void **state);
void realtek_mst_basic_lifecycle_test_success(void **state);
/* layout.c */