From 7d38db56a67d5f0d9f6e3fb499197b4d081108b2 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Fri, 30 Dec 2016 13:42:01 +0300 Subject: [PATCH] zdtm: Fix race in locks08 test The sub-process should wait for the parent task signal before checking the locks status Signed-off-by: Pavel Emelyanov --- test/zdtm/static/file_locks08.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/zdtm/static/file_locks08.c b/test/zdtm/static/file_locks08.c index a0d93ddaf5..aa26d8cff0 100644 --- a/test/zdtm/static/file_locks08.c +++ b/test/zdtm/static/file_locks08.c @@ -52,14 +52,18 @@ int main(int argc, char **argv) int pid; int status; int ret = 0; + task_waiter_t tw; struct flock lck; test_init(argc, argv); if (init_file_lock(&fd, &lck)) return -1; + task_waiter_init(&tw); + pid = fork(); if (pid == 0) { + task_waiter_wait4(&tw, getppid()); if (check_file_lock_restored(getpid(), fd, &lck) || check_lock_exists(filename, &lck) < 0) ret = -1; @@ -69,6 +73,8 @@ int main(int argc, char **argv) test_daemon(); test_waitsig(); + task_waiter_complete_current(&tw); + if (check_file_lock_restored(getpid(), fd, &lck) || check_lock_exists(filename, &lck) < 0) fail("OFD file locks check failed\n");