From patchwork Wed Mar 7 04:35:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Yang X-Patchwork-Id: 882398 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=cn.fujitsu.com Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zx1Ld0sCJz9sYR for ; Wed, 7 Mar 2018 15:46:17 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 888CF3E6B9F for ; Wed, 7 Mar 2018 05:46:14 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [217.194.8.3]) by picard.linux.it (Postfix) with ESMTP id CC35A3E6B47 for ; Wed, 7 Mar 2018 05:46:12 +0100 (CET) Received: from heian.cn.fujitsu.com (mail.cn.fujitsu.com [183.91.158.132]) by in-3.smtp.seeweb.it (Postfix) with ESMTP id 4D09B1A014EB for ; Wed, 7 Mar 2018 05:46:09 +0100 (CET) X-IronPort-AV: E=Sophos;i="5.43,368,1503331200"; d="scan'208";a="37562782" Received: from bogon (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 07 Mar 2018 12:46:03 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (unknown [10.167.33.83]) by cn.fujitsu.com (Postfix) with ESMTP id 3CFEF48AE762; Wed, 7 Mar 2018 12:46:03 +0800 (CST) Received: from RHEL7U5Alpha_SERVER.g08.fujitsu.local (10.167.220.185) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 7 Mar 2018 12:46:00 +0800 From: Xiao Yang To: Date: Wed, 7 Mar 2018 12:35:50 +0800 Message-ID: <1520397350-28216-1-git-send-email-yangx.jy@cn.fujitsu.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <20180306124242.GC16934@rei.lan> References: <20180306124242.GC16934@rei.lan> MIME-Version: 1.0 X-Originating-IP: [10.167.220.185] X-yoursite-MailScanner-ID: 3CFEF48AE762.ABFD3 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: yangx.jy@cn.fujitsu.com X-Spam-Status: No, score=-0.0 required=7.0 tests=T_RP_MATCHES_RCVD autolearn=disabled version=3.4.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-3.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-3.smtp.seeweb.it Cc: ltp@lists.linux.it Subject: [LTP] [PATCH v2] commands/sysctl: Add new regression test for invalid sched_time_avg X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" The kernel bug has been fixed in kernel: '5ccba44ba118("sched/sysctl: Check user input value of sysctl_sched_time_avg")' Signed-off-by: Xiao Yang --- 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 diff --git a/runtest/commands b/runtest/commands index 92df3af..fde8063 100644 --- a/runtest/commands +++ b/runtest/commands @@ -44,3 +44,4 @@ wc01 wc01.sh keyctl01 keyctl01.sh gdb01 gdb01.sh unshare01 unshare01.sh +sysctl01 sysctl01.sh diff --git a/testcases/commands/sysctl/Makefile b/testcases/commands/sysctl/Makefile new file mode 100644 index 0000000..61ff705 --- /dev/null +++ b/testcases/commands/sysctl/Makefile @@ -0,0 +1,25 @@ +# +# Copyright (c) 2018 FUJITSU LIMITED. All rights reserved. +# Author: Xiao Yang +# +# 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 . +# + +top_srcdir ?= ../../.. + +include $(top_srcdir)/include/mk/env_pre.mk + +INSTALL_TARGETS := *.sh + +include $(top_srcdir)/include/mk/generic_leaf_target.mk diff --git a/testcases/commands/sysctl/sysctl01.sh b/testcases/commands/sysctl/sysctl01.sh new file mode 100755 index 0000000..6fa5a02 --- /dev/null +++ b/testcases/commands/sysctl/sysctl01.sh @@ -0,0 +1,58 @@ +#!/bin/sh + +# Copyright (c) 2018 FUJITSU LIMITED. All rights reserved. +# Author: Xiao Yang +# +# 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 . +# +# 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