tests/gpio: fix test GPIO_INT_LEVEL bug

According to include/gpio.h, GPIO_INT_LEVEL is 0,
which means the branch to test GPIO_INT_LEVEL is
always false and GPIO_INT_LEVEL cases will always
pass.

This patch also fixes another minor bug in main.c.

Coverity-CID: 160074

Change-Id: I1fefa978e65bf801f244b4c2960cb87a26b0829e
Signed-off-by: Qiu Peiyang <peiyangx.qiu@intel.com>
This commit is contained in:
Qiu Peiyang 2017-01-22 13:17:15 +08:00 committed by Anas Nashif
commit 41ffe0240d
2 changed files with 3 additions and 3 deletions

View file

@ -42,6 +42,6 @@ void test_main(void)
ztest_unit_test(test_gpio_callback_level_high), ztest_unit_test(test_gpio_callback_level_high),
ztest_unit_test(test_gpio_callback_add_remove), ztest_unit_test(test_gpio_callback_add_remove),
ztest_unit_test(test_gpio_callback_enable_disable), ztest_unit_test(test_gpio_callback_enable_disable),
ztest_unit_test(test_gpio_callback_level_high)); ztest_unit_test(test_gpio_callback_level_low));
ztest_run_test_suite(gpio_basic_test); ztest_run_test_suite(gpio_basic_test);
} }

View file

@ -85,14 +85,14 @@ static int test_callback(int mode)
/*= checkpoint: check callback is triggered =*/ /*= checkpoint: check callback is triggered =*/
TC_PRINT("check enabled callback\n"); TC_PRINT("check enabled callback\n");
if (mode & GPIO_INT_EDGE) { if ((mode & GPIO_INT_EDGE) == GPIO_INT_EDGE) {
if (cb_cnt != 1) { if (cb_cnt != 1) {
TC_ERROR("not trigger callback correctly\n"); TC_ERROR("not trigger callback correctly\n");
goto err_exit; goto err_exit;
} }
} }
if (mode & GPIO_INT_LEVEL) { if ((mode & GPIO_INT_LEVEL) == GPIO_INT_LEVEL) {
if (cb_cnt != MAX_INT_CNT) { if (cb_cnt != MAX_INT_CNT) {
TC_ERROR("not trigger callback correctly\n"); TC_ERROR("not trigger callback correctly\n");
goto err_exit; goto err_exit;