Return-Path: Received: from mx1.redhat.com ([209.132.183.28]:43442 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932672AbbDJNCi (ORCPT ); Fri, 10 Apr 2015 09:02:38 -0400 From: =?UTF-8?q?Jan=20=C5=A4ul=C3=A1k?= Subject: [PATCH 6/7] fstests: environments - add envs to the skeleton in ./new script and README Date: Fri, 10 Apr 2015 15:02:28 +0200 Message-Id: <1428670949-17524-7-git-send-email-jtulak@redhat.com> In-Reply-To: <1428670949-17524-1-git-send-email-jtulak@redhat.com> References: <1428670949-17524-1-git-send-email-jtulak@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: fstests-owner@vger.kernel.org To: fstests@vger.kernel.org Cc: david@fromorbit.com List-ID: New section in README file to shortly describe the environments. Adds support for environments into the skeleton generated by the ./new script, so new tests can easily opt-in into using the environments. Signed-off-by: Jan Ťulák --- README | 12 +++++++++++- new | 37 +++++++++++++++++++++++++++++++++++-- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/README b/README index f8a878c..6d4f8d7 100644 --- a/README +++ b/README @@ -194,7 +194,17 @@ Test script environment: and the content of the NIS database if it is likely to be present) - 5. General recommendations, usage conventions, etc.: + 5. For setting up files and state of the filesystem before a test, + you can use environments. These scripts allows both sharing of the + set-up between tests, and running a single test in different + conditions (like empty and full filesystem). + In new tests, you can simply add them to a list at the beginning + of the test script (see "environments" directory for all available + environments). The skeleton created by ./new script already contains + everything necessary. + + + 6. General recommendations, usage conventions, etc.: - When the content of the password or group file is required, get it using the _cat_passwd and _cat_group functions, to ensure NIS information is included if NIS diff --git a/new b/new index c734bdc..a6eb113 100755 --- a/new +++ b/new @@ -181,6 +181,18 @@ cat <$tdir/$id #----------------------------------------------------------------------- # +# List of environments this test can use for preparing files for the testing. +# They are independent of each other (multiple entries = multiple runs). +# If "none" is given, the test can be run without any environment, +# ommiting it signifies that the test won't run without any of them. +# +# Example: supported_environments="none empty_files full_partition" +# +# If you want to combine multiple environments at once, you have to +# call them yourself: _environment_require PATH ENVIRONMENT_NAME + +supported_environments="none" + seq=\`basename \$0\` seqres=\$RESULT_DIR/\$seq echo "QA output created by \$seq" @@ -207,8 +219,29 @@ _supported_fs generic _supported_os IRIX Linux _require_test -# if error -exit +run_test(){ + # If you don't set any environment at the beginning, + # this will do nothing. + _environment_require \$TEST_DIR + + # PUT TEST BELOW + + # if error + exit + + # PUT TEST ABOVE + _environment_clean \$TEST_DIR +} + + +# Filter the supported_environments by user input (-eo/-ex arguments) +# and run the test for all environments in the intersect of +# the supported and user-allowed environments. +for environment in \$(_filter_environments "\$supported_environments") +do + export ENV_NAME="\$environment" + run_test +done # optional stuff if your test has verbose output to help resolve problems #echo -- 2.1.0