Skip to contentSkip to conversation

signal: add new testcase signal06.c

PATCH New Li Wang 2 participants 3 messages Nov 7, 2015 – Nov 10, 2015

lore
Share & tools
lore

Li Wang

author
#0 lore raw

PATCH 1/1 signal: add new testcase signal06.c

Regression test for kernel commit:
commit df24fb859a4e200d9324e2974229fbb7adf00aef
Author: Oleg Nesterov <[email protected]>
Date: Tue Sep 2 19:57:17 2014 +0200

        commit 66463db4fc5605d51c7bb81d009d5bf30a783a2c
                Author: Oleg Nesterov <[email protected]>
                Date:   Tue Sep 2 19:57:13 2014 +0200
---
 runtest/ltplite                             |   1 +
 runtest/stress.part3                        |   1 +
 runtest/syscalls                            |   1 +
 testcases/kernel/syscalls/signal/Makefile   |   2 +
 testcases/kernel/syscalls/signal/signal06.c | 148 ++++++++++++++++++++++++++++
 5 files changed, 153 insertions(+)
 create mode 100644 testcases/kernel/syscalls/signal/signal06.c
runtest/ltplite +1 -0
index aaa5c73..f2c9dcf 100644
@@ -840,6 +840,7 @@ signal02 signal02
 signal03 signal03
 signal04 signal04
 signal05 signal05
+signal06 signal06
 
 sigpending02 sigpending02
 
runtest/stress.part3 +1 -0
index 63505ec..36bb16f 100644
@@ -744,6 +744,7 @@ signal02 signal02
 signal03 signal03
 signal04 signal04
 signal05 signal05
+signal06 signal06
 
 sigpending02 sigpending02
 
runtest/syscalls +1 -0
index 958f66e..cfbcbea 100644
@@ -1143,6 +1143,7 @@ signal02 signal02
 signal03 signal03
 signal04 signal04
 signal05 signal05
+signal06 signal06
 
 signalfd01 signalfd01
 
testcases/kernel/syscalls/signal/Makefile +2 -0
index bd617d8..46885db 100644
@@ -21,3 +21,5 @@ top_srcdir		?= ../../../..
 include $(top_srcdir)/include/mk/testcases.mk
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
+
+signal06: CFLAGS+=-O2 -lpthread
testcases/kernel/syscalls/signal/signal06.c new file +148 -0

148 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/1 signal: add new testcase signal06.c

----- Original Message -----

Quoted 4 lines

From: "Li Wang" <[email protected]>
To: [email protected]
Sent: Saturday, 7 November, 2015 1:28:17 PM
Subject: [LTP] [PATCH] signal: add new testcase signal06.c

Hi,

Quoted 9 lines

Regression test for kernel commit:
commit df24fb859a4e200d9324e2974229fbb7adf00aef
Author: Oleg Nesterov <[email protected]>
Date: Tue Sep 2 19:57:17 2014 +0200

        commit 66463db4fc5605d51c7bb81d009d5bf30a783a2c
                Author: Oleg Nesterov <[email protected]>
                Date:   Tue Sep 2 19:57:13 2014 +0200

Short summary what the problem is would be appreciated here.

Quoted 54 lines
---
 runtest/ltplite                             |   1 +
 runtest/stress.part3                        |   1 +
 runtest/syscalls                            |   1 +
 testcases/kernel/syscalls/signal/Makefile   |   2 +
 testcases/kernel/syscalls/signal/signal06.c | 148
 ++++++++++++++++++++++++++++
 5 files changed, 153 insertions(+)
 create mode 100644 testcases/kernel/syscalls/signal/signal06.c
runtest/ltplite +1 -0
index aaa5c73..f2c9dcf 100644
@@ -840,6 +840,7 @@ signal02 signal02
 signal03 signal03
 signal04 signal04
 signal05 signal05
+signal06 signal06
 
 sigpending02 sigpending02
 
runtest/stress.part3 +1 -0
index 63505ec..36bb16f 100644
@@ -744,6 +744,7 @@ signal02 signal02
 signal03 signal03
 signal04 signal04
 signal05 signal05
+signal06 signal06
 
 sigpending02 sigpending02
 
runtest/syscalls +1 -0
index 958f66e..cfbcbea 100644
@@ -1143,6 +1143,7 @@ signal02 signal02
 signal03 signal03
 signal04 signal04
 signal05 signal05
+signal06 signal06
 
 signalfd01 signalfd01
 
testcases/kernel/syscalls/signal/Makefile +0 -0
index bd617d8..46885db 100644

testcases/kernel/syscalls/signal/Makefile top_srcdir ?= ../../../.. · line 25

Quoted 5 lines
testcases/kernel/syscalls/signal/Makefile +2 -0
@@ -21,3 +21,5 @@ top_srcdir		?= ../../../..
 include $(top_srcdir)/include/mk/testcases.mk
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
+
+signal06: CFLAGS+=-O2 -lpthread

