From: Cyril Hrubis <chrubis@suse.cz>
To: Ma Xinjian <maxj.fnst@fujitsu.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2 2/2] signalfd: Add negative tests
Date: Fri, 13 Sep 2024 12:51:11 +0200 [thread overview]
Message-ID: <ZuQZH3FB8Fo_B_oS@yuki.lan> (raw)
In-Reply-To: <20240530082522.2505-1-maxj.fnst@fujitsu.com>
Hi!
Pushed with changes described below, thanks.
- there is no need for three masks we just need one valid mask
+ moved the mask structure into a guarded buffer
- it's pointless to attempt to close the fd_einval2 and fd_ebadf
as these variables are never assigned a valid fd
diff --git a/testcases/kernel/syscalls/signalfd/signalfd02.c b/testcases/kernel/syscalls/signalfd/signalfd02.c
index 527e1aff9..fdd15781c 100644
--- a/testcases/kernel/syscalls/signalfd/signalfd02.c
+++ b/testcases/kernel/syscalls/signalfd/signalfd02.c
@@ -7,7 +7,7 @@
/*\
* [Description]
*
- * Verify that signalfd(2) fails with
+ * Verify that signalfd(2) fails with:
*
* - EBADF when fd is invalid
* - EINVAL when fd is not a valid signalfd file descriptor
@@ -23,53 +23,40 @@ static int fd_ebadf = -2;
static int fd_einval1;
static int fd_einval2 = -1;
-static sigset_t mask1;
-static sigset_t mask2;
-static sigset_t mask3;
+static sigset_t *mask;
static struct test_case_t {
int *fd;
- sigset_t *mask;
int flags;
int expected_errno;
char *desc;
} tcases[] = {
- {&fd_ebadf, &mask1, 0, EBADF, "fd is invalid"},
- {&fd_einval1, &mask2, 0, EINVAL,
+ {&fd_ebadf, 0, EBADF, "fd is invalid"},
+ {&fd_einval1, 0, EINVAL,
"fd is not a valid signalfd file descriptor"},
- {&fd_einval2, &mask3, -1, EINVAL, "flags are invalid"},
+ {&fd_einval2, -1, EINVAL, "flags are invalid"},
};
static void setup(void)
{
- SAFE_SIGEMPTYSET(&mask1);
- SAFE_SIGADDSET(&mask1, SIGUSR1);
- SAFE_SIGPROCMASK(SIG_BLOCK, &mask1, NULL);
- SAFE_SIGEMPTYSET(&mask2);
- SAFE_SIGADDSET(&mask2, SIGUSR2);
- SAFE_SIGPROCMASK(SIG_BLOCK, &mask2, NULL);
- SAFE_SIGEMPTYSET(&mask2);
- SAFE_SIGADDSET(&mask3, SIGUSR2);
- SAFE_SIGPROCMASK(SIG_BLOCK, &mask3, NULL);
+ SAFE_SIGEMPTYSET(mask);
+ SAFE_SIGADDSET(mask, SIGUSR1);
+ SAFE_SIGPROCMASK(SIG_BLOCK, mask, NULL);
fd_einval1 = SAFE_OPEN(SIGNAL_FILE, O_CREAT, 0777);
}
static void cleanup(void)
{
- if (fd_ebadf > 0)
- SAFE_CLOSE(fd_ebadf);
if (fd_einval1 > 0)
SAFE_CLOSE(fd_einval1);
- if (fd_einval2 > 0)
- SAFE_CLOSE(fd_einval2);
}
static void verify_signalfd(unsigned int i)
{
struct test_case_t *tc = &tcases[i];
- TST_EXP_FAIL2(signalfd(*(tc->fd), tc->mask, tc->flags),
+ TST_EXP_FAIL2(signalfd(*(tc->fd), mask, tc->flags),
tc->expected_errno, "%s", tc->desc);
}
@@ -79,4 +66,8 @@ static struct tst_test test = {
.setup = setup,
.cleanup = cleanup,
.needs_tmpdir = 1,
+ .bufs = (struct tst_buffers []) {
+ {&mask, .size = sizeof(sigset_t)},
+ {}
+ }
};
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2024-09-13 10:52 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-28 10:31 [LTP] [PATCH 0/2] signalfd: Improve testsuite for signalfd Ma Xinjian via ltp
2024-05-28 10:32 ` [LTP] [PATCH 1/2] signalfd01: Refactor old case with new API Ma Xinjian via ltp
2024-05-28 11:29 ` Andrea Cervesato via ltp
2024-05-30 8:23 ` [LTP] [PATCH v2 " Ma Xinjian via ltp
2024-09-13 9:37 ` Cyril Hrubis
2024-05-28 10:33 ` [LTP] [PATCH 2/2] signalfd: Add negative tests Ma Xinjian via ltp
2024-05-28 11:31 ` Andrea Cervesato via ltp
2024-05-30 8:25 ` [LTP] [PATCH v2 " Ma Xinjian via ltp
2024-09-13 10:51 ` Cyril Hrubis [this message]
2024-09-13 10:52 ` [LTP] [PATCH 0/2] signalfd: Improve testsuite for signalfd 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=ZuQZH3FB8Fo_B_oS@yuki.lan \
--to=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
--cc=maxj.fnst@fujitsu.com \
/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