blob: 3bd8abdf4b8ef4545e45ef9129b5a329af732f72 [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 for SPL
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_spl_is_enabled(struct unit_test_state *uts)
14{
15 ulong val;
16
Marek Vasut1531c4e2023-03-10 04:33:13 +010017 ut_asserteq(0, CONFIG_IS_ENABLED(CMDLINE));
18 ut_asserteq(1, CONFIG_IS_ENABLED(OF_PLATDATA));
19 ut_asserteq(0, CONFIG_IS_ENABLED(_UNDEFINED));
Simon Glass644d8072022-08-01 07:57:59 -060020
21 /*
22 * This fails if CONFIG_TEST_KCONFIG_ENABLE is not enabled, since the
23 * value is used.
24 */
25 if (IS_ENABLED(CONFIG_TEST_KCONFIG)) {
26 val = IF_ENABLED_INT(CONFIG_TEST_KCONFIG_ENABLE,
27 CONFIG_TEST_KCONFIG_VALUE);
28 printf("value %ld\n", val);
29 }
30
31 /*
32 * This fails if CONFIG_TEST_KCONFIG_ENABLE is not enabled, since the
33 * value is used.
34 */
35 if (CONFIG_IS_ENABLED(TEST_KCONFIG)) {
36 val = CONFIG_IF_ENABLED_INT(TEST_KCONFIG_ENABLE,
37 TEST_KCONFIG_VALUE);
38 printf("value2 %ld\n", val);
39 }
40
41 return 0;
42}
43LIB_TEST(lib_test_spl_is_enabled, 0);