cont_test.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (c) 2020, Heinrich Schuchardt <xypron.glpk@gmx.de>
  4. *
  5. * Test continuation of log messages.
  6. */
  7. #include <common.h>
  8. #include <console.h>
  9. #include <test/log.h>
  10. #include <test/test.h>
  11. #include <test/suites.h>
  12. #include <test/ut.h>
  13. DECLARE_GLOBAL_DATA_PTR;
  14. #define BUFFSIZE 64
  15. static int log_test_cont(struct unit_test_state *uts)
  16. {
  17. int log_fmt;
  18. int log_level;
  19. log_fmt = gd->log_fmt;
  20. log_level = gd->default_log_level;
  21. /* Write two messages, the second continuing the first */
  22. gd->log_fmt = (1 << LOGF_CAT) | (1 << LOGF_LEVEL) | (1 << LOGF_MSG);
  23. gd->default_log_level = LOGL_INFO;
  24. console_record_reset_enable();
  25. log(LOGC_ARCH, LOGL_ERR, "ea%d ", 1);
  26. log(LOGC_CONT, LOGL_CONT, "cc%d\n", 2);
  27. gd->default_log_level = log_level;
  28. gd->log_fmt = log_fmt;
  29. gd->flags &= ~GD_FLG_RECORD;
  30. ut_assertok(ut_check_console_line(uts, "ERR.arch, ea1 ERR.arch, cc2"));
  31. ut_assertok(ut_check_console_end(uts));
  32. /* Write a third message which is not a continuation */
  33. gd->log_fmt = (1 << LOGF_CAT) | (1 << LOGF_LEVEL) | (1 << LOGF_MSG);
  34. gd->default_log_level = LOGL_INFO;
  35. console_record_reset_enable();
  36. log(LOGC_EFI, LOGL_INFO, "ie%d\n", 3);
  37. gd->default_log_level = log_level;
  38. gd->log_fmt = log_fmt;
  39. gd->flags &= ~GD_FLG_RECORD;
  40. ut_assertok(ut_check_console_line(uts, "INFO.efi, ie3"));
  41. ut_assertok(ut_check_console_end(uts));
  42. return 0;
  43. }
  44. LOG_TEST(log_test_cont);