TEST: Move all the version checking functions into version.inc.sh

Move all the version checking functions into version.inc.sh.

Signed-off-by: David Howells <dhowells@redhat.com>
TEST: Include version.inc.sh from prepare.inc.sh

Include version.inc.sh from prepare.inc.sh rather than toolbox.inc.sh so that
prepare.inc.sh can test for the presence of features.

Signed-off-by: David Howells <dhowells@redhat.com>
TEST: Add kernel version checking support

Provide function to check for the kernel version to use in feature checks.

Signed-off-by: David Howells <dhowells@redhat.com>
TEST: Make sure the TEST envvar is set

Make sure the TEST envvar is set so that the scripts don't break if it isn't.

Signed-off-by: David Howells <dhowells@redhat.com>
TEST: Add function to record skipped tests

Add a function to the toolbox to record skipped tests.

Signed-off-by: David Howells <dhowells@redhat.com>
TEST: Make toolbox_report_result use its parameters

Make toolbox_report_result use its parameters rather than going directly to
the TEST envvar.  Possibly the first parameter should be dropped.

Signed-off-by: David Howells <dhowells@redhat.com>
TEST: Can't do the bz1031154 test before 3.13-rc1

Can't do the bz1031154 test before 3.13-rc1 so skip the test if the kernel is
too old.  The big_key facility was backported to the 3.10 kernel used by
RHEL-7 so permit the test there.

Signed-off-by: David Howells <dhowells@redhat.com>
TEST: Display the name of the test we're about to run

Display the name of the test we're about to run to make it easier to work out
which test went wrong.

Signed-off-by: David Howells <dhowells@redhat.com>
TEST: Don't use "%..." key search commands generally

Don't use "%..." key search commands generally in the testsuite so that more
of it can be run on platforms for which the keyutils package installed doesn't
support this feature.

Signed-off-by: David Howells <dhowells@redhat.com>
TEST: keyctl show only takes an argument from 1.5.4 onwards

keyctl show only takes an argument from 1.5.4 onwards, so it cannot be tested
for prior to that.

Signed-off-by: David Howells <dhowells@redhat.com>
TEST: keyctl padd tests can't use big_key type if it's not available

keyctl padd tests can't use big_key type if it's not available because the
kernel is too old.

Signed-off-by: David Howells <dhowells@redhat.com>
TEST: Conditionalise usage and testing of key invalidation

Key invalidation only came in with 3.5-rc1.  Don't use it if the running
kernel doesn't support it.

Signed-off-by: David Howells <dhowells@redhat.com>
TEST: Make it possible to use OSRELEASE with the version comparison functions

Make it possible to use OSRELEASE with the version comparison functions.
Currently it's set to a text string (eg. "6.5") but not set to a numeric type
(which it can't be since it's not a simple number).  This means that the shell
numeric comparison operators (eg. "-lt") cannot be used.

Signed-off-by: David Howells <dhowells@redhat.com>
TEST: Insert a delay in the key invalidation test to allow for gc delays

The key invalidation test may fail because the check for a key having been
invalidated may occur too quickly after the call to invalidate the key.

The problem is that whilst the key is marked invalidated immediately, the
subsequent process of garbage collecting the invalidated key isn't synchronous
and may be delayed as the keyrings gc is merely scheduled to be run at some
later time.

Stick a small delay in there to give the gc a chance to run.

Bugzilla-entry: https://bugzilla.redhat.com/show_bug.cgi?id=1072798
Reported-by: Jan Stancek <jstancek@redhat.com>
Signed-off-by: David Howells <dhowells@redhat.com>