blob: a3645abf9464785461c7250260c816e6bca03193 [file] [log] [blame]
Simon Glass644d8072022-08-01 07:57:59 -06001// 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 Glass644d8072022-08-01 07:57:59 -06009#include <test/lib.h>
10#include <test/test.h>
11#include <test/ut.h>
12
13static int lib_test_is_enabled(struct unit_test_state *uts)
14{
15 ulong val;
16
Marek Vasut1531c4e2023-03-10 04:33:13 +010017 ut_asserteq(1, IS_ENABLED(CONFIG_CMDLINE));
18 ut_asserteq(0, IS_ENABLED(CONFIG__UNDEFINED));
Simon Glass644d8072022-08-01 07:57:59 -060019
Marek Vasut1531c4e2023-03-10 04:33:13 +010020 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 Glass644d8072022-08-01 07:57:59 -060023
Evgeny Bachinin9cd1b822024-12-02 16:45:23 +030024 if (IS_ENABLED(CONFIG_BLOBLIST)) {
25 ut_asserteq(0xb000, IF_ENABLED_INT(CONFIG_BLOBLIST_FIXED,
26 CONFIG_BLOBLIST_ADDR));
27 ut_asserteq(0xb000, CONFIG_IF_ENABLED_INT(BLOBLIST_FIXED,
28 BLOBLIST_ADDR));
29 }
Simon Glass644d8072022-08-01 07:57:59 -060030
31 /*
32 * This fails if CONFIG_TEST_KCONFIG_ENABLE is not enabled, since the
33 * value is used. Disable for SPL so that the errors in kconfig_spl.c
34 * are detected, since otherwise a build error when building U-Boot may
35 * cause SPL to not be built.
36 */
37 if (!IS_ENABLED(CONFIG_SANDBOX_SPL) &&
38 IS_ENABLED(CONFIG_TEST_KCONFIG)) {
39 val = IF_ENABLED_INT(CONFIG_TEST_KCONFIG_ENABLE,
40 CONFIG_TEST_KCONFIG_VALUE);
41 printf("value %ld\n", val);
42 }
43
44 /*
45 * This fails if CONFIG_TEST_KCONFIG_ENABLE is not enabled, since the
46 * value is used. Disable for SPL so that the errors in kconfig_spl.c
47 * are detected, since otherwise a build error when building U-Boot may
48 * cause SPL to not be built.
49 */
50 if (!IS_ENABLED(CONFIG_SANDBOX_SPL) &&
51 CONFIG_IS_ENABLED(TEST_KCONFIG)) {
52 val = CONFIG_IF_ENABLED_INT(TEST_KCONFIG_ENABLE,
53 TEST_KCONFIG_VALUE);
54 printf("value2 %ld\n", val);
55 }
56
57 return 0;
58}
59LIB_TEST(lib_test_is_enabled, 0);