1da668aa1SThomas Huth /*
2da668aa1SThomas Huth * libqos driver framework
3da668aa1SThomas Huth *
4da668aa1SThomas Huth * Copyright (c) 2018 Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com>
5da668aa1SThomas Huth *
6da668aa1SThomas Huth * This library is free software; you can redistribute it and/or
7da668aa1SThomas Huth * modify it under the terms of the GNU Lesser General Public
8da668aa1SThomas Huth * License version 2.1 as published by the Free Software Foundation.
9da668aa1SThomas Huth *
10da668aa1SThomas Huth * This library is distributed in the hope that it will be useful,
11da668aa1SThomas Huth * but WITHOUT ANY WARRANTY; without even the implied warranty of
12da668aa1SThomas Huth * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13da668aa1SThomas Huth * Lesser General Public License for more details.
14da668aa1SThomas Huth *
15da668aa1SThomas Huth * You should have received a copy of the GNU Lesser General Public
16da668aa1SThomas Huth * License along with this library; if not, see <http://www.gnu.org/licenses/>
17da668aa1SThomas Huth */
18da668aa1SThomas Huth
19da668aa1SThomas Huth #include "qemu/osdep.h"
20da668aa1SThomas Huth #include "../qtest/libqos/qgraph.h"
21da668aa1SThomas Huth #include "../qtest/libqos/qgraph_internal.h"
22da668aa1SThomas Huth
23da668aa1SThomas Huth #define MACHINE_PC "x86_64/pc"
24*cd066eeaSPhilippe Mathieu-Daudé #define MACHINE_RASPI2 "arm/raspi2b"
25da668aa1SThomas Huth #define I440FX "i440FX-pcihost"
26da668aa1SThomas Huth #define PCIBUS_PC "pcibus-pc"
27da668aa1SThomas Huth #define SDHCI "sdhci"
28da668aa1SThomas Huth #define PCIBUS "pci-bus"
29da668aa1SThomas Huth #define SDHCI_PCI "sdhci-pci"
30da668aa1SThomas Huth #define SDHCI_MM "generic-sdhci"
31da668aa1SThomas Huth #define REGISTER_TEST "register-test"
32da668aa1SThomas Huth
33da668aa1SThomas Huth int npath;
34da668aa1SThomas Huth
machinefunct(QTestState * qts)35da668aa1SThomas Huth static void *machinefunct(QTestState *qts)
36da668aa1SThomas Huth {
37da668aa1SThomas Huth return NULL;
38da668aa1SThomas Huth }
39da668aa1SThomas Huth
driverfunct(void * obj,QGuestAllocator * machine,void * arg)40da668aa1SThomas Huth static void *driverfunct(void *obj, QGuestAllocator *machine, void *arg)
41da668aa1SThomas Huth {
42da668aa1SThomas Huth return NULL;
43da668aa1SThomas Huth }
44da668aa1SThomas Huth
testfunct(void * obj,void * arg,QGuestAllocator * alloc)45da668aa1SThomas Huth static void testfunct(void *obj, void *arg, QGuestAllocator *alloc)
46da668aa1SThomas Huth {
47da668aa1SThomas Huth return;
48da668aa1SThomas Huth }
49da668aa1SThomas Huth
check_interface(const char * interface)50da668aa1SThomas Huth static void check_interface(const char *interface)
51da668aa1SThomas Huth {
52da668aa1SThomas Huth g_assert_cmpint(qos_graph_has_machine(interface), ==, FALSE);
53da668aa1SThomas Huth g_assert_nonnull(qos_graph_get_node(interface));
54da668aa1SThomas Huth g_assert_cmpint(qos_graph_has_node(interface), ==, TRUE);
55da668aa1SThomas Huth g_assert_cmpint(qos_graph_get_node_type(interface), ==, QNODE_INTERFACE);
56da668aa1SThomas Huth qos_graph_node_set_availability(interface, TRUE);
57da668aa1SThomas Huth g_assert_cmpint(qos_graph_get_node_availability(interface), ==, TRUE);
58da668aa1SThomas Huth }
59da668aa1SThomas Huth
check_machine(const char * machine)60da668aa1SThomas Huth static void check_machine(const char *machine)
61da668aa1SThomas Huth {
62da668aa1SThomas Huth qos_node_create_machine(machine, machinefunct);
63da668aa1SThomas Huth g_assert_nonnull(qos_graph_get_machine(machine));
64da668aa1SThomas Huth g_assert_cmpint(qos_graph_has_machine(machine), ==, TRUE);
65da668aa1SThomas Huth g_assert_nonnull(qos_graph_get_node(machine));
66da668aa1SThomas Huth g_assert_cmpint(qos_graph_get_node_availability(machine), ==, FALSE);
67da668aa1SThomas Huth qos_graph_node_set_availability(machine, TRUE);
68da668aa1SThomas Huth g_assert_cmpint(qos_graph_get_node_availability(machine), ==, TRUE);
69da668aa1SThomas Huth g_assert_cmpint(qos_graph_has_node(machine), ==, TRUE);
70da668aa1SThomas Huth g_assert_cmpint(qos_graph_get_node_type(machine), ==, QNODE_MACHINE);
71da668aa1SThomas Huth }
72da668aa1SThomas Huth
check_contains(const char * machine,const char * driver)73da668aa1SThomas Huth static void check_contains(const char *machine, const char *driver)
74da668aa1SThomas Huth {
75da668aa1SThomas Huth QOSGraphEdge *edge;
76da668aa1SThomas Huth qos_node_contains(machine, driver, NULL);
77da668aa1SThomas Huth
78da668aa1SThomas Huth edge = qos_graph_get_edge(machine, driver);
79da668aa1SThomas Huth g_assert_nonnull(edge);
80da668aa1SThomas Huth g_assert_cmpint(qos_graph_edge_get_type(edge), ==, QEDGE_CONTAINS);
81da668aa1SThomas Huth g_assert_cmpint(qos_graph_has_edge(machine, driver), ==, TRUE);
82da668aa1SThomas Huth }
83da668aa1SThomas Huth
check_produces(const char * machine,const char * interface)84da668aa1SThomas Huth static void check_produces(const char *machine, const char *interface)
85da668aa1SThomas Huth {
86da668aa1SThomas Huth QOSGraphEdge *edge;
87da668aa1SThomas Huth
88da668aa1SThomas Huth qos_node_produces(machine, interface);
89da668aa1SThomas Huth check_interface(interface);
90da668aa1SThomas Huth edge = qos_graph_get_edge(machine, interface);
91da668aa1SThomas Huth g_assert_nonnull(edge);
92da668aa1SThomas Huth g_assert_cmpint(qos_graph_edge_get_type(edge), ==,
93da668aa1SThomas Huth QEDGE_PRODUCES);
94da668aa1SThomas Huth g_assert_cmpint(qos_graph_has_edge(machine, interface), ==, TRUE);
95da668aa1SThomas Huth }
96da668aa1SThomas Huth
check_consumes(const char * driver,const char * interface)97da668aa1SThomas Huth static void check_consumes(const char *driver, const char *interface)
98da668aa1SThomas Huth {
99da668aa1SThomas Huth QOSGraphEdge *edge;
100da668aa1SThomas Huth
101da668aa1SThomas Huth qos_node_consumes(driver, interface, NULL);
102da668aa1SThomas Huth check_interface(interface);
103da668aa1SThomas Huth edge = qos_graph_get_edge(interface, driver);
104da668aa1SThomas Huth g_assert_nonnull(edge);
105da668aa1SThomas Huth g_assert_cmpint(qos_graph_edge_get_type(edge), ==, QEDGE_CONSUMED_BY);
106da668aa1SThomas Huth g_assert_cmpint(qos_graph_has_edge(interface, driver), ==, TRUE);
107da668aa1SThomas Huth }
108da668aa1SThomas Huth
check_driver(const char * driver)109da668aa1SThomas Huth static void check_driver(const char *driver)
110da668aa1SThomas Huth {
111da668aa1SThomas Huth qos_node_create_driver(driver, driverfunct);
112da668aa1SThomas Huth g_assert_cmpint(qos_graph_has_machine(driver), ==, FALSE);
113da668aa1SThomas Huth g_assert_nonnull(qos_graph_get_node(driver));
114da668aa1SThomas Huth g_assert_cmpint(qos_graph_has_node(driver), ==, TRUE);
115da668aa1SThomas Huth g_assert_cmpint(qos_graph_get_node_type(driver), ==, QNODE_DRIVER);
116da668aa1SThomas Huth g_assert_cmpint(qos_graph_get_node_availability(driver), ==, FALSE);
117da668aa1SThomas Huth qos_graph_node_set_availability(driver, TRUE);
118da668aa1SThomas Huth g_assert_cmpint(qos_graph_get_node_availability(driver), ==, TRUE);
119da668aa1SThomas Huth }
120da668aa1SThomas Huth
check_test(const char * test,const char * interface)121da668aa1SThomas Huth static void check_test(const char *test, const char *interface)
122da668aa1SThomas Huth {
123da668aa1SThomas Huth QOSGraphEdge *edge;
124da668aa1SThomas Huth char *full_name = g_strdup_printf("%s-tests/%s", interface, test);
125da668aa1SThomas Huth
126da668aa1SThomas Huth qos_add_test(test, interface, testfunct, NULL);
127da668aa1SThomas Huth g_assert_cmpint(qos_graph_has_machine(test), ==, FALSE);
128da668aa1SThomas Huth g_assert_cmpint(qos_graph_has_machine(full_name), ==, FALSE);
129da668aa1SThomas Huth g_assert_nonnull(qos_graph_get_node(full_name));
130da668aa1SThomas Huth g_assert_cmpint(qos_graph_has_node(full_name), ==, TRUE);
131da668aa1SThomas Huth g_assert_cmpint(qos_graph_get_node_type(full_name), ==, QNODE_TEST);
132da668aa1SThomas Huth edge = qos_graph_get_edge(interface, full_name);
133da668aa1SThomas Huth g_assert_nonnull(edge);
134da668aa1SThomas Huth g_assert_cmpint(qos_graph_edge_get_type(edge), ==,
135da668aa1SThomas Huth QEDGE_CONSUMED_BY);
136da668aa1SThomas Huth g_assert_cmpint(qos_graph_has_edge(interface, full_name), ==, TRUE);
137da668aa1SThomas Huth g_assert_cmpint(qos_graph_get_node_availability(full_name), ==, TRUE);
138da668aa1SThomas Huth qos_graph_node_set_availability(full_name, FALSE);
139da668aa1SThomas Huth g_assert_cmpint(qos_graph_get_node_availability(full_name), ==, FALSE);
140da668aa1SThomas Huth g_free(full_name);
141da668aa1SThomas Huth }
142da668aa1SThomas Huth
count_each_test(QOSGraphNode * path,int len)143da668aa1SThomas Huth static void count_each_test(QOSGraphNode *path, int len)
144da668aa1SThomas Huth {
145da668aa1SThomas Huth npath++;
146da668aa1SThomas Huth }
147da668aa1SThomas Huth
check_leaf_discovered(int n)148da668aa1SThomas Huth static void check_leaf_discovered(int n)
149da668aa1SThomas Huth {
150da668aa1SThomas Huth npath = 0;
151da668aa1SThomas Huth qos_graph_foreach_test_path(count_each_test);
152da668aa1SThomas Huth g_assert_cmpint(n, ==, npath);
153da668aa1SThomas Huth }
154da668aa1SThomas Huth
155da668aa1SThomas Huth /* G_Test functions */
156da668aa1SThomas Huth
init_nop(void)157da668aa1SThomas Huth static void init_nop(void)
158da668aa1SThomas Huth {
159da668aa1SThomas Huth qos_graph_init();
160da668aa1SThomas Huth qos_graph_destroy();
161da668aa1SThomas Huth }
162da668aa1SThomas Huth
test_machine(void)163da668aa1SThomas Huth static void test_machine(void)
164da668aa1SThomas Huth {
165da668aa1SThomas Huth qos_graph_init();
166da668aa1SThomas Huth check_machine(MACHINE_PC);
167da668aa1SThomas Huth qos_graph_destroy();
168da668aa1SThomas Huth }
169da668aa1SThomas Huth
test_contains(void)170da668aa1SThomas Huth static void test_contains(void)
171da668aa1SThomas Huth {
172da668aa1SThomas Huth qos_graph_init();
173da668aa1SThomas Huth check_contains(MACHINE_PC, I440FX);
174da668aa1SThomas Huth g_assert_null(qos_graph_get_machine(MACHINE_PC));
175da668aa1SThomas Huth g_assert_null(qos_graph_get_machine(I440FX));
176da668aa1SThomas Huth g_assert_null(qos_graph_get_node(MACHINE_PC));
177da668aa1SThomas Huth g_assert_null(qos_graph_get_node(I440FX));
178da668aa1SThomas Huth qos_graph_destroy();
179da668aa1SThomas Huth }
180da668aa1SThomas Huth
test_multiple_contains(void)181da668aa1SThomas Huth static void test_multiple_contains(void)
182da668aa1SThomas Huth {
183da668aa1SThomas Huth qos_graph_init();
184da668aa1SThomas Huth check_contains(MACHINE_PC, I440FX);
185da668aa1SThomas Huth check_contains(MACHINE_PC, PCIBUS_PC);
186da668aa1SThomas Huth qos_graph_destroy();
187da668aa1SThomas Huth }
188da668aa1SThomas Huth
test_produces(void)189da668aa1SThomas Huth static void test_produces(void)
190da668aa1SThomas Huth {
191da668aa1SThomas Huth qos_graph_init();
192da668aa1SThomas Huth check_produces(MACHINE_PC, I440FX);
193da668aa1SThomas Huth g_assert_null(qos_graph_get_machine(MACHINE_PC));
194da668aa1SThomas Huth g_assert_null(qos_graph_get_machine(I440FX));
195da668aa1SThomas Huth g_assert_null(qos_graph_get_node(MACHINE_PC));
196da668aa1SThomas Huth g_assert_nonnull(qos_graph_get_node(I440FX));
197da668aa1SThomas Huth qos_graph_destroy();
198da668aa1SThomas Huth }
199da668aa1SThomas Huth
test_multiple_produces(void)200da668aa1SThomas Huth static void test_multiple_produces(void)
201da668aa1SThomas Huth {
202da668aa1SThomas Huth qos_graph_init();
203da668aa1SThomas Huth check_produces(MACHINE_PC, I440FX);
204da668aa1SThomas Huth check_produces(MACHINE_PC, PCIBUS_PC);
205da668aa1SThomas Huth qos_graph_destroy();
206da668aa1SThomas Huth }
207da668aa1SThomas Huth
test_consumes(void)208da668aa1SThomas Huth static void test_consumes(void)
209da668aa1SThomas Huth {
210da668aa1SThomas Huth qos_graph_init();
211da668aa1SThomas Huth check_consumes(I440FX, SDHCI);
212da668aa1SThomas Huth g_assert_null(qos_graph_get_machine(I440FX));
213da668aa1SThomas Huth g_assert_null(qos_graph_get_machine(SDHCI));
214da668aa1SThomas Huth g_assert_null(qos_graph_get_node(I440FX));
215da668aa1SThomas Huth g_assert_nonnull(qos_graph_get_node(SDHCI));
216da668aa1SThomas Huth qos_graph_destroy();
217da668aa1SThomas Huth }
218da668aa1SThomas Huth
test_multiple_consumes(void)219da668aa1SThomas Huth static void test_multiple_consumes(void)
220da668aa1SThomas Huth {
221da668aa1SThomas Huth qos_graph_init();
222da668aa1SThomas Huth check_consumes(I440FX, SDHCI);
223da668aa1SThomas Huth check_consumes(PCIBUS_PC, SDHCI);
224da668aa1SThomas Huth qos_graph_destroy();
225da668aa1SThomas Huth }
226da668aa1SThomas Huth
test_driver(void)227da668aa1SThomas Huth static void test_driver(void)
228da668aa1SThomas Huth {
229da668aa1SThomas Huth qos_graph_init();
230da668aa1SThomas Huth check_driver(I440FX);
231da668aa1SThomas Huth qos_graph_destroy();
232da668aa1SThomas Huth }
233da668aa1SThomas Huth
test_test(void)234da668aa1SThomas Huth static void test_test(void)
235da668aa1SThomas Huth {
236da668aa1SThomas Huth qos_graph_init();
237da668aa1SThomas Huth check_test(REGISTER_TEST, SDHCI);
238da668aa1SThomas Huth qos_graph_destroy();
239da668aa1SThomas Huth }
240da668aa1SThomas Huth
test_machine_contains_driver(void)241da668aa1SThomas Huth static void test_machine_contains_driver(void)
242da668aa1SThomas Huth {
243da668aa1SThomas Huth qos_graph_init();
244da668aa1SThomas Huth check_machine(MACHINE_PC);
245da668aa1SThomas Huth check_driver(I440FX);
246da668aa1SThomas Huth check_contains(MACHINE_PC, I440FX);
247da668aa1SThomas Huth qos_graph_destroy();
248da668aa1SThomas Huth }
249da668aa1SThomas Huth
test_driver_contains_driver(void)250da668aa1SThomas Huth static void test_driver_contains_driver(void)
251da668aa1SThomas Huth {
252da668aa1SThomas Huth qos_graph_init();
253da668aa1SThomas Huth check_driver(PCIBUS_PC);
254da668aa1SThomas Huth check_driver(I440FX);
255da668aa1SThomas Huth check_contains(PCIBUS_PC, I440FX);
256da668aa1SThomas Huth qos_graph_destroy();
257da668aa1SThomas Huth }
258da668aa1SThomas Huth
test_machine_produces_interface(void)259da668aa1SThomas Huth static void test_machine_produces_interface(void)
260da668aa1SThomas Huth {
261da668aa1SThomas Huth qos_graph_init();
262da668aa1SThomas Huth check_machine(MACHINE_PC);
263da668aa1SThomas Huth check_produces(MACHINE_PC, SDHCI);
264da668aa1SThomas Huth qos_graph_destroy();
265da668aa1SThomas Huth }
266da668aa1SThomas Huth
test_driver_produces_interface(void)267da668aa1SThomas Huth static void test_driver_produces_interface(void)
268da668aa1SThomas Huth {
269da668aa1SThomas Huth qos_graph_init();
270da668aa1SThomas Huth check_driver(I440FX);
271da668aa1SThomas Huth check_produces(I440FX, SDHCI);
272da668aa1SThomas Huth qos_graph_destroy();
273da668aa1SThomas Huth }
274da668aa1SThomas Huth
test_machine_consumes_interface(void)275da668aa1SThomas Huth static void test_machine_consumes_interface(void)
276da668aa1SThomas Huth {
277da668aa1SThomas Huth qos_graph_init();
278da668aa1SThomas Huth check_machine(MACHINE_PC);
279da668aa1SThomas Huth check_consumes(MACHINE_PC, SDHCI);
280da668aa1SThomas Huth qos_graph_destroy();
281da668aa1SThomas Huth }
282da668aa1SThomas Huth
test_driver_consumes_interface(void)283da668aa1SThomas Huth static void test_driver_consumes_interface(void)
284da668aa1SThomas Huth {
285da668aa1SThomas Huth qos_graph_init();
286da668aa1SThomas Huth check_driver(I440FX);
287da668aa1SThomas Huth check_consumes(I440FX, SDHCI);
288da668aa1SThomas Huth qos_graph_destroy();
289da668aa1SThomas Huth }
290da668aa1SThomas Huth
test_test_consumes_interface(void)291da668aa1SThomas Huth static void test_test_consumes_interface(void)
292da668aa1SThomas Huth {
293da668aa1SThomas Huth qos_graph_init();
294da668aa1SThomas Huth check_test(REGISTER_TEST, SDHCI);
295da668aa1SThomas Huth qos_graph_destroy();
296da668aa1SThomas Huth }
297da668aa1SThomas Huth
test_full_sample(void)298da668aa1SThomas Huth static void test_full_sample(void)
299da668aa1SThomas Huth {
300da668aa1SThomas Huth qos_graph_init();
301da668aa1SThomas Huth check_machine(MACHINE_PC);
302da668aa1SThomas Huth check_contains(MACHINE_PC, I440FX);
303da668aa1SThomas Huth check_driver(I440FX);
304da668aa1SThomas Huth check_driver(PCIBUS_PC);
305da668aa1SThomas Huth check_contains(I440FX, PCIBUS_PC);
306da668aa1SThomas Huth check_produces(PCIBUS_PC, PCIBUS);
307da668aa1SThomas Huth check_driver(SDHCI_PCI);
308da668aa1SThomas Huth qos_node_consumes(SDHCI_PCI, PCIBUS, NULL);
309da668aa1SThomas Huth check_produces(SDHCI_PCI, SDHCI);
310da668aa1SThomas Huth check_driver(SDHCI_MM);
311da668aa1SThomas Huth check_produces(SDHCI_MM, SDHCI);
312da668aa1SThomas Huth qos_add_test(REGISTER_TEST, SDHCI, testfunct, NULL);
313da668aa1SThomas Huth check_leaf_discovered(1);
314da668aa1SThomas Huth qos_print_graph();
315da668aa1SThomas Huth qos_graph_destroy();
316da668aa1SThomas Huth }
317da668aa1SThomas Huth
test_full_sample_raspi(void)318da668aa1SThomas Huth static void test_full_sample_raspi(void)
319da668aa1SThomas Huth {
320da668aa1SThomas Huth qos_graph_init();
321da668aa1SThomas Huth check_machine(MACHINE_PC);
322da668aa1SThomas Huth check_contains(MACHINE_PC, I440FX);
323da668aa1SThomas Huth check_driver(I440FX);
324da668aa1SThomas Huth check_driver(PCIBUS_PC);
325da668aa1SThomas Huth check_contains(I440FX, PCIBUS_PC);
326da668aa1SThomas Huth check_produces(PCIBUS_PC, PCIBUS);
327da668aa1SThomas Huth check_driver(SDHCI_PCI);
328da668aa1SThomas Huth qos_node_consumes(SDHCI_PCI, PCIBUS, NULL);
329da668aa1SThomas Huth check_produces(SDHCI_PCI, SDHCI);
330da668aa1SThomas Huth check_machine(MACHINE_RASPI2);
331da668aa1SThomas Huth check_contains(MACHINE_RASPI2, SDHCI_MM);
332da668aa1SThomas Huth check_driver(SDHCI_MM);
333da668aa1SThomas Huth check_produces(SDHCI_MM, SDHCI);
334da668aa1SThomas Huth qos_add_test(REGISTER_TEST, SDHCI, testfunct, NULL);
335da668aa1SThomas Huth qos_print_graph();
336da668aa1SThomas Huth check_leaf_discovered(2);
337da668aa1SThomas Huth qos_graph_destroy();
338da668aa1SThomas Huth }
339da668aa1SThomas Huth
test_cycle(void)340da668aa1SThomas Huth static void test_cycle(void)
341da668aa1SThomas Huth {
342da668aa1SThomas Huth qos_graph_init();
343da668aa1SThomas Huth check_machine(MACHINE_RASPI2);
344da668aa1SThomas Huth check_driver("B");
345da668aa1SThomas Huth check_driver("C");
346da668aa1SThomas Huth check_driver("D");
347da668aa1SThomas Huth check_contains(MACHINE_RASPI2, "B");
348da668aa1SThomas Huth check_contains("B", "C");
349da668aa1SThomas Huth check_contains("C", "D");
350da668aa1SThomas Huth check_contains("D", MACHINE_RASPI2);
351da668aa1SThomas Huth check_leaf_discovered(0);
352da668aa1SThomas Huth qos_print_graph();
353da668aa1SThomas Huth qos_graph_destroy();
354da668aa1SThomas Huth }
355da668aa1SThomas Huth
test_two_test_same_interface(void)356da668aa1SThomas Huth static void test_two_test_same_interface(void)
357da668aa1SThomas Huth {
358da668aa1SThomas Huth qos_graph_init();
359da668aa1SThomas Huth check_machine(MACHINE_RASPI2);
360da668aa1SThomas Huth check_produces(MACHINE_RASPI2, "B");
361da668aa1SThomas Huth qos_add_test("C", "B", testfunct, NULL);
362da668aa1SThomas Huth qos_add_test("D", "B", testfunct, NULL);
363da668aa1SThomas Huth check_contains(MACHINE_RASPI2, "B");
364da668aa1SThomas Huth check_leaf_discovered(4);
365da668aa1SThomas Huth qos_print_graph();
366da668aa1SThomas Huth qos_graph_destroy();
367da668aa1SThomas Huth }
368da668aa1SThomas Huth
test_test_in_path(void)369da668aa1SThomas Huth static void test_test_in_path(void)
370da668aa1SThomas Huth {
371da668aa1SThomas Huth qos_graph_init();
372da668aa1SThomas Huth check_machine(MACHINE_RASPI2);
373da668aa1SThomas Huth check_produces(MACHINE_RASPI2, "B");
374da668aa1SThomas Huth qos_add_test("C", "B", testfunct, NULL);
375da668aa1SThomas Huth check_driver("D");
376da668aa1SThomas Huth check_consumes("D", "B");
377da668aa1SThomas Huth check_produces("D", "E");
378da668aa1SThomas Huth qos_add_test("F", "E", testfunct, NULL);
379da668aa1SThomas Huth check_leaf_discovered(2);
380da668aa1SThomas Huth qos_print_graph();
381da668aa1SThomas Huth qos_graph_destroy();
382da668aa1SThomas Huth }
383da668aa1SThomas Huth
test_double_edge(void)384da668aa1SThomas Huth static void test_double_edge(void)
385da668aa1SThomas Huth {
386da668aa1SThomas Huth qos_graph_init();
387da668aa1SThomas Huth check_machine(MACHINE_RASPI2);
388da668aa1SThomas Huth check_produces("B", "C");
389da668aa1SThomas Huth qos_node_consumes("C", "B", NULL);
390da668aa1SThomas Huth qos_add_test("D", "C", testfunct, NULL);
391da668aa1SThomas Huth check_contains(MACHINE_RASPI2, "B");
392da668aa1SThomas Huth qos_print_graph();
393da668aa1SThomas Huth qos_graph_destroy();
394da668aa1SThomas Huth }
395da668aa1SThomas Huth
main(int argc,char ** argv)396da668aa1SThomas Huth int main(int argc, char **argv)
397da668aa1SThomas Huth {
398da668aa1SThomas Huth g_test_init(&argc, &argv, NULL);
399da668aa1SThomas Huth g_test_add_func("/qgraph/init_nop", init_nop);
400da668aa1SThomas Huth g_test_add_func("/qgraph/test_machine", test_machine);
401da668aa1SThomas Huth g_test_add_func("/qgraph/test_contains", test_contains);
402da668aa1SThomas Huth g_test_add_func("/qgraph/test_multiple_contains", test_multiple_contains);
403da668aa1SThomas Huth g_test_add_func("/qgraph/test_produces", test_produces);
404da668aa1SThomas Huth g_test_add_func("/qgraph/test_multiple_produces", test_multiple_produces);
405da668aa1SThomas Huth g_test_add_func("/qgraph/test_consumes", test_consumes);
406da668aa1SThomas Huth g_test_add_func("/qgraph/test_multiple_consumes",
407da668aa1SThomas Huth test_multiple_consumes);
408da668aa1SThomas Huth g_test_add_func("/qgraph/test_driver", test_driver);
409da668aa1SThomas Huth g_test_add_func("/qgraph/test_test", test_test);
410da668aa1SThomas Huth g_test_add_func("/qgraph/test_machine_contains_driver",
411da668aa1SThomas Huth test_machine_contains_driver);
412da668aa1SThomas Huth g_test_add_func("/qgraph/test_driver_contains_driver",
413da668aa1SThomas Huth test_driver_contains_driver);
414da668aa1SThomas Huth g_test_add_func("/qgraph/test_machine_produces_interface",
415da668aa1SThomas Huth test_machine_produces_interface);
416da668aa1SThomas Huth g_test_add_func("/qgraph/test_driver_produces_interface",
417da668aa1SThomas Huth test_driver_produces_interface);
418da668aa1SThomas Huth g_test_add_func("/qgraph/test_machine_consumes_interface",
419da668aa1SThomas Huth test_machine_consumes_interface);
420da668aa1SThomas Huth g_test_add_func("/qgraph/test_driver_consumes_interface",
421da668aa1SThomas Huth test_driver_consumes_interface);
422da668aa1SThomas Huth g_test_add_func("/qgraph/test_test_consumes_interface",
423da668aa1SThomas Huth test_test_consumes_interface);
424da668aa1SThomas Huth g_test_add_func("/qgraph/test_full_sample", test_full_sample);
425da668aa1SThomas Huth g_test_add_func("/qgraph/test_full_sample_raspi", test_full_sample_raspi);
426da668aa1SThomas Huth g_test_add_func("/qgraph/test_cycle", test_cycle);
427da668aa1SThomas Huth g_test_add_func("/qgraph/test_two_test_same_interface",
428da668aa1SThomas Huth test_two_test_same_interface);
429da668aa1SThomas Huth g_test_add_func("/qgraph/test_test_in_path", test_test_in_path);
430da668aa1SThomas Huth g_test_add_func("/qgraph/test_double_edge", test_double_edge);
431da668aa1SThomas Huth
432da668aa1SThomas Huth g_test_run();
433da668aa1SThomas Huth return 0;
434da668aa1SThomas Huth }
435