xref: /openbmc/qemu/tests/qtest/display-vga-test.c (revision f2e57851)
1 /*
2  * QTest testcase for vga cards
3  *
4  * Copyright (c) 2014 Red Hat, Inc
5  *
6  * This work is licensed under the terms of the GNU GPL, version 2 or later.
7  * See the COPYING file in the top-level directory.
8  */
9 
10 #include "qemu/osdep.h"
11 #include "libqtest.h"
12 
pci_multihead(void)13 static void pci_multihead(void)
14 {
15     QTestState *qts;
16 
17     qts = qtest_init("-vga none -device VGA -device secondary-vga");
18     qtest_quit(qts);
19 }
20 
test_vga(gconstpointer data)21 static void test_vga(gconstpointer data)
22 {
23     QTestState *qts;
24 
25     qts = qtest_initf("-vga none -device %s", (const char *)data);
26     qtest_quit(qts);
27 }
28 
main(int argc,char ** argv)29 int main(int argc, char **argv)
30 {
31     static const char *devices[] = {
32         "cirrus-vga",
33         "VGA",
34         "secondary-vga",
35         "virtio-gpu-pci",
36         "virtio-vga"
37     };
38 
39     g_test_init(&argc, &argv, NULL);
40 
41     for (int i = 0; i < ARRAY_SIZE(devices); i++) {
42         if (qtest_has_device(devices[i])) {
43             char *testpath = g_strdup_printf("/display/pci/%s", devices[i]);
44             qtest_add_data_func(testpath, devices[i], test_vga);
45             g_free(testpath);
46         }
47     }
48 
49     if (qtest_has_device("secondary-vga")) {
50         qtest_add_func("/display/pci/multihead", pci_multihead);
51     }
52 
53     return g_test_run();
54 }
55