aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2011-09-01 12:01:05 +0100
committerDavid Howells <dhowells@redhat.com>2011-09-01 12:01:05 +0100
commit13229fc1b048aef136b8e2ecad2484e7ba74b676 (patch)
tree296d306efe67971d192af00beebcb61643f00d9d
parentdce230d5290166af0997af3275a4946b0d2da7c9 (diff)
downloadkeyutils-13229fc1b048aef136b8e2ecad2484e7ba74b676.tar.gz
TEST: Extract the version string from keyctl
Extract the version string from keyctl so that tests can be made contingent upon it. Signed-off-by: David Howells <dhowells@redhat.com>
-rw-r--r--tests/prepare.inc.sh16
-rw-r--r--tests/toolbox.inc.sh43
2 files changed, 58 insertions, 1 deletions
diff --git a/tests/prepare.inc.sh b/tests/prepare.inc.sh
index 4200e92..55b105b 100644
--- a/tests/prepare.inc.sh
+++ b/tests/prepare.inc.sh
@@ -26,4 +26,18 @@ case `lsb_release -i | awk '{ print $3}'` in
*) OSDIST=Unknown;;
esac
-OSVER=`lsb_release -r | awk '{ print $2}'`
+OSRELEASE=`lsb_release -r | awk '{ print $2}'`
+
+KEYUTILSVER=`keyctl --version 2>/dev/null`
+if [ -n "$KEYUTILSVER" ]
+then
+ :
+elif [ -x /bin/rpm ]
+then
+ KEYUTILSVER=`rpm -q keyutils`
+else
+ echo "Can't determine keyutils version" >&2
+ exit 9
+fi
+
+KEYUTILSVER=`expr $KEYUTILSVER : '.*keyutils-\([0-9.]*\).*'`
diff --git a/tests/toolbox.inc.sh b/tests/toolbox.inc.sh
index 1c5d792..29ce0fa 100644
--- a/tests/toolbox.inc.sh
+++ b/tests/toolbox.inc.sh
@@ -137,6 +137,49 @@ function __version_less_than_dot ()
fi
}
+###############################################################################
+#
+# Return true if the keyutils package being tested is older than the given
+# version.
+#
+###############################################################################
+function keyutils_older_than ()
+{
+ version_less_than $KEYUTILSVER $1
+}
+
+###############################################################################
+#
+# Return true if the keyutils package being tested is at or later than the
+# given version.
+#
+###############################################################################
+function keyutils_at_or_later_than ()
+{
+ ! keyutils_older_than $1
+}
+
+###############################################################################
+#
+# Return true if the keyutils package being tested is newer than the given
+# version.
+#
+###############################################################################
+function keyutils_newer_than ()
+{
+ version_less_than $1 $KEYUTILSVER
+}
+
+###############################################################################
+#
+# Return true if the keyutils package being tested is at or older than the
+# given version.
+#
+###############################################################################
+function keyutils_at_or_older_than ()
+{
+ ! keyutils_newer_than $1
+}
###############################################################################
#