From 0cd5a726e365e67690a81e3ce33ecd0cb0b5178d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Fri, 17 Jun 2016 14:09:30 +0200 Subject: [PATCH] Allow disjunct ranges in VIR_TEST_RANGE Use virBitmapParseUnlimited to parse the env variable. --- tests/testutils.c | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/tests/testutils.c b/tests/testutils.c index 54adab28c9..21b3bc66da 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -59,6 +59,7 @@ VIR_LOG_INIT("tests.testutils"); +#include "virbitmap.h" #include "virfile.h" static unsigned int testDebug = -1; @@ -79,8 +80,7 @@ int ntestAllocStack; static bool testOOMActive; static size_t testCounter; -static size_t testStart; -static size_t testEnd; +static virBitmapPtr testBitmap; char *progname; @@ -169,9 +169,7 @@ virTestRun(const char *title, /* Skip tests if out of range */ - if ((testStart != 0) && - (testCounter < testStart || - testCounter > testEnd)) + if (testBitmap && !virBitmapIsBitSet(testBitmap, testCounter)) return 0; if (virTestGetVerbose()) @@ -914,30 +912,10 @@ int virTestMain(int argc, } if ((testRange = getenv("VIR_TEST_RANGE")) != NULL) { - char *end = NULL; - unsigned int iv; - if (virStrToLong_ui(testRange, &end, 10, &iv) < 0) { + if (virBitmapParseUnlimited(testRange, &testBitmap) < 0) { fprintf(stderr, "Cannot parse range %s\n", testRange); return EXIT_FAILURE; } - testStart = testEnd = iv; - if (end && *end) { - if (*end != '-') { - fprintf(stderr, "Cannot parse range %s\n", testRange); - return EXIT_FAILURE; - } - end++; - if (virStrToLong_ui(end, NULL, 10, &iv) < 0) { - fprintf(stderr, "Cannot parse range %s\n", testRange); - return EXIT_FAILURE; - } - testEnd = iv; - - if (testEnd < testStart) { - fprintf(stderr, "Test range end %zu must be >= %zu\n", testEnd, testStart); - return EXIT_FAILURE; - } - } } #ifdef TEST_OOM