From: "Jan Ťulák" <jtulak@redhat.com>
To: fstests@vger.kernel.org
Cc: "Jan Ťulák" <jtulak@redhat.com>,
lczerner@redhat.com, david@fromorbit.com
Subject: [PATCH 7/7] Adds functions for tests to call environment setup/cleaning
Date: Fri, 14 Nov 2014 14:27:47 +0100 [thread overview]
Message-ID: <1415971667-16873-7-git-send-email-jtulak@redhat.com> (raw)
In-Reply-To: <1415971667-16873-1-git-send-email-jtulak@redhat.com>
This patch adds two functions into common/rc. These two functions are
called by tests to setup and clean environment. They have a single
argument - a target directory. So everything required in a test to
support environments is to call _require_environment $target after
requireing test or scratch dir, and then call the clean function at
the end.
Specific environment name is taken from variables exported by check
script.
Calling of the cleaning function is not critical as before setup,
cleaning is called automatically.
Signed-off-by: Jan Ťulák <jtulak@redhat.com>
---
common/rc | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/common/rc b/common/rc
index d5e3aff..14dbb1f 100644
--- a/common/rc
+++ b/common/rc
@@ -1037,6 +1037,55 @@ _supported_os()
_notrun "not suitable for this OS: $HOSTOS"
}
+_require_environment()
+{
+ target="$1"
+ if [ "$target" = "" ];then
+ 1>&2 echo "Target directory for environment can't be empty! Aborting."
+ exit 1
+ fi
+
+ if [ "$env" != "" -a "$env" != "none" ];then
+ prepare_method="prepare-once"
+ if $env_force;then
+ prepare_method="prepare-always"
+ fi
+ bash ./environments/$env $prepare_method $target
+ sts=$?
+ if [ "$sts" != 0 ]; then
+ echo " [skipped]"
+ 1>&2 echo "Failed to prepare environment $env "\
+ " (will skip the test)!"
+ 1>&2 echo ""
+ exit 1
+ fi
+ fi
+}
+
+
+
+_environment_clean()
+{
+ target="$1"
+ if [ "$target" = "" ];then
+ 1>&2 echo "Target directory for environment cleaning can't be empty!"\
+ " Aborting."
+ exit 1
+ fi
+ # Clean environment if there was some
+ # and the next environment is different.
+ # The variables are exported from check script.
+ if [ "$env" != "" -a "$env" != "none" -a "$env" != "$env_next" ];then
+ bash ./environments/$env clean $target
+ sts=$?
+ if [ "$sts" != "0" ];then
+ 1>&2 echo "An error happened when cleaning environment $env!"
+ 1>&2 echo ""
+ fi
+ fi
+
+}
+
# this test needs a scratch partition - check we're ok & unmount it
# No post-test check of the device is required. e.g. the test intentionally
# finishes the test with the filesystem in a corrupt state
--
1.9.3
next prev parent reply other threads:[~2014-11-14 13:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-14 13:27 [PATCH 1/7] Create environment setup files Jan Ťulák
2014-11-14 13:27 ` [PATCH 2/7] Created empty environment files in test categories Jan Ťulák
2014-11-14 13:27 ` [PATCH 3/7] Created new performance test category Jan Ťulák
2014-11-14 13:27 ` [PATCH 4/7] get_group_list changed to more universal get_list_from_file Jan Ťulák
2014-11-14 13:27 ` [PATCH 5/7] Creates new functions for the entire environments functionality Jan Ťulák
2014-11-14 13:27 ` [PATCH 6/7] Integrates environment functionality into existing code Jan Ťulák
2014-11-14 13:27 ` Jan Ťulák [this message]
2014-11-19 23:06 ` [PATCH 1/7] Create environment setup files Dave Chinner
2014-11-21 13:34 ` Jan Tulak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1415971667-16873-7-git-send-email-jtulak@redhat.com \
--to=jtulak@redhat.com \
--cc=david@fromorbit.com \
--cc=fstests@vger.kernel.org \
--cc=lczerner@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.