public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/4] posix/conformance/interfaces/fork/7-1: Fix test
@ 2021-11-22  7:25 Joerg Vehlow
  2021-11-22  7:25 ` [LTP] [PATCH 2/4] posix/conformance/interfaces: Fix all unused variable warnings Joerg Vehlow
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Joerg Vehlow @ 2021-11-22  7:25 UTC (permalink / raw)
  To: ltp, chrubis; +Cc: Joerg Vehlow

From: Joerg Vehlow <joerg.vehlow@aox-tech.de>

The test could never fail:
It only checked for errno after executing getcats, but getcats
never sets errno, instead it returns its forth parameter.

Signed-off-by: Joerg Vehlow <joerg.vehlow@aox-tech.de>
---
 .../conformance/interfaces/fork/7-1.c         | 42 +++++++++----------
 1 file changed, 19 insertions(+), 23 deletions(-)

diff --git a/testcases/open_posix_testsuite/conformance/interfaces/fork/7-1.c b/testcases/open_posix_testsuite/conformance/interfaces/fork/7-1.c
index aaf1403f9..cff904816 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/fork/7-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/fork/7-1.c
@@ -49,33 +49,22 @@
 #define MESSCAT_IN  "messcat.txt"
 #define MESSCAT_OUT "messcat.cat"
 
-static void read_catalog(nl_catd cat, char *who)
+static int read_catalog(nl_catd cat)
 {
+	static const char *notfound = "not found";
 	char *msg = NULL;
 	int i, j;
 
-#if VERBOSE > 0
-	output("Reading the message catalog from %s...\n", who);
-#endif
-
-	errno = 0;
-
-	for (i = 1; i <= 2; i++) {
+	for (i = 1; i <= 3; i++) {
 		for (j = 1; j <= 2; j++) {
 
-			msg = catgets(cat, i, j, "not found");
-
-			if (errno != 0)
-				UNRESOLVED(errno, "catgets returned an error");
-#if VERBOSE > 1
-			output("set %i msg %i: %s\n", i, j, msg);
-#endif
+			msg = catgets(cat, i, j, notfound);
+			if (msg == notfound) {
+				return 1;
+			}
 		}
 	}
-
-#if VERBOSE > 0
-	output("Message catalog read successfully in %s\n", who);
-#endif
+	return 0;
 }
 
 static char *messcat_in =
@@ -132,7 +121,10 @@ int main(void)
 	if (messcat == (nl_catd) - 1)
 		UNRESOLVED(errno, "Could not open ./" MESSCAT_OUT);
 
-	read_catalog(messcat, "parent");
+	if (read_catalog(messcat)) {
+		printf("UNRESOLVED: Unable to read message catalog in parent\n");
+		return PTS_UNRESOLVED;
+	}
 
 	child = fork();
 
@@ -140,8 +132,11 @@ int main(void)
 		UNRESOLVED(errno, "Failed to fork");
 
 	if (child == 0) {
-		read_catalog(messcat, "child");
-		exit(PTS_PASS);
+		if (read_catalog(messcat)) {
+			printf("FAILED: Unable to read message catalog in child\n");
+			return PTS_FAIL;
+		}
+		return PTS_PASS;
 	}
 
 	ctl = waitpid(child, &status, 0);
@@ -157,7 +152,8 @@ int main(void)
 	if (ret != 0)
 		UNRESOLVED(errno, "Failed to close the message catalog");
 
-	system("rm -f " MESSCAT_IN " " MESSCAT_OUT);
+	unlink(MESSCAT_IN);
+	unlink(MESSCAT_OUT);
 
 #if VERBOSE > 0
 	output("Test passed\n");
-- 
2.25.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-11-22 10:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-22  7:25 [LTP] [PATCH 1/4] posix/conformance/interfaces/fork/7-1: Fix test Joerg Vehlow
2021-11-22  7:25 ` [LTP] [PATCH 2/4] posix/conformance/interfaces: Fix all unused variable warnings Joerg Vehlow
2021-11-22  7:26 ` [LTP] [PATCH 3/4] posix/conformance/interfaces: Fix unused result for write Joerg Vehlow
2021-11-22  7:26 ` [LTP] [PATCH 4/4] posix/interface/conformance: Fix all unused-result warnings Joerg Vehlow
2021-11-22  9:41 ` [LTP] [PATCH 1/4] posix/conformance/interfaces/fork/7-1: Fix test Cyril Hrubis
2021-11-22  9:50   ` Joerg Vehlow
2021-11-22 10:32     ` Cyril Hrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox