From: Cyril Hrubis <chrubis@suse.cz>
To: Tudor Cretu <tudor.cretu@arm.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2 4/4] syscalls/statfs: Accept segfault instead of EFAULT
Date: Mon, 22 Aug 2022 16:11:13 +0200 [thread overview]
Message-ID: <YwOOgSakY7VFN+3e@yuki> (raw)
In-Reply-To: <20220822113919.196953-5-tudor.cretu@arm.com>
> int main(int ac, char **av)
> {
> int lc;
> @@ -67,23 +73,20 @@ int main(int ac, char **av)
> tst_count = 0;
>
> for (i = 0; i < TST_TOTAL; i++) {
> + sig_caught = 0;
> + if (sigsetjmp(env, 1) == 0)
> + fstatfs_verify(&TC[i]);
>
> - TEST(fstatfs(TC[i].fd, TC[i].sbuf));
> + if (!sig_caught)
> + continue;
>
> - if (TEST_RETURN != -1) {
> - tst_resm(TFAIL, "call succeeded unexpectedly");
> + if (TC[i].error == EFAULT && sig_caught == SIGSEGV) {
> + tst_resm(TINFO, "received SIGSEGV instead of returning EFAULT");
> + tst_resm(TPASS | TTERRNO, "expected failure");
This can be just a signle message tst_resm(TPASS | TERRNO, "Got SIGSEGV intead of EFAULT");
> continue;
> }
>
> - if (TEST_ERRNO == TC[i].error) {
> - tst_resm(TPASS, "expected failure - "
> - "errno = %d : %s", TEST_ERRNO,
> - strerror(TEST_ERRNO));
> - } else {
> - tst_resm(TFAIL, "unexpected error - %d : %s - "
> - "expected %d", TEST_ERRNO,
> - strerror(TEST_ERRNO), TC[i].error);
> - }
> + tst_resm(TFAIL, "Received an unexpected signal: %d", sig_caught);
> }
> }
> cleanup();
> @@ -91,9 +94,16 @@ int main(int ac, char **av)
> tst_exit();
> }
>
> +static void sighandler(int sig)
> +{
> + sig_caught = sig;
> + siglongjmp(env, 1);
> +
> +}
> +
> static void setup(void)
> {
> - tst_sig(NOFORK, DEF_HANDLER, cleanup);
> + tst_sig(NOFORK, sighandler, cleanup);
Can we just setup handler for the SIGSEGV signal and keep everything
else for the DEF_HANDLER?
> TEST_PAUSE;
>
> @@ -103,6 +113,24 @@ static void setup(void)
> #endif
> }
>
> +static void fstatfs_verify(const struct test_case_t *test)
> +{
> + TEST(fstatfs(test->fd, test->sbuf));
> +
> + if (TEST_RETURN != -1) {
> + tst_resm(TFAIL, "call succeeded unexpectedly");
> + return;
> + }
> +
> + if (TEST_ERRNO == test->error) {
> + tst_resm(TPASS, "expected failure - errno = %d : %s",
> + TEST_ERRNO, strerror(TEST_ERRNO));
> + } else {
> + tst_resm(TFAIL, "unexpected error - %d : %s - expected %d",
> + TEST_ERRNO, strerror(TEST_ERRNO), test->error);
> + }
> +}
If we converted the test to the new test API this would be a single line as:
TST_EXP_FAIL(fstatfs(test->fd, test->sbuf), test->error, "fstatfs()");
Generally with the new test api the code would be much shorter...
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
prev parent reply other threads:[~2022-08-22 14:09 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-22 11:39 [LTP] [PATCH v2 0/4] syscalls: Fix various syscall tests when compiled with Musl Tudor Cretu
2022-08-22 11:39 ` [LTP] [PATCH v2 1/4] lib: Fix initialization of recursive mutex Tudor Cretu
2022-08-23 9:22 ` Petr Vorel
2022-08-22 11:39 ` [LTP] [PATCH v2 2/4] syscalls/mprotect01: Invoke the syscall directly instead of the libc wrapper Tudor Cretu
2022-08-23 9:23 ` Petr Vorel
2022-08-22 11:39 ` [LTP] [PATCH v2 3/4] syscalls/prctl04: Allow rt_sigprocmask in the syscall filter Tudor Cretu
2022-08-23 9:41 ` Petr Vorel
2022-08-23 13:24 ` Cyril Hrubis
2022-08-23 14:59 ` Tudor Cretu
2022-08-23 15:06 ` Petr Vorel
2022-08-22 11:39 ` [LTP] [PATCH v2 4/4] syscalls/statfs: Accept segfault instead of EFAULT Tudor Cretu
2022-08-22 14:11 ` 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=YwOOgSakY7VFN+3e@yuki \
--to=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
--cc=tudor.cretu@arm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.