From patchwork Thu Mar 15 08:22:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Yang X-Patchwork-Id: 886146 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=2001:1418:10:5::2; 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 [IPv6:2001:1418:10:5::2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40220D6CsFz9sVY for ; Thu, 15 Mar 2018 19:32:44 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 992A73E6E42 for ; Thu, 15 Mar 2018 09:32:41 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [IPv6:2001:4b78:1:20::6]) by picard.linux.it (Postfix) with ESMTP id D62773E6E40 for ; Thu, 15 Mar 2018 09:32:39 +0100 (CET) Received: from heian.cn.fujitsu.com (mail.cn.fujitsu.com [183.91.158.132]) by in-6.smtp.seeweb.it (Postfix) with ESMTP id 9B7D514044B9 for ; Thu, 15 Mar 2018 09:32:29 +0100 (CET) X-IronPort-AV: E=Sophos;i="5.43,368,1503331200"; d="scan'208";a="37844419" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 15 Mar 2018 16:32:27 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (unknown [10.167.33.83]) by cn.fujitsu.com (Postfix) with ESMTP id C8BF04D0EFF7; Thu, 15 Mar 2018 16:32:25 +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; Thu, 15 Mar 2018 16:32:25 +0800 From: Xiao Yang To: Date: Thu, 15 Mar 2018 16:22:34 +0800 Message-ID: <1521102154-4307-1-git-send-email-yangx.jy@cn.fujitsu.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <20180314170148.GC27794@rei> References: <20180314170148.GC27794@rei> MIME-Version: 1.0 X-Originating-IP: [10.167.220.185] X-yoursite-MailScanner-ID: C8BF04D0EFF7.ABDC9 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-6.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-6.smtp.seeweb.it Cc: ltp@lists.linux.it Subject: [LTP] [PATCH v3] 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 | 55 +++++++++++++++++++++++++++++++++++ 3 files changed, 81 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..7522da5 --- /dev/null +++ b/testcases/commands/sysctl/sysctl01.sh @@ -0,0 +1,55 @@ +#!/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 + + 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