Anastasia Klimchuk has uploaded this change for review.
[FIX ME] tests: Add test for extract operation
This patch adds a test for do_extract operation. However test fails
because do_extract, as it is currently written, always returns 1.
Something needs to be fixed: either do_extract itself, or API how
to call it, or maybe that's the test which is doing it wrong?
To repro: ninja test
Change-Id: I13107c0e095d53184e32a41fa72227cf7dc1d449
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
---
M tests/chip.c
M tests/tests.c
M tests/tests.h
3 files changed, 20 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/32/59532/1
diff --git a/tests/chip.c b/tests/chip.c
index 9c06fe7..cf8441d 100644
--- a/tests/chip.c
+++ b/tests/chip.c
@@ -317,3 +317,21 @@
free(param_dup);
}
+
+void extract_layout_test_success(void **state)
+{
+ (void) state; /* unused */
+
+ struct flashrom_flashctx flashctx = { 0 };
+ struct flashrom_layout *layout;
+ struct flashchip mock_chip = chip_8MiB;
+ const char *param = ""; /* Default values for all params. */
+
+ setup_chip(&flashctx, &layout, &mock_chip, param);
+
+ printf("Extract layout operation started.\n");
+ assert_int_equal(0, do_extract(&flashctx));
+ printf("Extract layout operation done.\n");
+
+ teardown(&layout);
+}
diff --git a/tests/tests.c b/tests/tests.c
index f2547ff..c8bce6a 100644
--- a/tests/tests.c
+++ b/tests/tests.c
@@ -375,6 +375,7 @@
cmocka_unit_test(read_chip_with_dummyflasher_test_success),
cmocka_unit_test(write_chip_test_success),
cmocka_unit_test(write_chip_with_dummyflasher_test_success),
+ cmocka_unit_test(extract_layout_test_success),
};
ret |= cmocka_run_group_tests_name("chip.c tests", chip_tests, NULL, NULL);
diff --git a/tests/tests.h b/tests/tests.h
index 732920a..a6a0df6 100644
--- a/tests/tests.h
+++ b/tests/tests.h
@@ -63,5 +63,6 @@
void read_chip_with_dummyflasher_test_success(void **state);
void write_chip_test_success(void **state);
void write_chip_with_dummyflasher_test_success(void **state);
+void extract_layout_test_success(void **state);
#endif /* TESTS_H */
To view, visit change 59532. To unsubscribe, or for help writing mail filters, visit settings.