diff mbox series

[v4,3/4] mmapstress01: return TBROK for unexpected failures and TERRNO if syscall fails

Message ID 20221006184228.3281392-4-edliaw@google.com
State Changes Requested
Headers show
Series mmapstress01: refactor to ltp framework | expand

Commit Message

Edward Liaw Oct. 6, 2022, 6:42 p.m. UTC
Signed-off-by: Edward Liaw <edliaw@google.com>
---
 testcases/kernel/mem/mmapstress/mmapstress01.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/testcases/kernel/mem/mmapstress/mmapstress01.c b/testcases/kernel/mem/mmapstress/mmapstress01.c
index 67a2b747d..9a18587cf 100644
--- a/testcases/kernel/mem/mmapstress/mmapstress01.c
+++ b/testcases/kernel/mem/mmapstress/mmapstress01.c
@@ -155,7 +155,7 @@  static void child_mapper(char *file, unsigned int procno, unsigned int nprocs)
 	fd = SAFE_OPEN(file, O_RDWR);
 
 	if (statbuf.st_size - sparseoffset > UINT_MAX)
-		tst_brk(TFAIL, "size_t overflow when setting up map");
+		tst_brk(TBROK, "size_t overflow when setting up map");
 	mapsize = (size_t) (statbuf.st_size - sparseoffset);
 	mappages = roundup(mapsize, pagesize) / pagesize;
 	offset = sparseoffset;
@@ -212,7 +212,7 @@  static void child_mapper(char *file, unsigned int procno, unsigned int nprocs)
 		paddr = maddr + (randpage * pagesize);	/* page address */
 		if (msync(paddr, (mappages - randpage) * pagesize,
 			  MS_SYNC) == -1)
-			tst_brk(TFAIL, "msync failed");
+			tst_brk(TBROK | TERRNO, "msync failed");
 	}
 	SAFE_MUNMAP(maddr, mapsize);
 	exit(0);
@@ -237,7 +237,7 @@  static void fileokay(char *file, unsigned char *expbuf)
 	SAFE_LSEEK(fd, sparseoffset, SEEK_SET);
 
 	if (statbuf.st_size - sparseoffset > UINT_MAX)
-		tst_brk(TFAIL, "size_t overflow when setting up map");
+		tst_brk(TBROK, "size_t overflow when setting up map");
 	mapsize = (size_t) (statbuf.st_size - sparseoffset);
 
 	mappages = roundup(mapsize, pagesize) / pagesize;
@@ -383,13 +383,13 @@  static void run(void)
 			 */
 			if (!WIFEXITED(wait_stat)
 			    || WEXITSTATUS(wait_stat) != 0)
-				tst_brk(TFAIL, "child exit with err <x%x>",
+				tst_brk(TBROK, "child exit with err <x%x>",
 					wait_stat);
 			for (i = 0; i < nprocs; i++)
 				if (pid == pidarray[i])
 					break;
 			if (i == nprocs)
-				tst_brk(TFAIL, "unknown child pid %d, <x%x>",
+				tst_brk(TBROK, "unknown child pid %d, <x%x>",
 					pid, wait_stat);
 
 			pid = SAFE_FORK();
@@ -406,7 +406,8 @@  static void run(void)
 			 *  error...
 			 */
 			if (errno != EINTR || !finished)
-				tst_brk(TFAIL, "unexpected wait error");
+				tst_brk(TBROK | TERRNO,
+					"unexpected wait error");
 		}
 		SAFE_SIGPROCMASK(SIG_UNBLOCK, &set_mask, NULL);
 	}