Skip to content

Commit ac1cc55

Browse files
committed
tests: drivers: gpio: basic_api: Improve test
Add return code checking for gpio_pin_interrupt_configure functions. Add disabling pin interrupt at the end of the test to restore pin state. Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
1 parent eeef86d commit ac1cc55

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

tests/drivers/gpio/gpio_basic_api/src/test_callback_manage.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,19 @@ static int init_callback(const struct device *dev_in, const struct device *dev_o
6666
static void trigger_callback(const struct device *dev_in, const struct device *dev_out,
6767
int enable_cb)
6868
{
69+
int rc;
70+
6971
gpio_pin_set(dev_out, PIN_OUT, 0);
7072
k_sleep(K_MSEC(100));
7173

7274
cb_cnt[0] = 0;
7375
cb_cnt[1] = 0;
7476
if (enable_cb == 1) {
75-
gpio_pin_interrupt_configure(dev_in, PIN_IN, GPIO_INT_EDGE_RISING);
77+
rc = gpio_pin_interrupt_configure(dev_in, PIN_IN, GPIO_INT_EDGE_RISING);
7678
} else {
77-
gpio_pin_interrupt_configure(dev_in, PIN_IN, GPIO_INT_DISABLE);
79+
rc = gpio_pin_interrupt_configure(dev_in, PIN_IN, GPIO_INT_DISABLE);
7880
}
81+
zassert_equal(rc, 0);
7982
k_sleep(K_MSEC(100));
8083
gpio_pin_set(dev_out, PIN_OUT, 1);
8184
k_sleep(K_MSEC(1000));

tests/drivers/gpio/gpio_basic_api/src/test_config_trigger.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ ZTEST(after_flash_gpio_config_trigger, test_gpio_config_twice_trigger)
7373
k_sleep(K_MSEC(10));
7474
zassert_between_inclusive(cb_cnt, 0, 1, "Got %d interrupts", cb_cnt);
7575

76+
ret = gpio_pin_interrupt_configure(dev_in, PIN_IN, GPIO_INT_DISABLE);
77+
zassert_ok(ret, "interrupt disabling failed");
78+
7679
gpio_remove_callback(dev_in, &drv_data->gpio_cb);
7780
}
7881

@@ -125,5 +128,8 @@ ZTEST(after_flash_gpio_config_trigger, test_gpio_config_trigger)
125128
k_sleep(K_MSEC(10));
126129
zassert_between_inclusive(cb_cnt, 0, 1, "Got %d interrupts", cb_cnt);
127130

131+
ret = gpio_pin_interrupt_configure(dev_in, PIN_IN, GPIO_INT_DISABLE);
132+
zassert_ok(ret, "interrupt disabling failed");
133+
128134
gpio_remove_callback(dev_in, &drv_data->gpio_cb);
129135
}

0 commit comments

Comments
 (0)