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 <piotr.mienkowski@gmail.com>
This commit is contained in:
parent
c793c0edda
commit
49bcafc9f5
5 changed files with 0 additions and 164 deletions
|
@ -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})
|
|
@ -1,3 +0,0 @@
|
|||
CONFIG_GPIO=y
|
||||
CONFIG_PINMUX=y
|
||||
CONFIG_ZTEST=y
|
|
@ -1,17 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2017 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
|
||||
#include <ztest.h>
|
||||
|
||||
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);
|
||||
}
|
|
@ -1,130 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2017 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <drivers/gpio.h>
|
||||
#include <drivers/pinmux.h>
|
||||
#include <ztest.h>
|
||||
|
||||
#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);
|
||||
}
|
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue