pr_cont_test.c 979 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. DECLARE_GLOBAL_DATA_PTR;
  17. static int log_test_pr_cont(struct unit_test_state *uts)
  18. {
  19. int log_fmt;
  20. int log_level;
  21. log_fmt = gd->log_fmt;
  22. log_level = gd->default_log_level;
  23. /* Write two messages, the second continuing the first */
  24. gd->log_fmt = BIT(LOGF_MSG);
  25. gd->default_log_level = LOGL_INFO;
  26. console_record_reset_enable();
  27. pr_err("ea%d ", 1);
  28. pr_cont("cc%d\n", 2);
  29. gd->default_log_level = log_level;
  30. gd->log_fmt = log_fmt;
  31. gd->flags &= ~GD_FLG_RECORD;
  32. ut_assertok(ut_check_console_line(uts, "ea1 cc2"));
  33. ut_assertok(ut_check_console_end(uts));
  34. return 0;
  35. }
  36. LOG_TEST(log_test_pr_cont);