* [LTP] [RFC PATCH] lib: add tst_no_corefile to avoid corefile dumping
@ 2019-07-01 10:03 Li Wang
2019-07-01 11:01 ` Jan Stancek
0 siblings, 1 reply; 5+ messages in thread
From: Li Wang @ 2019-07-01 10:03 UTC (permalink / raw)
To: ltp
Signed-off-by: Li Wang <liwang@redhat.com>
Cc: Jan Stancek <jstancek@redhat.com>
---
include/tst_safe_macros.h | 16 ++++++++++++++++
testcases/kernel/security/umip/umip_basic_test.c | 2 ++
testcases/kernel/syscalls/ipc/shmat/shmat01.c | 16 +++-------------
3 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
index 53a888c80..110e2984f 100644
--- a/include/tst_safe_macros.h
+++ b/include/tst_safe_macros.h
@@ -394,6 +394,22 @@ static inline int safe_setrlimit(const char *file, const int lineno,
#define SAFE_SETRLIMIT(resource, rlim) \
safe_setrlimit(__FILE__, __LINE__, (resource), (rlim))
+/*
+ * Crash is expected, avoid dumping corefile.
+ * 1 is a special value, that disables core-to-pipe.
+ * At the same time it is small enough value for
+ * core-to-file, so it skips creating cores as well.
+ */
+static inline void tst_no_corefile(void)
+{
+ struct rlimit r;
+
+ r.rlim_cur = 1;
+ r.rlim_max = 1;
+ SAFE_SETRLIMIT(RLIMIT_CORE, &r);
+ tst_res(TINFO, "Avoid dumping corefile in following test");
+}
+
typedef void (*sighandler_t)(int);
static inline sighandler_t safe_signal(const char *file, const int lineno,
int signum, sighandler_t handler)
diff --git a/testcases/kernel/security/umip/umip_basic_test.c b/testcases/kernel/security/umip/umip_basic_test.c
index c34d4a1f6..0a86f0727 100644
--- a/testcases/kernel/security/umip/umip_basic_test.c
+++ b/testcases/kernel/security/umip/umip_basic_test.c
@@ -86,6 +86,8 @@ static void verify_umip_instruction(unsigned int n)
pid = SAFE_FORK();
if (pid == 0) {
+ tst_no_corefile();
+
switch (n) {
case 0:
asm_sgdt();
diff --git a/testcases/kernel/syscalls/ipc/shmat/shmat01.c b/testcases/kernel/syscalls/ipc/shmat/shmat01.c
index aa9dfd4e5..415af01ec 100644
--- a/testcases/kernel/syscalls/ipc/shmat/shmat01.c
+++ b/testcases/kernel/syscalls/ipc/shmat/shmat01.c
@@ -59,19 +59,9 @@ static void *expected_addr(void *in_addr, void *out_addr)
static void do_child(int *in_addr, int expect_crash)
{
- if (expect_crash) {
- /*
- * Crash is expected, avoid dumping corefile.
- * 1 is a special value, that disables core-to-pipe.
- * At the same time it is small enough value for
- * core-to-file, so it skips creating cores as well.
- */
- struct rlimit r;
-
- r.rlim_cur = 1;
- r.rlim_max = 1;
- SAFE_SETRLIMIT(RLIMIT_CORE, &r);
- }
+ if (expect_crash)
+ tst_no_corefile();
+
*in_addr = 10;
exit(0);
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* [LTP] [RFC PATCH] lib: add tst_no_corefile to avoid corefile dumping
2019-07-01 10:03 [LTP] [RFC PATCH] lib: add tst_no_corefile to avoid corefile dumping Li Wang
@ 2019-07-01 11:01 ` Jan Stancek
2019-07-02 7:53 ` Li Wang
0 siblings, 1 reply; 5+ messages in thread
From: Jan Stancek @ 2019-07-01 11:01 UTC (permalink / raw)
To: ltp
----- Original Message -----
> Signed-off-by: Li Wang <liwang@redhat.com>
> Cc: Jan Stancek <jstancek@redhat.com>
> ---
> include/tst_safe_macros.h | 16 ++++++++++++++++
> testcases/kernel/security/umip/umip_basic_test.c | 2 ++
> testcases/kernel/syscalls/ipc/shmat/shmat01.c | 16 +++-------------
> 3 files changed, 21 insertions(+), 13 deletions(-)
>
> diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
> index 53a888c80..110e2984f 100644
> --- a/include/tst_safe_macros.h
> +++ b/include/tst_safe_macros.h
> @@ -394,6 +394,22 @@ static inline int safe_setrlimit(const char *file, const
> int lineno,
> #define SAFE_SETRLIMIT(resource, rlim) \
> safe_setrlimit(__FILE__, __LINE__, (resource), (rlim))
>
> +/*
> + * Crash is expected, avoid dumping corefile.
> + * 1 is a special value, that disables core-to-pipe.
> + * At the same time it is small enough value for
> + * core-to-file, so it skips creating cores as well.
> + */
> +static inline void tst_no_corefile(void)
> +{
> + struct rlimit r;
> +
> + r.rlim_cur = 1;
> + r.rlim_max = 1;
> + SAFE_SETRLIMIT(RLIMIT_CORE, &r);
> + tst_res(TINFO, "Avoid dumping corefile in following test");
I'm fine with helper func. Maybe I'd print also current pid.
It could be little spammy if there are many children, but we could
address that later (if needed) with a parameter to control verbosity.
^ permalink raw reply [flat|nested] 5+ messages in thread* [LTP] [RFC PATCH] lib: add tst_no_corefile to avoid corefile dumping
2019-07-01 11:01 ` Jan Stancek
@ 2019-07-02 7:53 ` Li Wang
2019-07-02 16:11 ` Jan Stancek
0 siblings, 1 reply; 5+ messages in thread
From: Li Wang @ 2019-07-02 7:53 UTC (permalink / raw)
To: ltp
On Mon, Jul 1, 2019 at 7:01 PM Jan Stancek <jstancek@redhat.com> wrote:
>
>
> ----- Original Message -----
> > Signed-off-by: Li Wang <liwang@redhat.com>
> > Cc: Jan Stancek <jstancek@redhat.com>
> > ---
> > include/tst_safe_macros.h | 16 ++++++++++++++++
> > testcases/kernel/security/umip/umip_basic_test.c | 2 ++
> > testcases/kernel/syscalls/ipc/shmat/shmat01.c | 16 +++-------------
> > 3 files changed, 21 insertions(+), 13 deletions(-)
> >
> > diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
> > index 53a888c80..110e2984f 100644
> > --- a/include/tst_safe_macros.h
> > +++ b/include/tst_safe_macros.h
> > @@ -394,6 +394,22 @@ static inline int safe_setrlimit(const char *file,
> const
> > int lineno,
> > #define SAFE_SETRLIMIT(resource, rlim) \
> > safe_setrlimit(__FILE__, __LINE__, (resource), (rlim))
> >
> > +/*
> > + * Crash is expected, avoid dumping corefile.
> > + * 1 is a special value, that disables core-to-pipe.
> > + * At the same time it is small enough value for
> > + * core-to-file, so it skips creating cores as well.
> > + */
> > +static inline void tst_no_corefile(void)
> > +{
> > + struct rlimit r;
> > +
> > + r.rlim_cur = 1;
> > + r.rlim_max = 1;
> > + SAFE_SETRLIMIT(RLIMIT_CORE, &r);
> > + tst_res(TINFO, "Avoid dumping corefile in following test");
>
> I'm fine with helper func. Maybe I'd print also current pid.
> It could be little spammy if there are many children, but we could
> address that later (if needed) with a parameter to control verbosity.
>
To add a parameter (int verbose) sounds good to me.
Btw, should we add some note/comment in the
document(test-writing-guidelines.txt)? I take a rough look but not sure
which line is the best position for that.
--
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20190702/b9356c20/attachment-0001.htm>
^ permalink raw reply [flat|nested] 5+ messages in thread* [LTP] [RFC PATCH] lib: add tst_no_corefile to avoid corefile dumping
2019-07-02 7:53 ` Li Wang
@ 2019-07-02 16:11 ` Jan Stancek
2019-07-03 3:37 ` Li Wang
0 siblings, 1 reply; 5+ messages in thread
From: Jan Stancek @ 2019-07-02 16:11 UTC (permalink / raw)
To: ltp
----- Original Message -----
> On Mon, Jul 1, 2019 at 7:01 PM Jan Stancek <jstancek@redhat.com> wrote:
>
> >
> >
> > ----- Original Message -----
> > > Signed-off-by: Li Wang <liwang@redhat.com>
> > > Cc: Jan Stancek <jstancek@redhat.com>
> > > ---
> > > include/tst_safe_macros.h | 16 ++++++++++++++++
> > > testcases/kernel/security/umip/umip_basic_test.c | 2 ++
> > > testcases/kernel/syscalls/ipc/shmat/shmat01.c | 16 +++-------------
> > > 3 files changed, 21 insertions(+), 13 deletions(-)
> > >
> > > diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
> > > index 53a888c80..110e2984f 100644
> > > --- a/include/tst_safe_macros.h
> > > +++ b/include/tst_safe_macros.h
> > > @@ -394,6 +394,22 @@ static inline int safe_setrlimit(const char *file,
> > const
> > > int lineno,
> > > #define SAFE_SETRLIMIT(resource, rlim) \
> > > safe_setrlimit(__FILE__, __LINE__, (resource), (rlim))
> > >
> > > +/*
> > > + * Crash is expected, avoid dumping corefile.
> > > + * 1 is a special value, that disables core-to-pipe.
> > > + * At the same time it is small enough value for
> > > + * core-to-file, so it skips creating cores as well.
> > > + */
> > > +static inline void tst_no_corefile(void)
> > > +{
> > > + struct rlimit r;
> > > +
> > > + r.rlim_cur = 1;
> > > + r.rlim_max = 1;
> > > + SAFE_SETRLIMIT(RLIMIT_CORE, &r);
> > > + tst_res(TINFO, "Avoid dumping corefile in following test");
> >
> > I'm fine with helper func. Maybe I'd print also current pid.
> > It could be little spammy if there are many children, but we could
> > address that later (if needed) with a parameter to control verbosity.
> >
>
> To add a parameter (int verbose) sounds good to me.
>
> Btw, should we add some note/comment in the
> document(test-writing-guidelines.txt)? I take a rough look but not sure
> which line is the best position for that.
How about we extend "2.2.10 Signal handlers" to "2.2.10 Signals and signal handlers"
and put a note there?
>
> --
> Regards,
> Li Wang
>
^ permalink raw reply [flat|nested] 5+ messages in thread* [LTP] [RFC PATCH] lib: add tst_no_corefile to avoid corefile dumping
2019-07-02 16:11 ` Jan Stancek
@ 2019-07-03 3:37 ` Li Wang
0 siblings, 0 replies; 5+ messages in thread
From: Li Wang @ 2019-07-03 3:37 UTC (permalink / raw)
To: ltp
On Wed, Jul 3, 2019 at 12:11 AM Jan Stancek <jstancek@redhat.com> wrote:
>
>
> ----- Original Message -----
> > On Mon, Jul 1, 2019 at 7:01 PM Jan Stancek <jstancek@redhat.com> wrote:
> >
> > >
> > >
> > > ----- Original Message -----
> > > > Signed-off-by: Li Wang <liwang@redhat.com>
> > > > Cc: Jan Stancek <jstancek@redhat.com>
> > > > ---
> > > > include/tst_safe_macros.h | 16
> ++++++++++++++++
> > > > testcases/kernel/security/umip/umip_basic_test.c | 2 ++
> > > > testcases/kernel/syscalls/ipc/shmat/shmat01.c | 16
> +++-------------
> > > > 3 files changed, 21 insertions(+), 13 deletions(-)
> > > >
> > > > diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
> > > > index 53a888c80..110e2984f 100644
> > > > --- a/include/tst_safe_macros.h
> > > > +++ b/include/tst_safe_macros.h
> > > > @@ -394,6 +394,22 @@ static inline int safe_setrlimit(const char
> *file,
> > > const
> > > > int lineno,
> > > > #define SAFE_SETRLIMIT(resource, rlim) \
> > > > safe_setrlimit(__FILE__, __LINE__, (resource), (rlim))
> > > >
> > > > +/*
> > > > + * Crash is expected, avoid dumping corefile.
> > > > + * 1 is a special value, that disables core-to-pipe.
> > > > + * At the same time it is small enough value for
> > > > + * core-to-file, so it skips creating cores as well.
> > > > + */
> > > > +static inline void tst_no_corefile(void)
> > > > +{
> > > > + struct rlimit r;
> > > > +
> > > > + r.rlim_cur = 1;
> > > > + r.rlim_max = 1;
> > > > + SAFE_SETRLIMIT(RLIMIT_CORE, &r);
> > > > + tst_res(TINFO, "Avoid dumping corefile in following test");
> > >
> > > I'm fine with helper func. Maybe I'd print also current pid.
> > > It could be little spammy if there are many children, but we could
> > > address that later (if needed) with a parameter to control verbosity.
> > >
> >
> > To add a parameter (int verbose) sounds good to me.
> >
> > Btw, should we add some note/comment in the
> > document(test-writing-guidelines.txt)? I take a rough look but not sure
> > which line is the best position for that.
>
> How about we extend "2.2.10 Signal handlers" to "2.2.10 Signals and signal
> handlers"
> and put a note there?
Good point.
Since that core file dumping is(sometimes) a response for signal SIGSEGV in
process, we purpose to change that behavior and avoid to generate a dump
that related to this topic.
--
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20190703/07ab69ce/attachment.htm>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-07-03 3:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-01 10:03 [LTP] [RFC PATCH] lib: add tst_no_corefile to avoid corefile dumping Li Wang
2019-07-01 11:01 ` Jan Stancek
2019-07-02 7:53 ` Li Wang
2019-07-02 16:11 ` Jan Stancek
2019-07-03 3:37 ` Li Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox