[LTP] [PATCH 1/2] ltp-aiodio: sleep less time when waiting for target file creation

Eryu Guan eguan@redhat.com
Tue May 3 11:33:49 CEST 2016


dio_sparse calls read_sparse() to check the content of sparse file,
which is direct written by another process. It waits for the file to be
existent in a loop and sleeps 0.1s in each loop if the file isn't there
yet.

But the sleep time is too long, if the target file doesn't exist in the
first loop, the reading process might never read the file before it gets
killed. e.g. Running ADSP045 on extN I got:

dio_sparse    0  TINFO  :  Dirtying free blocks
dio_sparse    0  TINFO  :  Starting I/O tests
Child 4554 waits for 'dio_sparse' to appear
dio_sparse    0  TINFO  :  Killing childrens(s)
dio_sparse    1  TPASS  :  Test passed)

The child for reading got killed before it read anything.

So shorten the sleep time, give the child a chance to read the file and
really do the test.

dio_sparse    0  TINFO  :  Dirtying free blocks
dio_sparse    0  TINFO  :  Starting I/O tests
Child 4767 waits for 'dio_sparse' to appear
Child 4767 has opened 'dio_sparse' for reading
Child 4767 loop 0
Child 4767 loop 1
dio_sparse    0  TINFO  :  Killing childrens(s)
dio_sparse    1  TPASS  :  Test passed)

Signed-off-by: Eryu Guan <eguan@redhat.com>
---
 testcases/kernel/io/ltp-aiodio/common_sparse.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testcases/kernel/io/ltp-aiodio/common_sparse.h b/testcases/kernel/io/ltp-aiodio/common_sparse.h
index f7f4ef4..a7f5035 100644
--- a/testcases/kernel/io/ltp-aiodio/common_sparse.h
+++ b/testcases/kernel/io/ltp-aiodio/common_sparse.h
@@ -123,7 +123,7 @@ static void read_sparse(char *filename, int filesize)
 			fprintf(stderr, "Child %i waits for '%s' to appear\n",
 			        getpid(), filename);
 
-		usleep(100000);
+		usleep(10);
 	}
 
 	if (fd == -1) {
-- 
2.5.5



More information about the ltp mailing list