Simon Glass | 644d807 | 2022-08-01 07:57:59 -0600 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Test of linux/kconfig.h macros for SPL |
| 4 | * |
| 5 | * Copyright 2022 Google LLC |
| 6 | * Written by Simon Glass <sjg@chromium.org> |
| 7 | */ |
| 8 | |
| 9 | #include <common.h> |
| 10 | #include <test/lib.h> |
| 11 | #include <test/test.h> |
| 12 | #include <test/ut.h> |
| 13 | |
| 14 | static int lib_test_spl_is_enabled(struct unit_test_state *uts) |
| 15 | { |
| 16 | ulong val; |
| 17 | |
| 18 | ut_asserteq(0, CONFIG_IS_ENABLED(CMDLINE)) |
| 19 | ut_asserteq(1, CONFIG_IS_ENABLED(OF_PLATDATA)) |
| 20 | ut_asserteq(0, CONFIG_IS_ENABLED(_UNDEFINED)) |
| 21 | |
| 22 | /* |
| 23 | * This fails if CONFIG_TEST_KCONFIG_ENABLE is not enabled, since the |
| 24 | * value is used. |
| 25 | */ |
| 26 | if (IS_ENABLED(CONFIG_TEST_KCONFIG)) { |
| 27 | val = IF_ENABLED_INT(CONFIG_TEST_KCONFIG_ENABLE, |
| 28 | CONFIG_TEST_KCONFIG_VALUE); |
| 29 | printf("value %ld\n", val); |
| 30 | } |
| 31 | |
| 32 | /* |
| 33 | * This fails if CONFIG_TEST_KCONFIG_ENABLE is not enabled, since the |
| 34 | * value is used. |
| 35 | */ |
| 36 | if (CONFIG_IS_ENABLED(TEST_KCONFIG)) { |
| 37 | val = CONFIG_IF_ENABLED_INT(TEST_KCONFIG_ENABLE, |
| 38 | TEST_KCONFIG_VALUE); |
| 39 | printf("value2 %ld\n", val); |
| 40 | } |
| 41 | |
| 42 | return 0; |
| 43 | } |
| 44 | LIB_TEST(lib_test_spl_is_enabled, 0); |