Change in flashrom[master]: tests/: Add flashrom.c unit tests

Edward O'Callaghan has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/41646 ) Change subject: tests/: Add flashrom.c unit tests ...................................................................... tests/: Add flashrom.c unit tests Change-Id: I2d9213f98c6c9639f2417466ba4895117e8d600a Signed-off-by: Edward O'Callaghan <quasisec@google.com> --- A tests/flashrom.c M tests/meson.build M tests/tests.c M tests/tests.h 4 files changed, 45 insertions(+), 0 deletions(-) git pull ssh://review.coreboot.org:29418/flashrom refs/changes/46/41646/1 diff --git a/tests/flashrom.c b/tests/flashrom.c new file mode 100644 index 0000000..ad46dd8 --- /dev/null +++ b/tests/flashrom.c @@ -0,0 +1,36 @@ +#include <include/test.h> + +#include "programmer.h" + +void flashbuses_to_text_test_success(void **state) +{ + (void) state; /* unused */ + + enum chipbustype bustype; + + bustype = BUS_NONSPI; + assert_string_equal(flashbuses_to_text(bustype), "Non-SPI"); + + bustype |= BUS_PARALLEL; + assert_string_not_equal(flashbuses_to_text(bustype), "Non-SPI, Parallel"); + + bustype = BUS_PARALLEL; + bustype |= BUS_LPC; + assert_string_equal(flashbuses_to_text(bustype), "Parallel, LPC"); + + bustype |= BUS_FWH; + //BUS_NONSPI = BUS_PARALLEL | BUS_LPC | BUS_FWH, + assert_string_equal(flashbuses_to_text(bustype), "Non-SPI"); + + bustype |= BUS_SPI; + assert_string_equal(flashbuses_to_text(bustype), "Parallel, LPC, FWH, SPI"); + + bustype |= BUS_PROG; + assert_string_equal( + flashbuses_to_text(bustype), + "Parallel, LPC, FWH, SPI, Programmer-specific" + ); + + bustype = BUS_NONE; + assert_string_equal(flashbuses_to_text(bustype), "None"); +} diff --git a/tests/meson.build b/tests/meson.build index 3ed1c3b..aad1372 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -3,6 +3,7 @@ srcs = [ 'tests.c', 'spi.c', + 'flashrom.c', 'spi25.c', ] diff --git a/tests/tests.c b/tests/tests.c index 16f4863..a3ad791 100644 --- a/tests/tests.c +++ b/tests/tests.c @@ -24,6 +24,11 @@ }; ret |= cmocka_run_group_tests_name("spi.c tests", spi_tests, NULL, NULL); + const struct CMUnitTest flashrom_tests[] = { + cmocka_unit_test(flashbuses_to_text_test_success), + }; + ret |= cmocka_run_group_tests_name("flashrom.c tests", flashrom_tests, NULL, NULL); + const struct CMUnitTest spi25_tests[] = { cmocka_unit_test(spi_write_enable_test_success), cmocka_unit_test(spi_write_disable_test_success), diff --git a/tests/tests.h b/tests/tests.h index 9377817..688c280 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -4,6 +4,9 @@ void registered_masters_test_success(void **state); void programmer_init_test_success(void **state); +/* flashrom.c */ +void flashbuses_to_text_test_success(void **state); + /* spi25.c */ void spi_write_enable_test_success(void **state); void spi_write_disable_test_success(void **state); -- To view, visit https://review.coreboot.org/c/flashrom/+/41646 To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings Gerrit-Project: flashrom Gerrit-Branch: master Gerrit-Change-Id: I2d9213f98c6c9639f2417466ba4895117e8d600a Gerrit-Change-Number: 41646 Gerrit-PatchSet: 1 Gerrit-Owner: Edward O'Callaghan <quasisec@chromium.org> Gerrit-MessageType: newchange

