Simon Glass | 29784d6 | 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 | |
| 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_is_enabled(struct unit_test_state *uts) |
| 15 | { |
| 16 | ulong val; |
| 17 | |
| 18 | ut_asserteq(1, IS_ENABLED(CONFIG_CMDLINE)) |
| 19 | ut_asserteq(0, IS_ENABLED(CONFIG__UNDEFINED)) |
| 20 | |
| 21 | ut_asserteq(1, CONFIG_IS_ENABLED(CMDLINE)) |
| 22 | ut_asserteq(0, CONFIG_IS_ENABLED(OF_PLATDATA)) |
| 23 | ut_asserteq(0, CONFIG_IS_ENABLED(_UNDEFINED)) |
| 24 | |
| 25 | ut_asserteq(0xc000, |
| 26 | IF_ENABLED_INT(CONFIG_BLOBLIST_FIXED, CONFIG_BLOBLIST_ADDR)); |
| 27 | ut_asserteq(0xc000, |
| 28 | CONFIG_IF_ENABLED_INT(BLOBLIST_FIXED, BLOBLIST_ADDR)); |
| 29 | |
| 30 | /* |
| 31 | * This fails if CONFIG_TEST_KCONFIG_ENABLE is not enabled, since the |
| 32 | * value is used. Disable for SPL so that the errors in kconfig_spl.c |
| 33 | * are detected, since otherwise a build error when building U-Boot may |
| 34 | * cause SPL to not be built. |
| 35 | */ |
| 36 | if (!IS_ENABLED(CONFIG_SANDBOX_SPL) && |
| 37 | IS_ENABLED(CONFIG_TEST_KCONFIG)) { |
| 38 | val = IF_ENABLED_INT(CONFIG_TEST_KCONFIG_ENABLE, |
| 39 | CONFIG_TEST_KCONFIG_VALUE); |
| 40 | printf("value %ld\n", val); |
| 41 | } |
| 42 | |
| 43 | /* |
| 44 | * This fails if CONFIG_TEST_KCONFIG_ENABLE is not enabled, since the |
| 45 | * value is used. Disable for SPL so that the errors in kconfig_spl.c |
| 46 | * are detected, since otherwise a build error when building U-Boot may |
| 47 | * cause SPL to not be built. |
| 48 | */ |
| 49 | if (!IS_ENABLED(CONFIG_SANDBOX_SPL) && |
| 50 | CONFIG_IS_ENABLED(TEST_KCONFIG)) { |
| 51 | val = CONFIG_IF_ENABLED_INT(TEST_KCONFIG_ENABLE, |
| 52 | TEST_KCONFIG_VALUE); |
| 53 | printf("value2 %ld\n", val); |
| 54 | } |
| 55 | |
| 56 | return 0; |
| 57 | } |
| 58 | LIB_TEST(lib_test_is_enabled, 0); |