All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petri Latvala <petri.latvala@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Petri Latvala <petri.latvala@intel.com>
Subject: [igt-dev] [PATCH i-g-t v2 2/6] igt_core: Split too long log lines when sending to runner with comms
Date: Tue,  8 Nov 2022 12:07:29 +0200	[thread overview]
Message-ID: <20221108100733.2378106-2-petri.latvala@intel.com> (raw)
In-Reply-To: <20221108100733.2378106-1-petri.latvala@intel.com>

Especially with file dumps a single log packet could exceed the max
size of a UNIX datagram. Split too long log chunks instead.

v2: Use while loop instead of recursion (Kamil).

Signed-off-by: Petri Latvala <petri.latvala@intel.com>
Cc: Arkadiusz Hiler <arek@hiler.eu>
Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com>
---
 lib/igt_core.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/lib/igt_core.c b/lib/igt_core.c
index 3941c528..cab5f860 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -457,6 +457,27 @@ static void _igt_log_buffer_reset(void)
 	pthread_mutex_unlock(&log_buffer_mutex);
 }
 
+static void _log_to_runner_split(int stream, const char *str)
+{
+	size_t limit = 4096;
+	char *buf = NULL;
+
+	while (strlen(str) > limit) {
+		if (!buf)
+			buf = malloc(limit + 1);
+
+		strncpy(buf, str, limit);
+		buf[limit] = '\0';
+
+		send_to_runner(runnerpacket_log(stream, buf));
+
+		str += limit;
+	}
+
+	send_to_runner(runnerpacket_log(stream, str));
+	free(buf);
+}
+
 __attribute__((format(printf, 2, 3)))
 static void _log_line_fprintf(FILE* stream, const char *format, ...)
 {
@@ -467,7 +488,7 @@ static void _log_line_fprintf(FILE* stream, const char *format, ...)
 
 	if (runner_connected()) {
 		vasprintf(&str, format, ap);
-		send_to_runner(runnerpacket_log(fileno(stream), str));
+		_log_to_runner_split(fileno(stream), str);
 		free(str);
 	} else {
 		vfprintf(stream, format, ap);
-- 
2.30.2

  reply	other threads:[~2022-11-08 10:07 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-08 10:07 [igt-dev] [PATCH i-g-t v2 1/6] runner: Use a bigger buffer for receiving test outputs Petri Latvala
2022-11-08 10:07 ` Petri Latvala [this message]
2022-11-08 11:56   ` [igt-dev] [PATCH i-g-t v2 2/6] igt_core: Split too long log lines when sending to runner with comms Kamil Konieczny
2022-11-09 12:33   ` [igt-dev] [PATCH i-g-t v3 " Petri Latvala
2022-11-08 10:07 ` [igt-dev] [PATCH i-g-t 3/6] runner: Continue using socket comms when getting an invalid packet Petri Latvala
2022-11-08 10:07 ` [igt-dev] [PATCH i-g-t 4/6] igt_core: Make sure test result gets to runner when test has no subtests Petri Latvala
2022-11-08 10:07 ` [igt-dev] [PATCH i-g-t 5/6] lib/runnercomms: Report empty comms dump as empty Petri Latvala
2022-11-08 10:07 ` [igt-dev] [PATCH i-g-t 6/6] Revert "runner: Disable socket communications for now" Petri Latvala
2022-11-08 11:57 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,v2,1/6] runner: Use a bigger buffer for receiving test outputs Patchwork
2022-11-08 14:15 ` [igt-dev] [PATCH i-g-t v2 1/6] " Kamil Konieczny
2022-11-08 15:41 ` [igt-dev] ✗ Fi.CI.IGT: failure for series starting with [i-g-t,v2,1/6] " Patchwork
2022-11-09 13:24 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,v2,1/6] runner: Use a bigger buffer for receiving test outputs (rev2) Patchwork
2022-11-09 17:06 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2022-11-10  8:07   ` Petri Latvala
2022-11-10 15:23     ` Vudum, Lakshminarayana
2022-11-10 15:06 ` [igt-dev] ✓ Fi.CI.IGT: success " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221108100733.2378106-2-petri.latvala@intel.com \
    --to=petri.latvala@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.