Skip to contentSkip to conversation

commands/sysctl: Add new regression test for invalid sched_time_avg

PATCH New Xiao Yang 2 participants 11 messages Jan 23, 2018 – Mar 15, 2018

lore
Share & tools
lore

Xiao Yang

author
#0 lore raw

PATCH 1/1 commands/sysctl: Add new regression test for invalid sched_time_avg

The kernel bug has been fixed in kernel:
'5ccba44ba118("sched/sysctl: Check user input value of sysctl_sched_time_avg")'

---
 runtest/commands                      |  1 +
 testcases/commands/sysctl/Makefile    | 25 ++++++++++++++
 testcases/commands/sysctl/sysctl01.sh | 65 +++++++++++++++++++++++++++++++++++
 3 files changed, 91 insertions(+)
 create mode 100644 testcases/commands/sysctl/Makefile
 create mode 100755 testcases/commands/sysctl/sysctl01.sh
runtest/commands +1 -0
index 92df3af..fde8063 100644
@@ -44,3 +44,4 @@ wc01 wc01.sh
 keyctl01 keyctl01.sh
 gdb01 gdb01.sh
 unshare01 unshare01.sh
+sysctl01 sysctl01.sh
testcases/commands/sysctl/Makefile new file +25 -0
new file mode 100644
index 0000000..61ff705
@@ -0,0 +1,25 @@
+#
+# Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
+# Author: Xiao Yang <[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/env_pre.mk
+
+INSTALL_TARGETS		:= *.sh
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/commands/sysctl/sysctl01.sh new file +65 -0

65 lines not on this page · raw message

Signature · 1 line
1.8.3.1
author
#1 lore raw

PATCH 1/1 commands/sysctl: Add new regression test for invalid sched_time_avg

Hi,

Ping :-)

Thanks,
Xiao Yang

Quoted 123 lines · Xiao Yang

The kernel bug has been fixed in kernel:
'5ccba44ba118("sched/sysctl: Check user input value of sysctl_sched_time_avg")'

---
 runtest/commands                      |  1 +
 testcases/commands/sysctl/Makefile    | 25 ++++++++++++++
 testcases/commands/sysctl/sysctl01.sh | 65 +++++++++++++++++++++++++++++++++++
 3 files changed, 91 insertions(+)
 create mode 100644 testcases/commands/sysctl/Makefile
 create mode 100755 testcases/commands/sysctl/sysctl01.sh
runtest/commands +1 -0
index 92df3af..fde8063 100644
@@ -44,3 +44,4 @@ wc01 wc01.sh
 keyctl01 keyctl01.sh
 gdb01 gdb01.sh
 unshare01 unshare01.sh
+sysctl01 sysctl01.sh
testcases/commands/sysctl/Makefile new file +25 -0
new file mode 100644
index 0000000..61ff705
@@ -0,0 +1,25 @@
+#
+# Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
+# Author: Xiao Yang <[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/env_pre.mk
+
+INSTALL_TARGETS		:= *.sh
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/commands/sysctl/sysctl01.sh new file +65 -0
new file mode 100755
index 0000000..2bcf9a7
@@ -0,0 +1,65 @@
+#!/bin/sh
+#
+# Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
+# Author: Xiao Yang <[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/>.
+#
+# Description:
+# This is a regression test for invalid value of sched_time_avg.
+# System will hang if user set sched_time_avg to 0 on buggy kernel.
+#
+# The kernel bug has been fixed in kernel:
+# '5ccba44ba118("sched/sysctl: Check user input value of sysctl_sched_time_avg")'
+
+TST_TESTFUNC=sysctl_test
+TST_NEEDS_CMDS="sysctl"
+
+. tst_test.sh
+
+get_value()
+{
+	local value=$(sysctl -n $1)
+	[ -z "$value" ] && tst_brk TBROK \
+		"Failed to get the value of sched_time_avg(_ms)"
+
+	echo $value
+}
+
+sysctl_test()
+{
+	# With commit d00535d, sched_time_avg was renamed as sched_time_avg_ms
+	local name=$(sysctl -a 2>&1 | egrep -o \
+		'kernel.(sched_time_avg|sched_time_avg_ms)')
+	[ -z "$name" ] && tst_brk TCONF \
+		"sched_time_avg(_ms) was not supported"
+
+	local orig_value=$(get_value $name)
+
+	sysctl -w $name=0 >/dev/null 2>&1
+
+	# Increase the chance of exposing the problem on RHEL6
+	sleep 3
+
+	local curr_value=$(get_value $name)
+
+	if [ ${curr_value} -eq ${orig_value} ]; then
+		tst_res TPASS "Setting sched_time_avg(_ms) failed"
+	else
+		tst_res TFAIL "Setting sched_time_avg(_ms) succeeded"
+		sysctl -w $name=${orig_value} >/dev/null 2>&1
+	fi
+}
+
+tst_run
author
#2 lore raw

