From a1dd4a32aba415b1bbbcd43afdb316bf9893d5c1 Mon Sep 17 00:00:00 2001 From: Dong Wang Date: Thu, 23 May 2024 09:30:04 +0800 Subject: [PATCH] iut: add case to test divide0 exception Make sure divide zero exception happens as expected and fatal context is correctly printed out in logs. Signed-off-by: Dong Wang --- zephyr/iut_test/test_zephyr/CMakeLists.txt | 2 ++ zephyr/iut_test/test_zephyr/x86/test_fatal.c | 23 ++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 zephyr/iut_test/test_zephyr/x86/test_fatal.c diff --git a/zephyr/iut_test/test_zephyr/CMakeLists.txt b/zephyr/iut_test/test_zephyr/CMakeLists.txt index 3cd1840..25ecb03 100644 --- a/zephyr/iut_test/test_zephyr/CMakeLists.txt +++ b/zephyr/iut_test/test_zephyr/CMakeLists.txt @@ -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) diff --git a/zephyr/iut_test/test_zephyr/x86/test_fatal.c b/zephyr/iut_test/test_zephyr/x86/test_fatal.c new file mode 100644 index 0000000..e4782af --- /dev/null +++ b/zephyr/iut_test/test_zephyr/x86/test_fatal.c @@ -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);