2012-09-14 15:46:57 +08:00
|
|
|
/*
|
2013-08-16 18:12:55 +08:00
|
|
|
* virbitmaptest.c: Test the bitmap code
|
|
|
|
*
|
2013-02-02 08:33:18 +08:00
|
|
|
* Copyright (C) 2013 Red Hat, Inc.
|
2012-09-14 15:46:57 +08:00
|
|
|
* Copyright (C) 2012 Fujitsu.
|
|
|
|
*
|
|
|
|
* 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
|
2012-09-21 06:30:55 +08:00
|
|
|
* License along with this library. If not, see
|
2012-09-14 15:46:57 +08:00
|
|
|
* <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "testutils.h"
|
|
|
|
|
2012-12-04 19:56:32 +08:00
|
|
|
#include "virbitmap.h"
|
2012-09-14 15:46:57 +08:00
|
|
|
|
2013-08-16 18:12:55 +08:00
|
|
|
static int
|
2019-10-14 20:45:03 +08:00
|
|
|
test1(const void *data G_GNUC_UNUSED)
|
2012-09-14 15:46:57 +08:00
|
|
|
{
|
|
|
|
virBitmapPtr bitmap;
|
|
|
|
int size;
|
|
|
|
int bit;
|
|
|
|
bool result;
|
2013-01-23 06:09:28 +08:00
|
|
|
int ret = -1;
|
2012-09-14 15:46:57 +08:00
|
|
|
|
|
|
|
size = 1024;
|
|
|
|
bit = 100;
|
2013-01-23 06:09:28 +08:00
|
|
|
if (!(bitmap = virBitmapNew(size)))
|
|
|
|
goto error;
|
|
|
|
|
2012-09-14 15:46:57 +08:00
|
|
|
if (virBitmapSetBit(bitmap, bit) < 0)
|
2013-01-23 06:09:28 +08:00
|
|
|
goto error;
|
2012-09-14 15:46:57 +08:00
|
|
|
|
|
|
|
if (virBitmapGetBit(bitmap, bit, &result) < 0)
|
2013-01-23 06:09:28 +08:00
|
|
|
goto error;
|
2012-09-14 15:46:57 +08:00
|
|
|
|
|
|
|
if (!result)
|
2013-01-23 06:09:28 +08:00
|
|
|
goto error;
|
2012-09-14 15:46:57 +08:00
|
|
|
|
|
|
|
if (virBitmapGetBit(bitmap, bit + 1, &result) < 0)
|
2013-01-23 06:09:28 +08:00
|
|
|
goto error;
|
2012-09-14 15:46:57 +08:00
|
|
|
|
|
|
|
if (result)
|
2013-01-23 06:09:28 +08:00
|
|
|
goto error;
|
2012-09-14 15:46:57 +08:00
|
|
|
|
2013-01-23 06:09:28 +08:00
|
|
|
ret = 0;
|
|
|
|
|
2014-03-25 14:53:44 +08:00
|
|
|
error:
|
2013-01-23 06:09:28 +08:00
|
|
|
virBitmapFree(bitmap);
|
|
|
|
return ret;
|
2012-09-14 15:46:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
testBit(virBitmapPtr bitmap,
|
|
|
|
unsigned int start,
|
|
|
|
unsigned int end,
|
|
|
|
bool expected)
|
|
|
|
{
|
Convert 'int i' to 'size_t i' in tests/ files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 22:09:33 +08:00
|
|
|
size_t i;
|
2012-09-14 15:46:57 +08:00
|
|
|
bool result;
|
|
|
|
|
|
|
|
for (i = start; i <= end; i++) {
|
|
|
|
if (virBitmapGetBit(bitmap, i, &result) < 0)
|
|
|
|
return -1;
|
2015-03-07 00:55:38 +08:00
|
|
|
if (result != expected)
|
|
|
|
return -1;
|
2012-09-14 15:46:57 +08:00
|
|
|
}
|
|
|
|
|
2015-03-07 00:55:38 +08:00
|
|
|
return 0;
|
2012-09-14 15:46:57 +08:00
|
|
|
}
|
|
|
|
|
2013-08-16 18:12:55 +08:00
|
|
|
static int
|
2019-10-14 20:45:03 +08:00
|
|
|
test2(const void *data G_GNUC_UNUSED)
|
2012-09-14 15:46:57 +08:00
|
|
|
{
|
|
|
|
const char *bitsString1 = "1-32,50,88-99,1021-1023";
|
|
|
|
char *bitsString2 = NULL;
|
|
|
|
virBitmapPtr bitmap = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
int size = 1025;
|
|
|
|
|
2016-06-17 20:56:45 +08:00
|
|
|
if (virBitmapParse(bitsString1, &bitmap, size) < 0)
|
2012-09-14 15:46:57 +08:00
|
|
|
goto error;
|
|
|
|
|
|
|
|
if (testBit(bitmap, 1, 32, true) < 0)
|
|
|
|
goto error;
|
|
|
|
if (testBit(bitmap, 50, 50, true) < 0)
|
|
|
|
goto error;
|
|
|
|
if (testBit(bitmap, 88, 99, true) < 0)
|
|
|
|
goto error;
|
|
|
|
if (testBit(bitmap, 1021, 1023, true) < 0)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
if (testBit(bitmap, 0, 0, false) < 0)
|
|
|
|
goto error;
|
|
|
|
if (testBit(bitmap, 33, 49, false) < 0)
|
|
|
|
goto error;
|
|
|
|
if (testBit(bitmap, 51, 87, false) < 0)
|
|
|
|
goto error;
|
|
|
|
if (testBit(bitmap, 100, 1020, false) < 0)
|
|
|
|
goto error;
|
|
|
|
|
2012-10-25 08:44:27 +08:00
|
|
|
if (virBitmapCountBits(bitmap) != 48)
|
|
|
|
goto error;
|
|
|
|
|
2013-01-23 06:09:28 +08:00
|
|
|
if (!(bitsString2 = virBitmapFormat(bitmap)))
|
|
|
|
goto error;
|
2012-09-14 15:46:57 +08:00
|
|
|
if (strcmp(bitsString1, bitsString2))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
virBitmapSetAll(bitmap);
|
|
|
|
if (testBit(bitmap, 0, size - 1, true) < 0)
|
|
|
|
goto error;
|
2012-10-25 08:44:27 +08:00
|
|
|
if (virBitmapCountBits(bitmap) != size)
|
|
|
|
goto error;
|
2012-09-14 15:46:57 +08:00
|
|
|
|
|
|
|
if (!virBitmapIsAllSet(bitmap))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
virBitmapClearAll(bitmap);
|
2013-04-06 02:06:16 +08:00
|
|
|
if (!virBitmapIsAllClear(bitmap))
|
|
|
|
goto error;
|
2012-09-14 15:46:57 +08:00
|
|
|
if (testBit(bitmap, 0, size - 1, false) < 0)
|
|
|
|
goto error;
|
2012-10-25 08:44:27 +08:00
|
|
|
if (virBitmapCountBits(bitmap) != 0)
|
|
|
|
goto error;
|
2012-09-14 15:46:57 +08:00
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
|
2014-03-25 14:53:44 +08:00
|
|
|
error:
|
2012-09-14 15:46:57 +08:00
|
|
|
virBitmapFree(bitmap);
|
|
|
|
VIR_FREE(bitsString2);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-08-16 18:12:55 +08:00
|
|
|
static int
|
2019-10-14 20:45:03 +08:00
|
|
|
test3(const void *data G_GNUC_UNUSED)
|
2012-09-14 15:46:57 +08:00
|
|
|
{
|
|
|
|
virBitmapPtr bitmap = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
int size = 5;
|
Convert 'int i' to 'size_t i' in tests/ files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 22:09:33 +08:00
|
|
|
size_t i;
|
2012-09-14 15:46:57 +08:00
|
|
|
|
|
|
|
if ((bitmap = virBitmapNew(size)) == NULL)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
for (i = 0; i < size; i++)
|
|
|
|
ignore_value(virBitmapSetBit(bitmap, i));
|
|
|
|
|
|
|
|
if (!virBitmapIsAllSet(bitmap))
|
|
|
|
goto error;
|
|
|
|
|
2013-04-06 02:06:16 +08:00
|
|
|
virBitmapClearAll(bitmap);
|
|
|
|
if (!virBitmapIsAllClear(bitmap))
|
|
|
|
goto error;
|
2012-09-14 15:46:57 +08:00
|
|
|
ret = 0;
|
|
|
|
|
2014-03-25 14:53:44 +08:00
|
|
|
error:
|
2012-09-14 15:46:57 +08:00
|
|
|
virBitmapFree(bitmap);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-11-04 10:44:39 +08:00
|
|
|
/* test for virBitmapNextSetBit, virBitmapLastSetBit, virBitmapNextClearBit */
|
2013-08-16 18:12:55 +08:00
|
|
|
static int
|
2019-10-14 20:45:03 +08:00
|
|
|
test4(const void *data G_GNUC_UNUSED)
|
2012-09-14 15:46:57 +08:00
|
|
|
{
|
|
|
|
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
|
|
|
|
};
|
2013-02-02 08:33:18 +08:00
|
|
|
int bitsPosInv[] = {
|
|
|
|
1, 5, 11, 13, 19, 21, 23, 24, 26, 27,
|
|
|
|
28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39
|
|
|
|
};
|
2012-09-14 15:46:57 +08:00
|
|
|
virBitmapPtr bitmap = NULL;
|
Convert 'int i' to 'size_t i' in tests/ files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 22:09:33 +08:00
|
|
|
ssize_t i, j;
|
2012-09-14 15:46:57 +08:00
|
|
|
|
2019-10-15 19:55:26 +08:00
|
|
|
if (G_N_ELEMENTS(bitsPos) + G_N_ELEMENTS(bitsPosInv) != size)
|
2013-02-02 08:33:18 +08:00
|
|
|
goto error;
|
|
|
|
|
2016-07-06 20:02:28 +08:00
|
|
|
/* 0. empty set */
|
|
|
|
|
|
|
|
if (!(bitmap = virBitmapNewEmpty()))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
if (virBitmapNextSetBit(bitmap, -1) != -1)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
if (virBitmapLastSetBit(bitmap) != -1)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
if (virBitmapNextClearBit(bitmap, -1) != -1)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
virBitmapFree(bitmap);
|
|
|
|
bitmap = NULL;
|
|
|
|
|
2012-09-14 15:46:57 +08:00
|
|
|
/* 1. zero set */
|
|
|
|
|
|
|
|
bitmap = virBitmapNew(size);
|
|
|
|
if (!bitmap)
|
|
|
|
goto error;
|
|
|
|
|
2013-02-02 08:33:18 +08:00
|
|
|
if (virBitmapNextSetBit(bitmap, -1) != -1)
|
|
|
|
goto error;
|
|
|
|
|
2014-11-04 10:44:39 +08:00
|
|
|
if (virBitmapLastSetBit(bitmap) != -1)
|
|
|
|
goto error;
|
|
|
|
|
2013-02-02 08:33:18 +08:00
|
|
|
for (i = 0; i < size; i++) {
|
|
|
|
if (virBitmapNextClearBit(bitmap, i - 1) != i)
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
if (virBitmapNextClearBit(bitmap, i) != -1)
|
2012-09-14 15:46:57 +08:00
|
|
|
goto error;
|
|
|
|
|
2013-04-06 02:06:16 +08:00
|
|
|
if (!virBitmapIsAllClear(bitmap))
|
|
|
|
goto error;
|
|
|
|
|
2012-09-14 15:46:57 +08:00
|
|
|
virBitmapFree(bitmap);
|
|
|
|
bitmap = NULL;
|
|
|
|
|
|
|
|
/* 2. partial set */
|
|
|
|
|
2016-06-17 20:56:45 +08:00
|
|
|
if (virBitmapParse(bitsString, &bitmap, size) < 0)
|
2012-09-14 15:46:57 +08:00
|
|
|
goto error;
|
|
|
|
if (!bitmap)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
j = 0;
|
|
|
|
i = -1;
|
|
|
|
|
2019-10-15 19:55:26 +08:00
|
|
|
while (j < G_N_ELEMENTS(bitsPos)) {
|
2012-09-14 15:46:57 +08:00
|
|
|
i = virBitmapNextSetBit(bitmap, i);
|
|
|
|
if (i != bitsPos[j++])
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2013-02-02 08:33:18 +08:00
|
|
|
if (virBitmapNextSetBit(bitmap, i) != -1)
|
|
|
|
goto error;
|
|
|
|
|
2014-11-04 10:44:39 +08:00
|
|
|
j = sizeof(bitsPos)/sizeof(int) - 1;
|
|
|
|
|
|
|
|
if (virBitmapLastSetBit(bitmap) != bitsPos[j])
|
|
|
|
goto error;
|
|
|
|
|
2013-02-02 08:33:18 +08:00
|
|
|
j = 0;
|
|
|
|
i = -1;
|
|
|
|
|
2019-10-15 19:55:26 +08:00
|
|
|
while (j < G_N_ELEMENTS(bitsPosInv)) {
|
2013-02-02 08:33:18 +08:00
|
|
|
i = virBitmapNextClearBit(bitmap, i);
|
|
|
|
if (i != bitsPosInv[j++])
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (virBitmapNextClearBit(bitmap, i) != -1)
|
2012-09-14 15:46:57 +08:00
|
|
|
goto error;
|
|
|
|
|
|
|
|
/* 3. full set */
|
|
|
|
|
|
|
|
virBitmapSetAll(bitmap);
|
|
|
|
|
2013-02-02 08:33:18 +08:00
|
|
|
for (i = 0; i < size; i++) {
|
|
|
|
if (virBitmapNextSetBit(bitmap, i - 1) != i)
|
2012-09-14 15:46:57 +08:00
|
|
|
goto error;
|
|
|
|
}
|
2013-02-02 08:33:18 +08:00
|
|
|
if (virBitmapNextSetBit(bitmap, i) != -1)
|
|
|
|
goto error;
|
2012-09-14 15:46:57 +08:00
|
|
|
|
2014-11-04 10:44:39 +08:00
|
|
|
if (virBitmapLastSetBit(bitmap) != size - 1)
|
|
|
|
goto error;
|
|
|
|
|
2013-02-02 08:33:18 +08:00
|
|
|
if (virBitmapNextClearBit(bitmap, -1) != -1)
|
2012-09-14 15:46:57 +08:00
|
|
|
goto error;
|
|
|
|
|
|
|
|
virBitmapFree(bitmap);
|
|
|
|
return 0;
|
|
|
|
|
2014-03-25 14:53:44 +08:00
|
|
|
error:
|
2012-09-14 15:46:57 +08:00
|
|
|
virBitmapFree(bitmap);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2017-08-23 15:05:41 +08:00
|
|
|
/* test for virBitmapNewData/ToData/DataFormat */
|
2013-08-16 18:12:55 +08:00
|
|
|
static int
|
2019-10-14 20:45:03 +08:00
|
|
|
test5(const void *v G_GNUC_UNUSED)
|
2012-09-14 15:46:57 +08:00
|
|
|
{
|
2012-09-19 07:20:03 +08:00
|
|
|
char data[] = {0x01, 0x02, 0x00, 0x00, 0x04};
|
2012-09-14 15:46:57 +08:00
|
|
|
unsigned char *data2 = NULL;
|
|
|
|
int len2;
|
2012-09-19 07:20:03 +08:00
|
|
|
int bits[] = {0, 9, 34};
|
2012-09-14 15:46:57 +08:00
|
|
|
virBitmapPtr bitmap;
|
Convert 'int i' to 'size_t i' in tests/ files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 22:09:33 +08:00
|
|
|
size_t i;
|
|
|
|
ssize_t j;
|
2012-09-14 15:46:57 +08:00
|
|
|
int ret = -1;
|
2014-06-05 17:23:28 +08:00
|
|
|
char *str = NULL;
|
2012-09-14 15:46:57 +08:00
|
|
|
|
2012-09-19 07:20:03 +08:00
|
|
|
bitmap = virBitmapNewData(data, sizeof(data));
|
2012-09-14 15:46:57 +08:00
|
|
|
if (!bitmap)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
j = -1;
|
|
|
|
while (i < sizeof(bits)/sizeof(int) &&
|
|
|
|
(j = virBitmapNextSetBit(bitmap, j)) >= 0) {
|
|
|
|
if (j != bits[i++])
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
if (virBitmapNextSetBit(bitmap, j) > 0)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
ignore_value(virBitmapSetBit(bitmap, 2));
|
|
|
|
ignore_value(virBitmapSetBit(bitmap, 15));
|
|
|
|
|
|
|
|
if (virBitmapToData(bitmap, &data2, &len2) < 0)
|
|
|
|
goto error;
|
|
|
|
|
2012-09-19 07:20:03 +08:00
|
|
|
if (len2 != sizeof(data) ||
|
|
|
|
data2[0] != 0x05 ||
|
2012-09-14 15:46:57 +08:00
|
|
|
data2[1] != 0x82 ||
|
|
|
|
data2[2] != 0x00 ||
|
2012-09-19 07:20:03 +08:00
|
|
|
data2[3] != 0x00 ||
|
|
|
|
data2[4] != 0x04)
|
2012-09-14 15:46:57 +08:00
|
|
|
goto error;
|
|
|
|
|
2017-08-23 15:05:41 +08:00
|
|
|
if (!(str = virBitmapDataFormat(data, sizeof(data))))
|
2014-06-05 17:23:28 +08:00
|
|
|
goto error;
|
|
|
|
if (STRNEQ(str, "0,9,34"))
|
|
|
|
goto error;
|
|
|
|
VIR_FREE(str);
|
2017-08-23 15:05:41 +08:00
|
|
|
if (!(str = virBitmapDataFormat(data2, len2)))
|
2014-06-05 17:23:28 +08:00
|
|
|
goto error;
|
|
|
|
if (STRNEQ(str, "0,2,9,15,34"))
|
|
|
|
goto error;
|
|
|
|
|
2012-09-14 15:46:57 +08:00
|
|
|
ret = 0;
|
2014-03-25 14:53:44 +08:00
|
|
|
error:
|
2014-06-05 17:23:28 +08:00
|
|
|
VIR_FREE(str);
|
2012-09-14 15:46:57 +08:00
|
|
|
virBitmapFree(bitmap);
|
|
|
|
VIR_FREE(data2);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* test for virBitmapFormat */
|
2013-08-16 18:12:55 +08:00
|
|
|
static int
|
2019-10-14 20:45:03 +08:00
|
|
|
test6(const void *v G_GNUC_UNUSED)
|
2012-09-14 15:46:57 +08:00
|
|
|
{
|
|
|
|
virBitmapPtr bitmap = NULL;
|
|
|
|
char *str = NULL;
|
|
|
|
int size = 64;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
bitmap = virBitmapNew(size);
|
|
|
|
if (!bitmap)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
str = virBitmapFormat(bitmap);
|
|
|
|
if (!str)
|
|
|
|
goto error;
|
|
|
|
|
2015-10-21 00:15:12 +08:00
|
|
|
if (STRNEQ(str, ""))
|
2012-09-14 15:46:57 +08:00
|
|
|
goto error;
|
|
|
|
|
|
|
|
VIR_FREE(str);
|
|
|
|
|
|
|
|
ignore_value(virBitmapSetBit(bitmap, 0));
|
|
|
|
str = virBitmapFormat(bitmap);
|
|
|
|
if (!str)
|
|
|
|
goto error;
|
|
|
|
|
2015-10-21 00:15:12 +08:00
|
|
|
if (STRNEQ(str, "0"))
|
2012-09-14 15:46:57 +08:00
|
|
|
goto error;
|
|
|
|
|
|
|
|
VIR_FREE(str);
|
|
|
|
|
|
|
|
ignore_value(virBitmapSetBit(bitmap, 4));
|
|
|
|
ignore_value(virBitmapSetBit(bitmap, 5));
|
|
|
|
str = virBitmapFormat(bitmap);
|
|
|
|
if (!str)
|
|
|
|
goto error;
|
|
|
|
|
2015-10-21 00:15:12 +08:00
|
|
|
if (STRNEQ(str, "0,4-5"))
|
2012-09-14 15:46:57 +08:00
|
|
|
goto error;
|
|
|
|
|
|
|
|
VIR_FREE(str);
|
|
|
|
|
|
|
|
ignore_value(virBitmapSetBit(bitmap, 6));
|
|
|
|
str = virBitmapFormat(bitmap);
|
|
|
|
if (!str)
|
|
|
|
goto error;
|
|
|
|
|
2015-10-21 00:15:12 +08:00
|
|
|
if (STRNEQ(str, "0,4-6"))
|
2012-09-14 15:46:57 +08:00
|
|
|
goto error;
|
|
|
|
|
|
|
|
VIR_FREE(str);
|
|
|
|
|
|
|
|
ignore_value(virBitmapSetBit(bitmap, 13));
|
|
|
|
ignore_value(virBitmapSetBit(bitmap, 14));
|
|
|
|
ignore_value(virBitmapSetBit(bitmap, 15));
|
|
|
|
ignore_value(virBitmapSetBit(bitmap, 16));
|
|
|
|
str = virBitmapFormat(bitmap);
|
|
|
|
if (!str)
|
|
|
|
goto error;
|
|
|
|
|
2015-10-21 00:15:12 +08:00
|
|
|
if (STRNEQ(str, "0,4-6,13-16"))
|
2012-09-14 15:46:57 +08:00
|
|
|
goto error;
|
|
|
|
|
|
|
|
VIR_FREE(str);
|
|
|
|
|
|
|
|
ignore_value(virBitmapSetBit(bitmap, 62));
|
|
|
|
ignore_value(virBitmapSetBit(bitmap, 63));
|
|
|
|
str = virBitmapFormat(bitmap);
|
|
|
|
if (!str)
|
|
|
|
goto error;
|
|
|
|
|
2015-10-21 00:15:12 +08:00
|
|
|
if (STRNEQ(str, "0,4-6,13-16,62-63"))
|
2012-09-14 15:46:57 +08:00
|
|
|
goto error;
|
|
|
|
|
|
|
|
|
|
|
|
ret = 0;
|
2014-03-25 14:53:44 +08:00
|
|
|
error:
|
2012-09-14 15:46:57 +08:00
|
|
|
virBitmapFree(bitmap);
|
|
|
|
VIR_FREE(str);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-08-16 18:12:55 +08:00
|
|
|
static int
|
2019-10-14 20:45:03 +08:00
|
|
|
test7(const void *v G_GNUC_UNUSED)
|
2012-11-28 14:15:38 +08:00
|
|
|
{
|
|
|
|
virBitmapPtr bitmap;
|
|
|
|
size_t i;
|
|
|
|
size_t maxBit[] = {
|
|
|
|
1, 8, 31, 32, 63, 64, 95, 96, 127, 128, 159, 160
|
|
|
|
};
|
|
|
|
size_t nmaxBit = 12;
|
|
|
|
|
|
|
|
for (i = 0; i < nmaxBit; i++) {
|
|
|
|
bitmap = virBitmapNew(maxBit[i]);
|
|
|
|
if (!bitmap)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
if (virBitmapIsAllSet(bitmap))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
ignore_value(virBitmapSetBit(bitmap, 1));
|
|
|
|
if (virBitmapIsAllSet(bitmap))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
virBitmapSetAll(bitmap);
|
|
|
|
if (!virBitmapIsAllSet(bitmap))
|
|
|
|
goto error;
|
|
|
|
|
2013-04-06 02:06:16 +08:00
|
|
|
virBitmapClearAll(bitmap);
|
|
|
|
if (!virBitmapIsAllClear(bitmap))
|
|
|
|
goto error;
|
|
|
|
|
2012-11-28 14:15:38 +08:00
|
|
|
virBitmapFree(bitmap);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
2014-03-25 14:53:44 +08:00
|
|
|
error:
|
2012-11-28 14:15:38 +08:00
|
|
|
virBitmapFree(bitmap);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2013-08-16 18:12:55 +08:00
|
|
|
static int
|
2019-10-14 20:45:03 +08:00
|
|
|
test8(const void *v G_GNUC_UNUSED)
|
2013-04-06 02:06:16 +08:00
|
|
|
{
|
|
|
|
virBitmapPtr bitmap = NULL;
|
|
|
|
char data[108] = {0x00,};
|
2013-04-15 23:50:59 +08:00
|
|
|
int ret = -1;
|
2013-04-06 02:06:16 +08:00
|
|
|
|
|
|
|
bitmap = virBitmapNewData(data, sizeof(data));
|
|
|
|
if (!bitmap)
|
2013-04-15 23:50:59 +08:00
|
|
|
goto cleanup;
|
2013-04-06 02:06:16 +08:00
|
|
|
|
|
|
|
if (!virBitmapIsAllClear(bitmap))
|
2013-04-15 23:50:59 +08:00
|
|
|
goto cleanup;
|
2013-04-06 02:06:16 +08:00
|
|
|
|
|
|
|
if (virBitmapSetBit(bitmap, 11) < 0)
|
2013-04-15 23:50:59 +08:00
|
|
|
goto cleanup;
|
2013-04-06 02:06:16 +08:00
|
|
|
|
|
|
|
if (virBitmapIsAllClear(bitmap))
|
2013-04-15 23:50:59 +08:00
|
|
|
goto cleanup;
|
2013-04-06 02:06:16 +08:00
|
|
|
|
2013-04-15 23:50:59 +08:00
|
|
|
ret = 0;
|
2014-03-25 14:53:44 +08:00
|
|
|
cleanup:
|
2013-04-06 02:06:16 +08:00
|
|
|
virBitmapFree(bitmap);
|
2013-04-15 23:50:59 +08:00
|
|
|
return ret;
|
2013-04-06 02:06:16 +08:00
|
|
|
}
|
|
|
|
|
2013-08-16 18:13:27 +08:00
|
|
|
|
|
|
|
/* test out of bounds conditions on virBitmapParse */
|
|
|
|
static int
|
2019-10-14 20:45:03 +08:00
|
|
|
test9(const void *opaque G_GNUC_UNUSED)
|
2013-08-16 18:13:27 +08:00
|
|
|
{
|
|
|
|
int ret = -1;
|
2013-08-19 20:02:52 +08:00
|
|
|
virBitmapPtr bitmap = NULL;
|
2013-08-16 18:13:27 +08:00
|
|
|
|
2016-06-17 20:56:45 +08:00
|
|
|
if (virBitmapParse("100000000", &bitmap, 20) != -1)
|
2013-08-16 18:13:27 +08:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (bitmap)
|
|
|
|
goto cleanup;
|
|
|
|
|
2016-06-17 20:56:45 +08:00
|
|
|
if (virBitmapParse("1-1000000000", &bitmap, 20) != -1)
|
2013-08-16 18:13:27 +08:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (bitmap)
|
|
|
|
goto cleanup;
|
|
|
|
|
2016-06-17 20:56:45 +08:00
|
|
|
if (virBitmapParse("1-10^10000000000", &bitmap, 20) != -1)
|
2013-08-16 18:13:27 +08:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (bitmap)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
ret = 0;
|
2014-03-25 14:53:44 +08:00
|
|
|
cleanup:
|
2013-08-19 20:02:52 +08:00
|
|
|
virBitmapFree(bitmap);
|
2013-08-16 18:13:27 +08:00
|
|
|
return ret;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-07-23 23:37:19 +08:00
|
|
|
static int
|
2019-10-14 20:45:03 +08:00
|
|
|
test10(const void *opaque G_GNUC_UNUSED)
|
2014-07-23 23:37:19 +08:00
|
|
|
{
|
|
|
|
int ret = -1;
|
2015-04-10 17:11:21 +08:00
|
|
|
virBitmapPtr b1 = NULL, b2 = NULL, b3 = NULL, b4 = NULL;
|
2014-07-23 23:37:19 +08:00
|
|
|
|
2016-06-17 20:38:11 +08:00
|
|
|
if (virBitmapParseSeparator("0-3,5-8,11-15f16", 'f', &b1, 20) < 0 ||
|
2016-06-17 20:56:45 +08:00
|
|
|
virBitmapParse("4,9,10,16-19", &b2, 20) < 0 ||
|
|
|
|
virBitmapParse("15", &b3, 20) < 0 ||
|
|
|
|
virBitmapParse("0,^0", &b4, 20) < 0)
|
2015-04-10 17:11:21 +08:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (!virBitmapIsAllClear(b4))
|
2014-07-23 23:37:19 +08:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (virBitmapOverlaps(b1, b2) ||
|
2015-04-10 17:11:21 +08:00
|
|
|
virBitmapOverlaps(b1, b4) ||
|
2014-07-23 23:37:19 +08:00
|
|
|
virBitmapOverlaps(b2, b3) ||
|
2015-04-10 17:11:21 +08:00
|
|
|
virBitmapOverlaps(b2, b4) ||
|
|
|
|
!virBitmapOverlaps(b1, b3) ||
|
|
|
|
virBitmapOverlaps(b3, b4))
|
2014-07-23 23:37:19 +08:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
cleanup:
|
|
|
|
virBitmapFree(b1);
|
|
|
|
virBitmapFree(b2);
|
|
|
|
virBitmapFree(b3);
|
2015-04-15 22:16:36 +08:00
|
|
|
virBitmapFree(b4);
|
2014-07-23 23:37:19 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2016-01-07 22:45:39 +08:00
|
|
|
struct testBinaryOpData {
|
|
|
|
const char *a;
|
|
|
|
const char *b;
|
|
|
|
const char *res;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
test11(const void *opaque)
|
|
|
|
{
|
|
|
|
const struct testBinaryOpData *data = opaque;
|
|
|
|
virBitmapPtr amap = NULL;
|
|
|
|
virBitmapPtr bmap = NULL;
|
|
|
|
virBitmapPtr resmap = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
|
2016-06-17 20:56:45 +08:00
|
|
|
if (virBitmapParse(data->a, &amap, 256) < 0 ||
|
|
|
|
virBitmapParse(data->b, &bmap, 256) < 0 ||
|
|
|
|
virBitmapParse(data->res, &resmap, 256) < 0)
|
2016-01-07 22:45:39 +08:00
|
|
|
goto cleanup;
|
|
|
|
|
2017-07-12 19:30:47 +08:00
|
|
|
virBitmapIntersect(amap, bmap);
|
2016-01-07 22:45:39 +08:00
|
|
|
|
|
|
|
if (!virBitmapEqual(amap, resmap)) {
|
2017-07-12 19:30:47 +08:00
|
|
|
fprintf(stderr,
|
|
|
|
"\n bitmap intersection failed: intersect('%s','%s') !='%s'\n",
|
2016-01-07 22:45:39 +08:00
|
|
|
data->a, data->b, data->res);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virBitmapFree(amap);
|
|
|
|
virBitmapFree(bmap);
|
|
|
|
virBitmapFree(resmap);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-11-03 20:09:47 +08:00
|
|
|
#define TEST_MAP(sz, expect) \
|
|
|
|
do { \
|
|
|
|
char *actual; \
|
|
|
|
if (virBitmapSize(map) != sz) { \
|
|
|
|
fprintf(stderr, "\n expected bitmap size: '%d' actual size: " \
|
|
|
|
"'%zu'\n", sz, virBitmapSize(map)); \
|
|
|
|
goto cleanup; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
actual = virBitmapFormat(map); \
|
|
|
|
\
|
|
|
|
if (STRNEQ_NULLABLE(expect, actual)) { \
|
2016-03-18 22:41:59 +08:00
|
|
|
fprintf(stderr, "\n expected bitmap contents '%s' actual contents "\
|
2017-11-03 20:09:47 +08:00
|
|
|
"'%s'\n", NULLSTR(expect), NULLSTR(actual)); \
|
|
|
|
VIR_FREE(actual); \
|
|
|
|
goto cleanup; \
|
|
|
|
} \
|
|
|
|
VIR_FREE(actual); \
|
2016-03-18 22:41:59 +08:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
/* test self-expanding bitmap APIs */
|
|
|
|
static int
|
2019-10-14 20:45:03 +08:00
|
|
|
test12(const void *opaque G_GNUC_UNUSED)
|
2016-03-18 22:41:59 +08:00
|
|
|
{
|
|
|
|
virBitmapPtr map = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
if (!(map = virBitmapNewEmpty()))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
TEST_MAP(0, "");
|
|
|
|
|
2017-01-30 20:52:02 +08:00
|
|
|
if (virBitmapSetBitExpand(map, 128) < 0)
|
2016-03-18 22:41:59 +08:00
|
|
|
goto cleanup;
|
|
|
|
|
2017-01-30 20:52:02 +08:00
|
|
|
TEST_MAP(129, "128");
|
2016-03-18 22:41:59 +08:00
|
|
|
|
|
|
|
if (virBitmapClearBitExpand(map, 150) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2017-01-30 20:52:02 +08:00
|
|
|
TEST_MAP(151, "128");
|
2016-03-18 22:41:59 +08:00
|
|
|
|
2016-06-17 21:12:02 +08:00
|
|
|
virBitmapFree(map);
|
2017-03-22 21:39:53 +08:00
|
|
|
if (!(map = virBitmapParseUnlimited("34,1023")))
|
2016-06-17 21:12:02 +08:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
TEST_MAP(1024, "34,1023");
|
|
|
|
|
2018-02-05 20:50:44 +08:00
|
|
|
virBitmapShrink(map, 35);
|
2018-02-01 21:33:02 +08:00
|
|
|
TEST_MAP(35, "34");
|
|
|
|
|
2018-02-05 20:50:44 +08:00
|
|
|
virBitmapShrink(map, 34);
|
2018-02-01 21:33:02 +08:00
|
|
|
TEST_MAP(34, "");
|
|
|
|
|
2016-03-18 22:41:59 +08:00
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virBitmapFree(map);
|
|
|
|
return ret;
|
|
|
|
}
|
2016-06-17 21:12:02 +08:00
|
|
|
|
2017-08-23 15:12:10 +08:00
|
|
|
|
|
|
|
/* virBitmap(New/To)String */
|
|
|
|
static int
|
2019-10-14 20:45:03 +08:00
|
|
|
test13(const void *opaque G_GNUC_UNUSED)
|
2017-08-23 15:12:10 +08:00
|
|
|
{
|
|
|
|
virBitmapPtr map = NULL;
|
|
|
|
const char *strings[] = { "1234feebee", "000c0fefe" };
|
|
|
|
char *str = NULL;
|
|
|
|
size_t i = 0;
|
|
|
|
int ret = -1;
|
|
|
|
|
2019-10-15 19:55:26 +08:00
|
|
|
for (i = 0; i < G_N_ELEMENTS(strings); i++) {
|
2017-08-23 15:12:10 +08:00
|
|
|
map = virBitmapNewString(strings[i]);
|
2019-11-03 20:55:21 +08:00
|
|
|
if (!map)
|
|
|
|
goto cleanup;
|
2017-08-23 15:12:10 +08:00
|
|
|
|
2019-11-03 20:55:21 +08:00
|
|
|
str = virBitmapToString(map, false, true);
|
|
|
|
if (!str)
|
2017-08-23 15:12:10 +08:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (STRNEQ(strings[i], str)) {
|
|
|
|
fprintf(stderr, "\n expected bitmap string '%s' actual string "
|
|
|
|
"'%s'\n", strings[i], str);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
VIR_FREE(str);
|
|
|
|
virBitmapFree(map);
|
|
|
|
map = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
cleanup:
|
|
|
|
VIR_FREE(str);
|
|
|
|
virBitmapFree(map);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2016-03-18 22:41:59 +08:00
|
|
|
#undef TEST_MAP
|
|
|
|
|
2017-10-05 21:09:30 +08:00
|
|
|
static int
|
|
|
|
test14(const void *opaque)
|
|
|
|
{
|
|
|
|
const struct testBinaryOpData *data = opaque;
|
|
|
|
virBitmapPtr amap = NULL;
|
|
|
|
virBitmapPtr bmap = NULL;
|
|
|
|
virBitmapPtr resmap = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
if (virBitmapParse(data->a, &amap, 256) < 0 ||
|
|
|
|
virBitmapParse(data->b, &bmap, 256) < 0 ||
|
|
|
|
virBitmapParse(data->res, &resmap, 256) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
virBitmapSubtract(amap, bmap);
|
|
|
|
|
|
|
|
if (!virBitmapEqual(amap, resmap)) {
|
|
|
|
fprintf(stderr,
|
|
|
|
"\n bitmap subtraction failed: '%s' - '%s' != '%s'\n",
|
|
|
|
data->a, data->b, data->res);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virBitmapFree(amap);
|
|
|
|
virBitmapFree(bmap);
|
|
|
|
virBitmapFree(resmap);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-05-31 01:08:28 +08:00
|
|
|
/* virBitmapUnion() */
|
|
|
|
static int
|
|
|
|
test15(const void *opaque)
|
|
|
|
{
|
|
|
|
const struct testBinaryOpData *data = opaque;
|
2019-10-15 20:47:50 +08:00
|
|
|
g_autoptr(virBitmap) amap = NULL;
|
|
|
|
g_autoptr(virBitmap) bmap = NULL;
|
|
|
|
g_autoptr(virBitmap) resmap = NULL;
|
2019-05-31 01:08:28 +08:00
|
|
|
|
|
|
|
if (!(amap = virBitmapParseUnlimited(data->a)) ||
|
|
|
|
!(bmap = virBitmapParseUnlimited(data->b)) ||
|
|
|
|
!(resmap = virBitmapParseUnlimited(data->res))) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (virBitmapUnion(amap, bmap) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (!virBitmapEqual(amap, resmap)) {
|
|
|
|
fprintf(stderr,
|
|
|
|
"\n bitmap union failed: union('%s', '%s') != '%s'\n",
|
|
|
|
data->a, data->b, data->res);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-03-18 22:41:59 +08:00
|
|
|
|
2017-11-03 20:09:47 +08:00
|
|
|
#define TESTBINARYOP(A, B, RES, FUNC) \
|
|
|
|
testBinaryOpData.a = A; \
|
|
|
|
testBinaryOpData.b = B; \
|
|
|
|
testBinaryOpData.res = RES; \
|
|
|
|
if (virTestRun(virTestCounterNext(), FUNC, &testBinaryOpData) < 0) \
|
2016-01-07 22:45:39 +08:00
|
|
|
ret = -1;
|
|
|
|
|
2012-09-14 15:46:57 +08:00
|
|
|
static int
|
|
|
|
mymain(void)
|
|
|
|
{
|
2016-01-07 22:45:39 +08:00
|
|
|
struct testBinaryOpData testBinaryOpData;
|
2012-09-14 15:46:57 +08:00
|
|
|
int ret = 0;
|
|
|
|
|
2016-05-26 23:01:50 +08:00
|
|
|
if (virTestRun("test1", test1, NULL) < 0)
|
2012-09-14 15:46:57 +08:00
|
|
|
ret = -1;
|
2016-05-26 23:01:50 +08:00
|
|
|
if (virTestRun("test2", test2, NULL) < 0)
|
2012-09-14 15:46:57 +08:00
|
|
|
ret = -1;
|
2016-05-26 23:01:50 +08:00
|
|
|
if (virTestRun("test3", test3, NULL) < 0)
|
2012-09-14 15:46:57 +08:00
|
|
|
ret = -1;
|
2016-05-26 23:01:50 +08:00
|
|
|
if (virTestRun("test4", test4, NULL) < 0)
|
2012-09-14 15:46:57 +08:00
|
|
|
ret = -1;
|
2016-05-26 23:01:50 +08:00
|
|
|
if (virTestRun("test5", test5, NULL) < 0)
|
2012-09-14 15:46:57 +08:00
|
|
|
ret = -1;
|
2016-05-26 23:01:50 +08:00
|
|
|
if (virTestRun("test6", test6, NULL) < 0)
|
2012-09-14 15:46:57 +08:00
|
|
|
ret = -1;
|
2016-05-26 23:01:50 +08:00
|
|
|
if (virTestRun("test7", test7, NULL) < 0)
|
2012-11-28 14:15:38 +08:00
|
|
|
ret = -1;
|
2016-05-26 23:01:50 +08:00
|
|
|
if (virTestRun("test8", test8, NULL) < 0)
|
2013-04-06 02:06:16 +08:00
|
|
|
ret = -1;
|
2016-05-26 23:01:50 +08:00
|
|
|
if (virTestRun("test9", test9, NULL) < 0)
|
2013-08-16 18:13:27 +08:00
|
|
|
ret = -1;
|
2016-05-26 23:01:50 +08:00
|
|
|
if (virTestRun("test10", test10, NULL) < 0)
|
2014-07-23 23:37:19 +08:00
|
|
|
ret = -1;
|
2012-09-14 15:46:57 +08:00
|
|
|
|
2016-05-26 23:01:57 +08:00
|
|
|
virTestCounterReset("test11-");
|
2017-07-12 19:30:47 +08:00
|
|
|
TESTBINARYOP("0", "0", "0", test11);
|
|
|
|
TESTBINARYOP("0-3", "0", "0", test11);
|
|
|
|
TESTBINARYOP("0-3", "0,3", "0,3", test11);
|
2016-01-07 22:45:39 +08:00
|
|
|
TESTBINARYOP("0,^0", "0", "0,^0", test11);
|
2017-07-12 19:30:47 +08:00
|
|
|
TESTBINARYOP("0-3", "0-3", "0-3", test11);
|
|
|
|
TESTBINARYOP("0-3", "0,^0", "0,^0", test11);
|
|
|
|
TESTBINARYOP("0,2", "1,3", "0,^0", test11);
|
2016-01-07 22:45:39 +08:00
|
|
|
|
2016-05-26 23:01:50 +08:00
|
|
|
if (virTestRun("test12", test12, NULL) < 0)
|
2016-03-18 22:41:59 +08:00
|
|
|
ret = -1;
|
2017-08-23 15:12:10 +08:00
|
|
|
if (virTestRun("test13", test13, NULL) < 0)
|
|
|
|
ret = -1;
|
2016-03-18 22:41:59 +08:00
|
|
|
|
2017-10-05 21:09:30 +08:00
|
|
|
virTestCounterReset("test14-");
|
|
|
|
TESTBINARYOP("0", "0", "0,^0", test14);
|
|
|
|
TESTBINARYOP("0-3", "0", "1-3", test14);
|
|
|
|
TESTBINARYOP("0-3", "0,3", "1-2", test14);
|
|
|
|
TESTBINARYOP("0,^0", "0", "0,^0", test14);
|
|
|
|
TESTBINARYOP("0-3", "0-3", "0,^0", test14);
|
|
|
|
TESTBINARYOP("0-3", "0,^0", "0-3", test14);
|
|
|
|
TESTBINARYOP("0,2", "1,3", "0,2", test14);
|
|
|
|
|
2019-05-31 01:08:28 +08:00
|
|
|
/* virBitmapUnion() */
|
|
|
|
virTestCounterReset("test15-");
|
|
|
|
TESTBINARYOP("0-1", "0-1", "0-1", test15);
|
|
|
|
TESTBINARYOP("0", "1", "0-1", test15);
|
|
|
|
TESTBINARYOP("0-1", "2-3", "0-3", test15);
|
|
|
|
TESTBINARYOP("0-3", "1-2", "0-3", test15);
|
|
|
|
TESTBINARYOP("0,^0", "12345", "12345", test15);
|
|
|
|
TESTBINARYOP("12345", "0,^0", "12345", test15);
|
|
|
|
TESTBINARYOP("0,^0", "0,^0", "0,^0", test15);
|
|
|
|
|
2012-09-14 15:46:57 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-03-29 22:45:42 +08:00
|
|
|
VIR_TEST_MAIN(mymain)
|