Skip to contentSkip to conversation

io/ltp-aiodio: fix function return value

PATCH New liubo03 2 participants 2 messages Jun 4, 2021 – Jun 21, 2021

lore
Share & tools
lore

liubo03

author
#0 lore raw

PATCH 1/1 io/ltp-aiodio: fix function return value

Function return value is determined using tst_resm (TFAIL,) and tst_exit function

---
 testcases/kernel/io/ltp-aiodio/aiodio_append.c | 9 ++++-----
 testcases/kernel/io/ltp-aiodio/dio_append.c    | 7 ++++---
 testcases/kernel/io/ltp-aiodio/dio_truncate.c  | 6 +++---
 3 files changed, 11 insertions(+), 11 deletions(-)
testcases/kernel/io/ltp-aiodio/aiodio_append.c +4 -5
index 5d97ed9..5490bd5 100644
@@ -93,7 +93,7 @@ void aiodio_append(char *filename)
 
 	fd = open(filename, O_DIRECT | O_WRONLY | O_CREAT, 0666);
 	if (fd < 0) {
-		perror("cannot create file");
+		tst_resm(TFAIL, "cannot create file %s", filename);
 		return;
 	}
 
@@ -116,7 +116,7 @@ void aiodio_append(char *filename)
 	 * Start the 1st NUM_AIO requests
 	 */
 	if ((w = io_submit(myctx, NUM_AIO, iocbs)) < 0) {
-		fprintf(stderr, "io_submit write returned %d\n", w);
+		tst_resm(TFAIL, "io_submit write returned %d", w);
 	}
 
 	/*
@@ -135,8 +135,7 @@ void aiodio_append(char *filename)
 					       AIO_SIZE, offset);
 				offset += AIO_SIZE;
 				if ((w = io_submit(myctx, 1, &iocbp)) < 0) {
-					fprintf(stderr,
-						"write %d returned %d\n", i, w);
+					tst_resm(TFAIL, "write %d returned %d", i, w);
 				}
 			}
 		}
@@ -176,7 +175,7 @@ int main(int argc, char **argv)
 		kill(pid[i], SIGTERM);
 	}
 
-	return 0;
+	tst_exit();
 }
 #else
 int main(void)
testcases/kernel/io/ltp-aiodio/dio_append.c +4 -3
index 3f0ed29..585847f 100644
@@ -85,7 +85,7 @@ void dio_append(char *filename)
 	fd = open(filename, O_DIRECT | O_WRONLY | O_CREAT, 0666);
 
 	if (fd < 0) {
-		perror("cannot create file");
+		tst_resm(TFAIL, "cannot create file %s", filename);
 		return;
 	}
 
@@ -99,7 +99,7 @@ void dio_append(char *filename)
 	memset(bufptr, 0, 64 * 1024);
 	for (i = 0; i < 1000; i++) {
 		if ((w = write(fd, bufptr, 64 * 1024)) != 64 * 1024) {
-			fprintf(stderr, "write %d returned %d\n", i, w);
+			tst_resm(TFAIL, "write %d returned %d", i, w);
 		}
 	}
 }
@@ -139,5 +139,6 @@ int main(void)
 	for (i = 0; i < num_children; i++) {
 		kill(pid[i], SIGTERM);
 	}
-	return 0;
+
+	tst_exit();
 }
testcases/kernel/io/ltp-aiodio/dio_truncate.c +3 -3
index 7d466dc..0b67f7b 100644
@@ -112,7 +112,7 @@ void dio_append(char *filename, int fill)
 	fd = open(filename, O_DIRECT | O_WRONLY | O_CREAT, 0666);
 
 	if (fd < 0) {
-		perror("cannot create file");
+		tst_resm(TFAIL, "cannot create file %s", filename);
 		return;
 	}
 
@@ -127,7 +127,7 @@ void dio_append(char *filename, int fill)
 
 	for (i = 0; i < 1000; i++) {
 		if ((w = write(fd, bufptr, 64 * 1024)) != 64 * 1024) {
-			fprintf(stderr, "write %d returned %d\n", i, w);
+			tst_resm(TFAIL, "write %d returned %d", i, w);
 		}
 	}
 	close(fd);
@@ -173,5 +173,5 @@ int main(void)
 		kill(pid[i], SIGTERM);
 	}
 
-	return 0;
+	tst_exit();
 }
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/1 io/ltp-aiodio: fix function return value

Hi!
This makes it slightly better but still the most imporant part, the check in the child process, is ignored.

Easiest fix would be rewriting the tests to the new test library so that we could use tst_res(TFAIL, ...) in the child processess as well.

Signature · 2 lines
Cyril Hrubis
[email protected]