@@ -40,6 +40,7 @@
#include <sys/wait.h>
#include "tst_test.h"
+#include "tst_timer.h"
#include "move_pages_support.h"
#include "lapi/mmap.h"
@@ -101,6 +102,9 @@ static void do_test(void)
int i;
pid_t cpid = -1;
int status;
+ unsigned int test_time = (tst_get_timeout() / 5) * 4;
+
+ tst_timer_start(CLOCK_MONOTONIC);
addr = SAFE_MMAP(NULL, TEST_PAGES * hpsz, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB, -1, 0);
@@ -123,14 +127,15 @@ static void do_test(void)
memset(addr, 0, TEST_PAGES * hpsz);
SAFE_MUNMAP(addr, TEST_PAGES * hpsz);
- }
- if (i == LOOPS) {
- SAFE_KILL(cpid, SIGKILL);
- SAFE_WAITPID(cpid, &status, 0);
- if (!WIFEXITED(status))
- tst_res(TPASS, "Bug not reproduced");
+ if (tst_timer_expired_ms(test_time))
+ break;
}
+
+ SAFE_KILL(cpid, SIGKILL);
+ SAFE_WAITPID(cpid, &status, 0);
+ if (!WIFEXITED(status))
+ tst_res(TPASS, "Bug not reproduced");
}
static void alloc_free_huge_on_node(unsigned int node, size_t size)
@@ -183,6 +188,8 @@ static void setup(void)
int ret;
long memfree;
+ tst_timer_check(CLOCK_MONOTONIC);
+
check_config(TEST_NODES);
if (access(PATH_HUGEPAGES, F_OK))
Most systems can complete this reproducer in standard test time. Small groups of systems (e.g. aarch64 with 512M hugepages) can hit a timeout. Add a check for elapsed time and end test early if we are getting close (80%). Fixes: #387 Signed-off-by: Jan Stancek <jstancek@redhat.com> --- testcases/kernel/syscalls/move_pages/move_pages12.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)