summaryrefslogtreecommitdiff
path: root/tests/virbitmaptest.c
diff options
context:
space:
mode:
authorPeter Krempa <pkrempa@redhat.com>2020-10-05 11:17:38 +0200
committerPeter Krempa <pkrempa@redhat.com>2020-10-05 15:38:47 +0200
commit5e309e82a76c24bfcf40d98e6932bc55dc30fcb6 (patch)
treecea373accdcd8376e0af73fb25b821862aca96c3 /tests/virbitmaptest.c
parent110b95d573d8f91ee13b8cd906de81b16f8e1dbe (diff)
downloadlibvirt-5e309e82a76c24bfcf40d98e6932bc55dc30fcb6.tar.gz
virbitmaptest: Split up test4
'test4' was testing three distinct operations on separate instances of a bitmap. Split it up into 'test4a', 'test4b' and 'test4c' so that the 'bitmap' variable is not reused. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
Diffstat (limited to 'tests/virbitmaptest.c')
-rw-r--r--tests/virbitmaptest.c64
1 files changed, 46 insertions, 18 deletions
diff --git a/tests/virbitmaptest.c b/tests/virbitmaptest.c
index 32187ebec4..98ac06c406 100644
--- a/tests/virbitmaptest.c
+++ b/tests/virbitmaptest.c
@@ -173,23 +173,9 @@ test3(const void *data G_GNUC_UNUSED)
/* test for virBitmapNextSetBit, virBitmapLastSetBit, virBitmapNextClearBit */
static int
-test4(const void *data G_GNUC_UNUSED)
+test4a(const void *data G_GNUC_UNUSED)
{
- const char *bitsString = "0, 2-4, 6-10, 12, 14-18, 20, 22, 25";
- int size = 40;
- int bitsPos[] = {
- 0, 2, 3, 4, 6, 7, 8, 9, 10, 12,
- 14, 15, 16, 17, 18, 20, 22, 25
- };
- int bitsPosInv[] = {
- 1, 5, 11, 13, 19, 21, 23, 24, 26, 27,
- 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39
- };
virBitmapPtr bitmap = NULL;
- ssize_t i, j;
-
- if (G_N_ELEMENTS(bitsPos) + G_N_ELEMENTS(bitsPosInv) != size)
- goto error;
/* 0. empty set */
@@ -205,7 +191,20 @@ test4(const void *data G_GNUC_UNUSED)
goto error;
virBitmapFree(bitmap);
- bitmap = NULL;
+ return 0;
+
+ error:
+ virBitmapFree(bitmap);
+ return -1;
+}
+
+
+static int
+test4b(const void *data G_GNUC_UNUSED)
+{
+ virBitmapPtr bitmap = NULL;
+ int size = 40;
+ size_t i;
/* 1. zero set */
@@ -230,7 +229,32 @@ test4(const void *data G_GNUC_UNUSED)
goto error;
virBitmapFree(bitmap);
- bitmap = NULL;
+ return 0;
+
+ error:
+ virBitmapFree(bitmap);
+ return -1;
+}
+
+
+static int
+test4c(const void *data G_GNUC_UNUSED)
+{
+ const char *bitsString = "0, 2-4, 6-10, 12, 14-18, 20, 22, 25";
+ int size = 40;
+ int bitsPos[] = {
+ 0, 2, 3, 4, 6, 7, 8, 9, 10, 12,
+ 14, 15, 16, 17, 18, 20, 22, 25
+ };
+ int bitsPosInv[] = {
+ 1, 5, 11, 13, 19, 21, 23, 24, 26, 27,
+ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39
+ };
+ virBitmapPtr bitmap = NULL;
+ ssize_t i, j;
+
+ if (G_N_ELEMENTS(bitsPos) + G_N_ELEMENTS(bitsPosInv) != size)
+ goto error;
/* 2. partial set */
@@ -818,7 +842,11 @@ mymain(void)
ret = -1;
if (virTestRun("test3", test3, NULL) < 0)
ret = -1;
- if (virTestRun("test4", test4, NULL) < 0)
+ if (virTestRun("test4a", test4a, NULL) < 0)
+ ret = -1;
+ if (virTestRun("test4b", test4b, NULL) < 0)
+ ret = -1;
+ if (virTestRun("test4c", test4c, NULL) < 0)
ret = -1;
if (virTestRun("test5", test5, NULL) < 0)
ret = -1;