summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Raiskup <praiskup@redhat.com>2015-11-19 14:45:17 +0100
committerPavel Raiskup <praiskup@redhat.com>2015-11-19 14:45:17 +0100
commit68a04dce41a7d9a42a87ff5aa7ad2b7206e69b02 (patch)
treebf5e0f55070818713f54989f8520f236e3777953
parent1b7bc656b207685ce8cb04363fdca660d9595593 (diff)
downloaddtf-68a04dce41a7d9a42a87ff5aa7ad2b7206e69b02.zip
dtf-68a04dce41a7d9a42a87ff5aa7ad2b7206e69b02.tar.gz
dtf-68a04dce41a7d9a42a87ff5aa7ad2b7206e69b02.tar.xz
tests-api: new 'dtf prereq pkg missing' added
* bin/dtf-gen (DG): Allow to be overridden from environment. * share/dtf/lib/tests (dtf_pkg): Merge similar functions into one. (dtf_pkg_install): Use dtf_pkg. (dtf_pkg_remove): New function. (__dtf_prereq_pkg): Handle 'missing' argument.
-rwxr-xr-xbin/dtf-gen2
-rw-r--r--share/dtf/lib/tests42
2 files changed, 38 insertions, 6 deletions
diff --git a/bin/dtf-gen b/bin/dtf-gen
index 7307520..89c9ee0 100755
--- a/bin/dtf-gen
+++ b/bin/dtf-gen
@@ -7,7 +7,7 @@
## - each test might have several tags -- future dependencies
DTF_OUTPUT=DTF_OUTPUT
-DG=dg
+: ${DG=dg}
export opt_distro=fedora-rawhide-x86_64
diff --git a/share/dtf/lib/tests b/share/dtf/lib/tests
index 1aa376a..3f104cb 100644
--- a/share/dtf/lib/tests
+++ b/share/dtf/lib/tests
@@ -95,16 +95,42 @@ dtf_assert ()
}
-dtf_pkg_install ()
+dtf_pkg ()
{
- __dtf_assert_nargs 1 'dtf_pkg_install' ${1+"$@"}
-
- _d_pkg_inst=$1 ; shift
+ __dtf_assert_nargs 2 'dtf_pkg' ${1+"$@"}
+ _d_action=$1 ; shift
+ _d_pkg=$1 ; shift
dtf_assert root
- # {{ "\n " + commands.pkginstaller.install(['"$_d_pkg_inst"'], {'docs': True}) }}
+ case $_d_action in
+ remove)
+ # {{ "\n " + commands.pkginstaller.remove(['"$_d_pkg"'], {'docs': True}) }}
+ ;;
+ install)
+ # {{ "\n " + commands.pkginstaller.install(['"$_d_pkg"'], {'docs': True}) }}
+ ;;
+ *)
+ dtf_fail "dtf_pkg: unimplemented action '$_d_action'"
+ ;;
+ esac
+}
+
+
+dtf_pkg_install ()
+{
+ __dtf_assert_nargs 2 'dtf_pkg_install' ${1+"$@"}
+ _d_pkg_rem=$1 ; shift
+ dtf_pkg remove "$_d_pkg_inst"
+ test $? -eq 0 || dtf_fail "can't remove '$_d_pkg_inst' package"
+}
+
+dtf_pkg_remove ()
+{
+ __dtf_assert_nargs 1 'dtf_pkg_install' ${1+"$@"}
+ _d_pkg_inst=$1 ; shift
+ dtf_pkg install "$_d_pkg_inst"
test $? -eq 0 || dtf_fail "can't install '$_d_pkg_inst' package"
}
@@ -116,11 +142,17 @@ __dtf_prereq_pkg ()
_d_subaction=$1 ; shift
_d_pkg=$1 ; shift
+ __dtf_debug "making sure $_d_pkg is $_d_subaction"
+
case $_d_subaction in
installed)
dtf_pkg_installed "$_d_pkg" && return 0
dtf_pkg_install "$_d_pkg"
;;
+ missing)
+ dtf_pkg_installed "$_d_pkg" || return 0
+ dtf_pkg_remove "$_d_pkg"
+ ;;
*)
dtf_fail "dtf_prereq pkg: not implemented action $_d_subaction"
;;