PATCH 1/1 commands/sysctl: Add new regression test for invalid sched_time_avg

In reply to Xiao Yang

Hi,

Ping! :-)

Thanks,
Xiao Yang

Quoted 123 lines · Xiao Yang

The kernel bug has been fixed in kernel:
'5ccba44ba118("sched/sysctl: Check user input value of sysctl_sched_time_avg")'

---
 runtest/commands                      |  1 +
 testcases/commands/sysctl/Makefile    | 25 ++++++++++++++
 testcases/commands/sysctl/sysctl01.sh | 65 +++++++++++++++++++++++++++++++++++
 3 files changed, 91 insertions(+)
 create mode 100644 testcases/commands/sysctl/Makefile
 create mode 100755 testcases/commands/sysctl/sysctl01.sh
runtest/commands +1 -0
index 92df3af..fde8063 100644
@@ -44,3 +44,4 @@ wc01 wc01.sh
 keyctl01 keyctl01.sh
 gdb01 gdb01.sh
 unshare01 unshare01.sh
+sysctl01 sysctl01.sh
testcases/commands/sysctl/Makefile new file +25 -0
new file mode 100644
index 0000000..61ff705
@@ -0,0 +1,25 @@
+#
+# Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
+# Author: Xiao Yang <[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/env_pre.mk
+
+INSTALL_TARGETS		:= *.sh
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/commands/sysctl/sysctl01.sh new file +65 -0
new file mode 100755
index 0000000..2bcf9a7
@@ -0,0 +1,65 @@
+#!/bin/sh
+#
+# Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
+# Author: Xiao Yang <[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/>.
+#
+# Description:
+# This is a regression test for invalid value of sched_time_avg.
+# System will hang if user set sched_time_avg to 0 on buggy kernel.
+#
+# The kernel bug has been fixed in kernel:
+# '5ccba44ba118("sched/sysctl: Check user input value of sysctl_sched_time_avg")'
+
+TST_TESTFUNC=sysctl_test
+TST_NEEDS_CMDS="sysctl"
+
+. tst_test.sh
+
+get_value()
+{
+	local value=$(sysctl -n $1)
+	[ -z "$value" ] && tst_brk TBROK \
+		"Failed to get the value of sched_time_avg(_ms)"
+
+	echo $value
+}
+
+sysctl_test()
+{
+	# With commit d00535d, sched_time_avg was renamed as sched_time_avg_ms
+	local name=$(sysctl -a 2>&1 | egrep -o \
+		'kernel.(sched_time_avg|sched_time_avg_ms)')
+	[ -z "$name" ] && tst_brk TCONF \
+		"sched_time_avg(_ms) was not supported"
+
+	local orig_value=$(get_value $name)
+
+	sysctl -w $name=0 >/dev/null 2>&1
+
+	# Increase the chance of exposing the problem on RHEL6
+	sleep 3
+
+	local curr_value=$(get_value $name)
+
+	if [ ${curr_value} -eq ${orig_value} ]; then
+		tst_res TPASS "Setting sched_time_avg(_ms) failed"
+	else
+		tst_res TFAIL "Setting sched_time_avg(_ms) succeeded"
+		sysctl -w $name=${orig_value} >/dev/null 2>&1
+	fi
+}
+
+tst_run
#3 lore raw

PATCH 1/1 commands/sysctl: Add new regression test for invalid sched_time_avg

In reply to Xiao Yang

Hi!

