summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Raiskup <praiskup@redhat.com>2015-11-19 13:45:16 +0100
committerPavel Raiskup <praiskup@redhat.com>2015-11-19 13:45:16 +0100
commit1b7bc656b207685ce8cb04363fdca660d9595593 (patch)
tree4e96d4d14f71dad7c61663902c5ee417a3b023e7
parentd553d5e4e85e6f05dacfdc87833db5574fc662f4 (diff)
downloaddtf-1b7bc656b207685ce8cb04363fdca660d9595593.zip
dtf-1b7bc656b207685ce8cb04363fdca660d9595593.tar.gz
dtf-1b7bc656b207685ce8cb04363fdca660d9595593.tar.xz
tests-api: new 'dtf_prereq pkg' method
* share/dtf/lib/tests (dtf_debug): New function to simplify debugging. (__dtf_debug): Internal wrapper for debugging. (dtf_pkg_install): Be more verbose if the method is used wrongly. (dtf_prereq): Accept 'pkg installed' subaction.
-rw-r--r--share/dtf/lib/tests40
1 files changed, 35 insertions, 5 deletions
diff --git a/share/dtf/lib/tests b/share/dtf/lib/tests
index b4a1a4c..1aa376a 100644
--- a/share/dtf/lib/tests
+++ b/share/dtf/lib/tests
@@ -10,6 +10,7 @@ dtf_skip ()
exit 77
}
+
dtf_fail ()
{
test -n "$1" && echo >&2 "$1"
@@ -17,6 +18,26 @@ dtf_fail ()
}
+dtf_debug ()
+{
+ for _d_i in $1
+ do
+ case " $DTF_DBG_KEYWORDS " in
+ *\ $_d_i\ *)
+ shift
+ echo >&4 " ~ $*"
+ return 0
+ ;;
+ esac
+ done
+}
+
+
+__dtf_debug ()
+{
+ dtf_debug dtf_lib "$*"
+}
+
__dtf_method_not_implemented ()
{
dtf_fail "'$1' method is not implemented"
@@ -27,6 +48,7 @@ __dtf_method_not_implemented ()
# -------------------------
dtf_pkg_installed ()
{
+ __dtf_debug "checking whether '$1' is installed"
# {% if config.os.id in ["fedora", "rhel", "centos"] %}
rpm -q "$1" &>/dev/null
# {% else %}
@@ -42,10 +64,11 @@ __dtf_assert_nargs ()
test $# -ge "$_d_nargs" && return
+ _d_tr="$# given ($*)"
if test "$_d_nargs" -eq 1; then
- dtf_fail "method '$_d_method' requires at least 1 argument"
+ dtf_fail "method '$_d_method' requires at least 1 argument, $_d_tr"
else
- dtf_fail "method '$_d_method' requires at least $_d_nargs arguments"
+ dtf_fail "method '$_d_method' requires at least $_d_nargs arguments, $_d_tr"
fi
}
@@ -90,11 +113,18 @@ __dtf_prereq_pkg ()
{
__dtf_assert_nargs 2 'dtf_prereq pkg' ${1+"$@"}
+ _d_subaction=$1 ; shift
_d_pkg=$1 ; shift
- dtf_pkg_installed "$_d_pkg" && return 0
-
- dtf_pkg_install "$_d_pkg"
+ case $_d_subaction in
+ installed)
+ dtf_pkg_installed "$_d_pkg" && return 0
+ dtf_pkg_install "$_d_pkg"
+ ;;
+ *)
+ dtf_fail "dtf_prereq pkg: not implemented action $_d_subaction"
+ ;;
+ esac
}