summaryrefslogtreecommitdiffstats
path: root/meta/recipes-support/ptest-runner
diff options
context:
space:
mode:
authorRandy MacLeod <Randy.MacLeod@windriver.com>2019-08-01 16:36:48 -0400
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-08-03 23:56:01 +0100
commit640c59a70658708863ff15e3b9de5a4b4bfab2e4 (patch)
treec9e59d45867b4c482adbc58d9dcff880da861a37 /meta/recipes-support/ptest-runner
parentf2a951f479bbb68ae7702785c7916325fc97f1c2 (diff)
downloadpoky-640c59a70658708863ff15e3b9de5a4b4bfab2e4.tar.gz
ptest-runner: update from 2.3.1 to 2.3.2
All local patches are now upstream so they have been dropped. Other upstream commits make ptest-runner build using: clang -Weverything $ git log --oneline b73bd54..7015e91 7015e91 (HEAD -> oe-core-master, tag: v2.3.2, origin/master, origin/HEAD, master) Fix additional warnings when using clang dd1daa8 tests: fix clang warnings. 15fd131 main code: fix clang warnings 59381a6 utils: ensure child can be session leader 5fe2c0a utils: Ensure pipes are read after exit 79a9c27 use process groups when spawning b73bd54 utils: Ensure stdout/stderr are flushed (From OE-Core rev: 9a80a352a9d0c4ea09de7bb370267672c32771f2) Signed-off-by: Randy MacLeod <Randy.MacLeod@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-support/ptest-runner')
-rw-r--r--meta/recipes-support/ptest-runner/ptest-runner/0001-utils-Ensure-stdout-stderr-are-flushed.patch45
-rw-r--r--meta/recipes-support/ptest-runner/ptest-runner/0002-use-process-groups-when-spawning.patch35
-rw-r--r--meta/recipes-support/ptest-runner/ptest-runner/0003-utils-Ensure-pipes-are-read-after-exit.patch76
-rw-r--r--meta/recipes-support/ptest-runner/ptest-runner/0004-utils-ensure-child-can-be-session-leader.patch212
-rw-r--r--meta/recipes-support/ptest-runner/ptest-runner_2.3.2.bb (renamed from meta/recipes-support/ptest-runner/ptest-runner_2.3.1.bb)8
5 files changed, 2 insertions, 374 deletions
diff --git a/meta/recipes-support/ptest-runner/ptest-runner/0001-utils-Ensure-stdout-stderr-are-flushed.patch b/meta/recipes-support/ptest-runner/ptest-runner/0001-utils-Ensure-stdout-stderr-are-flushed.patch
deleted file mode 100644
index c9a9dd7cf4..0000000000
--- a/meta/recipes-support/ptest-runner/ptest-runner/0001-utils-Ensure-stdout-stderr-are-flushed.patch
+++ /dev/null
@@ -1,45 +0,0 @@
1From 9b36993794c1de733c521b2477370c874c07b617 Mon Sep 17 00:00:00 2001
2From: Richard Purdie <richard.purdie@linuxfoundation.org>
3Date: Thu, 4 Apr 2019 14:18:55 +0100
4Subject: [PATCH 1/3] utils: Ensure stdout/stderr are flushed
5
6There is no guarantee that the data written with fwrite will be flushed to the
7buffer. If stdout and stderr are the same thing, this could lead to interleaved
8writes. The common case is stdout output so flush the output pipes when writing to
9stderr. Also flush stdout before the function returns.
10
11Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
12Upstream-Status: Pending [code being tested]
13---
14 utils.c | 7 +++++--
15 1 file changed, 5 insertions(+), 2 deletions(-)
16
17diff --git a/utils.c b/utils.c
18index 504df0b..3ceb342 100644
19--- a/utils.c
20+++ b/utils.c
21@@ -295,8 +295,11 @@ wait_child(const char *ptest_dir, const char *run_ptest, pid_t pid,
22 }
23
24 if (pfds[1].revents != 0) {
25- while ((n = read(fds[1], buf, WAIT_CHILD_BUF_MAX_SIZE)) > 0)
26+ while ((n = read(fds[1], buf, WAIT_CHILD_BUF_MAX_SIZE)) > 0) {
27+ fflush(fps[0]);
28 fwrite(buf, n, 1, fps[1]);
29+ fflush(fps[1]);
30+ }
31 }
32
33 clock_gettime(clock, &sentinel);
34@@ -315,7 +318,7 @@ wait_child(const char *ptest_dir, const char *run_ptest, pid_t pid,
35 break;
36 }
37
38-
39+ fflush(fps[0]);
40 return status;
41 }
42
43--
442.17.1
45
diff --git a/meta/recipes-support/ptest-runner/ptest-runner/0002-use-process-groups-when-spawning.patch b/meta/recipes-support/ptest-runner/ptest-runner/0002-use-process-groups-when-spawning.patch
deleted file mode 100644
index 5436a3340c..0000000000
--- a/meta/recipes-support/ptest-runner/ptest-runner/0002-use-process-groups-when-spawning.patch
+++ /dev/null
@@ -1,35 +0,0 @@
1From f0c42a65633341ad048718c7a6dbd035818e9eaf Mon Sep 17 00:00:00 2001
2From: Richard Purdie <richard.purdie@linuxfoundation.org>
3Date: Thu, 4 Apr 2019 14:20:31 +0100
4Subject: [PATCH 2/3] use process groups when spawning
5
6Rather than just killing the process we've swawned, set the process group
7for spawned children and then kill the group of processes.
8
9Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
10Upstream-Status: Pending [code being tested]
11---
12 utils.c | 9 +++++----
13 1 file changed, 5 insertions(+), 4 deletions(-)
14
15diff --git a/utils.c b/utils.c
16index 3ceb342..c5b3b8d 100644
17--- a/utils.c
18+++ b/utils.c
19@@ -309,7 +309,7 @@ wait_child(const char *ptest_dir, const char *run_ptest, pid_t pid,
20 clock_gettime(clock, &time);
21 if ((time.tv_sec - sentinel.tv_sec) > timeout) {
22 *timeouted = 1;
23- kill(pid, SIGKILL);
24+ kill(-pid, SIGKILL);
25 waitflags = 0;
26 }
27 }
28@@ -371,6 +371,7 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts,
29 rc = -1;
30 break;
31 } else if (child == 0) {
32+ setsid();
33 run_child(p->run_ptest, pipefd_stdout[1], pipefd_stderr[1]);
34 } else {
35 int status;
diff --git a/meta/recipes-support/ptest-runner/ptest-runner/0003-utils-Ensure-pipes-are-read-after-exit.patch b/meta/recipes-support/ptest-runner/ptest-runner/0003-utils-Ensure-pipes-are-read-after-exit.patch
deleted file mode 100644
index f7c3ebe6f2..0000000000
--- a/meta/recipes-support/ptest-runner/ptest-runner/0003-utils-Ensure-pipes-are-read-after-exit.patch
+++ /dev/null
@@ -1,76 +0,0 @@
1From e58e4e1a7f854953f823dc5135d35f728f253f31 Mon Sep 17 00:00:00 2001
2From: Richard Purdie <richard.purdie@linuxfoundation.org>
3Date: Thu, 4 Apr 2019 14:24:14 +0100
4Subject: [PATCH 3/3] utils: Ensure pipes are read after exit
5
6There was a race in the code where the pipes may not be read after the process has exited
7and data may be left behind in them. This change to ordering ensures the pipes are read
8after the exit code has been read meaning no data can be left behind and the logs should
9be complete.
10
11Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
12Upstream-Status: Pending [code being tested]
13---
14 utils.c | 29 ++++++++++++++++-------------
15 1 file changed, 16 insertions(+), 13 deletions(-)
16
17diff --git a/utils.c b/utils.c
18index c5b3b8d..37e88ab 100644
19--- a/utils.c
20+++ b/utils.c
21@@ -264,6 +264,7 @@ wait_child(const char *ptest_dir, const char *run_ptest, pid_t pid, pid_t group,
22 struct pollfd pfds[2];
23 struct timespec sentinel;
24 clockid_t clock = CLOCK_MONOTONIC;
25+ int looping = 1;
26 int r;
27
28 int status;
29@@ -281,9 +282,23 @@ wait_child(const char *ptest_dir, const char *run_ptest, pid_t pid, pid_t group,
30
31 *timeouted = 0;
32
33- while (1) {
34+ while (looping) {
35 waitflags = WNOHANG;
36
37+ if (timeout >= 0) {
38+ struct timespec time;
39+
40+ clock_gettime(clock, &time);
41+ if ((time.tv_sec - sentinel.tv_sec) > timeout) {
42+ *timeouted = 1;
43+ kill(-pid, SIGKILL);
44+ waitflags = 0;
45+ }
46+ }
47+
48+ if (waitpid(pid, &status, waitflags) == pid)
49+ looping = 0;
50+
51 r = poll(pfds, 2, WAIT_CHILD_POLL_TIMEOUT_MS);
52 if (r > 0) {
53 char buf[WAIT_CHILD_BUF_MAX_SIZE];
54@@ -303,19 +318,7 @@ wait_child(const char *ptest_dir, const char *run_ptest, pid_t pid, pid_t group,
55 }
56
57 clock_gettime(clock, &sentinel);
58- } else if (timeout >= 0) {
59- struct timespec time;
60-
61- clock_gettime(clock, &time);
62- if ((time.tv_sec - sentinel.tv_sec) > timeout) {
63- *timeouted = 1;
64- kill(-pid, SIGKILL);
65- waitflags = 0;
66- }
67 }
68-
69- if (waitpid(pid, &status, waitflags) == pid)
70- break;
71 }
72
73 fflush(fps[0]);
74--
752.17.1
76
diff --git a/meta/recipes-support/ptest-runner/ptest-runner/0004-utils-ensure-child-can-be-session-leader.patch b/meta/recipes-support/ptest-runner/ptest-runner/0004-utils-ensure-child-can-be-session-leader.patch
deleted file mode 100644
index 13b4cbc7fb..0000000000
--- a/meta/recipes-support/ptest-runner/ptest-runner/0004-utils-ensure-child-can-be-session-leader.patch
+++ /dev/null
@@ -1,212 +0,0 @@
1From 79698d3205dedba887e0d2492de945d3079de029 Mon Sep 17 00:00:00 2001
2From: Randy MacLeod <Randy.MacLeod@windriver.com>
3Date: Thu, 6 Jun 2019 17:03:50 -0400
4Subject: [PATCH] utils: ensure child can be session leader
5
6When running the run-execscript bash ptest as a user rather than root, a warning:
7 bash: cannot set terminal process group (16036): Inappropriate ioctl for device
8 bash: no job control in this shell
9contaminates the bash log files causing the test to fail. This happens only
10when run under ptest-runner and not when interactively testing!
11
12The changes made to fix this include:
131. Get the process group id (pgid) before forking,
142. Set the pgid in both the parent and child to avoid a race,
153. Find, open and set permission on the child tty, and
164. Allow the child to attach to controlling tty.
17
18Also add '-lutil' to Makefile. This lib is from libc and provides openpty.
19
20Upstream-Status: Submitted [yocto@yoctoproject.org]
21
22Signed-off-by: Sakib Sajal <sakib.sajal@windriver.com>
23Signed-off-by: Randy MacLeod <Randy.MacLeod@windriver.com>
24---
25 Makefile | 2 +-
26 utils.c | 102 +++++++++++++++++++++++++++++++++++++++++++++++++------
27 2 files changed, 92 insertions(+), 12 deletions(-)
28
29diff --git a/Makefile b/Makefile
30index 1bde7be..439eb79 100644
31--- a/Makefile
32+++ b/Makefile
33@@ -29,7 +29,7 @@ TEST_DATA=$(shell echo `pwd`/tests/data)
34 all: $(SOURCES) $(EXECUTABLE)
35
36 $(EXECUTABLE): $(OBJECTS)
37- $(CC) $(LDFLAGS) $(OBJECTS) -o $@
38+ $(CC) $(LDFLAGS) $(OBJECTS) -lutil -o $@
39
40 tests: $(TEST_SOURCES) $(TEST_EXECUTABLE)
41
42diff --git a/utils.c b/utils.c
43index ad737c2..f11ce39 100644
44--- a/utils.c
45+++ b/utils.c
46@@ -1,5 +1,6 @@
47 /**
48 * Copyright (c) 2016 Intel Corporation
49+ * Copyright (C) 2019 Wind River Systems, Inc.
50 *
51 * This program is free software; you can redistribute it and/or
52 * modify it under the terms of the GNU General Public License
53@@ -22,23 +23,27 @@
54 */
55
56 #define _GNU_SOURCE
57+
58 #include <stdio.h>
59
60+#include <dirent.h>
61+#include <errno.h>
62+#include <fcntl.h>
63+#include <grp.h>
64 #include <libgen.h>
65-#include <signal.h>
66 #include <poll.h>
67-#include <fcntl.h>
68+#include <pty.h>
69+#include <signal.h>
70+#include <stdlib.h>
71+#include <string.h>
72 #include <time.h>
73-#include <dirent.h>
74+#include <unistd.h>
75+
76+#include <sys/ioctl.h>
77 #include <sys/resource.h>
78+#include <sys/stat.h>
79 #include <sys/types.h>
80 #include <sys/wait.h>
81-#include <sys/stat.h>
82-#include <unistd.h>
83-#include <string.h>
84-#include <stdlib.h>
85-
86-#include <errno.h>
87
88 #include "ptest_list.h"
89 #include "utils.h"
90@@ -346,6 +351,53 @@ wait_child(const char *ptest_dir, const char *run_ptest, pid_t pid,
91 return status;
92 }
93
94+/* Returns an integer file descriptor.
95+ * If it returns < 0, an error has occurred.
96+ * Otherwise, it has returned the slave pty file descriptor.
97+ * fp should be writable, likely stdout/err.
98+ */
99+static int
100+setup_slave_pty(FILE *fp) {
101+ int pty_master = -1;
102+ int pty_slave = -1;
103+ char pty_name[256];
104+ struct group *gptr;
105+ gid_t gid;
106+ int slave = -1;
107+
108+ if (openpty(&pty_master, &pty_slave, pty_name, NULL, NULL) < 0) {
109+ fprintf(fp, "ERROR: openpty() failed with: %s.\n", strerror(errno));
110+ return -1;
111+ }
112+
113+ if ((gptr = getgrnam(pty_name)) != 0) {
114+ gid = gptr->gr_gid;
115+ } else {
116+ /* If the tty group does not exist, don't change the
117+ * group on the slave pty, only the owner
118+ */
119+ gid = -1;
120+ }
121+
122+ /* chown/chmod the corresponding pty, if possible.
123+ * This will only work if the process has root permissions.
124+ */
125+ if (chown(pty_name, getuid(), gid) != 0) {
126+ fprintf(fp, "ERROR; chown() failed with: %s.\n", strerror(errno));
127+ }
128+
129+ /* Makes the slave read/writeable for the user. */
130+ if (chmod(pty_name, S_IRUSR|S_IWUSR) != 0) {
131+ fprintf(fp, "ERROR: chmod() failed with: %s.\n", strerror(errno));
132+ }
133+
134+ if ((slave = open(pty_name, O_RDWR)) == -1) {
135+ fprintf(fp, "ERROR: open() failed with: %s.\n", strerror(errno));
136+ }
137+ return (slave);
138+}
139+
140+
141 int
142 run_ptests(struct ptest_list *head, const struct ptest_options opts,
143 const char *progname, FILE *fp, FILE *fp_stderr)
144@@ -362,6 +414,8 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts,
145 int timeouted;
146 time_t sttime, entime;
147 int duration;
148+ int slave;
149+ int pgid = -1;
150
151 if (opts.xml_filename) {
152 xh = xml_create(ptest_list_length(head), opts.xml_filename);
153@@ -379,7 +433,6 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts,
154 close(pipefd_stdout[1]);
155 break;
156 }
157-
158 fprintf(fp, "START: %s\n", progname);
159 PTEST_LIST_ITERATE_START(head, p);
160 char *ptest_dir = strdup(p->run_ptest);
161@@ -388,6 +441,13 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts,
162 break;
163 }
164 dirname(ptest_dir);
165+ if (ioctl(0, TIOCNOTTY) == -1) {
166+ fprintf(fp, "ERROR: Unable to detach from controlling tty, %s\n", strerror(errno));
167+ }
168+
169+ if ((pgid = getpgid(0)) == -1) {
170+ fprintf(fp, "ERROR: getpgid() failed, %s\n", strerror(errno));
171+ }
172
173 child = fork();
174 if (child == -1) {
175@@ -395,13 +455,33 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts,
176 rc = -1;
177 break;
178 } else if (child == 0) {
179- setsid();
180+ close(0);
181+ if ((slave = setup_slave_pty(fp)) < 0) {
182+ fprintf(fp, "ERROR: could not setup pty (%d).", slave);
183+ }
184+ if (setpgid(0,pgid) == -1) {
185+ fprintf(fp, "ERROR: setpgid() failed, %s\n", strerror(errno));
186+ }
187+
188+ if (setsid() == -1) {
189+ fprintf(fp, "ERROR: setsid() failed, %s\n", strerror(errno));
190+ }
191+
192+ if (ioctl(0, TIOCSCTTY, NULL) == -1) {
193+ fprintf(fp, "ERROR: Unable to attach to controlling tty, %s\n", strerror(errno));
194+ }
195+
196 run_child(p->run_ptest, pipefd_stdout[1], pipefd_stderr[1]);
197+
198 } else {
199 int status;
200 int fds[2]; fds[0] = pipefd_stdout[0]; fds[1] = pipefd_stderr[0];
201 FILE *fps[2]; fps[0] = fp; fps[1] = fp_stderr;
202
203+ if (setpgid(child, pgid) == -1) {
204+ fprintf(fp, "ERROR: setpgid() failed, %s\n", strerror(errno));
205+ }
206+
207 sttime = time(NULL);
208 fprintf(fp, "%s\n", get_stime(stime, GET_STIME_BUF_SIZE, sttime));
209 fprintf(fp, "BEGIN: %s\n", ptest_dir);
210--
2112.17.0
212
diff --git a/meta/recipes-support/ptest-runner/ptest-runner_2.3.1.bb b/meta/recipes-support/ptest-runner/ptest-runner_2.3.2.bb
index dec60fcc9b..187f22df04 100644
--- a/meta/recipes-support/ptest-runner/ptest-runner_2.3.1.bb
+++ b/meta/recipes-support/ptest-runner/ptest-runner_2.3.2.bb
@@ -7,14 +7,10 @@ HOMEPAGE = "http://git.yoctoproject.org/cgit/cgit.cgi/ptest-runner2/about/"
7LICENSE = "GPLv2" 7LICENSE = "GPLv2"
8LIC_FILES_CHKSUM = "file://LICENSE;md5=751419260aa954499f7abaabaa882bbe" 8LIC_FILES_CHKSUM = "file://LICENSE;md5=751419260aa954499f7abaabaa882bbe"
9 9
10SRCREV = "63d097cc46142157931682fed076b5407757a0bd" 10SRCREV = "7015e9199ce748c0717addeebe7a8c47448bab03"
11PV = "2.3.1+git${SRCPV}" 11PV = "2.3.2+git${SRCPV}"
12 12
13SRC_URI = "git://git.yoctoproject.org/ptest-runner2 \ 13SRC_URI = "git://git.yoctoproject.org/ptest-runner2 \
14 file://0001-utils-Ensure-stdout-stderr-are-flushed.patch \
15 file://0002-use-process-groups-when-spawning.patch \
16 file://0003-utils-Ensure-pipes-are-read-after-exit.patch \
17 file://0004-utils-ensure-child-can-be-session-leader.patch \
18" 14"
19 15
20S = "${WORKDIR}/git" 16S = "${WORKDIR}/git"