From patchwork Fri Jun 16 09:28:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Orson Zhai X-Patchwork-Id: 105700 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp1208494qgd; Fri, 16 Jun 2017 02:28:29 -0700 (PDT) X-Received: by 10.98.23.73 with SMTP id 70mr9789073pfx.76.1497605309261; Fri, 16 Jun 2017 02:28:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497605309; cv=none; d=google.com; s=arc-20160816; b=rBUu/RTcp/U+odgiWgBQgJdB72XLADAy7iYxgSaPF5DsDMUrMQQZybwkwkUvNVlaC6 6TUik9jXqERS7j0t/R6xTlcuvN27g5bMVGlHmhEcDmse6hDXRY5weTQZu/1zfBLJMW/b jei6/SvPihhmX647VFsX/TVGeAL2+ZqfJhpcSlbGRvos9S8lkQ2ADoe3tVD0nxejbqRy L0GhIdVhzl0jlXLgaxBv6N3si0Nr77LAqzn7DO2fwt9qZM6im5qKdQPN75L2L+09jtgn OiriDh7A5mxwz3wT+P/yvqwwB/wBRactWVmVpXXkZ4zWev2N28sJkqQqwkeJp6qb9h4x NZJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=etSi43vKkRyfkeT3ExUn8h9jYVHW/YysYy8Y82Knnho=; b=HZSydo7SqoFcYgm3DEbq4k7DU6A3n/TZoX2bDUc359r0rXaqTqif7YuAjDa22TBtuk Q0pFX6ku56bJnyZx624FmMkrJF7/Ebv8g6jAV/cqJY0SqgIsk4BpCeYGg9Shwh0b8EaT G/4YHPf4Gf7f48p1CgCAdVya7WU3LkJKWTmFsN4ny5PsubQbEk20G15upKSpFdsNxPKH eWPFjJUbImRm/+TQ4ohBvsGatugVHC212HWc5oNFQLL8L/RUXohdb9PDTmJv/P4JqGkv pKnMYrUdg7u2B/xTDzkiJ7aitwuKHLlDyALHwPviYaV5r7azuX6n2/7vN9+l4W0f9DVV 5EdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=bHgHI32P; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 33si1463740ply.290.2017.06.16.02.28.28; Fri, 16 Jun 2017 02:28:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.b=bHgHI32P; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753286AbdFPJ2V (ORCPT + 25 others); Fri, 16 Jun 2017 05:28:21 -0400 Received: from mail-ot0-f170.google.com ([74.125.82.170]:33633 "EHLO mail-ot0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753011AbdFPJ2T (ORCPT ); Fri, 16 Jun 2017 05:28:19 -0400 Received: by mail-ot0-f170.google.com with SMTP id y47so4192349oty.0 for ; Fri, 16 Jun 2017 02:28:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=etSi43vKkRyfkeT3ExUn8h9jYVHW/YysYy8Y82Knnho=; b=bHgHI32PdE2AMm/TkvOGvELl32iw3N8gQvNZ/zqTzvgzPTG/ZHM3zdb6aNfRZcwWcU ay40jqXktwouWUAXp9ec8uEcZ5g685xnLL9VxtLmkeH9oMIaX+sEEnlfH4x2qCZ4eUrY ZyGXXVzevaEndO7xHKytdlBvy6/aWpP+Rclh4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=etSi43vKkRyfkeT3ExUn8h9jYVHW/YysYy8Y82Knnho=; b=QSweL0ZYa0bt1OYp8jn4sAuP3jgPE08pGccZq8nPwvGF4mFLQAEvyiLytwkHoB3Mlz HwLtAapy0M7QM41V3JRw9OEML3NsjR2OTFpzBc81GEiHIJfHKhyczP/yqTrv4ITRfRaH sszzc3wDkB6pAj5FkCqgsTmkJahzkbD2mUMOUATAlgc8Ry+zD1XVnf3Lpsxz4ogqql96 sWK6eh1unO+7NjyC6naYn3cfCUg+V7zyxtEsiMqHTLBM7caeC+bwO1DghjUn3Acwj+Bb UAusiHIbVyHk9LHK6E0J+SeoU7EcaxcS66JJtd5KiopCH8286QUUsp9fLgofooLUSvCu 0qDw== X-Gm-Message-State: AKS2vOyarbS65jUH2NwGfwgPvTnL1lkJNbsVvPh6h8KVtUjWNUKrZIjT tvr/zuV78jjiFgWjTiS/AOJtht4f8L4Y X-Received: by 10.157.58.66 with SMTP id j60mr5932330otc.86.1497605299172; Fri, 16 Jun 2017 02:28:19 -0700 (PDT) MIME-Version: 1.0 Received: by 10.182.144.104 with HTTP; Fri, 16 Jun 2017 02:28:18 -0700 (PDT) In-Reply-To: <20170616042255.22653-1-orson.zhai@spreadtrum.com> References: <20170616042255.22653-1-orson.zhai@spreadtrum.com> From: Orson Zhai Date: Fri, 16 Jun 2017 17:28:18 +0800 Message-ID: Subject: Fwd: [PATCH] tools/testing/selftests/sysctl: Add pre-check to the value of writes_strict To: Shuah@kernel.org Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Sumit Semwal , keescook@chromium.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sysctl test will fail in some items if the value of /proc/sys/kernel /sysctrl_writes_strict is 0 as the default value in kernel older than v4.5. Make this test more robust and compatible with older kernels by checking and update sysctrl_writes_strict value and restore it when test is done. Signed-off-by: Orson Zhai --- tools/testing/selftests/sysctl/common_tests | 14 ++++++++++++++ tools/testing/selftests/sysctl/run_numerictests | 3 +++ tools/testing/selftests/sysctl/run_stringtests | 3 +++ 3 files changed, 20 insertions(+) -- 2.12.2 Reviewed-by: Sumit Semwal Tested-by: Sumit Semwal diff --git a/tools/testing/selftests/sysctl/common_tests b/tools/testing/selftests/sysctl/common_tests index 17d534b1b7b4..f5c5c51d16f3 100644 --- a/tools/testing/selftests/sysctl/common_tests +++ b/tools/testing/selftests/sysctl/common_tests @@ -63,6 +63,20 @@ else echo "ok" fi +echo -n "Checking writes strict setting ... " +WRITES_STRICT="${SYSCTL}/kernel/sysctl_writes_strict" +if [ ! -e ${WRITES_STRICT} ]; then + echo "FAIL, but skip in case of old kernel" >&2 +else + val=$(cat ${WRITES_STRICT}) + if [ "$val" = "1" ]; then + echo "ok" + else + echo "FAIL, strict value is 0 but force to 1 to continue" >&2 + echo "1" > ${WRITES_STRICT} + fi +fi + # Now that we've validated the sanity of "set_test" and "set_orig", # we can use those functions to set starting states before running # specific behavioral tests. diff --git a/tools/testing/selftests/sysctl/run_numerictests b/tools/testing/selftests/sysctl/run_numerictests index 8510f93f2d14..c0a98fd82c5c 100755 --- a/tools/testing/selftests/sysctl/run_numerictests +++ b/tools/testing/selftests/sysctl/run_numerictests @@ -7,4 +7,7 @@ TEST_STR=$(( $ORIG + 1 )) . ./common_tests +if [ ! -z ${val} ]; then + echo ${val} > ${WRITES_STRICT} +fi exit $rc diff --git a/tools/testing/selftests/sysctl/run_stringtests b/tools/testing/selftests/sysctl/run_stringtests index 90a9293d520c..ae98d66a9ec6 100755 --- a/tools/testing/selftests/sysctl/run_stringtests +++ b/tools/testing/selftests/sysctl/run_stringtests @@ -74,4 +74,7 @@ else echo "ok" fi +if [ ! -z ${val} ]; then + echo ${val} > ${WRITES_STRICT} +fi exit $rc