From cffaac1e0f802e3fe27c4997e931586ee738f94a Mon Sep 17 00:00:00 2001 From: Anastasia Klimchuk Date: Wed, 21 Apr 2021 07:58:30 +1000 Subject: tests: Add unit test to run init/shutdown for dummyflasher.c Introduce test to exercise that init and shutdown of drivers correctly manage the drivers life-time state. We constrain ourselves to dummyflasher in particular here as it does not need any mocking. BUG=b:181803212 TEST=builds and ninja test Change-Id: I3c0ef73397f00c1db7aabb5f9f00cb43525af29c Signed-off-by: Anastasia Klimchuk Reviewed-on: https://review.coreboot.org/c/flashrom/+/52497 Tested-by: build bot (Jenkins) Reviewed-by: Nico Huber --- tests/init_shutdown.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/init_shutdown.c (limited to 'tests/init_shutdown.c') diff --git a/tests/init_shutdown.c b/tests/init_shutdown.c new file mode 100644 index 00000000..52268601 --- /dev/null +++ b/tests/init_shutdown.c @@ -0,0 +1,37 @@ +/* + * This file is part of the flashrom project. + * + * Copyright 2021 Google LLC + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include + +#include "programmer.h" + +static void run_lifecycle(void **state, enum programmer prog, const char *param) +{ + (void) state; /* unused */ + + printf("Testing programmer_init for programmer=%u ...\n", prog); + assert_int_equal(0, programmer_init(prog, strdup(param))); + printf("... programmer_init for programmer=%u successful\n", prog); + + printf("Testing programmer_shutdown for programmer=%u ...\n", prog); + assert_int_equal(0, programmer_shutdown()); + printf("... programmer_shutdown for programmer=%u successful\n", prog); +} + +void dummy_init_and_shutdown_test_success(void **state) +{ + run_lifecycle(state, PROGRAMMER_DUMMY, "bus=parallel+lpc+fwh+spi"); +} -- cgit v1.2.3