nolog_ndebug.c 916 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright 2021 Google LLC
  4. *
  5. * Logging function tests for CONFIG_LOG=n without #define DEBUG
  6. */
  7. #include <common.h>
  8. #include <console.h>
  9. #include <log.h>
  10. #include <asm/global_data.h>
  11. #include <test/log.h>
  12. #include <test/ut.h>
  13. DECLARE_GLOBAL_DATA_PTR;
  14. #define BUFFSIZE 32
  15. static int log_test_log_disabled_ndebug(struct unit_test_state *uts)
  16. {
  17. char buf[BUFFSIZE];
  18. int i;
  19. memset(buf, 0, BUFFSIZE);
  20. console_record_reset_enable();
  21. /* Output a log record at every level */
  22. for (i = LOGL_EMERG; i < LOGL_COUNT; i++)
  23. log(LOGC_NONE, i, "testing level %i\n", i);
  24. gd->flags &= ~GD_FLG_RECORD;
  25. /* Since DEBUG is not defined, we expect to not get debug output */
  26. for (i = LOGL_EMERG; i < LOGL_DEBUG; i++)
  27. ut_assertok(ut_check_console_line(uts, "testing level %d", i));
  28. ut_assertok(ut_check_console_end(uts));
  29. return 0;
  30. }
  31. LOG_TEST(log_test_log_disabled_ndebug);