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 <[email protected]>
---
 README | 12 +++++++++++-
 new    | 34 ++++++++++++++++++++++++++++++++--
 2 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/README b/README
index 0c9449a..2e14b6c 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 86f9075..62a051b 100755
--- a/new
+++ b/new
@@ -137,6 +137,15 @@ cat <<End-of-File >$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"
+
+supported_environments="none"
+
 seq=\`basename \$0\`
 seqres=\$RESULT_DIR/\$seq
 echo "QA output created by \$seq"
@@ -163,8 +172,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

--
To unsubscribe from this list: send the line "unsubscribe fstests" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to