Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413(a)gmail.com>
---
tests/virstringtest.c | 136 ------------------------------------------
1 file changed, 136 deletions(-)
diff --git a/tests/virstringtest.c b/tests/virstringtest.c
index fc5f9bf937..1f195ab4b9 100644
--- a/tests/virstringtest.c
+++ b/tests/virstringtest.c
@@ -233,136 +233,6 @@ static int testRemove(const void *args)
}
-static bool fail;
-
-static const char *
-testStrdupLookup1(size_t i)
-{
- switch (i) {
- case 0:
- return "hello";
- case 1:
- return NULL;
- default:
- fail = true;
- return "oops";
- }
-}
-
-static size_t
-testStrdupLookup2(size_t i)
-{
- if (i)
- fail = true;
- return 5;
-}
-
-static int
-testStrdup(const void *data G_GNUC_UNUSED)
-{
- char *array[] = { NULL, NULL };
- size_t i = 0;
- size_t j = 0;
- size_t k = 0;
- int ret = -1;
- int value;
-
- value = VIR_STRDUP(array[i++], testStrdupLookup1(j++));
- if (value != 1) {
- virFilePrintf(stderr, "unexpected strdup result %d, expected 1\n",
value);
- goto cleanup;
- }
- /* coverity[dead_error_begin] */
- if (i != 1) {
- virFilePrintf(stderr, "unexpected side effects i=%zu, expected 1\n",
i);
- goto cleanup;
- }
- /* coverity[dead_error_begin] */
- if (j != 1) {
- virFilePrintf(stderr, "unexpected side effects j=%zu, expected 1\n",
j);
- goto cleanup;
- }
- if (STRNEQ_NULLABLE(array[0], "hello") || array[1]) {
- virFilePrintf(stderr, "incorrect array contents '%s'
'%s'\n",
- NULLSTR(array[0]), NULLSTR(array[1]));
- goto cleanup;
- }
-
- value = VIR_STRNDUP(array[i++], testStrdupLookup1(j++),
- testStrdupLookup2(k++));
- if (value != 0) {
- virFilePrintf(stderr, "unexpected strdup result %d, expected 0\n",
value);
- goto cleanup;
- }
- /* coverity[dead_error_begin] */
- if (i != 2) {
- virFilePrintf(stderr, "unexpected side effects i=%zu, expected 2\n",
i);
- goto cleanup;
- }
- /* coverity[dead_error_begin] */
- if (j != 2) {
- virFilePrintf(stderr, "unexpected side effects j=%zu, expected 2\n",
j);
- goto cleanup;
- }
- /* coverity[dead_error_begin] */
- if (k != 1) {
- virFilePrintf(stderr, "unexpected side effects k=%zu, expected 1\n",
k);
- goto cleanup;
- }
- if (STRNEQ_NULLABLE(array[0], "hello") || array[1]) {
- virFilePrintf(stderr, "incorrect array contents '%s'
'%s'\n",
- NULLSTR(array[0]), NULLSTR(array[1]));
- goto cleanup;
- }
-
- if (fail) {
- virFilePrintf(stderr, "side effects failed\n");
- goto cleanup;
- }
-
- ret = 0;
- cleanup:
- for (i = 0; i < G_N_ELEMENTS(array); i++)
- VIR_FREE(array[i]);
- return ret;
-}
-
-static int
-testStrndupNegative(const void *opaque G_GNUC_UNUSED)
-{
- int ret = -1;
- char *dst;
- const char *src = "Hello world";
- int value;
-
- if ((value = VIR_STRNDUP(dst, src, 5)) != 1) {
- fprintf(stderr, "unexpected virStrndup result %d, expected 1\n",
value);
- goto cleanup;
- }
-
- if (STRNEQ_NULLABLE(dst, "Hello")) {
- fprintf(stderr, "unexpected content '%s'", dst);
- goto cleanup;
- }
-
- VIR_FREE(dst);
- if ((value = VIR_STRNDUP(dst, src, -1)) != 1) {
- fprintf(stderr, "unexpected virStrndup result %d, expected 1\n",
value);
- goto cleanup;
- }
-
- if (STRNEQ_NULLABLE(dst, src)) {
- fprintf(stderr, "unexpected content '%s'", dst);
- goto cleanup;
- }
-
- ret = 0;
- cleanup:
- VIR_FREE(dst);
- return ret;
-}
-
-
static int
testStringSortCompare(const void *opaque G_GNUC_UNUSED)
{
@@ -847,12 +717,6 @@ mymain(void)
const char *tokens8[] = { "gluster", "rdma", NULL };
TEST_SPLIT("gluster+rdma", "+", 2, tokens8);
- if (virTestRun("strdup", testStrdup, NULL) < 0)
- ret = -1;
-
- if (virTestRun("strdup", testStrndupNegative, NULL) < 0)
- ret = -1;
-
if (virTestRun("virStringSortCompare", testStringSortCompare, NULL) <
0)
ret = -1;
--
2.21.0