public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v3] syscalls/fstat{03,05}: rewrote testcases
Date: Fri, 7 Jun 2019 15:31:12 +0200	[thread overview]
Message-ID: <20190607133112.GA20202@rei.lan> (raw)
In-Reply-To: <20190607091923.30683-1-camann@suse.com>

Hi!
Pushed with a few changes, thanks.

* Made the check for return value more strict

* Changed the code so that we do not rely on test number but on expected
  errno in the segfault check, this makes the test more robust in a case
  we would add tests to the tcase structure. Also this makes the code
  more clear to the reader.

* Added code to make sure the child has exitted with 0 in normal case

diff --git a/testcases/kernel/syscalls/fstat/fstat03.c b/testcases/kernel/syscalls/fstat/fstat03.c
index 3d6790eb2..7d213dea9 100644
--- a/testcases/kernel/syscalls/fstat/fstat03.c
+++ b/testcases/kernel/syscalls/fstat/fstat03.c
@@ -42,7 +42,7 @@ static void check_fstat(unsigned int tc_num)
 	struct tcase *tc = &tcases[tc_num];
 
 	TEST(fstat(*tc->fd, tc->stat_buf));
-	if (TST_RET != 0) {
+	if (TST_RET == -1) {
 		if (tc->exp_err == TST_ERR) {
 			tst_res(TPASS,
 				 "fstat() fails with expected error %s",
@@ -70,8 +70,15 @@ static void run(unsigned int tc_num)
 	}
 	SAFE_WAITPID(pid, &status, 0);
 
-	if (tc_num == 1 && WTERMSIG(status) == SIGSEGV)
+	if (tcases[tc_num].exp_err == EFAULT && WTERMSIG(status) == SIGSEGV) {
 		tst_res(TPASS, "fstat() failed as expected with SIGSEGV");
+		return;
+	}
+
+	if (WIFEXITED(status) && WEXITSTATUS(status) == 0)
+		return;
+
+	tst_res(TBROK, "child %s", tst_strstatus(status));
 }
 
 static void setup(void)

-- 
Cyril Hrubis
chrubis@suse.cz

      reply	other threads:[~2019-06-07 13:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-07  9:19 [LTP] [PATCH v3] syscalls/fstat{03,05}: rewrote testcases Christian Amann
2019-06-07 13:31 ` Cyril Hrubis [this message]

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=20190607133112.GA20202@rei.lan \
    --to=chrubis@suse.cz \
    --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