From: Steve Muckle <smuckle@google.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v1] rt_sigpending02: reuse code from sigpending02
Date: Tue, 12 Mar 2019 10:11:19 -0700 [thread overview]
Message-ID: <64d5553d-ac2d-fd8a-03d1-7cd05d1deeeb@google.com> (raw)
In-Reply-To: <20190308163832.212631-1-maennich@google.com>
Hi Matthias,
On 03/08/2019 08:38 AM, 'Matthias Maennich' via kernel-team wrote:
> Rather than forking the code of sigpending02 completely, reuse its code
> for rt_sigpending02 by conditionally compiling the syscalls accordingly.
>
> That way we ensure tests written for either rt_sigpending or sigpending
> are also considered for the respective other.
>
> Signed-off-by: Matthias Maennich <maennich@google.com>
Cyril recently proposed a test multiplex function which hasn't yet gone in:
http://lists.linux.it/pipermail/ltp/2019-March/011119.html
This would remove the need for the custom Makefile bit.
One downside with this multiplexed approach is that we then don't have
an entry in the testcases/kernel/syscalls/ directory for all syscalls
which can cause some confusion, but that could perhaps be addressed by
adding symlinks for the missing ones.
> ---
> .../kernel/syscalls/rt_sigpending/Makefile | 8 ++++
> .../syscalls/rt_sigpending/rt_sigpending02.c | 48 -------------------
> testcases/kernel/syscalls/sigpending/Makefile | 2 +
> .../kernel/syscalls/sigpending/sigpending02.c | 16 +++++--
> 4 files changed, 23 insertions(+), 51 deletions(-)
> delete mode 100644 testcases/kernel/syscalls/rt_sigpending/rt_sigpending02.c
>
> diff --git a/testcases/kernel/syscalls/rt_sigpending/Makefile b/testcases/kernel/syscalls/rt_sigpending/Makefile
> index 60c2e0140d85..57ba3dac2e41 100644
> --- a/testcases/kernel/syscalls/rt_sigpending/Makefile
> +++ b/testcases/kernel/syscalls/rt_sigpending/Makefile
> @@ -4,4 +4,12 @@
> top_srcdir ?= ../../../..
>
> include $(top_srcdir)/include/mk/testcases.mk
> +
> +CPPFLAGS += -DTEST_RT_SIGPENDING
> +
> +rt_sigpending02: $(abs_srcdir)/../sigpending/sigpending02.c
> + $(LINK.c) $^ $(LOADLIBES) $(LDLIBS) $(OUTPUT_OPTION)
> +
> +MAKE_TARGETS := rt_sigpending02
> +
> include $(top_srcdir)/include/mk/generic_leaf_target.mk
> diff --git a/testcases/kernel/syscalls/rt_sigpending/rt_sigpending02.c b/testcases/kernel/syscalls/rt_sigpending/rt_sigpending02.c
> deleted file mode 100644
> index 06d1c1578f4d..000000000000
> --- a/testcases/kernel/syscalls/rt_sigpending/rt_sigpending02.c
> +++ /dev/null
> @@ -1,48 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0
> -/*
> - * Copyright (c) International Business Machines Corp., 2002
> - *
> - * AUTHORS
> - * Paul Larson
> - *
> - * DESCRIPTION
> - * Test to see that the proper errors are returned by rt_sigpending
> - *
> - * Test 1:
> - * Call rt_sigpending(sigset_t*=-1, SIGSETSIZE),
> - * it should return -1 with errno EFAULT
> - */
> -
> -#include <errno.h>
> -#include <signal.h>
> -#include <sys/types.h>
> -
> -#include "tst_test.h"
> -#include "ltp_signal.h"
> -#include "lapi/syscalls.h"
> -
> -static void run(void)
> -{
> - /* set sigset to point to an invalid location */
> - sigset_t *sigset = (sigset_t *) - 1;
> -
> - TEST(tst_syscall(__NR_rt_sigpending, sigset, SIGSETSIZE));
> -
> - /* check return code */
> - if (TST_RET == -1) {
> - if (TST_ERR != EFAULT) {
> - tst_res(TFAIL | TTERRNO,
> - "rt_sigpending() Failed with wrong errno, "
> - "expected errno=%d, got ", EFAULT);
> - } else {
> - tst_res(TPASS | TTERRNO, "expected failure");
> - }
> - } else {
> - tst_res(TFAIL,
> - "rt_sigpending() Failed, expected return value=-1, got %ld", TST_RET);
> - }
> -}
> -
> -static struct tst_test test = {
> - .test_all = run
> -};
> diff --git a/testcases/kernel/syscalls/sigpending/Makefile b/testcases/kernel/syscalls/sigpending/Makefile
> index bd617d806675..00a7d5e2b538 100644
> --- a/testcases/kernel/syscalls/sigpending/Makefile
> +++ b/testcases/kernel/syscalls/sigpending/Makefile
> @@ -20,4 +20,6 @@ top_srcdir ?= ../../../..
>
> include $(top_srcdir)/include/mk/testcases.mk
>
> +CPPFLAGS += -DTEST_SIGPENDING
> +
> include $(top_srcdir)/include/mk/generic_leaf_target.mk
> diff --git a/testcases/kernel/syscalls/sigpending/sigpending02.c b/testcases/kernel/syscalls/sigpending/sigpending02.c
> index e7ec0d6819bd..cc50870b107a 100644
> --- a/testcases/kernel/syscalls/sigpending/sigpending02.c
> +++ b/testcases/kernel/syscalls/sigpending/sigpending02.c
> @@ -6,7 +6,10 @@
> * Paul Larson
> *
> * DESCRIPTION
> - * Test to see that the proper errors are returned by sigpending
> + * Test to see that the proper errors are returned by sigpending. All the
> + * tests can also be compiled to use the rt_sigpending syscall instead. To
> + * simplify the documentation, only sigpending() is usually mentioned
> + * below.
> *
> * Test 1:
> * Call sigpending(sigset_t*=-1), it should return -1 with errno EFAULT
> @@ -17,6 +20,7 @@
> #include <sys/types.h>
>
> #include "tst_test.h"
> +#include "ltp_signal.h"
> #include "lapi/syscalls.h"
>
> static void run(void)
> @@ -24,20 +28,26 @@ static void run(void)
> /* set sigset to point to an invalid location */
> sigset_t *sigset = (sigset_t *) - 1;
>
> +#if defined(TEST_SIGPENDING)
> TEST(tst_syscall(__NR_sigpending, sigset));
> +#elif defined(TEST_RT_SIGPENDING)
> + TEST(tst_syscall(__NR_rt_sigpending, sigset, SIGSETSIZE));
> +#else
> +#error Neither TEST_SIGPENDING nor TEST_RT_SIGPENDING is defined!
> +#endif
>
> /* check return code */
> if (TST_RET == -1) {
> if (TST_ERR != EFAULT) {
> tst_res(TFAIL | TTERRNO,
> - "sigpending() Failed with wrong errno, "
> + "syscall failed with wrong errno, "
> "expected errno=%d, got ", EFAULT);
> } else {
> tst_res(TPASS | TTERRNO, "expected failure");
> }
> } else {
> tst_res(TFAIL,
> - "sigpending() Failed, expected return value=-1, got %ld", TST_RET);
> + "syscall failed, expected return value=-1, got %ld", TST_RET);
> }
> }
>
>
next prev parent reply other threads:[~2019-03-12 17:11 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-08 16:38 [LTP] [PATCH v1] rt_sigpending02: reuse code from sigpending02 Matthias Maennich
2019-03-12 17:11 ` Steve Muckle [this message]
2019-03-13 9:42 ` Cyril Hrubis
2019-03-13 11:42 ` Matthias Maennich
2019-03-13 16:31 ` Steve Muckle
2019-03-13 12:02 ` [LTP] [PATCH v2 0/2] new test cases for sigpending / rt_sigpending Matthias Maennich
2019-03-13 12:02 ` [LTP] [PATCH v2 1/2] rt_sigpending02: reuse code from sigpending02 Matthias Maennich
2019-03-13 12:02 ` [LTP] [PATCH v2 2/2] sigpending/rt_sigpending: add basic test Matthias Maennich
2019-03-19 0:04 ` Steve Muckle
2019-03-19 11:31 ` [LTP] [PATCH v3 0/2] new test cases for sigpending / rt_sigpending Matthias Maennich
2019-03-19 11:31 ` [LTP] [PATCH v3 1/2] rt_sigpending02: reuse code from sigpending02 Matthias Maennich
2019-03-19 16:44 ` Petr Vorel
2019-03-19 16:52 ` Petr Vorel
2019-03-19 11:31 ` [LTP] [PATCH v3 2/2] sigpending/rt_sigpending: add basic test Matthias Maennich
2019-03-19 16:58 ` Petr Vorel
2019-03-19 17:24 ` Petr Vorel
2019-03-19 18:41 ` [LTP] [PATCH v4 0/3] rt_sigpending02: reuse code from sigpending02 Matthias Maennich
2019-03-19 18:41 ` [LTP] [PATCH v4 1/3] " Matthias Maennich
2019-03-19 18:41 ` [LTP] [PATCH v4 2/3] sigpending/rt_sigpending: add basic test Matthias Maennich
2019-03-19 18:41 ` [LTP] [PATCH v4 3/3] sigpending: improve portability by using tst_get_bad_addr() Matthias Maennich
2019-03-21 18:50 ` [LTP] [PATCH v4 0/3] rt_sigpending02: reuse code from sigpending02 Petr Vorel
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=64d5553d-ac2d-fd8a-03d1-7cd05d1deeeb@google.com \
--to=smuckle@google.com \
--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