mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-12 07:42:56 +00:00
tests: add helper to determine when to skip expensive tests
The logic set up in previous patch for exposing VIR_TEST_EXPENSIVE to individual tests is as follows: make check VIR_TEST_EXPENSIVE=0 => getenv("VIR_TEST_EXPENSIVE") sees "0" make check VIR_TEST_EXPENSIVE=1 => getenv("VIR_TEST_EXPENSIVE") sees "1" make check => getenv("VIR_TEST_EXPENSIVE") sees either "0" or "1", based on configure options cd tests; ./FOOtest => getenv("VIR_TEST_EXPENSIVE") sees whatever is in your environment (usually NULL, but possibly garbage) Merely checking if VIR_TEST_EXPENSIVE is set in the environment does the wrong thing; likewise, it is unsafe to assume the variable will always contain a valid number. As such, it helps to have helper functions, instead of making each expensive test repeat the probe of the environment. * tests/testutils.h (virTestGetExpensive): New prototype. * tests/testutils.c (virTestGetExpensive): Implement it. * tests/test-lib.sh (very_expensive_): Rename... (test_expensive): ...and tweak to use VIR_TEST_EXPENSIVE. Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
70363ea9ff
commit
38d4bf49a0
@ -1,4 +1,22 @@
|
||||
# source this file; set up for tests
|
||||
# test-lib.sh: source this file; set up for tests
|
||||
|
||||
# Copyright (C) 2008-2013 Red Hat, Inc.
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library. If not, see
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Based on an idea from GNU coreutils
|
||||
|
||||
test -z "$abs_srcdir" && abs_srcdir=$(pwd)
|
||||
test -z "$abs_builddir" && abs_builddir=$(pwd)
|
||||
@ -158,15 +176,12 @@ require_selinux_()
|
||||
esac
|
||||
}
|
||||
|
||||
very_expensive_()
|
||||
test_expensive()
|
||||
{
|
||||
if test "$RUN_VERY_EXPENSIVE_TESTS" != yes; then
|
||||
if test "$VIR_TEST_EXPENSIVE" != 1; then
|
||||
skip_test_ '
|
||||
This test is very expensive, so it is disabled by default.
|
||||
To run it anyway, rerun make check with the RUN_VERY_EXPENSIVE_TESTS
|
||||
environment variable set to yes. E.g.,
|
||||
|
||||
env RUN_VERY_EXPENSIVE_TESTS=yes make check
|
||||
To run it anyway, rerun: make check VIR_TEST_EXPENSIVE=1
|
||||
'
|
||||
fi
|
||||
}
|
||||
|
@ -66,6 +66,7 @@
|
||||
|
||||
static unsigned int testDebug = -1;
|
||||
static unsigned int testVerbose = -1;
|
||||
static unsigned int testExpensive = -1;
|
||||
|
||||
static unsigned int testOOM = 0;
|
||||
static size_t testCounter = 0;
|
||||
@ -581,6 +582,13 @@ virTestGetVerbose(void) {
|
||||
return testVerbose || virTestGetDebug();
|
||||
}
|
||||
|
||||
unsigned int
|
||||
virTestGetExpensive(void) {
|
||||
if (testExpensive == -1)
|
||||
testExpensive = virTestGetFlag("VIR_TEST_EXPENSIVE");
|
||||
return testExpensive;
|
||||
}
|
||||
|
||||
int virtTestMain(int argc,
|
||||
char **argv,
|
||||
int (*func)(void))
|
||||
|
@ -65,6 +65,7 @@ int virtTestDifferenceBin(FILE *stream,
|
||||
|
||||
unsigned int virTestGetDebug(void);
|
||||
unsigned int virTestGetVerbose(void);
|
||||
unsigned int virTestGetExpensive(void);
|
||||
|
||||
char *virtTestLogContentAndReset(void);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user