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 |
| 4 | * |
| 5 | * Copyright 2022 Google LLC |
| 6 | * Written by Simon Glass <sjg@chromium.org> |
| 7 | */ |
| 8 | |
Simon Glass | 644d807 | 2022-08-01 07:57:59 -0600 | [diff] [blame] | 9 | #include <test/lib.h> |
| 10 | #include <test/test.h> |
| 11 | #include <test/ut.h> |
| 12 | |
| 13 | static int lib_test_is_enabled(struct unit_test_state *uts) |
| 14 | { |
| 15 | ulong val; |
| 16 | |
Marek Vasut | 1531c4e | 2023-03-10 04:33:13 +0100 | [diff] [blame] | 17 | ut_asserteq(1, IS_ENABLED(CONFIG_CMDLINE)); |
| 18 | ut_asserteq(0, IS_ENABLED(CONFIG__UNDEFINED)); |
Simon Glass | 644d807 | 2022-08-01 07:57:59 -0600 | [diff] [blame] | 19 | |
Marek Vasut | 1531c4e | 2023-03-10 04:33:13 +0100 | [diff] [blame] | 20 | ut_asserteq(1, CONFIG_IS_ENABLED(CMDLINE)); |
| 21 | ut_asserteq(0, CONFIG_IS_ENABLED(OF_PLATDATA)); |
| 22 | ut_asserteq(0, CONFIG_IS_ENABLED(_UNDEFINED)); |
Simon Glass | 644d807 | 2022-08-01 07:57:59 -0600 | [diff] [blame] | 23 | |
Simon Glass | 9f076ea | 2023-09-26 08:14:50 -0600 | [diff] [blame] | 24 | ut_asserteq(0xb000, |
Simon Glass | 644d807 | 2022-08-01 07:57:59 -0600 | [diff] [blame] | 25 | IF_ENABLED_INT(CONFIG_BLOBLIST_FIXED, CONFIG_BLOBLIST_ADDR)); |
Simon Glass | 9f076ea | 2023-09-26 08:14:50 -0600 | [diff] [blame] | 26 | ut_asserteq(0xb000, |
Simon Glass | 644d807 | 2022-08-01 07:57:59 -0600 | [diff] [blame] | 27 | CONFIG_IF_ENABLED_INT(BLOBLIST_FIXED, BLOBLIST_ADDR)); |
| 28 | |
| 29 | /* |
| 30 | * This fails if CONFIG_TEST_KCONFIG_ENABLE is not enabled, since the |
| 31 | * value is used. Disable for SPL so that the errors in kconfig_spl.c |
| 32 | * are detected, since otherwise a build error when building U-Boot may |
| 33 | * cause SPL to not be built. |
| 34 | */ |
| 35 | if (!IS_ENABLED(CONFIG_SANDBOX_SPL) && |
| 36 | IS_ENABLED(CONFIG_TEST_KCONFIG)) { |
| 37 | val = IF_ENABLED_INT(CONFIG_TEST_KCONFIG_ENABLE, |
| 38 | CONFIG_TEST_KCONFIG_VALUE); |
| 39 | printf("value %ld\n", val); |
| 40 | } |
| 41 | |
| 42 | /* |
| 43 | * This fails if CONFIG_TEST_KCONFIG_ENABLE is not enabled, since the |
| 44 | * value is used. Disable for SPL so that the errors in kconfig_spl.c |
| 45 | * are detected, since otherwise a build error when building U-Boot may |
| 46 | * cause SPL to not be built. |
| 47 | */ |
| 48 | if (!IS_ENABLED(CONFIG_SANDBOX_SPL) && |
| 49 | CONFIG_IS_ENABLED(TEST_KCONFIG)) { |
| 50 | val = CONFIG_IF_ENABLED_INT(TEST_KCONFIG_ENABLE, |
| 51 | TEST_KCONFIG_VALUE); |
| 52 | printf("value2 %ld\n", val); |
| 53 | } |
| 54 | |
| 55 | return 0; |
| 56 | } |
| 57 | LIB_TEST(lib_test_is_enabled, 0); |