From: Joerg Vehlow <lkml@jv-coder.de>
To: ltp@lists.linux.it, chrubis@suse.cz
Cc: Joerg Vehlow <joerg.vehlow@aox-tech.de>
Subject: [LTP] [PATCH 1/4] posix/conformance/interfaces/fork/7-1: Fix test
Date: Mon, 22 Nov 2021 08:25:58 +0100 [thread overview]
Message-ID: <20211122072601.4096577-1-lkml@jv-coder.de> (raw)
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
next reply other threads:[~2021-11-22 7:26 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-22 7:25 Joerg Vehlow [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211122072601.4096577-1-lkml@jv-coder.de \
--to=lkml@jv-coder.de \
--cc=chrubis@suse.cz \
--cc=joerg.vehlow@aox-tech.de \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox