pr_cont_test.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (c) 2021, Heinrich Schuchardt <xypron.glpk@gmx.de>
  4. *
  5. * Test continuation of log messages using pr_cont().
  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. #include <asm/global_data.h>
  14. #include <linux/printk.h>
  15. #define BUFFSIZE 64
  16. #undef CONFIG_LOGLEVEL
  17. #define CONFIG_LOGLEVEL 4
  18. DECLARE_GLOBAL_DATA_PTR;
  19. static int log_test_pr_cont(struct unit_test_state *uts)
  20. {
  21. int log_fmt;
  22. int log_level;
  23. log_fmt = gd->log_fmt;
  24. log_level = gd->default_log_level;
  25. /* Write two messages, the second continuing the first */
  26. gd->log_fmt = BIT(LOGF_MSG);
  27. gd->default_log_level = LOGL_INFO;
  28. console_record_reset_enable();
  29. pr_err("ea%d ", 1);
  30. pr_cont("cc%d\n", 2);
  31. gd->default_log_level = log_level;
  32. gd->log_fmt = log_fmt;
  33. gd->flags &= ~GD_FLG_RECORD;
  34. ut_assertok(ut_check_console_line(uts, "ea1 cc2"));
  35. ut_assertok(ut_check_console_end(uts));
  36. return 0;
  37. }
  38. LOG_TEST(log_test_pr_cont);