just "-pthread"

Quoted 17 lines
testcases/kernel/syscalls/signal/signal06.c new file +10 -0
new file mode 100644
index 0000000..166d33c
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2015   Author: Oleg Nesterov <[email protected]>
+ *                      Modify: Li Wang <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of

testcases/kernel/syscalls/signal/signal06.c line 20

Quoted 10 lines
testcases/kernel/syscalls/signal/signal06.c new file +10 -0
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * you should have received a copy of the GNU General Public License along
+ * with this program; if not, write the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+/*
+ * Description:
+ * These below commits fix the issue on v3.17-rc3-3 stable kernel:

Here as well - short description what is the "issue".

Quoted 20 lines
testcases/kernel/syscalls/signal/signal06.c new file +20 -0
+ *
+ * 	commit df24fb859a4e200d9324e2974229fbb7adf00aef
+ * 		Author: Oleg Nesterov <[email protected]>
+ * 		Date:   Tue Sep 2 19:57:17 2014 +0200
+ *
+ *      commit 66463db4fc5605d51c7bb81d009d5bf30a783a2c
+ *               Author: Oleg Nesterov <[email protected]>
+ *               Date:   Tue Sep 2 19:57:13 2014 +0200
+ *
+ * Reproduce:
+ *	Test-case (needs -O2).
+ */
+
+#include <stdio.h>
+#include <signal.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+#include <sys/mman.h>
+#include <pthread.h>
+#include <assert.h>

testcases/kernel/syscalls/signal/signal06.c line 50

Quoted 10 lines
testcases/kernel/syscalls/signal/signal06.c new file +10 -0
+
+#include "test.h"
+
+char *TCID = "signal06";
+int TST_TOTAL = 5;
+
+#if __x86_64__
+
+volatile double D;
+int FLAGE;

FLAGE looks like it should be volatile too.

testcases/kernel/syscalls/signal/signal06.c line 60

Quoted 10 lines
testcases/kernel/syscalls/signal/signal06.c new file +10 -0
+
+char altstack[4096 * 10] __attribute__((aligned(4096)));
+
+void test(double d)
+{
+	int loop = 1;
+	int pid = getpid();
+
+	D = d;
+	while (D == d && loop < 10000) {

make "10000" DEFINE or@least a variable

testcases/kernel/syscalls/signal/signal06.c line 63

Quoted 3 lines
testcases/kernel/syscalls/signal/signal06.c new file +3 -0
+		/* sys_tkill(pid, SIGHUP); asm to avoid save/reload
+		 * fp regs around c call */
+		asm ("" : : "a"(200), "D"(pid), "S"(1));

If you include linux_syscall_numbers.h, you can be sure that __NR_tkill will be defined.

testcases/kernel/syscalls/signal/signal06.c line 76

Quoted 13 lines
testcases/kernel/syscalls/signal/signal06.c new file +13 -0
+		asm ("syscall" : : : "ax");
+
+		loop++;
+	}
+
+	FLAGE = 1;
+	tst_resm(TINFO, "loop = %d", loop);
+
+	if (loop == 10000) {
+		tst_resm(TPASS, "%s call succeeded", TCID);
+	} else {
+		tst_resm(TFAIL, "Bug Reproduced!");
+		exit(-1);

Why not tst_exit()?

Quoted 36 lines
testcases/kernel/syscalls/signal/signal06.c new file +36 -0
+	}
+}
+
+void sigh(int sig LTP_ATTRIBUTE_UNUSED)
+{
+}
+
+void *tfunc(void *arg LTP_ATTRIBUTE_UNUSED)
+{
+	FLAGE = 0;
+
+	for (; ;) {
+		mprotect(altstack, sizeof(altstack), PROT_READ);
+		mprotect(altstack, sizeof(altstack), PROT_READ|PROT_WRITE);
+
+		if (FLAGE == 1)
+			return NULL;
+	}
+}
+
+int main(int ac, char **av)
+{
+	int i, lc, res;
+	pthread_t pt;
+
+	stack_t st = {
+		.ss_sp = altstack,
+		.ss_size = sizeof(altstack),
+		.ss_flags = SS_ONSTACK,
+	};
+
+	struct sigaction sa = {
+		.sa_handler = sigh,
+	};
+
+	tst_parse_opts(ac, av, NULL, NULL);

testcases/kernel/syscalls/signal/signal06.c line 122

Quoted 10 lines
testcases/kernel/syscalls/signal/signal06.c new file +10 -0
+
+	for (lc = 0; TEST_LOOPING(lc); lc++) {
+		tst_count = 0;
+
+		for (i = 0; i < TST_TOTAL; i++) {
+
+			sigaction(SIGSEGV, &sa, NULL);
+			sigaltstack(&st, NULL);
+			sa.sa_flags = SA_ONSTACK;
+			sigaction(SIGHUP, &sa, NULL);

Signal handler setup looks like it can be moved outside both loops.

testcases/kernel/syscalls/signal/signal06.c line 127

Quoted 5 lines
testcases/kernel/syscalls/signal/signal06.c new file +5 -0
+
+			res = pthread_create(&pt, NULL, tfunc, NULL);
+			if (res) {
+				tst_brkm(TBROK, NULL, "pthread_create(): %s",
+						tst_strerrno(res));

If you use TEST(), then TRERRNO will print errno stored in TEST_RETURN.

Regards,
Jan

Quoted 28 lines
testcases/kernel/syscalls/signal/signal06.c new file +21 -1
+			}
+
+			test(123.456);
+
+			res = pthread_join(pt, NULL);
+			if (res)
+				tst_brkm(TBROK, NULL, "pthread_join(): %s",
+						tst_strerrno(res));
+
+		}
+	}
+
+	tst_exit();
+}
+
+#else
+int main(void)
+{
+	tst_brkm(TCONF, NULL, "Only test on x86_64.");
+}
+#endif
--

