summaryrefslogtreecommitdiffstats
path: root/meta-agl-bsp/recipes-support/ptest-runner/ptest-runner/0001-utils.c-Prefer-monotonic-clock-to-calculate-elapsed-.patch
diff options
context:
space:
mode:
authorKevin Hilman <khilman@baylibre.com>2018-11-19 11:29:12 -0800
committerJan-Simon Moeller <jsmoeller@linuxfoundation.org>2018-11-22 15:22:56 +0000
commitb820f82dac96ccb4b223a55488d9ffb9e1177358 (patch)
treefe71ae4baea0ffbe41f513467488676544402817 /meta-agl-bsp/recipes-support/ptest-runner/ptest-runner/0001-utils.c-Prefer-monotonic-clock-to-calculate-elapsed-.patch
parent8a0cd7c69c5df85924f3f065d0ef0f71d490e599 (diff)
meta-agl-bsp: ptest-runner: v2.2 and LAVA support
Upgrade ptest-runner to v2.2 (first 6 patches), and add the WIP support for LAVA signal (patch 7). From branch: https://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/log/?h=timo/lava-ptest-runner2 Commit: https://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/commit/?h=timo/lava-ptest-runner2&id=11b29ce444610a07067a89b38e9e85c2162bbf67 Change-Id: Ic4ee5e3a9ab796fe7ccd1810b31e582370f99a25 Signed-off-by: Kevin Hilman <khilman@baylibre.com>
Diffstat (limited to 'meta-agl-bsp/recipes-support/ptest-runner/ptest-runner/0001-utils.c-Prefer-monotonic-clock-to-calculate-elapsed-.patch')
-rw-r--r--meta-agl-bsp/recipes-support/ptest-runner/ptest-runner/0001-utils.c-Prefer-monotonic-clock-to-calculate-elapsed-.patch72
1 files changed, 72 insertions, 0 deletions
diff --git a/meta-agl-bsp/recipes-support/ptest-runner/ptest-runner/0001-utils.c-Prefer-monotonic-clock-to-calculate-elapsed-.patch b/meta-agl-bsp/recipes-support/ptest-runner/ptest-runner/0001-utils.c-Prefer-monotonic-clock-to-calculate-elapsed-.patch
new file mode 100644
index 000000000..6ca593be5
--- /dev/null
+++ b/meta-agl-bsp/recipes-support/ptest-runner/ptest-runner/0001-utils.c-Prefer-monotonic-clock-to-calculate-elapsed-.patch
@@ -0,0 +1,72 @@
+From 41b7f4814d39c1930b1fcf0be2e247a73546fb80 Mon Sep 17 00:00:00 2001
+From: Jeffrey Pautler <jeffrey.pautler@ni.com>
+Date: Tue, 31 Oct 2017 14:38:39 -0500
+Subject: [PATCH 1/7] utils.c: Prefer monotonic clock to calculate elapsed time
+
+The current implementation uses the system clock to calculate how long
+a ptest has been running with no output. If a ptest changes the system
+clock as part of the test, that can cause the current implementation
+to falsely trigger a timeout or miss an actual timeout. It is
+preferrable to use a monotonic clock for calculating elapsed time in
+order to avoid these issues.
+
+This change tries to use the monotonic clock first and falls back to
+the realtime clock if the monotonic clock is not supported.
+
+Signed-off-by: Jeffrey Pautler <jeffrey.pautler@ni.com>
+---
+ utils.c | 24 +++++++++++++++++-------
+ 1 file changed, 17 insertions(+), 7 deletions(-)
+
+diff --git a/utils.c b/utils.c
+index 6d653887e9e4..933ecedf57e8 100644
+--- a/utils.c
++++ b/utils.c
+@@ -257,7 +257,8 @@ wait_child(const char *ptest_dir, const char *run_ptest, pid_t pid,
+ int timeout, int *fds, FILE **fps)
+ {
+ struct pollfd pfds[2];
+- time_t sentinel;
++ struct timespec sentinel;
++ clockid_t clock = CLOCK_MONOTONIC;
+ int r;
+
+ int timeouted = 0;
+@@ -269,7 +270,11 @@ wait_child(const char *ptest_dir, const char *run_ptest, pid_t pid,
+ pfds[1].fd = fds[1];
+ pfds[1].events = POLLIN;
+
+- sentinel = time(NULL);
++ if (clock_gettime(clock, &sentinel) == -1) {
++ clock = CLOCK_REALTIME;
++ clock_gettime(clock, &sentinel);
++ }
++
+ while (1) {
+ waitflags = WNOHANG;
+
+@@ -288,11 +293,16 @@ wait_child(const char *ptest_dir, const char *run_ptest, pid_t pid,
+ fwrite(buf, n, 1, fps[1]);
+ }
+
+- sentinel = time(NULL);
+- } else if (timeout >= 0 && ((time(NULL) - sentinel) > timeout)) {
+- timeouted = 1;
+- kill(pid, SIGKILL);
+- waitflags = 0;
++ clock_gettime(clock, &sentinel);
++ } else if (timeout >= 0) {
++ struct timespec time;
++
++ clock_gettime(clock, &time);
++ if ((time.tv_sec - sentinel.tv_sec) > timeout) {
++ timeouted = 1;
++ kill(pid, SIGKILL);
++ waitflags = 0;
++ }
+ }
+
+ if (waitpid(pid, &status, waitflags) == pid)
+--
+2.11.0
+