@@ -44,9 +44,13 @@ static inline void io_append(const char *path, char pattern, int flags, size_t b
fd = SAFE_OPEN(path, flags, 0666);
- for (i = 0; i < bcount; i++)
+ for (i = 0; i < bcount; i++) {
SAFE_WRITE(1, fd, bufptr, bs);
+ if (!tst_remaining_runtime())
+ break;
+ }
+
free(bufptr);
SAFE_CLOSE(fd);
}
@@ -71,6 +71,9 @@ static void run(void)
io_append(filename, 0, O_DIRECT | O_WRONLY | O_CREAT, writesize, appends);
+ if (!tst_remaining_runtime())
+ tst_res(TINFO, "Test out of runtime, exitting");
+
if (SAFE_WAITPID(-1, &status, WNOHANG))
tst_res(TFAIL, "Non zero bytes read");
else
@@ -87,6 +90,7 @@ static struct tst_test test = {
.cleanup = cleanup,
.needs_tmpdir = 1,
.forks_child = 1,
+ .max_iteration_runtime = 1800,
.options = (struct tst_option[]) {
{"n:", &str_numchildren, "Number of processes (default 16)"},
{"w:", &str_writesize, "Write size for each append (default 64K)"},
@@ -142,6 +142,11 @@ static void run(void)
fail = 1;
break;
}
+
+ if (!tst_remaining_runtime()) {
+ tst_res(TINFO, "Test out of runtime, exitting");
+ break;
+ }
}
if (fail)
@@ -158,6 +163,7 @@ static struct tst_test test = {
.cleanup = cleanup,
.needs_tmpdir = 1,
.forks_child = 1,
+ .max_iteration_runtime = 1800,
.options = (struct tst_option[]) {
{"n:", &str_numchildren, "Number of threads (default 16)"},
{"s:", &str_filesize, "Size of file (default 64K)"},
Change the code so that the test runtime is capped at the maximal runtime allowed for the test, which is set to 30 minutes by default. The io_append() in common.h has to check for runtime to make this work. CC: Andrea Cervesato <andrea.cervesato@suse.de> Signed-off-by: Cyril Hrubis <chrubis@suse.cz> --- testcases/kernel/io/ltp-aiodio/common.h | 6 +++++- testcases/kernel/io/ltp-aiodio/dio_append.c | 4 ++++ testcases/kernel/io/ltp-aiodio/dio_truncate.c | 6 ++++++ 3 files changed, 15 insertions(+), 1 deletion(-)