test: detect linebreaks in log messages

If a single log message is composed of multiple calls (as are all from
evdev_log_*), don't prefix multiple times.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2017-03-28 11:38:12 +10:00
parent 0bd36f2542
commit 6ab2999be9

View file

@ -786,6 +786,7 @@ litest_log_handler(struct libinput *libinput,
va_list args) va_list args)
{ {
static int is_tty = -1; static int is_tty = -1;
static bool had_newline = true;
const char *priority = NULL; const char *priority = NULL;
const char *color; const char *color;
@ -812,11 +813,12 @@ litest_log_handler(struct libinput *libinput,
if (!is_tty) if (!is_tty)
color = ""; color = "";
if (had_newline)
fprintf(stderr, "%slitest %s ", color, priority); fprintf(stderr, "%slitest %s ", color, priority);
vfprintf(stderr, format, args); vfprintf(stderr, format, args);
had_newline = strlen(format) >= 1 &&
if (is_tty) format[strlen(format) - 1] == '\n';
if (is_tty && had_newline)
fprintf(stderr, ANSI_NORMAL); fprintf(stderr, ANSI_NORMAL);
if (strstr(format, "client bug: ") || if (strstr(format, "client bug: ") ||