Hello build bot (Jenkins), I'd like you to reexamine a change. Please visit https://review.coreboot.org/c/flashrom/+/41646 to look at the new patch set (#2). Change subject: tests/: Add flashrom.c unit tests ...................................................................... tests/: Add flashrom.c unit tests BUG=b:157280555 BRANCH=none TEST=builds Change-Id: I2d9213f98c6c9639f2417466ba4895117e8d600a Signed-off-by: Edward O'Callaghan <quasisec@google.com> --- A tests/flashrom.c M tests/meson.build M tests/tests.c M tests/tests.h 4 files changed, 45 insertions(+), 0 deletions(-) git pull ssh://review.coreboot.org:29418/flashrom refs/changes/46/41646/2 -- To view, visit https://review.coreboot.org/c/flashrom/+/41646 To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings Gerrit-Project: flashrom Gerrit-Branch: master Gerrit-Change-Id: I2d9213f98c6c9639f2417466ba4895117e8d600a Gerrit-Change-Number: 41646 Gerrit-PatchSet: 2 Gerrit-Owner: Edward O'Callaghan <quasisec@chromium.org> Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org> Gerrit-MessageType: newpatchset

Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/41646 ) Change subject: tests/: Add flashrom.c unit tests ...................................................................... Patch Set 2: (1 comment) https://review.coreboot.org/c/flashrom/+/41646/2/tests/flashrom.c File tests/flashrom.c: PS2: But then, if we change the strings we print, we'll have to update this test as well? -- To view, visit https://review.coreboot.org/c/flashrom/+/41646 To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings Gerrit-Project: flashrom Gerrit-Branch: master Gerrit-Change-Id: I2d9213f98c6c9639f2417466ba4895117e8d600a Gerrit-Change-Number: 41646 Gerrit-PatchSet: 2 Gerrit-Owner: Edward O'Callaghan <quasisec@chromium.org> Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org> Gerrit-CC: Angel Pons <th3fanbus@gmail.com> Gerrit-Comment-Date: Fri, 22 May 2020 12:43:10 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Gerrit-MessageType: comment

Edward O'Callaghan has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/41646 ) Change subject: tests/: Add flashrom.c unit tests ...................................................................... Patch Set 2: (1 comment) https://review.coreboot.org/c/flashrom/+/41646/2/tests/flashrom.c File tests/flashrom.c: PS2:
But then, if we change the strings we print, we'll have to update this test as well? Yes.
-- To view, visit https://review.coreboot.org/c/flashrom/+/41646 To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings Gerrit-Project: flashrom Gerrit-Branch: master Gerrit-Change-Id: I2d9213f98c6c9639f2417466ba4895117e8d600a Gerrit-Change-Number: 41646 Gerrit-PatchSet: 2 Gerrit-Owner: Edward O'Callaghan <quasisec@chromium.org> Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org> Gerrit-CC: Angel Pons <th3fanbus@gmail.com> Gerrit-Comment-Date: Fri, 22 May 2020 14:52:42 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: Angel Pons <th3fanbus@gmail.com> Gerrit-MessageType: comment

Hello build bot (Jenkins), I'd like you to reexamine a change. Please visit https://review.coreboot.org/c/flashrom/+/41646 to look at the new patch set (#3). Change subject: tests/: Add flashrom.c unit tests ...................................................................... tests/: Add flashrom.c unit tests BUG=b:157280555 BRANCH=none TEST=builds Change-Id: I2d9213f98c6c9639f2417466ba4895117e8d600a Signed-off-by: Edward O'Callaghan <quasisec@google.com> --- A tests/flashrom.c M tests/meson.build M tests/tests.c M tests/tests.h 4 files changed, 45 insertions(+), 0 deletions(-) git pull ssh://review.coreboot.org:29418/flashrom refs/changes/46/41646/3 -- To view, visit https://review.coreboot.org/c/flashrom/+/41646 To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings Gerrit-Project: flashrom Gerrit-Branch: master Gerrit-Change-Id: I2d9213f98c6c9639f2417466ba4895117e8d600a Gerrit-Change-Number: 41646 Gerrit-PatchSet: 3 Gerrit-Owner: Edward O'Callaghan <quasisec@chromium.org> Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org> Gerrit-CC: Angel Pons <th3fanbus@gmail.com> Gerrit-MessageType: newpatchset

Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/41646 ) Change subject: tests/: Add flashrom.c unit tests ...................................................................... Patch Set 3: Code-Review+2 (1 comment) https://review.coreboot.org/c/flashrom/+/41646/2/tests/flashrom.c File tests/flashrom.c: PS2:
Yes. Right. Maybe we want to change this in the future, but IMHO it's good enough to start off with.
-- To view, visit https://review.coreboot.org/c/flashrom/+/41646 To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings Gerrit-Project: flashrom Gerrit-Branch: master Gerrit-Change-Id: I2d9213f98c6c9639f2417466ba4895117e8d600a Gerrit-Change-Number: 41646 Gerrit-PatchSet: 3 Gerrit-Owner: Edward O'Callaghan <quasisec@chromium.org> Gerrit-Reviewer: Angel Pons <th3fanbus@gmail.com> Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org> Gerrit-Comment-Date: Tue, 16 Jun 2020 12:04:39 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: Yes Comment-In-Reply-To: Edward O'Callaghan <quasisec@chromium.org> Comment-In-Reply-To: Angel Pons <th3fanbus@gmail.com> Gerrit-MessageType: comment