Quoted 11 lines
testcases/commands/sysctl/sysctl01.sh new file +11 -0
+TST_TESTFUNC=sysctl_test
+TST_NEEDS_CMDS="sysctl"
+
+. tst_test.sh
+
+get_value()
+{
+	local value=$(sysctl -n $1)
+	[ -z "$value" ] && tst_brk TBROK \
+		"Failed to get the value of sched_time_avg(_ms)"
+

testcases/commands/sysctl/sysctl01.sh line 46

Quoted 10 lines
testcases/commands/sysctl/sysctl01.sh new file +10 -0
+	echo $value
+}
+
+sysctl_test()
+{
+	# With commit d00535d, sched_time_avg was renamed as sched_time_avg_ms
+	local name=$(sysctl -a 2>&1 | egrep -o \
+		'kernel.(sched_time_avg|sched_time_avg_ms)')
+	[ -z "$name" ] && tst_brk TCONF \
+		"sched_time_avg(_ms) was not supported"

Can't we just do?

if [ -e /proc/sys/kernel/sched_time_avg_ms ]; then

	name=...

fi

if [ -e /proc/sys/kernel/sched_time_avg ]; then

	name=...

fi

[ -z "$name" ] ...

testcases/commands/sysctl/sysctl01.sh line 53

Quoted 6 lines
testcases/commands/sysctl/sysctl01.sh new file +6 -0
+	local orig_value=$(get_value $name)
+
+	sysctl -w $name=0 >/dev/null 2>&1
+
+	# Increase the chance of exposing the problem on RHEL6
+	sleep 3

What is this sleep good for? Do we wait here for the kernel to crash?

Quoted 19 lines
testcases/commands/sysctl/sysctl01.sh new file +11 -0
+	local curr_value=$(get_value $name)
+
+	if [ ${curr_value} -eq ${orig_value} ]; then
+		tst_res TPASS "Setting sched_time_avg(_ms) failed"
+	else
+		tst_res TFAIL "Setting sched_time_avg(_ms) succeeded"
+		sysctl -w $name=${orig_value} >/dev/null 2>&1
+	fi
+}
+
+tst_run
Signature · 7 lines
1.8.3.1




-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 2 lines
Cyril Hrubis
[email protected]
author
#4 lore raw

PATCH 1/1 commands/sysctl: Add new regression test for invalid sched_time_avg

Quoted 25 lines · Cyril Hrubis

Hi!

Quoted 11 lines
testcases/commands/sysctl/sysctl01.sh new file +11 -0
+TST_TESTFUNC=sysctl_test
+TST_NEEDS_CMDS="sysctl"
+
+. tst_test.sh
+
+get_value()
+{
+	local value=$(sysctl -n $1)
+	[ -z "$value" ]&&  tst_brk TBROK \
+		"Failed to get the value of sched_time_avg(_ms)"
+

testcases/commands/sysctl/sysctl01.sh line 46

Quoted 10 lines
testcases/commands/sysctl/sysctl01.sh new file +10 -0
+	echo $value
+}
+
+sysctl_test()
+{
+	# With commit d00535d, sched_time_avg was renamed as sched_time_avg_ms
+	local name=$(sysctl -a 2>&1 | egrep -o \
+		'kernel.(sched_time_avg|sched_time_avg_ms)')
+	[ -z "$name" ]&&  tst_brk TCONF \
+		"sched_time_avg(_ms) was not supported"

Can't we just do?

if [ -e /proc/sys/kernel/sched_time_avg_ms ]; then

Quoted 8 lines
	name=...

fi

if [ -e /proc/sys/kernel/sched_time_avg ]; then

	name=...

fi

[ -z "$name" ] ...

Hi Cyril,

Agreed. Using /proc/sys/ instead of sysctl command seems better.

Quoted 7 lines

testcases/commands/sysctl/sysctl01.sh line 53

Quoted 6 lines
testcases/commands/sysctl/sysctl01.sh new file +6 -0
+	local orig_value=$(get_value $name)
+
+	sysctl -w $name=0>/dev/null 2>&1
+
+	# Increase the chance of exposing the problem on RHEL6
+	sleep 3

What is this sleep good for? Do we wait here for the kernel to crash?

On my RHEL6, restoring the original value immediately after setting an invalid value always didn't
trigger a hang in time, so we just wait a moment for kernel to hang.

Thanks,
Xiao Yang

Quoted 19 lines
Quoted 19 lines
testcases/commands/sysctl/sysctl01.sh new file +11 -0
+	local curr_value=$(get_value $name)
+
+	if [ ${curr_value} -eq ${orig_value} ]; then
+		tst_res TPASS "Setting sched_time_avg(_ms) failed"
+	else
+		tst_res TFAIL "Setting sched_time_avg(_ms) succeeded"
+		sysctl -w $name=${orig_value}>/dev/null 2>&1
+	fi
+}
+
+tst_run
Signature · 7 lines
1.8.3.1




