From 629b8f06ec59d2112539efe161f121ab22d99ec8 Mon Sep 17 00:00:00 2001 From: Edward O'Callaghan Date: Fri, 22 May 2020 16:46:52 +1000 Subject: tests/: Add flashrom.c unit tests BUG=b:157280555 BRANCH=none TEST=builds Change-Id: I2d9213f98c6c9639f2417466ba4895117e8d600a Signed-off-by: Edward O'Callaghan Reviewed-on: https://review.coreboot.org/c/flashrom/+/41646 Tested-by: build bot (Jenkins) Reviewed-by: Angel Pons --- tests/flashrom.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tests/flashrom.c (limited to 'tests/flashrom.c') diff --git a/tests/flashrom.c b/tests/flashrom.c new file mode 100644 index 00000000..ad46dd8d --- /dev/null +++ b/tests/flashrom.c @@ -0,0 +1,36 @@ +#include + +#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"); +} -- cgit v1.2.3