1 /* 2 * Copyright (c) 2024 Keith Packard 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #include <zephyr/kernel.h> 8 #include <errno.h> 9 #include <zephyr/tc_util.h> 10 #include <zephyr/ztest.h> 11 /** 12 * @addtogroup kernel_common_tests 13 * @{ 14 */ 15 16 /** 17 * @brief Test if constructors work 18 * 19 */ 20 21 static int constructor_value; 22 23 #define CONSTRUCTOR_VALUE 1 24 25 void 26 __attribute__((__constructor__)) __constructor_init(void)27__constructor_init(void) 28 { 29 constructor_value = CONSTRUCTOR_VALUE; 30 } 31 ZTEST(constructor,test_constructor)32ZTEST(constructor, test_constructor) 33 { 34 zassert_equal(constructor_value, CONSTRUCTOR_VALUE, 35 "constructor test failed: constructor not called"); 36 } 37 38 extern void *common_setup(void); 39 ZTEST_SUITE(constructor, NULL, common_setup, NULL, NULL, NULL); 40 41 /** 42 * @} 43 */ 44