From patchwork Fri Nov 14 13:27:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jan Tulak X-Patchwork-Id: 5305961 Return-Path: X-Original-To: patchwork-fstests@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 460F29F818 for ; Fri, 14 Nov 2014 13:29:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4CF692013D for ; Fri, 14 Nov 2014 13:29:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5657E20148 for ; Fri, 14 Nov 2014 13:29:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965230AbaKNN3P (ORCPT ); Fri, 14 Nov 2014 08:29:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45809 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965207AbaKNN3O (ORCPT ); Fri, 14 Nov 2014 08:29:14 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sAEDTD8v016809 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 14 Nov 2014 08:29:13 -0500 Received: from jtulak.redhat.com (ovpn-112-57.ams2.redhat.com [10.36.112.57]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sAEDT1KO016807; Fri, 14 Nov 2014 08:29:12 -0500 From: =?UTF-8?q?Jan=20=C5=A4ul=C3=A1k?= To: fstests@vger.kernel.org Cc: =?UTF-8?q?Jan=20=C5=A4ul=C3=A1k?= , lczerner@redhat.com, david@fromorbit.com Subject: [PATCH 6/7] Integrates environment functionality into existing code Date: Fri, 14 Nov 2014 14:27:46 +0100 Message-Id: <1415971667-16873-6-git-send-email-jtulak@redhat.com> In-Reply-To: <1415971667-16873-1-git-send-email-jtulak@redhat.com> References: <1415971667-16873-1-git-send-email-jtulak@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 This patch: 1) adds new arguments to --help and to the parser: -e use testing environments -eo environment[,environment...] test only in these environments -ex environment[,environment...] exclude these environments 2) Adds call of sort_tests_by_environment() when -e is supplied. Currently, randomization of tests order and environments are mutually exclusive. I plan to add this later. 3) It slightly changes the main loop where tests are run. The change is done because the tests and environments are paired in two variables and it needs to access both of them. Here the required environment name is exported and then when the test requires an environment, the exported variable is used to determine the current one. Signed-off-by: Jan ?ulák --- check | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/check b/check index 777c7a2..ca5082b 100755 --- a/check +++ b/check @@ -34,6 +34,7 @@ diff="diff -u" showme=false have_test_arg=false randomize=false +environments_used=false export here=`pwd` xfile="" @@ -76,12 +77,15 @@ check options -n show me, do not run tests -T output timestamps -r randomize test order + -e use testing environments --large-fs optimise scratch device for large filesystems -s section run only specified section from config file testlist options -g group[,group...] include tests from these groups -x group[,group...] exclude tests from these groups + -eo environment[,environment...] test only in these environments + -ex environment[,environment...] exclude these environments -X file exclude individual tests -E external_file exclude individual tests [testlist] include tests matching names in testlist @@ -283,7 +287,7 @@ get_all_tests() for d in $SRC_GROUPS $FSTYP; do ls $SRC_DIR/$d/* | \ grep -v "\..*" | \ - grep -v "group\|Makefile" >> $tmp.list 2>/dev/null + grep -v "group\|Makefile\|environment" >> $tmp.list 2>/dev/null done } @@ -325,6 +329,7 @@ _timestamp() _prepare_test_list() { unset list + unset list_env # Tests specified on the command line if [ -s $tmp.arglist ]; then cat $tmp.arglist > $tmp.list @@ -366,6 +371,15 @@ _prepare_test_list() list=`sort -n $tmp.list | uniq` rm -f $tmp.list $tmp.tmp $tmp.grep + if $environments_used + then + sort_tests_by_environment $list + list=$(cat $tmp.list) + list_env=$(cat $tmp.list_env) + rm -f $tmp.list $tmp.list_env + # TODO add randomizing also for environments + fi + if $randomize then list=`echo $list | awk -f randomize.awk` @@ -389,6 +403,16 @@ while [ $# -gt 0 ]; do XGROUP_LIST="$XGROUP_LIST $xgroup" ;; + -e) environments_used=true ;; + + -eo) environment=$2 ; shift ; + ENVIRONMENT_LIST="$ENVIRONMENT_LIST $environment" + ;; + + -ex) xenvironment=$2 ; shift ; + XENVIRONMENT_LIST="$XENVIRONMENT_LIST $xenvironment" + ;; + -X) xfile=$2; shift ; for d in $SRC_GROUPS $FSTYP; do [ -f $SRC_DIR/$d/$xfile ] || continue @@ -429,6 +453,13 @@ while [ $# -gt 0 ]; do shift done +# Test we don't have test randomizing and environment testing at the same time +if [ $environments_used = true -a $randomize = true ];then + >&2 echo "Environments can't be used at the same time"\ + " as randomized test order!" + exit 1 +fi + # Process tests from command line now. if $have_test_arg; then while [ $# -gt 0 ]; do @@ -665,8 +696,20 @@ for section in $HOST_OPTIONS_SECTIONS; do seqres="$check" _check_test_fs - for seq in $list + read -a list_a <<< $list + read -a list_env_a <<< $list_env + for i in "${!list_a[@]}" do + seq="${list_a[$i]}" + export env_last="$env" + export env="${list_env_a[$i]}" + export env_next="${list_env_a[$(($i+1))]}" + export env_force=false + if [ "${env:0:1}" = "_" ];then + env_force=true + env="${env#?}" + fi + err=false # the filename for the test and the name output are different. @@ -688,6 +731,12 @@ for section in $HOST_OPTIONS_SECTIONS; do echo -n "$seqnum" + # If an environment is requested, print it. + # When not requested, output is not changed. + if [ "$env" != "" ];then + echo -n " [$env]" + fi + if $showme then echo