Edward O'Callaghan has submitted this change. ( https://review.coreboot.org/c/flashrom/+/41646 ) Change subject: tests/: Add flashrom.c unit tests ...................................................................... tests/: Add flashrom.c unit tests BUG=b:157280555 BRANCH=none TEST=builds Change-Id: I2d9213f98c6c9639f2417466ba4895117e8d600a Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/41646 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com> --- A tests/flashrom.c M tests/meson.build M tests/tests.c M tests/tests.h 4 files changed, 45 insertions(+), 0 deletions(-) Approvals: build bot (Jenkins): Verified Angel Pons: Looks good to me, approved diff --git a/tests/flashrom.c b/tests/flashrom.c new file mode 100644 index 0000000..ad46dd8 --- /dev/null +++ b/tests/flashrom.c @@ -0,0 +1,36 @@ +#include <include/test.h> + +#include "programmer.h" + +void flashbuses_to_text_test_success(void **state) +{ + (void) state; /* unused */ + + enum chipbustype bustype; + + bustype = BUS_NONSPI; + assert_string_equal(flashbuses_to_text(bustype), "Non-SPI"); + + bustype |= BUS_PARALLEL; + assert_string_not_equal(flashbuses_to_text(bustype), "Non-SPI, Parallel"); + + bustype = BUS_PARALLEL; + bustype |= BUS_LPC; + assert_string_equal(flashbuses_to_text(bustype), "Parallel, LPC"); + + bustype |= BUS_FWH; + //BUS_NONSPI = BUS_PARALLEL | BUS_LPC | BUS_FWH, + assert_string_equal(flashbuses_to_text(bustype), "Non-SPI"); + + bustype |= BUS_SPI; + assert_string_equal(flashbuses_to_text(bustype), "Parallel, LPC, FWH, SPI"); + + bustype |= BUS_PROG; + assert_string_equal( + flashbuses_to_text(bustype), + "Parallel, LPC, FWH, SPI, Programmer-specific" + ); + + bustype = BUS_NONE; + assert_string_equal(flashbuses_to_text(bustype), "None"); +} diff --git a/tests/meson.build b/tests/meson.build index 76088c2..1e7ef4a 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -2,6 +2,7 @@ srcs = [ 'tests.c', + 'flashrom.c', 'spi25.c', ] diff --git a/tests/tests.c b/tests/tests.c index 82563ac..247c811 100644 --- a/tests/tests.c +++ b/tests/tests.c @@ -21,6 +21,11 @@ { int ret = 0; + const struct CMUnitTest flashrom_tests[] = { + cmocka_unit_test(flashbuses_to_text_test_success), + }; + ret |= cmocka_run_group_tests_name("flashrom.c tests", flashrom_tests, NULL, NULL); + const struct CMUnitTest spi25_tests[] = { cmocka_unit_test(spi_write_enable_test_success), cmocka_unit_test(spi_write_disable_test_success), diff --git a/tests/tests.h b/tests/tests.h index 6eafeea..3b91f65 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -1,6 +1,9 @@ #ifndef TESTS_H #define TESTS_H +/* flashrom.c */ +void flashbuses_to_text_test_success(void **state); + /* spi25.c */ void spi_write_enable_test_success(void **state); void spi_write_disable_test_success(void **state); -- To view, visit https://review.coreboot.org/c/flashrom/+/41646 To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings Gerrit-Project: flashrom Gerrit-Branch: master Gerrit-Change-Id: I2d9213f98c6c9639f2417466ba4895117e8d600a Gerrit-Change-Number: 41646 Gerrit-PatchSet: 4 Gerrit-Owner: Edward O'Callaghan <quasisec@chromium.org> Gerrit-Reviewer: Angel Pons <th3fanbus@gmail.com> Gerrit-Reviewer: Edward O'Callaghan <quasisec@chromium.org> Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org> Gerrit-MessageType: merged
participants (2)
-
Angel Pons (Code Review)
-
Edward O'Callaghan (Code Review)