Anastasia Klimchuk has uploaded this change for review.
tests: Add run_probe_lifecycle and use it in dummyflasher test
This patch implements run_probe_lifecycle and upgrades dummyflasher
lifecycle test to run probing lifecycle.
run_probe_lifecycle is operating via libflashrom API. Long term goal
for cli_classic is to operate via libflashrom API, so the test is
trying this approach.
BUG=b:181803212
TEST=ninja test
Change-Id: I9eb7fe3a436fbba5e70db957139fd26e00efec36
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
---
M tests/lifecycle.c
M tests/tests.c
M tests/tests.h
3 files changed, 30 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/41/59741/1
diff --git a/tests/lifecycle.c b/tests/lifecycle.c
index 8cb604b..4fd554a 100644
--- a/tests/lifecycle.c
+++ b/tests/lifecycle.c
@@ -16,6 +16,7 @@
#include <include/test.h>
#include <string.h>
+#include "libflashrom.h"
#include "io_mock.h"
#include "programmer.h"
@@ -36,10 +37,35 @@
free(param_dup);
}
-void dummy_basic_lifecycle_test_success(void **state)
+static void run_probe_lifecycle(void **state, const struct programmer_entry *prog,
+ const char *param, const char *const chip_name)
+{
+ (void) state; /* unused */
+
+ struct flashrom_programmer *flashprog = NULL;
+ struct flashrom_flashctx *flashctx = NULL;
+ char *param_dup = strdup(param);
+
+ printf("Testing flashrom_programmer_init for programmer=%s ...\n", prog->name);
+ assert_int_equal(0, flashrom_programmer_init(&flashprog, prog->name, param_dup));
+ printf("... flashrom_programmer_init for programmer=%s successful\n", prog->name);
+
+ printf("Testing flashrom_flash_probe for programmer=%s, chip=%s ... \n", prog->name, chip_name);
+ assert_int_equal(0, flashrom_flash_probe(&flashctx, flashprog, chip_name));
+ printf("... flashrom_flash_probe for programmer=%s successful\n", prog->name);
+
+ printf("Testing flashrom_programmer_shutdown for programmer=%s ...\n", prog->name);
+ assert_int_equal(0, flashrom_programmer_shutdown(flashprog));
+ printf("... flashrom_programmer_shutdown for programmer=%s successful\n", prog->name);
+
+ flashrom_flash_release(flashctx); /* cleanup */
+ free(param_dup);
+}
+
+void dummy_probe_lifecycle_test_success(void **state)
{
#if CONFIG_DUMMY == 1
- run_basic_lifecycle(state, &programmer_dummy, "bus=parallel+lpc+fwh+spi");
+ run_probe_lifecycle(state, &programmer_dummy, "bus=spi,emulate=W25Q128FV", "W25Q128.V");
#else
skip();
#endif
diff --git a/tests/tests.c b/tests/tests.c
index a9faa58..c840ba4 100644
--- a/tests/tests.c
+++ b/tests/tests.c
@@ -349,7 +349,7 @@
ret |= cmocka_run_group_tests_name("spi25.c tests", spi25_tests, NULL, NULL);
const struct CMUnitTest lifecycle_tests[] = {
- cmocka_unit_test(dummy_basic_lifecycle_test_success),
+ cmocka_unit_test(dummy_probe_lifecycle_test_success),
cmocka_unit_test(nicrealtek_basic_lifecycle_test_success),
cmocka_unit_test(raiden_debug_basic_lifecycle_test_success),
cmocka_unit_test(dediprog_basic_lifecycle_test_success),
diff --git a/tests/tests.h b/tests/tests.h
index 8a3de44..e450f15 100644
--- a/tests/tests.h
+++ b/tests/tests.h
@@ -41,7 +41,7 @@
void probe_spi_st95_test_success(void **state); /* spi95.c */
/* lifecycle.c */
-void dummy_basic_lifecycle_test_success(void **state);
+void dummy_probe_lifecycle_test_success(void **state);
void nicrealtek_basic_lifecycle_test_success(void **state);
void raiden_debug_basic_lifecycle_test_success(void **state);
void dediprog_basic_lifecycle_test_success(void **state);
To view, visit change 59741. To unsubscribe, or for help writing mail filters, visit settings.