// SPDX-License-Identifier: GPL-2.0+
/*
 * Copyright (c) 2020, Heinrich Schuchardt <xypron.glpk@gmx.de>
 *
 * Test continuation of log messages.
 */

#include <console.h>
#include <asm/global_data.h>
#include <test/log.h>
#include <test/test.h>
#include <test/suites.h>
#include <test/ut.h>

DECLARE_GLOBAL_DATA_PTR;

static int log_test_cont(struct unit_test_state *uts)
{
	int log_fmt;
	int log_level;

	log_fmt = gd->log_fmt;
	log_level = gd->default_log_level;

	/* Write two messages, the second continuing the first */
	gd->log_fmt = (1 << LOGF_CAT) | (1 << LOGF_LEVEL) | (1 << LOGF_MSG);
	gd->default_log_level = LOGL_INFO;
	log(LOGC_ARCH, LOGL_ERR, "ea%d\n", 1);
	log(LOGC_CONT, LOGL_CONT, "cc%d\n", 2);
	gd->default_log_level = log_level;
	gd->log_fmt = log_fmt;
	gd->flags &= ~GD_FLG_RECORD;
	ut_assertok(ut_check_console_line(uts, "ERR.arch, ea1"));
	ut_assertok(ut_check_console_line(uts, "ERR.arch, cc2"));
	ut_assert_console_end();

	/* Write a third message which is not a continuation */
	gd->log_fmt = (1 << LOGF_CAT) | (1 << LOGF_LEVEL) | (1 << LOGF_MSG);
	gd->default_log_level = LOGL_INFO;
	console_record_reset_enable();
	log(LOGC_EFI, LOGL_INFO, "ie%d\n", 3);
	gd->default_log_level = log_level;
	gd->log_fmt = log_fmt;
	gd->flags &= ~GD_FLG_RECORD;
	ut_assertok(ut_check_console_line(uts, "INFO.efi, ie3"));
	ut_assert_console_end();

	/* Write two messages without a newline between them */
	gd->log_fmt = (1 << LOGF_CAT) | (1 << LOGF_LEVEL) | (1 << LOGF_MSG);
	gd->default_log_level = LOGL_INFO;
	console_record_reset_enable();
	log(LOGC_ARCH, LOGL_ERR, "ea%d ", 1);
	log(LOGC_CONT, LOGL_CONT, "cc%d\n", 2);
	gd->default_log_level = log_level;
	gd->log_fmt = log_fmt;
	gd->flags &= ~GD_FLG_RECORD;
	ut_assertok(ut_check_console_line(uts, "ERR.arch, ea1 cc2"));
	ut_assert_console_end();

	return 0;
}
LOG_TEST(log_test_cont);
