diff options
Diffstat (limited to 'tests/flashrom.c')
-rw-r--r-- | tests/flashrom.c | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/tests/flashrom.c b/tests/flashrom.c index 50464ddb..c3508c51 100644 --- a/tests/flashrom.c +++ b/tests/flashrom.c @@ -17,35 +17,54 @@ #include "programmer.h" +#define assert_equal_and_free(text, expected) \ + do { \ + assert_string_equal(text, expected); \ + free(text); \ + } while (0) + +#define assert_not_equal_and_free(text, expected) \ + do { \ + assert_string_not_equal(text, expected); \ + free(text); \ + } while (0) + + void flashbuses_to_text_test_success(void **state) { (void) state; /* unused */ enum chipbustype bustype; + char *text; bustype = BUS_NONSPI; - assert_string_equal(flashbuses_to_text(bustype), "Non-SPI"); + text = flashbuses_to_text(bustype); + assert_equal_and_free(text, "Non-SPI"); bustype |= BUS_PARALLEL; - assert_string_not_equal(flashbuses_to_text(bustype), "Non-SPI, Parallel"); + text = flashbuses_to_text(bustype); + assert_not_equal_and_free(text, "Non-SPI, Parallel"); bustype = BUS_PARALLEL; bustype |= BUS_LPC; - assert_string_equal(flashbuses_to_text(bustype), "Parallel, LPC"); + text = flashbuses_to_text(bustype); + assert_equal_and_free(text, "Parallel, LPC"); bustype |= BUS_FWH; //BUS_NONSPI = BUS_PARALLEL | BUS_LPC | BUS_FWH, - assert_string_equal(flashbuses_to_text(bustype), "Non-SPI"); + text = flashbuses_to_text(bustype); + assert_equal_and_free(text, "Non-SPI"); bustype |= BUS_SPI; - assert_string_equal(flashbuses_to_text(bustype), "Parallel, LPC, FWH, SPI"); + text = flashbuses_to_text(bustype); + assert_equal_and_free(text, "Parallel, LPC, FWH, SPI"); bustype |= BUS_PROG; - assert_string_equal( - flashbuses_to_text(bustype), - "Parallel, LPC, FWH, SPI, Programmer-specific" - ); + text = flashbuses_to_text(bustype); + assert_equal_and_free(text, + "Parallel, LPC, FWH, SPI, Programmer-specific"); bustype = BUS_NONE; - assert_string_equal(flashbuses_to_text(bustype), "None"); + text = flashbuses_to_text(bustype); + assert_equal_and_free(text, "None"); } |