Skip to contentSkip to conversation

SAFE_MACROS: Add SAFE_SETSID()

PATCH New Guangwen Feng 2 participants 5 messages Jun 15, 2017 – Jun 19, 2017 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 SAFE_MACROS: Add SAFE_SETSID()

---
 include/tst_safe_macros.h |  3 +++
 lib/safe_macros.c         | 13 +++++++++++++
 2 files changed, 16 insertions(+)
include/tst_safe_macros.h +3 -0
index a25a4f0..09745c1 100644
@@ -430,4 +430,7 @@ int safe_removexattr(const char *file, const int lineno, const char *path,
 int safe_fsync(const char *file, const int lineno, int fd);
 #define SAFE_FSYNC(fd) safe_fsync(__FILE__, __LINE__, (fd))
 
+int safe_setsid(const char *file, const int lineno);
+#define SAFE_SETSID() safe_setsid(__FILE__, __LINE__)
+
 #endif /* SAFE_MACROS_H__ */
lib/safe_macros.c +13 -0
index a6b4ff7..3ef9266 100644
@@ -895,3 +895,16 @@ int safe_fsync(const char *file, const int lineno, int fd)
 
 	return rval;
 }
+
+pid_t safe_setsid(const char *file, const int lineno)
+{
+	pid_t rval;
+
+	rval = setsid();
+	if (rval == -1) {
+		tst_brkm(TBROK | TERRNO, NULL,
+			 "%s:%d: setsid() failed", file, lineno);
+	}
+
+	return rval;
+}
Signature · 1 line
1.8.4.2
#1 lore raw

PATCH 2/2 sched/autogroup01: Add new regression test

Fixed by:
commit 18f649ef344127ef6de23a5a4272dbe2fdb73dde

Author: Oleg Nesterov <[email protected]>
Date:   Mon Nov 14 19:46:09 2016 +0100

sched/autogroup: Fix autogroup_move_group() to never skip sched_move_task()

---
 runtest/sched                                  |  2 +
 testcases/kernel/sched/autogroup/.gitignore    |  1 +
 testcases/kernel/sched/autogroup/Makefile      | 23 +++++++
 testcases/kernel/sched/autogroup/autogroup01.c | 95 ++++++++++++++++++++++++++
 4 files changed, 121 insertions(+)
 create mode 100644 testcases/kernel/sched/autogroup/.gitignore
 create mode 100644 testcases/kernel/sched/autogroup/Makefile
 create mode 100644 testcases/kernel/sched/autogroup/autogroup01.c
runtest/sched +2 -0
index 89398df..774d11f 100644
@@ -16,3 +16,5 @@ sched_getattr02 sched_getattr02
 sched_cli_serv run_sched_cliserv.sh
 # Run this stress test for 2 minutes
 sched_stress sched_stress.sh
+
+autogroup01 autogroup01
testcases/kernel/sched/autogroup/.gitignore new file +1 -0
new file mode 100644
index 0000000..bcc7453
@@ -0,0 +1 @@
+/autogroup01
testcases/kernel/sched/autogroup/Makefile new file +23 -0
new file mode 100644
index 0000000..6cc7782
@@ -0,0 +1,23 @@
+#
+#  Copyright (c) 2017 Fujitsu Ltd.
+#  Author: Guangwen Feng <[email protected]>
+#
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, see <http://www.gnu.org/licenses/>.
+#
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/sched/autogroup/autogroup01.c new file +95 -0

95 lines not on this page · raw message

Signature · 1 line
1.8.4.2
#2 lore raw

PATCH 2/2 sched/autogroup01: Add new regression test

Hi!

testcases/kernel/sched/autogroup/autogroup01.c line 50

Quoted 11 lines
testcases/kernel/sched/autogroup/autogroup01.c new file +11 -0
+static void do_test(void)
+{
+	int i;
+
+	if (!SAFE_FORK()) {
+		SAFE_FILE_PRINTF(PATH_AUTOGROUP, "%d", 1);
+		SAFE_SETSID();
+
+		if (SAFE_FORK()) {
+			pause();
+			exit(0);

Do we really reach this exit(0)?

We are sending SIGKILL to this process after all...

Quoted 12 lines
testcases/kernel/sched/autogroup/autogroup01.c new file +12 -0
+		}
+
+		SAFE_KILL(getppid(), SIGKILL);
+		usleep(1000);
+
+		SAFE_FILE_PRINTF(PATH_AUTOGROUP, "%d", 0);
+		SAFE_SETSID();
+
+		for (i = 0; i < LOOPS; i++)
+			usleep(10);
+
+		TST_CHECKPOINT_WAKE(0);

testcases/kernel/sched/autogroup/autogroup01.c line 72

Quoted 10 lines
testcases/kernel/sched/autogroup/autogroup01.c new file +10 -0
+
+		exit(0);
+	}
+
+	SAFE_WAIT(NULL);
+
+	TST_CHECKPOINT_WAIT(0);
+
+	tst_res(TPASS, "Bug not reproduced");
+}

Otherwise it looks fine. We may as well include the comments that were present in the original reproducer as that makes the code a bit easier to understand.

Signature · 2 lines
Cyril Hrubis
[email protected]
#3 lore raw

PATCH v2 1/1 sched/autogroup01: Add new regression test

Fixed by:
commit 18f649ef344127ef6de23a5a4272dbe2fdb73dde

Author: Oleg Nesterov <[email protected]>
Date:   Mon Nov 14 19:46:09 2016 +0100

sched/autogroup: Fix autogroup_move_group() to never skip sched_move_task()

---
 runtest/sched                                  |  2 +
 testcases/kernel/sched/autogroup/.gitignore    |  1 +
 testcases/kernel/sched/autogroup/Makefile      | 23 +++++++
 testcases/kernel/sched/autogroup/autogroup01.c | 95 ++++++++++++++++++++++++++
 4 files changed, 121 insertions(+)
 create mode 100644 testcases/kernel/sched/autogroup/.gitignore
 create mode 100644 testcases/kernel/sched/autogroup/Makefile
 create mode 100644 testcases/kernel/sched/autogroup/autogroup01.c
runtest/sched +2 -0
index 89398df..774d11f 100644
@@ -16,3 +16,5 @@ sched_getattr02 sched_getattr02
 sched_cli_serv run_sched_cliserv.sh
 # Run this stress test for 2 minutes
 sched_stress sched_stress.sh
+
+autogroup01 autogroup01
testcases/kernel/sched/autogroup/.gitignore new file +1 -0
new file mode 100644
index 0000000..bcc7453
@@ -0,0 +1 @@
+/autogroup01
testcases/kernel/sched/autogroup/Makefile new file +23 -0
new file mode 100644
index 0000000..6cc7782
@@ -0,0 +1,23 @@
+#
+#  Copyright (c) 2017 Fujitsu Ltd.
+#  Author: Guangwen Feng <[email protected]>
+#
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, see <http://www.gnu.org/licenses/>.
+#
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/sched/autogroup/autogroup01.c new file +95 -0

95 lines not on this page · raw message

Signature · 1 line
1.8.4.2