From 83da9832c2798846d2754ae812b9e6739c06c276 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Tue, 22 May 2018 14:00:38 +0200 Subject: [PATCH] tests: Drop qemumonitortest MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We don't use the text monitor since we dropped support for pre-JSON qemus. Drop the test so that we can later delete the text monitor support. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- tests/Makefile.am | 11 +-- tests/qemumonitortest.c | 203 ---------------------------------------- 2 files changed, 2 insertions(+), 212 deletions(-) delete mode 100644 tests/qemumonitortest.c diff --git a/tests/Makefile.am b/tests/Makefile.am index ac92190845..1ce3dbb50f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -282,7 +282,7 @@ endif WITH_LIBXL if WITH_QEMU test_programs += qemuxml2argvtest qemuxml2xmltest \ qemuargv2xmltest domainsnapshotxml2xmltest \ - qemumonitortest qemumonitorjsontest qemuhotplugtest \ + qemumonitorjsontest qemuhotplugtest \ qemuagenttest qemucapabilitiestest qemucaps2xmltest \ qemumemlocktest \ qemucommandutiltest \ @@ -590,13 +590,6 @@ qemuargv2xmltest_SOURCES = \ testutils.c testutils.h qemuargv2xmltest_LDADD = $(qemu_LDADDS) $(LDADDS) -qemumonitortest_SOURCES = \ - qemumonitortest.c \ - testutils.c testutils.h \ - testutilsqemu.c testutilsqemu.h -qemumonitortest_LDADD = libqemumonitortestutils.la \ - $(qemu_LDADDS) $(LDADDS) - qemumonitorjsontest_SOURCES = \ qemumonitorjsontest.c \ testutils.c testutils.h \ @@ -691,7 +684,7 @@ qemumigparamstest_LDADD = libqemumonitortestutils.la \ else ! WITH_QEMU EXTRA_DIST += qemuxml2argvtest.c qemuxml2xmltest.c qemuargv2xmltest.c \ domainsnapshotxml2xmltest.c \ - qemumonitortest.c testutilsqemu.c testutilsqemu.h \ + testutilsqemu.c testutilsqemu.h \ testutilsqemuschema.c testutilsqemuschema.h \ qemumonitorjsontest.c qemuhotplugtest.c \ qemuagenttest.c qemucapabilitiestest.c \ diff --git a/tests/qemumonitortest.c b/tests/qemumonitortest.c deleted file mode 100644 index 0231ce083e..0000000000 --- a/tests/qemumonitortest.c +++ /dev/null @@ -1,203 +0,0 @@ -#include - -#include -#include -#include -#include - -#include "testutils.h" - -#ifdef WITH_QEMU - -# include "internal.h" -# include "viralloc.h" -# include "qemu/qemu_monitor.h" -# include "qemu/qemu_monitor_text.h" -# include "qemumonitortestutils.h" -# include "testutilsqemu.h" - -# define VIR_FROM_THIS VIR_FROM_NONE - -struct testEscapeString -{ - const char *unescaped; - const char *escaped; -}; - -static struct testEscapeString escapeStrings[] = { - { "", "" }, - { " ", " " }, - { "\\", "\\\\" }, - { "\n", "\\n" }, - { "\r", "\\r" }, - { "\"", "\\\"" }, - { "\"\"\"\\\\\n\r\\\\\n\r\"\"\"", "\\\"\\\"\\\"\\\\\\\\\\n\\r\\\\\\\\\\n\\r\\\"\\\"\\\"" }, - { "drive_add dummy file=foo\\", "drive_add dummy file=foo\\\\" }, - { "block info", "block info" }, - { "set_password \":\\\"\"", "set_password \\\":\\\\\\\"\\\"" }, -}; - -static int testEscapeArg(const void *data ATTRIBUTE_UNUSED) -{ - size_t i; - char *escaped = NULL; - for (i = 0; i < ARRAY_CARDINALITY(escapeStrings); ++i) { - escaped = qemuMonitorEscapeArg(escapeStrings[i].unescaped); - if (!escaped) { - VIR_TEST_DEBUG("\nUnescaped string [%s]\n", - escapeStrings[i].unescaped); - VIR_TEST_DEBUG("Expect result [%s]\n", - escapeStrings[i].escaped); - VIR_TEST_DEBUG("Actual result [(null)]\n"); - return -1; - } - if (STRNEQ(escapeStrings[i].escaped, escaped)) { - virTestDifference(stderr, escapeStrings[i].escaped, escaped); - VIR_FREE(escaped); - return -1; - } - VIR_FREE(escaped); - } - - return 0; -} - -static int testUnescapeArg(const void *data ATTRIBUTE_UNUSED) -{ - size_t i; - char *unescaped = NULL; - for (i = 0; i < ARRAY_CARDINALITY(escapeStrings); ++i) { - unescaped = qemuMonitorUnescapeArg(escapeStrings[i].escaped); - if (!unescaped) { - VIR_TEST_DEBUG("\nEscaped string [%s]\n", - escapeStrings[i].escaped); - VIR_TEST_DEBUG("Expect result [%s]\n", - escapeStrings[i].unescaped); - VIR_TEST_DEBUG("Actual result [(null)]\n"); - return -1; - } - if (STRNEQ(escapeStrings[i].unescaped, unescaped)) { - virTestDifference(stderr, escapeStrings[i].unescaped, unescaped); - VIR_FREE(unescaped); - return -1; - } - VIR_FREE(unescaped); - } - - return 0; -} - -struct blockInfoData { - const char *dev; - qemuBlockStats data; -}; - -static const struct blockInfoData testBlockInfoData[] = -{ -/* NAME, rd_req, rd_bytes, wr_req, wr_bytes, rd_total_time, wr_total_time, - * flush_req, flush_total_time, capacity, physical, wr_highest_offset, - * wr_highest_offset_valid*/ - {"vda", {11, 12, 13, 14, 15, 16, 17, 18, 0, 0, 0, false}}, - {"vdb", {21, 22, 23, 24, 25, 26, 27, 28, 0, 0, 0, false}}, - {"vdc", {31, 32, 33, -1, 35, 36, 37, 38, 0, 0, 0, false}}, - {"vdd", {-1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, false}}, - {"vde", {41, 42, 43, 44, 45, 46, 47, 48, 0, 0, 0, false}} -}; - -static const char testBlockInfoReply[] = -"(qemu) info blockstats\r\n" -"vda: rd_operations=11 rd_bytes=12 wr_operations=13 wr_bytes=14 rd_total_time_ns=15 wr_total_time_ns=16 flush_operations=17 flush_total_time_ns=18\n" -"vdb: rd_total_time_ns=25 wr_total_time_ns=26 flush_operations=27 flush_total_time_ns=28 rd_operations=21 rd_bytes=22 wr_operations=23 wr_bytes=24 \n" -"drive-vdc: rd_operations=31 rd_bytes=32 wr_operations=33 rd_total_time_ns=35 wr_total_time_ns=36 flush_operations=37 flush_total_time_ns=38\n" -"vdd: \n" -"vde: rd_operations=41 rd_bytes=42 wr_operations=43 wr_bytes=44 rd_total_time_ns=45 wr_total_time_ns=46 flush_operations=47 flush_total_time_ns=48\n" -"(qemu) "; - -static int -testMonitorTextBlockInfo(const void *opaque) -{ - virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr) opaque; - qemuMonitorTestPtr test = qemuMonitorTestNewSimple(false, xmlopt); - virHashTablePtr blockstats = NULL; - size_t i; - int ret = -1; - - if (!test) - return -1; - - if (!(blockstats = virHashCreate(10, virHashValueFree))) - goto cleanup; - - if (qemuMonitorTestAddItem(test, "info", testBlockInfoReply) < 0) - goto cleanup; - - if (qemuMonitorTextGetAllBlockStatsInfo(qemuMonitorTestGetMonitor(test), - blockstats) < 0) - goto cleanup; - - for (i = 0; i < ARRAY_CARDINALITY(testBlockInfoData); i++) { - qemuBlockStatsPtr entry; - - if (!(entry = virHashLookup(blockstats, testBlockInfoData[i].dev))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "device '%s' was not found in text block stats reply", - testBlockInfoData[i].dev); - goto cleanup; - } - - if (memcmp(entry, &testBlockInfoData[i].data, sizeof(qemuBlockStats)) != 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "block stats for device '%s' differ", - testBlockInfoData[i].dev); - goto cleanup; - } - } - - ret = 0; - - cleanup: - qemuMonitorTestFree(test); - virHashFree(blockstats); - return ret; -} - - -static int -mymain(void) -{ - virQEMUDriver driver; - int result = 0; - - if (virThreadInitialize() < 0 || - qemuTestDriverInit(&driver) < 0) - return EXIT_FAILURE; - - virEventRegisterDefaultImpl(); - -# define DO_TEST(_name) \ - do { \ - if (virTestRun("qemu monitor "#_name, test##_name, \ - driver.xmlopt) < 0) { \ - result = -1; \ - } \ - } while (0) - - DO_TEST(EscapeArg); - DO_TEST(UnescapeArg); - DO_TEST(MonitorTextBlockInfo); - - qemuTestDriverFree(&driver); - - return result == 0 ? EXIT_SUCCESS : EXIT_FAILURE; -} - -VIR_TEST_MAIN(mymain) - -#else - -int main(void) -{ - return EXIT_AM_SKIP; -} - -#endif /* WITH_QEMU */ -- GitLab