xref: /openbmc/qemu/tests/qtest/display-vga-test.c (revision 387b2b52558bbb44ad74634415e1ab488d3c62a7)
11e8a1faeSThomas Huth /*
21e8a1faeSThomas Huth  * QTest testcase for vga cards
31e8a1faeSThomas Huth  *
41e8a1faeSThomas Huth  * Copyright (c) 2014 Red Hat, Inc
51e8a1faeSThomas Huth  *
61e8a1faeSThomas Huth  * This work is licensed under the terms of the GNU GPL, version 2 or later.
71e8a1faeSThomas Huth  * See the COPYING file in the top-level directory.
81e8a1faeSThomas Huth  */
91e8a1faeSThomas Huth 
101e8a1faeSThomas Huth #include "qemu/osdep.h"
11*f2e57851SThomas Huth #include "libqtest.h"
121e8a1faeSThomas Huth 
pci_multihead(void)131e8a1faeSThomas Huth static void pci_multihead(void)
141e8a1faeSThomas Huth {
15*f2e57851SThomas Huth     QTestState *qts;
16*f2e57851SThomas Huth 
17*f2e57851SThomas Huth     qts = qtest_init("-vga none -device VGA -device secondary-vga");
18*f2e57851SThomas Huth     qtest_quit(qts);
191e8a1faeSThomas Huth }
201e8a1faeSThomas Huth 
test_vga(gconstpointer data)21*f2e57851SThomas Huth static void test_vga(gconstpointer data)
221e8a1faeSThomas Huth {
23*f2e57851SThomas Huth     QTestState *qts;
241e8a1faeSThomas Huth 
25*f2e57851SThomas Huth     qts = qtest_initf("-vga none -device %s", (const char *)data);
26*f2e57851SThomas Huth     qtest_quit(qts);
271e8a1faeSThomas Huth }
281e8a1faeSThomas Huth 
main(int argc,char ** argv)291e8a1faeSThomas Huth int main(int argc, char **argv)
301e8a1faeSThomas Huth {
31*f2e57851SThomas Huth     static const char *devices[] = {
32*f2e57851SThomas Huth         "cirrus-vga",
33*f2e57851SThomas Huth         "VGA",
34*f2e57851SThomas Huth         "secondary-vga",
35*f2e57851SThomas Huth         "virtio-gpu-pci",
36*f2e57851SThomas Huth         "virtio-vga"
37*f2e57851SThomas Huth     };
381e8a1faeSThomas Huth 
391e8a1faeSThomas Huth     g_test_init(&argc, &argv, NULL);
401e8a1faeSThomas Huth 
41*f2e57851SThomas Huth     for (int i = 0; i < ARRAY_SIZE(devices); i++) {
42*f2e57851SThomas Huth         if (qtest_has_device(devices[i])) {
43*f2e57851SThomas Huth             char *testpath = g_strdup_printf("/display/pci/%s", devices[i]);
44*f2e57851SThomas Huth             qtest_add_data_func(testpath, devices[i], test_vga);
45*f2e57851SThomas Huth             g_free(testpath);
461e8a1faeSThomas Huth         }
47*f2e57851SThomas Huth     }
48*f2e57851SThomas Huth 
49*f2e57851SThomas Huth     if (qtest_has_device("secondary-vga")) {
501e8a1faeSThomas Huth         qtest_add_func("/display/pci/multihead", pci_multihead);
511e8a1faeSThomas Huth     }
521e8a1faeSThomas Huth 
531e8a1faeSThomas Huth     return g_test_run();
541e8a1faeSThomas Huth }
55