kconfig_spl.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. #include <common.h>
  9. #include <test/lib.h>
  10. #include <test/test.h>
  11. #include <test/ut.h>
  12. static int lib_test_spl_is_enabled(struct unit_test_state *uts)
  13. {
  14. ulong val;
  15. ut_asserteq(0, CONFIG_IS_ENABLED(CMDLINE));
  16. ut_asserteq(1, CONFIG_IS_ENABLED(OF_PLATDATA));
  17. ut_asserteq(0, CONFIG_IS_ENABLED(_UNDEFINED));
  18. /*
  19. * This fails if CONFIG_TEST_KCONFIG_ENABLE is not enabled, since the
  20. * value is used.
  21. */
  22. if (IS_ENABLED(CONFIG_TEST_KCONFIG)) {
  23. val = IF_ENABLED_INT(CONFIG_TEST_KCONFIG_ENABLE,
  24. CONFIG_TEST_KCONFIG_VALUE);
  25. printf("value %ld\n", val);
  26. }
  27. /*
  28. * This fails if CONFIG_TEST_KCONFIG_ENABLE is not enabled, since the
  29. * value is used.
  30. */
  31. if (CONFIG_IS_ENABLED(TEST_KCONFIG)) {
  32. val = CONFIG_IF_ENABLED_INT(TEST_KCONFIG_ENABLE,
  33. TEST_KCONFIG_VALUE);
  34. printf("value2 %ld\n", val);
  35. }
  36. return 0;
  37. }
  38. LIB_TEST(lib_test_spl_is_enabled, 0);