From 0ce0ace68b8791a907e36013309682a757673168 Mon Sep 17 00:00:00 2001 From: Piotr Mienkowski Date: Sun, 29 Dec 2019 22:54:37 +0100 Subject: [PATCH] tests: remove pinmux_basic_api test The pinmux_basic_api test relies on a hardware loopback, manual shorting of two GPIO pins. The Zephyr test framework does not allow currently to define such pins in a generic way. The pinmux_basic_api test hard codes pin numbers specific to a few evaluation boards. The test has a few more flaws and limitations: - it verifies that pin configured to function A can be controlled by GPIO driver. It doesn't verify that pin configured to function B can be contorolled by a corresponding peripheral driver. - the test relies on level sensitive interrupt support which is not always available. - the test will pass even if there are erros when pin is configured to function B. - the test allows to configure both test pins as an output therefore shorting the outputs. Considering the flaws and limited coverage of the test as well as missing features of the Zephyr test framework this commit removes the testcase. It is not currently possible to write a generic pinmux testcase that supports multiple boards and can be used to assess the quality of the driver. Instead, to ensure the driver code will not degrade, we need to rely on implicit testing done by the board initialization code located in boards/ folder. Signed-off-by: Piotr Mienkowski --- .../pinmux/pinmux_basic_api/CMakeLists.txt | 8 -- .../drivers/pinmux/pinmux_basic_api/prj.conf | 3 - .../pinmux/pinmux_basic_api/src/main.c | 17 --- .../pinmux/pinmux_basic_api/src/pinmux_gpio.c | 130 ------------------ .../pinmux/pinmux_basic_api/testcase.yaml | 6 - 5 files changed, 164 deletions(-) delete mode 100644 tests/drivers/pinmux/pinmux_basic_api/CMakeLists.txt delete mode 100644 tests/drivers/pinmux/pinmux_basic_api/prj.conf delete mode 100644 tests/drivers/pinmux/pinmux_basic_api/src/main.c delete mode 100644 tests/drivers/pinmux/pinmux_basic_api/src/pinmux_gpio.c delete mode 100644 tests/drivers/pinmux/pinmux_basic_api/testcase.yaml diff --git a/tests/drivers/pinmux/pinmux_basic_api/CMakeLists.txt b/tests/drivers/pinmux/pinmux_basic_api/CMakeLists.txt deleted file mode 100644 index f08185114b5f7..0000000000000 --- a/tests/drivers/pinmux/pinmux_basic_api/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -cmake_minimum_required(VERSION 3.13.1) -include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE) -project(pinmux_basic_api) - -FILE(GLOB app_sources src/*.c) -target_sources(app PRIVATE ${app_sources}) diff --git a/tests/drivers/pinmux/pinmux_basic_api/prj.conf b/tests/drivers/pinmux/pinmux_basic_api/prj.conf deleted file mode 100644 index 60de47326632d..0000000000000 --- a/tests/drivers/pinmux/pinmux_basic_api/prj.conf +++ /dev/null @@ -1,3 +0,0 @@ -CONFIG_GPIO=y -CONFIG_PINMUX=y -CONFIG_ZTEST=y diff --git a/tests/drivers/pinmux/pinmux_basic_api/src/main.c b/tests/drivers/pinmux/pinmux_basic_api/src/main.c deleted file mode 100644 index ec0b1d72d3eb3..0000000000000 --- a/tests/drivers/pinmux/pinmux_basic_api/src/main.c +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2017 Intel Corporation - * - * SPDX-License-Identifier: Apache-2.0 - */ - - -#include - -extern void test_pinmux_gpio(void); - -void test_main(void) -{ - ztest_test_suite(pinmux_basic_test, - ztest_unit_test(test_pinmux_gpio)); - ztest_run_test_suite(pinmux_basic_test); -} diff --git a/tests/drivers/pinmux/pinmux_basic_api/src/pinmux_gpio.c b/tests/drivers/pinmux/pinmux_basic_api/src/pinmux_gpio.c deleted file mode 100644 index c0b94e3bf17e3..0000000000000 --- a/tests/drivers/pinmux/pinmux_basic_api/src/pinmux_gpio.c +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2017 Intel Corporation - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include - -#define PINMUX_NAME CONFIG_PINMUX_NAME - -#if defined(DT_ALIAS_GPIO_0_LABEL) -#define GPIO_DEV_NAME DT_ALIAS_GPIO_0_LABEL -#elif defined(DT_ALIAS_GPIO_1_LABEL) -#define GPIO_DEV_NAME DT_ALIAS_GPIO_1_LABEL -#elif defined(DT_ALIAS_GPIO_3_LABEL) -#define GPIO_DEV_NAME DT_ALIAS_GPIO_3_LABEL -#else -#error Unsupported board -#endif - -#define GPIO_OUT 4 -#define GPIO_IN 5 -#define PIN_IN 3 - -#define MAX_INT_CNT 10 - -static bool cb_triggered; - -static void callback(struct device *dev, - struct gpio_callback *gpio_cb, u32_t pins) -{ - static int cb_cnt; - - TC_PRINT("callback triggered: %d\n", ++cb_cnt); - - if (cb_cnt >= MAX_INT_CNT) { - cb_triggered = true; - gpio_pin_write(dev, GPIO_OUT, 0); - } -} - -static int test_gpio(u32_t pin, u32_t func) -{ - u32_t function; - struct gpio_callback gpio_cb; - struct device *pinmux = device_get_binding(PINMUX_NAME); - - if (!pinmux) { - TC_PRINT("Cannot get PINMUX\n"); - return TC_FAIL; - } - - struct device *gpio_dev = device_get_binding(GPIO_DEV_NAME); - - if (!gpio_dev) { - TC_PRINT("Cannot get GPIO device\n"); - return TC_FAIL; - } - - cb_triggered = false; - - /* 1. Configure PIN_OUT and set init voltage */ - if (gpio_pin_configure(gpio_dev, GPIO_OUT, GPIO_DIR_OUT)) { - TC_PRINT("PIN_OUT configure fail\n"); - return TC_FAIL; - } - - if (gpio_pin_write(gpio_dev, GPIO_OUT, 0)) { - TC_PRINT("Set PIN_OUT init LOW fail\n"); - return TC_FAIL; - } - - /* 2. Configure PIN_IN and set callback */ - if (gpio_pin_configure(gpio_dev, GPIO_IN, - GPIO_DIR_IN | GPIO_INT | GPIO_INT_DEBOUNCE | - GPIO_INT_LEVEL | GPIO_INT_ACTIVE_HIGH)) { - TC_PRINT("PIN_IN configure fail\n"); - return TC_FAIL; - } - - gpio_init_callback(&gpio_cb, callback, BIT(GPIO_IN)); - if (gpio_add_callback(gpio_dev, &gpio_cb)) { - TC_PRINT("Set PIN_IN callback fail\n"); - return TC_FAIL; - } - - gpio_pin_enable_callback(gpio_dev, GPIO_IN); - - /* 3. Verify pinmux_pin_set() */ - if (pinmux_pin_set(pinmux, pin, func)) { - TC_PRINT("Fail to set pin func, %u : %u\n", pin, func); - return TC_FAIL; - } - - /* 4. Verify pinmux_pin_get() */ - if (pinmux_pin_get(pinmux, pin, &function)) { - TC_PRINT("Fail to get pin func\n"); - return TC_FAIL; - } - - /* 5. Verify the setting works */ - if (function != func) { - TC_PRINT("Error. PINMUX get doesn't match PINMUX set\n"); - return TC_FAIL; - } - - /* 6. Set PIN_OUT HIGH and verify pin func works */ - if (gpio_pin_write(gpio_dev, GPIO_OUT, 1)) { - TC_PRINT("Set PIN_OUT HIGH fail\n"); - return TC_FAIL; - } - - k_sleep(K_MSEC(1000)); - - if (cb_triggered) { - TC_PRINT("GPIO callback is triggered\n"); - return TC_PASS; - } else { - TC_PRINT("GPIO callback is not triggered\n"); - return TC_FAIL; - } -} - -void test_pinmux_gpio(void) -{ - zassert_true(test_gpio(PIN_IN, PINMUX_FUNC_A) == TC_PASS, NULL); - zassert_true(test_gpio(PIN_IN, PINMUX_FUNC_B) == TC_FAIL, NULL); -} diff --git a/tests/drivers/pinmux/pinmux_basic_api/testcase.yaml b/tests/drivers/pinmux/pinmux_basic_api/testcase.yaml deleted file mode 100644 index 9441ca72ced7d..0000000000000 --- a/tests/drivers/pinmux/pinmux_basic_api/testcase.yaml +++ /dev/null @@ -1,6 +0,0 @@ -tests: - drivers.pinmux: - tags: drivers - harness: loopback - filter: dt_alias_exists("gpio-0") or dt_alias_exists("gpio-1") - depends_on: gpio