xref: /qemu/tests/qtest/e1000-test.c (revision b167383ffbe995c6d48fbe8ca2bab5eb667e45dc)
1a21baf79SAndreas Färber /*
2a21baf79SAndreas Färber  * QTest testcase for e1000 NIC
3a21baf79SAndreas Färber  *
4a21baf79SAndreas Färber  * Copyright (c) 2013-2014 SUSE LINUX Products GmbH
5a21baf79SAndreas Färber  *
6a21baf79SAndreas Färber  * This work is licensed under the terms of the GNU GPL, version 2 or later.
7a21baf79SAndreas Färber  * See the COPYING file in the top-level directory.
8a21baf79SAndreas Färber  */
9a21baf79SAndreas Färber 
10a21baf79SAndreas Färber #include <glib.h>
11a21baf79SAndreas Färber #include <string.h>
12a21baf79SAndreas Färber #include "libqtest.h"
13a21baf79SAndreas Färber #include "qemu/osdep.h"
14a21baf79SAndreas Färber 
15a21baf79SAndreas Färber /* Tests only initialization so far. TODO: Replace with functional tests */
16*b167383fSGabriel L. Somlo static void test_device(gconstpointer data)
17a21baf79SAndreas Färber {
18*b167383fSGabriel L. Somlo     const char *model = data;
19*b167383fSGabriel L. Somlo     QTestState *s;
20*b167383fSGabriel L. Somlo     char *args;
21*b167383fSGabriel L. Somlo 
22*b167383fSGabriel L. Somlo     args = g_strdup_printf("-device %s", model);
23*b167383fSGabriel L. Somlo     s = qtest_start(args);
24*b167383fSGabriel L. Somlo 
25*b167383fSGabriel L. Somlo     if (s) {
26*b167383fSGabriel L. Somlo         qtest_quit(s);
27a21baf79SAndreas Färber     }
28*b167383fSGabriel L. Somlo     g_free(args);
29*b167383fSGabriel L. Somlo }
30*b167383fSGabriel L. Somlo 
31*b167383fSGabriel L. Somlo static const char *models[] = {
32*b167383fSGabriel L. Somlo     "e1000",
33*b167383fSGabriel L. Somlo     "e1000-82540em",
34*b167383fSGabriel L. Somlo     "e1000-82544gc",
35*b167383fSGabriel L. Somlo     "e1000-82545em",
36*b167383fSGabriel L. Somlo     "e1000-82573l",
37*b167383fSGabriel L. Somlo };
38a21baf79SAndreas Färber 
39a21baf79SAndreas Färber int main(int argc, char **argv)
40a21baf79SAndreas Färber {
41*b167383fSGabriel L. Somlo     int i;
42a21baf79SAndreas Färber 
43a21baf79SAndreas Färber     g_test_init(&argc, &argv, NULL);
44a21baf79SAndreas Färber 
45*b167383fSGabriel L. Somlo     for (i = 0; i < ARRAY_SIZE(models); i++) {
46*b167383fSGabriel L. Somlo         char *path;
47a21baf79SAndreas Färber 
48*b167383fSGabriel L. Somlo         path = g_strdup_printf("/%s/e1000/%s", qtest_get_arch(), models[i]);
49*b167383fSGabriel L. Somlo         g_test_add_data_func(path, models[i], test_device);
50*b167383fSGabriel L. Somlo     }
51a21baf79SAndreas Färber 
52*b167383fSGabriel L. Somlo     return g_test_run();
53a21baf79SAndreas Färber }
54