1.8.3.1

--
Mailing list info: http://lists.linux.it/listinfo/ltp

author
#2 lore raw

PATCH 1/1 signal: add new testcase signal06.c

Hi,

Quoted 5 lines · Jan Stancek

Short summary what the problem is would be appreciated here.

ok, l will try.

Quoted 6 lines

testcases/kernel/syscalls/signal/Makefile top_srcdir ?= ../../../.. · line 25

Quoted 3 lines
testcases/kernel/syscalls/signal/Makefile +2 -0
+
+signal06: CFLAGS+=-O2 -lpthread

just "-pthread"

ok.

Quoted 6 lines
Quoted 3 lines

+ * Description:
+ * These below commits fix the issue on v3.17-rc3-3 stable kernel:

Here as well - short description what is the "issue".

ok.

Quoted 14 lines

testcases/kernel/syscalls/signal/signal06.c line 50

Quoted 11 lines

+ *

testcases/kernel/syscalls/signal/signal06.c new file +9 -0
+#include "test.h"
+
+char *TCID = "signal06";
+int TST_TOTAL = 5;
+
+#if __x86_64__
+
+volatile double D;
+int FLAGE;

FLAGE looks like it should be volatile too.

yeah, no problem.

Quoted 14 lines

testcases/kernel/syscalls/signal/signal06.c line 60

Quoted 11 lines
testcases/kernel/syscalls/signal/signal06.c new file +10 -0
+
+char altstack[4096 * 10] __attribute__((aligned(4096)));
+
+void test(double d)
+{
+     int loop = 1;
+     int pid = getpid();
+
+     D = d;
+     while (D == d && loop < 10000) {

make "10000" DEFINE or at least a variable

yes.

Quoted 8 lines

testcases/kernel/syscalls/signal/signal06.c line 63

Quoted 4 lines
testcases/kernel/syscalls/signal/signal06.c new file +3 -0
+             /* sys_tkill(pid, SIGHUP); asm to avoid save/reload
+              * fp regs around c call */
+             asm ("" : : "a"(200), "D"(pid), "S"(1));

If you include linux_syscall_numbers.h, you can be sure that __NR_tkill will be defined.

ok, sounds good.

Quoted 6 lines

testcases/kernel/syscalls/signal/signal06.c line 76

Quoted 3 lines
testcases/kernel/syscalls/signal/signal06.c new file +3 -0
+     } else {
+             tst_resm(TFAIL, "Bug Reproduced!");
+             exit(-1);

Why not tst_exit()?

ok, good.

Quoted 12 lines

testcases/kernel/syscalls/signal/signal06.c line 122

Quoted 9 lines
testcases/kernel/syscalls/signal/signal06.c new file +8 -0
+             tst_count = 0;
+
+             for (i = 0; i < TST_TOTAL; i++) {
+
+                     sigaction(SIGSEGV, &sa, NULL);
+                     sigaltstack(&st, NULL);
+                     sa.sa_flags = SA_ONSTACK;
+                     sigaction(SIGHUP, &sa, NULL);

Signal handler setup looks like it can be moved outside both loops.

yes, that's would be great.

Quoted 10 lines

testcases/kernel/syscalls/signal/signal06.c

Quoted 5 lines
testcases/kernel/syscalls/signal/signal06.c new file +4 -0
+
+                     res = pthread_create(&pt, NULL, tfunc, NULL);
+                     if (res) {
+                             tst_brkm(TBROK, NULL, "pthread_create():

%s",

Quoted 1 line

+ tst_strerrno(res));

If you use TEST(), then TRERRNO will print errno stored in TEST_RETURN.

yes.

Quoted 5 lines

Regards,
Jan

Thanks for reviewing this patch. and then will sent V2.

Signature · 6 lines
Regards,
Li Wang
Email: [email protected]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20151110/319d7071/attachment.html>