From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52858) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFWch-00026l-QH for qemu-devel@nongnu.org; Mon, 17 Feb 2014 17:25:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WFWcb-0005sN-9X for qemu-devel@nongnu.org; Mon, 17 Feb 2014 17:25:11 -0500 Received: from cantor2.suse.de ([195.135.220.15]:41620 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFWca-0005qJ-Vi for qemu-devel@nongnu.org; Mon, 17 Feb 2014 17:25:05 -0500 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Mon, 17 Feb 2014 23:24:15 +0100 Message-Id: <1392675899-21210-6-git-send-email-afaerber@suse.de> In-Reply-To: <1392675899-21210-1-git-send-email-afaerber@suse.de> References: <1392675899-21210-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL v2 05/49] qom-test: Run for all available machines List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Markus Armbruster , =?UTF-8?q?Andreas=20F=C3=A4rber?= From: Markus Armbruster Get available machines via QMP instead of hardcoding a list that's perpetually out of date. Xen machines can work only when running under the Xen hypervisor. Blacklist them. Signed-off-by: Markus Armbruster Signed-off-by: Andreas F=C3=A4rber --- tests/qom-test.c | 274 ++++++++++++-------------------------------------= ------ 1 file changed, 60 insertions(+), 214 deletions(-) diff --git a/tests/qom-test.c b/tests/qom-test.c index 4dd23f8..24cb9c5 100644 --- a/tests/qom-test.c +++ b/tests/qom-test.c @@ -11,6 +11,36 @@ #include #include #include "qemu/osdep.h" +#include "qapi/qmp/types.h" + +static const char *blacklist_x86[] =3D { + "xenfv", "xenpv", NULL +}; + +static const struct { + const char *arch; + const char **machine; +} blacklists[] =3D { + { "i386", blacklist_x86 }, + { "x86_64", blacklist_x86 }, +}; + +static bool is_blacklisted(const char *arch, const char *mach) +{ + int i; + const char **p; + + for (i =3D 0; i < ARRAY_SIZE(blacklists); i++) { + if (!strcmp(blacklists[i].arch, arch)) { + for (p =3D blacklists[i].machine; *p; p++) { + if (!strcmp(*p, mach)) { + return true; + } + } + } + } + return false; +} =20 static void test_nop(gconstpointer data) { @@ -26,227 +56,43 @@ static void test_nop(gconstpointer data) g_free(args); } =20 -static const char *x86_machines[] =3D { - "pc", - "isapc", - "q35", -}; - -static const char *alpha_machines[] =3D { - "clipper", -}; - -static const char *arm_machines[] =3D { - "integratorcp", - "versatilepb", - "versatileab", - "lm3s811evb", - "lm3s6965evb", - "collie", - "akita", - "spitz", - "borzoi", - "terrier", - "tosa", - "cheetah", - "sx1-v1", - "sx1", - "realview-eb", - "realview-eb-mpcore", - "realview-pb-a8", - "realview-pbx-a9", - "musicpal", - "mainstone", - "connex", - "verdex", - "z2", - "n800", - "n810", - "kzm", - "vexpress-a9", - "vexpress-a15", - "smdkc210", - "nuri", - "xilinx-zynq-a9", - "highbank", - "midway", - "canon-a1100", - "cubieboard", -}; - -static const char *cris_machines[] =3D { - "axis-dev88", -}; - -static const char *lm32_machines[] =3D { - "lm32-evr", - "lm32-uclinux", - "milkymist", -}; - -static const char *m68k_machines[] =3D { - "mcf5208evb", - "an5206", - "dummy", -}; - -static const char *microblaze_machines[] =3D { - "petalogix-ml605", - "petalogix-s3adsp1800", -}; - -static const char *mips_machines[] =3D { - "malta", - "magnum", - "mips", - "mipssim", - "pica61", -}; - -static const char *moxie_machines[] =3D { - "moxiesim", -}; - -static const char *openrisc_machines[] =3D { - "or32-sim", -}; - -static const char *ppc_machines[] =3D { - "g3beige", - "mac99", - "prep", - "mpc8544ds", - "ppce500", -}; - -static const char *ppc64_machines[] =3D { - "pseries", -}; - -static const char *ppc405_machines[] =3D { - "ref405ep", - "taihu", -}; - -static const char *ppc440_machines[] =3D { - "bamboo", - "virtex-ml507", -}; - -static const char *s390_machines[] =3D { - "s390-virtio", - "s390-ccw-virtio", -}; - -static const char *superh_machines[] =3D { - "r2d", - "shix", -}; - -static const char *sparc_machines[] =3D { - "SS-4", - "SS-5", - "SS-10", - "SS-20", - "SS-600MP", - "LX", - "SPARCClassic", - "SPARCbook", - "leon3_generic", -}; - -static const char *sparc64_machines[] =3D { - "sun4u", - "sun4v", - "Niagara", -}; - -static const char *unicore32_machines[] =3D { - "puv3", -}; - -static const char *xtensa_machines[] =3D { - "sim", - "lx60", - "lx200", -}; - -static void add_test_cases(const char *arch, const char *machine) +static void add_machine_test_cases(void) { - char *path; - path =3D g_strdup_printf("/%s/qom/%s", arch, machine); - g_test_add_data_func(path, machine, test_nop); + const char *arch =3D qtest_get_arch(); + QDict *response, *minfo; + QList *list; + const QListEntry *p; + QObject *qobj; + QString *qstr; + const char *mname, *path; + + qtest_start("-machine none"); + response =3D qmp("{ 'execute': 'query-machines' }"); + g_assert(response); + list =3D qdict_get_qlist(response, "return"); + g_assert(list); + + for (p =3D qlist_first(list); p; p =3D qlist_next(p)) { + minfo =3D qobject_to_qdict(qlist_entry_obj(p)); + g_assert(minfo); + qobj =3D qdict_get(minfo, "name"); + g_assert(qobj); + qstr =3D qobject_to_qstring(qobj); + g_assert(qstr); + mname =3D qstring_get_str(qstr); + if (!is_blacklisted(arch, mname)) { + path =3D g_strdup_printf("/%s/qom/%s", arch, mname); + g_test_add_data_func(path, mname, test_nop); + } + } + qtest_end(); } =20 -#define ADD_MACHINE_TESTS(arch, array) do { \ - int i; \ - for (i =3D 0; i < ARRAY_SIZE(array); i++) { \ - add_test_cases((arch), (array)[i]); \ - } \ -} while (false) - int main(int argc, char **argv) { - const char *arch =3D qtest_get_arch(); - g_test_init(&argc, &argv, NULL); =20 - add_test_cases(arch, "none"); - - if (strcmp(arch, "i386") =3D=3D 0 || - strcmp(arch, "x86_64") =3D=3D 0) { - ADD_MACHINE_TESTS(arch, x86_machines); - } else if (strcmp(arch, "alpha") =3D=3D 0) { - ADD_MACHINE_TESTS(arch, alpha_machines); - } else if (strcmp(arch, "arm") =3D=3D 0) { - ADD_MACHINE_TESTS(arch, arm_machines); - } else if (strcmp(arch, "cris") =3D=3D 0) { - ADD_MACHINE_TESTS(arch, cris_machines); - } else if (strcmp(arch, "lm32") =3D=3D 0) { - ADD_MACHINE_TESTS(arch, lm32_machines); - } else if (strcmp(arch, "m68k") =3D=3D 0) { - ADD_MACHINE_TESTS(arch, m68k_machines); - } else if (strcmp(arch, "microblaze") =3D=3D 0 || - strcmp(arch, "microblazeel") =3D=3D 0) { - ADD_MACHINE_TESTS(arch, microblaze_machines); - } else if (strcmp(arch, "mips") =3D=3D 0 || - strcmp(arch, "mipsel") =3D=3D 0 || - strcmp(arch, "mips64") =3D=3D 0) { - ADD_MACHINE_TESTS(arch, mips_machines); - } else if (strcmp(arch, "mips64el") =3D=3D 0) { - ADD_MACHINE_TESTS(arch, mips_machines); - add_test_cases(arch, "fulong2e"); - } else if (strcmp(arch, "moxie") =3D=3D 0) { - ADD_MACHINE_TESTS(arch, moxie_machines); - } else if (strcmp(arch, "or32") =3D=3D 0) { - ADD_MACHINE_TESTS(arch, openrisc_machines); - } else if (strcmp(arch, "ppcemb") =3D=3D 0) { - ADD_MACHINE_TESTS(arch, ppc405_machines); - ADD_MACHINE_TESTS(arch, ppc440_machines); - } else if (strcmp(arch, "ppc") =3D=3D 0) { - ADD_MACHINE_TESTS(arch, ppc405_machines); - ADD_MACHINE_TESTS(arch, ppc440_machines); - ADD_MACHINE_TESTS(arch, ppc_machines); - } else if (strcmp(arch, "ppc64") =3D=3D 0) { - ADD_MACHINE_TESTS(arch, ppc405_machines); - ADD_MACHINE_TESTS(arch, ppc440_machines); - ADD_MACHINE_TESTS(arch, ppc_machines); - ADD_MACHINE_TESTS(arch, ppc64_machines); - } else if (strcmp(arch, "s390x") =3D=3D 0) { - ADD_MACHINE_TESTS(arch, s390_machines); - } else if (strcmp(arch, "sh4") =3D=3D 0 || - strcmp(arch, "sh4eb") =3D=3D 0) { - ADD_MACHINE_TESTS(arch, superh_machines); - } else if (strcmp(arch, "sparc") =3D=3D 0) { - ADD_MACHINE_TESTS(arch, sparc_machines); - } else if (strcmp(arch, "sparc64") =3D=3D 0) { - ADD_MACHINE_TESTS(arch, sparc64_machines); - } else if (strcmp(arch, "unicore32") =3D=3D 0) { - ADD_MACHINE_TESTS(arch, unicore32_machines); - } else if (strcmp(arch, "xtensa") =3D=3D 0 || - strcmp(arch, "xtensaeb") =3D=3D 0) { - ADD_MACHINE_TESTS(arch, xtensa_machines); - } + add_machine_test_cases(); =20 return g_test_run(); } --=20 1.8.4.5