Skip to contentSkip to conversation

rw tests improvements

PATCH Applied Pavel Begunkov 2 participants 4 messages Aug 19, 2021 io_uring

lore
Share & tools
lore
#0 lore raw

cover rw tests improvements

Two small patches for read-write.c and iopoll.c tests.

Pavel Begunkov (2):
tests: create new files for rw testing
tests: rename iopoll test variables

 test/iopoll.c     | 20 ++++++++++++--------
 test/read-write.c |  6 +++++-
 2 files changed, 17 insertions(+), 9 deletions(-)
Signature · 1 line
2.32.0
#1 lore raw

PATCH 1/2 tests: create new files for rw testing

Currently rw/iopoll tests use a fixed name file, so several instances of the same test can't run in parallel. Use unique names instead.

---
 test/iopoll.c     | 6 +++++-
 test/read-write.c | 6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)
test/iopoll.c +5 -1
index 3d94dfe..1adee7f 100644
@@ -325,6 +325,7 @@ static int probe_buf_select(void)
 int main(int argc, char *argv[])
 {
 	int i, ret, nr;
+	char buf[256];
 	char *fname;
 
 	if (probe_buf_select())
@@ -333,7 +334,10 @@ int main(int argc, char *argv[])
 	if (argc > 1) {
 		fname = argv[1];
 	} else {
-		fname = ".iopoll-rw";
+		srand((unsigned)time(NULL));
+		snprintf(buf, sizeof(buf), ".basic-rw-%u-%u",
+			(unsigned)rand(), (unsigned)getpid());
+		fname = buf;
 		t_create_file(fname, FILE_SIZE);
 	}
 
test/read-write.c +5 -1
index d0a77fa..b0a2bde 100644
@@ -746,12 +746,16 @@ err:
 int main(int argc, char *argv[])
 {
 	int i, ret, nr;
+	char buf[256];
 	char *fname;
 
 	if (argc > 1) {
 		fname = argv[1];
 	} else {
-		fname = ".basic-rw";
+		srand((unsigned)time(NULL));
+		snprintf(buf, sizeof(buf), ".basic-rw-%u-%u",
+			(unsigned)rand(), (unsigned)getpid());
+		fname = buf;
 		t_create_file(fname, FILE_SIZE);
 	}
 
Signature · 1 line
2.32.0
#2 lore raw

PATCH 2/2 tests: rename iopoll test variables

In reply to Pavel Begunkov

Rename v1-v4 variables into something more descriptive, makes debugging easier.

---
 test/iopoll.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
test/iopoll.c +7 -7
index 1adee7f..b450618 100644
@@ -347,15 +347,15 @@ int main(int argc, char *argv[])
 	if (no_buf_select)
 		nr = 8;
 	for (i = 0; i < nr; i++) {
-		int v1, v2, v3, v4;
+		int write = (i & 1) != 0;
+		int sqthread = (i & 2) != 0;
+		int fixed = (i & 4) != 0;
+		int buf_select = (i & 8) != 0;
 
-		v1 = (i & 1) != 0;
-		v2 = (i & 2) != 0;
-		v3 = (i & 4) != 0;
-		v4 = (i & 8) != 0;
-		ret = test_io(fname, v1, v2, v3, v4);
+		ret = test_io(fname, write, sqthread, fixed, buf_select);
 		if (ret) {
-			fprintf(stderr, "test_io failed %d/%d/%d/%d\n", v1, v2, v3, v4);
+			fprintf(stderr, "test_io failed %d/%d/%d/%d\n",
+				write, sqthread, fixed, buf_select);
 			goto err;
 		}
 		if (no_iopoll)
Signature · 1 line
2.32.0
maintainer Applied
#3 lore raw
In reply to Pavel Begunkov
Quoted 9 lines · Pavel Begunkov

Two small patches for read-write.c and iopoll.c tests.

Pavel Begunkov (2):
tests: create new files for rw testing
tests: rename iopoll test variables

 test/iopoll.c     | 20 ++++++++++++--------
 test/read-write.c |  6 +++++-
 2 files changed, 17 insertions(+), 9 deletions(-)

Applied, thanks.

Signature · 1 line
Jens Axboe