From patchwork Wed Oct 28 00:42:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olof Johansson X-Patchwork-Id: 7505811 Return-Path: X-Original-To: patchwork-linux-kbuild@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 501F19F36A for ; Wed, 28 Oct 2015 00:44:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5193920898 for ; Wed, 28 Oct 2015 00:44:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EF582209B9 for ; Wed, 28 Oct 2015 00:44:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754840AbbJ1Aoi (ORCPT ); Tue, 27 Oct 2015 20:44:38 -0400 Received: from mail-pa0-f47.google.com ([209.85.220.47]:36245 "EHLO mail-pa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754973AbbJ1Amw (ORCPT ); Tue, 27 Oct 2015 20:42:52 -0400 Received: by pacfv9 with SMTP id fv9so248529188pac.3 for ; Tue, 27 Oct 2015 17:42:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lixom_net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XkIC4u11T9denegS8LI+C37DCE9PZ2A3fi/lrlcWPcE=; b=2NgWQUaXYKk4hdWEVsTIwyottpAYWimCAs+GOI3ullz8K+Z1iI4mU3UkNZKy2TwKLT VIZ9HxcxqOQ6gzZXpsh8nCuzPwI+AvCfdSE9IRmS93FeUtRVWL2DOo1xxjWxXFR7ZV8x N5+0jM4QyRwoIhyiUXmOzSX0RkNfVH9GqOp5nhZQjrNZvQTOFMjKmNnxf1ddXNuGdQP/ 0LTDwT7y1pI6D4Oh8Qyy0B5QTNa6/ow1X2KghH2bl0wPsWHRueVxZ+KY9NUUGKoczgWF LeOR65V38GekkzPp08GZxcO4mGxRJ1ajZBnO3MMfGztqEAYJ2uHXBm4b5SQajJ5SO/aR b16g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=XkIC4u11T9denegS8LI+C37DCE9PZ2A3fi/lrlcWPcE=; b=QAegAHe1PKtqwj5OJmW9t/0ovRXYjMUSuZDRHnUemV5M/CHuIofN+ahJOhgWkcE/Dd uI7RddtbR5AmAnxdvEfCtcFwgiIBdLSM9NH+aPtDkzWiEzrONDuZgp/o51wJzMhgLaTq fqiBDfXgiWmQDGyifXJAd3PrJa++ZFuU8dOLi9YT8mIw0d4eB3wC5WVpXF5oSfNbj43P XeV68HtKVMj5LH1fxyETis/X9NcLJ4T3JLs3uIA8DW7K2hav2w6/6Xmsj3hxNyHmXZ7n geAk9iYe7HxWqFCRBANIoEtSYBn2UcWCS20tLkuOtCinegj36ZWlntiHdafDIr8EFrtw EdrA== X-Gm-Message-State: ALoCoQk88tr5wm5e240alzrqEjjCLKA/da40rjBIDot1Jvj2F69xAWnZsPg5lKbmRnLUnt2XFc5B X-Received: by 10.68.136.69 with SMTP id py5mr31672046pbb.94.1445992971627; Tue, 27 Oct 2015 17:42:51 -0700 (PDT) Received: from localhost.localdomain ([58.123.138.250]) by smtp.gmail.com with ESMTPSA id t9sm41801385pbs.17.2015.10.27.17.42.49 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Oct 2015 17:42:50 -0700 (PDT) From: Olof Johansson To: Michal Marek Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, dvhart@linux.intel.com, Olof Johansson Subject: [PATCH 07/10] merge_config.sh: add tests Date: Wed, 28 Oct 2015 09:42:08 +0900 Message-Id: <1445992931-28107-8-git-send-email-olof@lixom.net> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1445992931-28107-1-git-send-email-olof@lixom.net> References: <1445992931-28107-1-git-send-email-olof@lixom.net> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP For being a small script, merge_config.sh is fairly scary to change since there's no real way to know if you did something wrong. So it seems appropriate to add a simple test suite. I've started with testcases in the areas I care about, other should of course feel free to expand on this. Use is simple, from the kernel tree, run ./scripts/kconfig/merge_config_test/runall. It'll execute out of a tmpdir under /tmp. Signed-off-by: Olof Johansson Reviewed-by: Darren Hart --- .../kconfig/merge_config_test/01-no-fragment.sh | 12 +++++++++++ .../kconfig/merge_config_test/02-already-set.sh | 19 ++++++++++++++++++ .../merge_config_test/03-turnoff-failure.sh | 19 ++++++++++++++++++ .../merge_config_test/04-turnoff-failure2.sh | 19 ++++++++++++++++++ .../merge_config_test/05-turnoff-success.sh | 19 ++++++++++++++++++ .../merge_config_test/06-turnoff-success2.sh | 19 ++++++++++++++++++ .../kconfig/merge_config_test/07-turnon-success.sh | 19 ++++++++++++++++++ .../merge_config_test/08-tristate-success.sh | 20 +++++++++++++++++++ .../merge_config_test/09-tristate-failure.sh | 20 +++++++++++++++++++ .../merge_config_test/10-turnon-redundant.sh | 19 ++++++++++++++++++ .../merge_config_test/11-turnon-redundant-err.sh | 19 ++++++++++++++++++ scripts/kconfig/merge_config_test/common.sh | 23 ++++++++++++++++++++++ scripts/kconfig/merge_config_test/runall.sh | 22 +++++++++++++++++++++ 13 files changed, 249 insertions(+) create mode 100755 scripts/kconfig/merge_config_test/01-no-fragment.sh create mode 100755 scripts/kconfig/merge_config_test/02-already-set.sh create mode 100755 scripts/kconfig/merge_config_test/03-turnoff-failure.sh create mode 100755 scripts/kconfig/merge_config_test/04-turnoff-failure2.sh create mode 100755 scripts/kconfig/merge_config_test/05-turnoff-success.sh create mode 100755 scripts/kconfig/merge_config_test/06-turnoff-success2.sh create mode 100755 scripts/kconfig/merge_config_test/07-turnon-success.sh create mode 100755 scripts/kconfig/merge_config_test/08-tristate-success.sh create mode 100755 scripts/kconfig/merge_config_test/09-tristate-failure.sh create mode 100755 scripts/kconfig/merge_config_test/10-turnon-redundant.sh create mode 100755 scripts/kconfig/merge_config_test/11-turnon-redundant-err.sh create mode 100755 scripts/kconfig/merge_config_test/common.sh create mode 100755 scripts/kconfig/merge_config_test/runall.sh diff --git a/scripts/kconfig/merge_config_test/01-no-fragment.sh b/scripts/kconfig/merge_config_test/01-no-fragment.sh new file mode 100755 index 0000000..c892f9b --- /dev/null +++ b/scripts/kconfig/merge_config_test/01-no-fragment.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +. "$(dirname $0)/common.sh" + +# Simple merge: No fragment specified, just base config + +FRAG=$(echo "" | writefrag) + +merge ${FRAG} +M=$? + +[ $M -eq 0 ] diff --git a/scripts/kconfig/merge_config_test/02-already-set.sh b/scripts/kconfig/merge_config_test/02-already-set.sh new file mode 100755 index 0000000..1d71030 --- /dev/null +++ b/scripts/kconfig/merge_config_test/02-already-set.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +. "$(dirname $0)/common.sh" + +# Turn on an option that is already on + +FRAG=$(writefrag) << EOF +CONFIG_MMU=y +EOF + +merge "${FRAG}" +M=$? + +# Return pass if MMU is still set in output + +check CONFIG_MMU=y +G=$? + +[ $M -eq 0 -a $G -eq 0 ] diff --git a/scripts/kconfig/merge_config_test/03-turnoff-failure.sh b/scripts/kconfig/merge_config_test/03-turnoff-failure.sh new file mode 100755 index 0000000..aa9bf63 --- /dev/null +++ b/scripts/kconfig/merge_config_test/03-turnoff-failure.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +. "$(dirname $0)/common.sh" + +# Try to turn off a function that won't turn off. + +FRAG=$(writefrag) << EOF +# CONFIG_MMU is not set +EOF + +merge ${FRAG} +M=$? + +# Return pass if MMU is still set in output + +check CONFIG_MMU=y +G=$? + +[ $M -ne 0 -a $G -eq 0 ] diff --git a/scripts/kconfig/merge_config_test/04-turnoff-failure2.sh b/scripts/kconfig/merge_config_test/04-turnoff-failure2.sh new file mode 100755 index 0000000..cebcdbc --- /dev/null +++ b/scripts/kconfig/merge_config_test/04-turnoff-failure2.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +. "$(dirname $0)/common.sh" + +# Try to turn off a function that won't turn off. + +FRAG=$(writefrag) << EOF +CONFIG_MMU=n +EOF + +merge "${FRAG}" +M=$? + +# Return pass if MMU is still set in output + +check CONFIG_MMU=y +G=$? + +[ $M -ne 0 -a $G -eq 0 ] diff --git a/scripts/kconfig/merge_config_test/05-turnoff-success.sh b/scripts/kconfig/merge_config_test/05-turnoff-success.sh new file mode 100755 index 0000000..7a8822e --- /dev/null +++ b/scripts/kconfig/merge_config_test/05-turnoff-success.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +. "$(dirname $0)/common.sh" + +# Try to turn off a function that will turn off. + +FRAG=$(writefrag) << EOF +# CONFIG_64BIT is not set +EOF + +merge "${FRAG}" +M=$? + +# Return fail if 64BIT is still set in output + +check CONFIG_64BIT=y +G=$? + +[ $M -eq 0 -a $G -ne 0 ] diff --git a/scripts/kconfig/merge_config_test/06-turnoff-success2.sh b/scripts/kconfig/merge_config_test/06-turnoff-success2.sh new file mode 100755 index 0000000..d5e7cc5 --- /dev/null +++ b/scripts/kconfig/merge_config_test/06-turnoff-success2.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +. "$(dirname $0)/common.sh" + +# Try to turn off a function that will turn off. + +FRAG=$(writefrag) << EOF +CONFIG_64BIT=n +EOF + +merge "${FRAG}" +M=$? + +# Return fail if 64BIT is still set in output + +check CONFIG_64BIT=y +G=$? + +[ $M -eq 0 -a $G -ne 0 ] diff --git a/scripts/kconfig/merge_config_test/07-turnon-success.sh b/scripts/kconfig/merge_config_test/07-turnon-success.sh new file mode 100755 index 0000000..eb24ba0 --- /dev/null +++ b/scripts/kconfig/merge_config_test/07-turnon-success.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +. "$(dirname $0)/common.sh" + +# Try to turn on a function that will turn on. + +FRAG=$(writefrag) << EOF +CONFIG_EMBEDDED=y +EOF + +merge "${FRAG}" +M=$? + +# Return fail if EMBEDDED is not set in output + +check CONFIG_EMBEDDED=y +G=$? + +[ $M -eq 0 -a $G -eq 0 ] diff --git a/scripts/kconfig/merge_config_test/08-tristate-success.sh b/scripts/kconfig/merge_config_test/08-tristate-success.sh new file mode 100755 index 0000000..3c454b8 --- /dev/null +++ b/scripts/kconfig/merge_config_test/08-tristate-success.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +. "$(dirname $0)/common.sh" + +# Try to turn on a tristate that is allowed + +FRAG=$(writefrag) << EOF +CONFIG_MODULES=y +CONFIG_PCI_STUB=m +EOF + +merge "${FRAG}" +M=$? + +# Return fail if PCI_STUB=m is not set in output + +check CONFIG_PCI_STUB=m +G=$? + +[ $M -eq 0 -a $G -eq 0 ] diff --git a/scripts/kconfig/merge_config_test/09-tristate-failure.sh b/scripts/kconfig/merge_config_test/09-tristate-failure.sh new file mode 100755 index 0000000..7f586ea --- /dev/null +++ b/scripts/kconfig/merge_config_test/09-tristate-failure.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +. "$(dirname $0)/common.sh" + +# Try to turn on a tristate that failes + +FRAG=$(writefrag) << EOF +CONFIG_MODULES=n +CONFIG_PCI_STUB=m +EOF + +merge "${FRAG}" +M=$? + +# Return fail if PCI_STUB=m is set in output + +check CONFIG_PCI_STUB=m +G=$? + +[ $M -ne 0 -a $G -ne 0 ] diff --git a/scripts/kconfig/merge_config_test/10-turnon-redundant.sh b/scripts/kconfig/merge_config_test/10-turnon-redundant.sh new file mode 100755 index 0000000..65d9ea7 --- /dev/null +++ b/scripts/kconfig/merge_config_test/10-turnon-redundant.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +. "$(dirname $0)/common.sh" + +# Turn on something that's already on, should not warn + +FRAG=$(writefrag) << EOF +CONFIG_64BIT=y +EOF + +merge "${FRAG}" +M=$? + +# Return fail if 64BIT=y is not set in output + +check CONFIG_64BIT=y +G=$? + +[ $M -eq 0 -a $G -eq 0 ] diff --git a/scripts/kconfig/merge_config_test/11-turnon-redundant-err.sh b/scripts/kconfig/merge_config_test/11-turnon-redundant-err.sh new file mode 100755 index 0000000..24c1d9b --- /dev/null +++ b/scripts/kconfig/merge_config_test/11-turnon-redundant-err.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +. "$(dirname $0)/common.sh" + +# Turn on something that's already on, watch it warn/fail + +FRAG=$(writefrag) << EOF +CONFIG_64BIT=y +EOF + +merge_r "${FRAG}" "${FRAG}" +M=$? + +# Return fail if 64BIT=y is not set in output + +check CONFIG_64BIT=y +G=$? + +[ $M -ne 0 -a $G -eq 0 ] diff --git a/scripts/kconfig/merge_config_test/common.sh b/scripts/kconfig/merge_config_test/common.sh new file mode 100755 index 0000000..710c429 --- /dev/null +++ b/scripts/kconfig/merge_config_test/common.sh @@ -0,0 +1,23 @@ +TMPDIR=$(mktemp -d /tmp/mergetest.XXXXX) +SCRIPT="$(dirname $0)/../merge_config.sh" + +writefrag() { + FRAG=$(mktemp ${TMPDIR}/frag.XXXX) + cat > "${FRAG}" + echo $FRAG +} + +merge() { + "${SCRIPT}" -e -O "${TMPDIR}" /dev/null $* + return $? +} + +merge_r() { + "${SCRIPT}" -e -r -O "${TMPDIR}" /dev/null $* + return $? +} + +check() { + grep -q "$1" "${TMPDIR}/.config" + return $? +} diff --git a/scripts/kconfig/merge_config_test/runall.sh b/scripts/kconfig/merge_config_test/runall.sh new file mode 100755 index 0000000..3c73d70 --- /dev/null +++ b/scripts/kconfig/merge_config_test/runall.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +EXITVAL=0 +TMPDIR=$(mktemp -d /tmp/mergetest.XXXXX) || exit 1 +ARCH=x86 + +cleanup() { + rm -rf "${TMPDIR}" + exit $EXITVAL +} + +trap cleanup EXIT + +for test in $(dirname $0)/*-*.sh ; do + echo -n "test $(basename ${test}): " + if ${test} >/dev/null 2>&1 ; then + echo PASSED + else + echo FAILED + EXITVAL=1 + fi +done