static int mymain(void) { struct metadataTest test; int ret = EXIT_SUCCESS; if (!(test.conn = virConnectOpen("test:///default"))) return EXIT_FAILURE; if (!(test.dom = virDomainLookupByName(test.conn, "test"))) { virConnectClose(test.conn); return EXIT_FAILURE; } virtTestQuiesceLibvirtErrors(false); if (virtTestRun("Assign metadata ", testAssignMetadata, &test) < 0) ret = EXIT_FAILURE; if (virtTestRun("Rewrite Metadata ", testRewriteMetadata, &test) < 0) ret = EXIT_FAILURE; if (virtTestRun("Erase metadata ", testEraseMetadata, &test) < 0) ret = EXIT_FAILURE; virDomainFree(test.dom); virConnectClose(test.conn); return ret; }
static int mymain(void) { char scratchdir[] = SCRATCHDIRTEMPLATE; int ret = 0; const char *iohelper = abs_builddir "/../src/libvirt_iohelper"; virFDStreamSetIOHelper(iohelper); if (!mkdtemp(scratchdir)) { virFilePrintf(stderr, "Cannot create fakesysfsdir"); abort(); } if (virtTestRun("Stream read blocking ", testFDStreamReadBlock, scratchdir) < 0) ret = -1; if (virtTestRun("Stream read non-blocking ", testFDStreamReadNonblock, scratchdir) < 0) ret = -1; if (virtTestRun("Stream write blocking ", testFDStreamWriteBlock, scratchdir) < 0) ret = -1; if (virtTestRun("Stream write non-blocking ", testFDStreamWriteNonblock, scratchdir) < 0) ret = -1; if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL) virFileDeleteTree(scratchdir); return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; }
static int mymain(void) { int ret = 0; if (virtTestRun("Keycode mapping ", testKeycodeMapping, NULL) < 0) ret = -1; if (virtTestRun("Keycode strings ", testKeycodeStrings, NULL) < 0) ret = -1; return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; }
static int cpuTestRun(const char *name, const struct data *data) { char *label = NULL; if (virAsprintf(&label, "CPU %s(%s): %s", apis[data->api], data->arch, name) < 0) return -1; free(virtTestLogContentAndReset()); if (virtTestRun(label, 1, cpuTest[data->api], data) < 0) { if (virTestGetDebug()) { char *log; if ((log = virtTestLogContentAndReset()) && strlen(log) > 0) fprintf(stderr, "\n%s\n", log); free(log); } free(label); return -1; } free(label); return 0; }
static int sysinfotest_run(const char *test, const char *decoder, const char *sysinfo, const char *cpuinfo, const char *expected) { struct testSysinfoData testdata = { NULL }; int ret = EXIT_FAILURE; if ((decoder && virAsprintf(&testdata.decoder, "%s/%s", abs_srcdir, decoder) < 0) || (sysinfo && virAsprintf(&testdata.sysinfo, "%s/%s", abs_srcdir, sysinfo) < 0) || (cpuinfo && virAsprintf(&testdata.cpuinfo, "%s/%s", abs_srcdir, cpuinfo) < 0) || (expected && virAsprintf(&testdata.expected, "%s/%s", abs_srcdir, expected) < 0)) { goto error; } if (virtTestRun(test, testSysinfo, &testdata) < 0) goto error; ret = EXIT_SUCCESS; error: VIR_FREE(testdata.decoder); VIR_FREE(testdata.sysinfo); VIR_FREE(testdata.cpuinfo); VIR_FREE(testdata.expected); return ret; }
static int mymain(void) { int ret = 0; int i; const char *nodeData[] = { "test1", # if !(defined(__powerpc__) || \ defined(__powerpc64__)) "test2", "test3", "test4", "test5", "test6", # endif }; if (virInitialize() < 0) return EXIT_FAILURE; for (i = 0 ; i < ARRAY_CARDINALITY(nodeData); i++) if (virtTestRun(nodeData[i], 1, linuxTestNodeInfo, nodeData[i]) != 0) ret = -1; return ret==0 ? EXIT_SUCCESS : EXIT_FAILURE; }
static int cpuTestRun(const char *name, const struct data *data) { char *label = NULL; char *tmp; if (virAsprintf(&label, "CPU %s(%s): %s", apis[data->api], data->arch, name) < 0) return -1; tmp = virtTestLogContentAndReset(); VIR_FREE(tmp); if (virtTestRun(label, cpuTest[data->api], data) < 0) { if (virTestGetDebug()) { char *log; if ((log = virtTestLogContentAndReset()) && strlen(log) > 0) VIR_TEST_DEBUG("\n%s\n", log); VIR_FREE(log); } VIR_FREE(label); return -1; } VIR_FREE(label); return 0; }
static int mymain(void) { struct metadataTest test; int ret = EXIT_SUCCESS; if (!(test.conn = virConnectOpen("test:///default"))) return EXIT_FAILURE; if (!(test.dom = virDomainLookupByName(test.conn, "test"))) { virConnectClose(test.conn); return EXIT_FAILURE; } virtTestQuiesceLibvirtErrors(false); if (virtTestRun("Assign metadata ", testAssignMetadata, &test) < 0) ret = EXIT_FAILURE; if (virtTestRun("Rewrite Metadata ", testRewriteMetadata, &test) < 0) ret = EXIT_FAILURE; if (virtTestRun("Erase metadata ", testEraseMetadata, &test) < 0) ret = EXIT_FAILURE; TEST_TITLE("1", "qwert"); TEST_TITLE("2", NULL); TEST_TITLE("3", "blah"); TEST_TITLE_FAIL("4", "qwe\nrt"); TEST_TITLE("5", ""); TEST_TITLE_FAIL("6", "qwert\n"); TEST_TITLE_FAIL("7", "\n"); TEST_DESCR("1", "qwert\nqwert"); TEST_DESCR("2", NULL); TEST_DESCR("3", "qwert"); TEST_DESCR("4", "\n"); TEST_DESCR("5", ""); virDomainFree(test.dom); virConnectClose(test.conn); return ret; }
static int mymain(void) { int ret = 0; char *filedata = NULL; char *filename = NULL; size_t i; size_t *params = NULL; if (virAsprintf(&filename, "%s/../daemon/libvirtd.conf", abs_srcdir) < 0) { perror("Format filename"); return EXIT_FAILURE; } if (virFileReadAll(filename, 1024*1024, &filedata) < 0) { virErrorPtr err = virGetLastError(); fprintf(stderr, "Cannot load %s for testing: %s", filename, err->message); ret = -1; goto cleanup; } if (uncomment_all_params(filedata, ¶ms) < 0) { perror("Find params"); ret = -1; goto cleanup; } VIR_DEBUG("Initial config [%s]", filedata); for (i = 0; params[i] != 0; i++) { const struct testCorruptData data = { params, filedata, filename, i }; /* Skip now ignored config param */ if (STRPREFIX(filedata + params[i], "log_buffer_size")) continue; if (virtTestRun("Test corruption", testCorrupt, &data) < 0) ret = -1; } cleanup: VIR_FREE(filename); VIR_FREE(filedata); VIR_FREE(params); return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; }
static int mymain(void) { int ret = 0; size_t i; const struct linuxTestNodeInfoData nodeData[] = { {"test1", VIR_ARCH_X86_64}, {"test1", VIR_ARCH_PPC}, {"test2", VIR_ARCH_X86_64}, {"test3", VIR_ARCH_X86_64}, {"test4", VIR_ARCH_X86_64}, {"test5", VIR_ARCH_X86_64}, {"test6", VIR_ARCH_X86_64}, {"test7", VIR_ARCH_X86_64}, {"test8", VIR_ARCH_X86_64}, {"raspberrypi", VIR_ARCH_ARMV6L}, {"f21-mustang", VIR_ARCH_AARCH64}, {"rhelsa-3.19.0-mustang", VIR_ARCH_AARCH64}, {"deconfigured-cpus", VIR_ARCH_PPC64}, }; if (virInitialize() < 0) return EXIT_FAILURE; for (i = 0; i < ARRAY_CARDINALITY(nodeData); i++) if (virtTestRun(nodeData[i].testName, linuxTestNodeInfo, &nodeData[i]) != 0) ret = -1; # define DO_TEST_CPU_STATS(name, ncpus) \ do { \ static struct nodeCPUStatsData data = { name, ncpus }; \ if (virtTestRun("CPU stats " name, linuxTestNodeCPUStats, &data) < 0) \ ret = -1; \ } while (0) DO_TEST_CPU_STATS("24cpu", 24); return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; }