From 7e7a4426d8353a109369688555e3d4f3d2c3d5df Mon Sep 17 00:00:00 2001 From: Krzysztof Chruscinski Date: Tue, 28 Jan 2020 12:21:41 +0100 Subject: [PATCH] tests: drivers: counter: counter_basic_api: Fix teardown function Teardown may fail due to not supported setting of top_value. Modified to accept not supported case. Signed-off-by: Krzysztof Chruscinski --- .../drivers/counter/counter_basic_api/src/test_counter.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/drivers/counter/counter_basic_api/src/test_counter.c b/tests/drivers/counter/counter_basic_api/src/test_counter.c index d903d308e2a..dd484eb786c 100644 --- a/tests/drivers/counter/counter_basic_api/src/test_counter.c +++ b/tests/drivers/counter/counter_basic_api/src/test_counter.c @@ -95,7 +95,13 @@ static void counter_tear_down_instance(const char *dev_name) top_cfg.ticks = counter_get_max_top_value(dev); err = counter_set_top_value(dev, &top_cfg); - zassert_equal(0, err, + if (err == -ENOTSUP) { + /* If resetting is not support, attempt without reset. */ + top_cfg.flags = COUNTER_TOP_CFG_DONT_RESET; + err = counter_set_top_value(dev, &top_cfg); + + } + zassert_true((err == 0) || (err == -ENOTSUP), "%s: Setting top value to default failed", dev_name); err = counter_stop(dev);