Skip to content

Commit

Permalink
iut: add case to test divide0 exception
Browse files Browse the repository at this point in the history
Make sure divide zero exception happens as expected and fatal context is
correctly printed out in logs.

Signed-off-by: Dong Wang <[email protected]>
  • Loading branch information
kwd-doodling committed Jun 4, 2024
1 parent 1ed7e24 commit 9deeaee
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions zephyr/iut_test/test_zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ endif()
if(CONFIG_GPIO_SEDI)
target_sources(app PRIVATE gpio/test_gpio.c)
endif()

target_sources(app PRIVATE x86/test_fatal.c)
23 changes: 23 additions & 0 deletions zephyr/iut_test/test_zephyr/x86/test_fatal.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (c) 2023 Intel Corporation.
*
* SPDX-License-Identifier: Apache-2.0
*/

#include "iut.h"

int _divider;

static int test_divide0(int argc, char **argv)
{
int num = 1000;

num /= _divider;

iut_case_print("no way to come here, %d\n", num);
TEST_ASSERT_TRUE(1);

return IUT_ERR_OK;
}

DEFINE_IUT_CASE(divide0, fatal, IUT_ATTRI_NONE);

0 comments on commit 9deeaee

Please sign in to comment.