-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#5 lore raw

PATCH 1/1 commands/sysctl: Add new regression test for invalid sched_time_avg

Hi!

Quoted 4 lines
Quoted 1 line

What is this sleep good for? Do we wait here for the kernel to crash?

On my RHEL6, restoring the original value immediately after setting an invalid value always didn't
trigger a hang in time, so we just wait a moment for kernel to hang.

Shouldn't the kernel crash just by setting the avg_ms to 0 or do I misunderstand the kernel commit changelog?

Or is the offending code that crashes the kernel invoked asynchronously so that the value is picked up later by the scheduller? If so I would prefer removing the sleep anyways since the test will fail if we happen to be able to write 0 to the file anyways which is IMHO enough to inform the user about the present bug.

Other than that the test looks fine.

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

PATCH v3 1/1 commands/sysctl: Add new regression test for invalid sched_time_avg

The kernel bug has been fixed in kernel:
'5ccba44ba118("sched/sysctl: Check user input value of sysctl_sched_time_avg")'

---
 runtest/commands                      |  1 +
 testcases/commands/sysctl/Makefile    | 25 ++++++++++++++++
 testcases/commands/sysctl/sysctl01.sh | 55 +++++++++++++++++++++++++++++++++++
 3 files changed, 81 insertions(+)
 create mode 100644 testcases/commands/sysctl/Makefile
 create mode 100755 testcases/commands/sysctl/sysctl01.sh
runtest/commands +1 -0
index 92df3af..fde8063 100644
@@ -44,3 +44,4 @@ wc01 wc01.sh
 keyctl01 keyctl01.sh
 gdb01 gdb01.sh
 unshare01 unshare01.sh
+sysctl01 sysctl01.sh
testcases/commands/sysctl/Makefile new file +25 -0
new file mode 100644
index 0000000..61ff705
@@ -0,0 +1,25 @@
+#
+# Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
+# Author: Xiao Yang <[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/env_pre.mk
+
+INSTALL_TARGETS		:= *.sh
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/commands/sysctl/sysctl01.sh new file +55 -0

55 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#7 lore raw

PATCH v3 1/1 commands/sysctl: Add new regression test for invalid sched_time_avg

Hi!
Pushed, thanks.

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

PATCH 1/1 commands/sysctl: Add new regression test for invalid sched_time_avg

In reply to Cyril Hrubis
Quoted 5 lines · Cyril Hrubis

Hi!

Quoted 4 lines
Quoted 1 line

What is this sleep good for? Do we wait here for the kernel to crash?

On my RHEL6, restoring the original value immediately after setting an invalid value always didn't
trigger a hang in time, so we just wait a moment for kernel to hang.

Hi,

Quoted 2 lines

Shouldn't the kernel crash just by setting the avg_ms to 0 or do I misunderstand the kernel commit changelog?

Yes, if the value which is set to 0 is picked up by the scheduller, the kernel shouldn't crash.

Quoted 5 lines

Or is the offending code that crashes the kernel invoked asynchronously so that the value is picked up later by the scheduller? If so I would prefer removing the sleep anyways since the test will fail if we happen to be able to write 0 to the file anyways which is IMHO enough to inform the user about the present bug.

It seems reasonable, and i will remove the sleep.

Thanks,
Xiao Yang

Quoted 2 lines

Other than that the test looks fine.

author
#9 lore raw

PATCH v2 1/1 commands/sysctl: Add new regression test for invalid sched_time_avg

In reply to Cyril Hrubis

The kernel bug has been fixed in kernel:
'5ccba44ba118("sched/sysctl: Check user input value of sysctl_sched_time_avg")'

