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 1/6] runner: Use a bigger buffer for receiving test outputs
Date: Tue, 8 Nov 2022 12:07:28 +0200 [thread overview]
Message-ID: <20221108100733.2378106-1-petri.latvala@intel.com> (raw)
Stream-based receiving was able to use buffers of any size for read(),
but with datagrams we actually need to prepare for actual sizes. In
practice, some file dumps from tests come as single log packets of a
couple of kB.
v2: Use a KB() macro for the buffer size (Kamil).
Signed-off-by: Petri Latvala <petri.latvala@intel.com>
Cc: Arkadiusz Hiler <arek@hiler.eu>
Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com>
---
runner/executor.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/runner/executor.c b/runner/executor.c
index a79a34e0..7fa932ac 100644
--- a/runner/executor.c
+++ b/runner/executor.c
@@ -842,6 +842,9 @@ static void write_packet_with_canary(int fd, struct runnerpacket *packet, bool s
fdatasync(fd);
}
+/* TODO: Refactor this macro from here and from various tests to lib */
+#define KB(x) ((x) * 1024)
+
/*
* Returns:
* =0 - Success
@@ -857,7 +860,8 @@ static int monitor_output(pid_t child,
char **abortreason)
{
fd_set set;
- char buf[2048];
+ char *buf;
+ size_t bufsize;
char *outbuf = NULL;
size_t outbufsize = 0;
char current_subtest[256] = {};
@@ -910,6 +914,9 @@ static int monitor_output(pid_t child,
}
}
+ bufsize = KB(256);
+ buf = malloc(bufsize);
+
while (outfd >= 0 || errfd >= 0 || sigfd >= 0) {
const char *timeout_reason;
struct timeval tv = { .tv_sec = interval_length };
@@ -942,7 +949,7 @@ static int monitor_output(pid_t child,
time_last_activity = time_now;
- s = read(outfd, buf, sizeof(buf));
+ s = read(outfd, buf, bufsize);
if (s <= 0) {
if (s < 0) {
errf("Error reading test's stdout: %m\n");
@@ -1037,7 +1044,7 @@ static int monitor_output(pid_t child,
if (errfd >= 0 && FD_ISSET(errfd, &set)) {
time_last_activity = time_now;
- s = read(errfd, buf, sizeof(buf));
+ s = read(errfd, buf, bufsize);
if (s <= 0) {
if (s < 0) {
errf("Error reading test's stderr: %m\n");
@@ -1060,7 +1067,7 @@ static int monitor_output(pid_t child,
/* Fully drain everything */
while (true) {
- s = recv(socketfd, buf, sizeof(buf), MSG_DONTWAIT);
+ s = recv(socketfd, buf, bufsize, MSG_DONTWAIT);
if (s < 0) {
if (errno == EAGAIN)
@@ -1394,6 +1401,7 @@ static int monitor_output(pid_t child,
fdatasync(outputs[_F_DMESG]);
close_watchdogs(settings);
+ free(buf);
free(outbuf);
close(outfd);
close(errfd);
@@ -1418,6 +1426,7 @@ static int monitor_output(pid_t child,
if (settings->sync)
fdatasync(outputs[_F_DMESG]);
+ free(buf);
free(outbuf);
close(outfd);
close(errfd);
--
2.30.2
next 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 Petri Latvala [this message]
2022-11-08 10:07 ` [igt-dev] [PATCH i-g-t v2 2/6] igt_core: Split too long log lines when sending to runner with comms Petri Latvala
2022-11-08 11:56 ` 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-1-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox