This reverts commit e50f2175d9c6b8aeb8b0bf687e5cca64a0f6e61a.

The timeout is actually the amount of time to wait until there is no
output from the test, not the total test time.

Signed-off-by: Joshua Watt <jpewhac...@gmail.com>
---
 tests/data/hang/ptest/run-ptest |  1 -
 tests/utils.c                   |  2 +-
 utils.c                         | 23 +++++++++++------------
 3 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/tests/data/hang/ptest/run-ptest b/tests/data/hang/ptest/run-ptest
index 9031be3..738041d 100755
--- a/tests/data/hang/ptest/run-ptest
+++ b/tests/data/hang/ptest/run-ptest
@@ -3,6 +3,5 @@
 echo "hang" 1>&2
 echo "hang"
 while true; do
-       echo "hang"
        sleep 1
 done
diff --git a/tests/utils.c b/tests/utils.c
index 849a412..d82b90e 100644
--- a/tests/utils.c
+++ b/tests/utils.c
@@ -224,7 +224,7 @@ search_for_timeout_and_duration(const int rp, FILE 
*fp_stdout)
 START_TEST(test_run_timeout_duration_ptest)
 {
        struct ptest_list *head = get_available_ptests(opts_directory);
-       unsigned int timeout = 3;
+       unsigned int timeout = 1;
 
        test_ptest_expected_failure(head, timeout, "hang", 
search_for_timeout_and_duration);
 
diff --git a/utils.c b/utils.c
index 353d6dc..34ca2f0 100644
--- a/utils.c
+++ b/utils.c
@@ -403,8 +403,7 @@ run_ptests(struct ptest_list *head, const struct 
ptest_options opts,
        pid_t child;
        int pipefd_stdout[2] = {-1, -1};
        int pipefd_stderr[2] = {-1, -1};
-       time_t sttime, entime, now;
-       time_t timeout_deadline;
+       time_t sttime, entime;
        time_t duration;
        int slave;
        int pgid = -1;
@@ -490,7 +489,6 @@ run_ptests(struct ptest_list *head, const struct 
ptest_options opts,
                                }
 
                                sttime = time(NULL);
-                               timeout_deadline = sttime + opts.timeout;
                                fprintf(fp, "%s\n", get_stime(stime, 
GET_STIME_BUF_SIZE, sttime));
                                fprintf(fp, "BEGIN: %s\n", ptest_dir);
 
@@ -521,17 +519,18 @@ run_ptests(struct ptest_list *head, const struct 
ptest_options opts,
                                        if (done) {
                                                break;
                                        }
-                                       now = time(NULL);
-                                       if (now >= timeout_deadline) {
-                                               kill(-child, SIGKILL);
-                                               _child_reader.timeouted = 1;
-                                               break;
-                                       }
 
-                                       int ret = poll(pfds, 2, 
(timeout_deadline - now) * 1000);
+                                       int ret = poll(pfds, 2, 
_child_reader.timeout*1000);
 
-                                       if (ret == 0) {
-                                               continue;
+                                       if (ret == 0 && 
!_child_reader.timeouted) {
+                                               /* kill the child if we haven't
+                                                * already. Note that we
+                                                * continue to read data from
+                                                * the pipes until EOF to make
+                                                * sure we get all the output
+                                                */
+                                               kill(-child, SIGKILL);
+                                               _child_reader.timeouted = 1;
                                        }
 
                                        for (int i = 0; i < 2; i++) {
-- 
2.33.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#60607): https://lists.yoctoproject.org/g/yocto/message/60607
Mute This Topic: https://lists.yoctoproject.org/mt/100220151/21656
Group Owner: yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to