---
 runtest/commands                      |  1 +
 testcases/commands/sysctl/Makefile    | 25 +++++++++++++++
 testcases/commands/sysctl/sysctl01.sh | 58 +++++++++++++++++++++++++++++++++++
 3 files changed, 84 insertions(+)
 create mode 100644 testcases/commands/sysctl/Makefile
 create mode 100755 testcases/commands/sysctl/sysctl01.sh
runtest/commands +1 -0
index 92df3af..fde8063 100644
@@ -44,3 +44,4 @@ wc01 wc01.sh
 keyctl01 keyctl01.sh
 gdb01 gdb01.sh
 unshare01 unshare01.sh
+sysctl01 sysctl01.sh
testcases/commands/sysctl/Makefile new file +25 -0
new file mode 100644
index 0000000..61ff705
@@ -0,0 +1,25 @@
+#
+# Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
+# Author: Xiao Yang <[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/env_pre.mk
+
+INSTALL_TARGETS		:= *.sh
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/commands/sysctl/sysctl01.sh new file +58 -0

58 lines not on this page · raw message

Signature · 1 line
1.8.3.1
author
#10 lore raw

PATCH v2 1/1 commands/sysctl: Add new regression test for invalid sched_time_avg

Hi Cyril,

Could you help me review the v2 patch? :-)

Thanks,
Xiao Yang

Quoted 116 lines · Xiao Yang

The kernel bug has been fixed in kernel:
'5ccba44ba118("sched/sysctl: Check user input value of sysctl_sched_time_avg")'

---
 runtest/commands                      |  1 +
 testcases/commands/sysctl/Makefile    | 25 +++++++++++++++
 testcases/commands/sysctl/sysctl01.sh | 58 +++++++++++++++++++++++++++++++++++
 3 files changed, 84 insertions(+)
 create mode 100644 testcases/commands/sysctl/Makefile
 create mode 100755 testcases/commands/sysctl/sysctl01.sh
runtest/commands +1 -0
index 92df3af..fde8063 100644
@@ -44,3 +44,4 @@ wc01 wc01.sh
 keyctl01 keyctl01.sh
 gdb01 gdb01.sh
 unshare01 unshare01.sh
+sysctl01 sysctl01.sh
testcases/commands/sysctl/Makefile new file +25 -0
new file mode 100644
index 0000000..61ff705
@@ -0,0 +1,25 @@
+#
+# Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
+# Author: Xiao Yang <[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/env_pre.mk
+
+INSTALL_TARGETS		:= *.sh
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/commands/sysctl/sysctl01.sh new file +58 -0
new file mode 100755
index 0000000..6fa5a02
@@ -0,0 +1,58 @@
+#!/bin/sh
+
+# Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
+# Author: Xiao Yang <[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/>.
+#
+# Description:
+# This is a regression test for invalid value of sysctl_sched_time_avg.
+# System will hang if user set sysctl_sched_time_avg to 0 on buggy kernel.
+#
+# The kernel bug has been fixed in kernel:
+# '5ccba44ba118("sched/sysctl: Check user input value of sysctl_sched_time_avg")'
+
+TST_TESTFUNC=sysctl_test
+TST_NEEDS_ROOT=1
+TST_NEEDS_CMDS="sysctl"
+
+. tst_test.sh
+
+sysctl_test()
+{
+	# With commit d00535d, sched_time_avg was renamed as sched_time_avg_ms
+	local dir="/proc/sys/kernel/"
+	[ -e "$dir""sched_time_avg_ms" ] && local name="sched_time_avg_ms"
+	[ -e "$dir""sched_time_avg" ] && local name="sched_time_avg"
+	[ -z "$name" ] && tst_brk TCONF \
+		"sched_time_avg(_ms) was not supported"
+
+	local orig_value=$(cat "$dir""$name")
+
+	sysctl -w "kernel.""$name"=0 >/dev/null 2>&1
+
+	# Increase the chance of exposing the problem on RHEL6
+	sleep 3
+
+	local test_value=$(cat "$dir""$name")
+
+	if [ ${test_value} -eq ${orig_value} ]; then
+		tst_res TPASS "Setting $name failed"
+	else
+		tst_res TFAIL "Setting $name succeeded"
+		sysctl -w "kernel.""$name"=${orig_value} >/dev/null 2>&1
+	fi
+}
+
+tst_run