xref: /qemu/tests/qtest/endianness-test.c (revision 9cbd66028b82c57f3f24399c6851f21495ccc775)
18fefa31bSPaolo Bonzini /*
28fefa31bSPaolo Bonzini  * QTest testcase for ISA endianness
38fefa31bSPaolo Bonzini  *
48fefa31bSPaolo Bonzini  * Copyright Red Hat, Inc. 2012
58fefa31bSPaolo Bonzini  *
68fefa31bSPaolo Bonzini  * Authors:
78fefa31bSPaolo Bonzini  *  Paolo Bonzini <pbonzini@redhat.com>
88fefa31bSPaolo Bonzini  *
98fefa31bSPaolo Bonzini  * This work is licensed under the terms of the GNU GPL, version 2 or later.
108fefa31bSPaolo Bonzini  * See the COPYING file in the top-level directory.
118fefa31bSPaolo Bonzini  *
128fefa31bSPaolo Bonzini  */
138fefa31bSPaolo Bonzini 
14681c28a3SPeter Maydell #include "qemu/osdep.h"
158fefa31bSPaolo Bonzini 
16a2ce7dbdSPaolo Bonzini #include "libqos/libqtest.h"
178fefa31bSPaolo Bonzini #include "qemu/bswap.h"
188fefa31bSPaolo Bonzini 
198fefa31bSPaolo Bonzini typedef struct TestCase TestCase;
208fefa31bSPaolo Bonzini struct TestCase {
218fefa31bSPaolo Bonzini     const char *arch;
228fefa31bSPaolo Bonzini     const char *machine;
238fefa31bSPaolo Bonzini     uint64_t isa_base;
248fefa31bSPaolo Bonzini     bool bswap;
258fefa31bSPaolo Bonzini     const char *superio;
268fefa31bSPaolo Bonzini };
278fefa31bSPaolo Bonzini 
288fefa31bSPaolo Bonzini static const TestCase test_cases[] = {
298fefa31bSPaolo Bonzini     { "i386", "pc", -1 },
308fefa31bSPaolo Bonzini     { "mips", "malta", 0x10000000, .bswap = true },
318fefa31bSPaolo Bonzini     { "mips64", "magnum", 0x90000000, .bswap = true },
328fefa31bSPaolo Bonzini     { "mips64", "pica61", 0x90000000, .bswap = true },
338fefa31bSPaolo Bonzini     { "mips64", "malta", 0x10000000, .bswap = true },
34c3a09ff6SPhilippe Mathieu-Daudé     { "mips64el", "fuloong2e", 0x1fd00000 },
358fefa31bSPaolo Bonzini     { "ppc", "g3beige", 0xfe000000, .bswap = true, .superio = "i82378" },
36b2ce76a0SThomas Huth     { "ppc", "40p", 0x80000000, .bswap = true },
378fefa31bSPaolo Bonzini     { "ppc", "bamboo", 0xe8000000, .bswap = true, .superio = "i82378" },
388fefa31bSPaolo Bonzini     { "ppc64", "mac99", 0xf2000000, .bswap = true, .superio = "i82378" },
39357d1e3bSDavid Gibson     { "ppc64", "pseries", (1ULL << 45), .bswap = true, .superio = "i82378" },
40357d1e3bSDavid Gibson     { "ppc64", "pseries-2.7", 0x10080000000ULL,
415cb6be2cSStefan Hajnoczi       .bswap = true, .superio = "i82378" },
428fefa31bSPaolo Bonzini     { "sh4", "r2d", 0xfe240000, .superio = "i82378" },
438fefa31bSPaolo Bonzini     { "sh4eb", "r2d", 0xfe240000, .bswap = true, .superio = "i82378" },
448fefa31bSPaolo Bonzini     { "sparc64", "sun4u", 0x1fe02000000LL, .bswap = true },
458fefa31bSPaolo Bonzini     { "x86_64", "pc", -1 },
468fefa31bSPaolo Bonzini     {}
478fefa31bSPaolo Bonzini };
488fefa31bSPaolo Bonzini 
49fdba0d09SThomas Huth static uint8_t isa_inb(QTestState *qts, const TestCase *test, uint16_t addr)
508fefa31bSPaolo Bonzini {
518fefa31bSPaolo Bonzini     uint8_t value;
528fefa31bSPaolo Bonzini     if (test->isa_base == -1) {
53fdba0d09SThomas Huth         value = qtest_inb(qts, addr);
548fefa31bSPaolo Bonzini     } else {
55fdba0d09SThomas Huth         value = qtest_readb(qts, test->isa_base + addr);
568fefa31bSPaolo Bonzini     }
578fefa31bSPaolo Bonzini     return value;
588fefa31bSPaolo Bonzini }
598fefa31bSPaolo Bonzini 
60fdba0d09SThomas Huth static uint16_t isa_inw(QTestState *qts, const TestCase *test, uint16_t addr)
618fefa31bSPaolo Bonzini {
628fefa31bSPaolo Bonzini     uint16_t value;
638fefa31bSPaolo Bonzini     if (test->isa_base == -1) {
64fdba0d09SThomas Huth         value = qtest_inw(qts, addr);
658fefa31bSPaolo Bonzini     } else {
66fdba0d09SThomas Huth         value = qtest_readw(qts, test->isa_base + addr);
678fefa31bSPaolo Bonzini     }
688fefa31bSPaolo Bonzini     return test->bswap ? bswap16(value) : value;
698fefa31bSPaolo Bonzini }
708fefa31bSPaolo Bonzini 
71fdba0d09SThomas Huth static uint32_t isa_inl(QTestState *qts, const TestCase *test, uint16_t addr)
728fefa31bSPaolo Bonzini {
738fefa31bSPaolo Bonzini     uint32_t value;
748fefa31bSPaolo Bonzini     if (test->isa_base == -1) {
75fdba0d09SThomas Huth         value = qtest_inl(qts, addr);
768fefa31bSPaolo Bonzini     } else {
77fdba0d09SThomas Huth         value = qtest_readl(qts, test->isa_base + addr);
788fefa31bSPaolo Bonzini     }
798fefa31bSPaolo Bonzini     return test->bswap ? bswap32(value) : value;
808fefa31bSPaolo Bonzini }
818fefa31bSPaolo Bonzini 
82fdba0d09SThomas Huth static void isa_outb(QTestState *qts, const TestCase *test, uint16_t addr,
83fdba0d09SThomas Huth                      uint8_t value)
848fefa31bSPaolo Bonzini {
858fefa31bSPaolo Bonzini     if (test->isa_base == -1) {
86fdba0d09SThomas Huth         qtest_outb(qts, addr, value);
878fefa31bSPaolo Bonzini     } else {
88fdba0d09SThomas Huth         qtest_writeb(qts, test->isa_base + addr, value);
898fefa31bSPaolo Bonzini     }
908fefa31bSPaolo Bonzini }
918fefa31bSPaolo Bonzini 
92fdba0d09SThomas Huth static void isa_outw(QTestState *qts, const TestCase *test, uint16_t addr,
93fdba0d09SThomas Huth                      uint16_t value)
948fefa31bSPaolo Bonzini {
958fefa31bSPaolo Bonzini     value = test->bswap ? bswap16(value) : value;
968fefa31bSPaolo Bonzini     if (test->isa_base == -1) {
97fdba0d09SThomas Huth         qtest_outw(qts, addr, value);
988fefa31bSPaolo Bonzini     } else {
99fdba0d09SThomas Huth         qtest_writew(qts, test->isa_base + addr, value);
1008fefa31bSPaolo Bonzini     }
1018fefa31bSPaolo Bonzini }
1028fefa31bSPaolo Bonzini 
103fdba0d09SThomas Huth static void isa_outl(QTestState *qts, const TestCase *test, uint16_t addr,
104fdba0d09SThomas Huth                      uint32_t value)
1058fefa31bSPaolo Bonzini {
1068fefa31bSPaolo Bonzini     value = test->bswap ? bswap32(value) : value;
1078fefa31bSPaolo Bonzini     if (test->isa_base == -1) {
108fdba0d09SThomas Huth         qtest_outl(qts, addr, value);
1098fefa31bSPaolo Bonzini     } else {
110fdba0d09SThomas Huth         qtest_writel(qts, test->isa_base + addr, value);
1118fefa31bSPaolo Bonzini     }
1128fefa31bSPaolo Bonzini }
1138fefa31bSPaolo Bonzini 
1148fefa31bSPaolo Bonzini 
1158fefa31bSPaolo Bonzini static void test_endianness(gconstpointer data)
1168fefa31bSPaolo Bonzini {
1178fefa31bSPaolo Bonzini     const TestCase *test = data;
118fdba0d09SThomas Huth     QTestState *qts;
1198fefa31bSPaolo Bonzini 
120fdba0d09SThomas Huth     qts = qtest_initf("-M %s%s%s -device pc-testdev", test->machine,
1218fefa31bSPaolo Bonzini                       test->superio ? " -device " : "",
1228fefa31bSPaolo Bonzini                       test->superio ?: "");
123fdba0d09SThomas Huth     isa_outl(qts, test, 0xe0, 0x87654321);
124fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87654321);
125fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8765);
126fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4321);
127fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe3), ==, 0x87);
128fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe2), ==, 0x65);
129fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe1), ==, 0x43);
130fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe0), ==, 0x21);
1318fefa31bSPaolo Bonzini 
132fdba0d09SThomas Huth     isa_outw(qts, test, 0xe2, 0x8866);
133fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x88664321);
134fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8866);
135fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4321);
136fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe3), ==, 0x88);
137fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe2), ==, 0x66);
138fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe1), ==, 0x43);
139fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe0), ==, 0x21);
1408fefa31bSPaolo Bonzini 
141fdba0d09SThomas Huth     isa_outw(qts, test, 0xe0, 0x4422);
142fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x88664422);
143fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8866);
144fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4422);
145fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe3), ==, 0x88);
146fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe2), ==, 0x66);
147fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe1), ==, 0x44);
148fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe0), ==, 0x22);
1498fefa31bSPaolo Bonzini 
150fdba0d09SThomas Huth     isa_outb(qts, test, 0xe3, 0x87);
151fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87664422);
152fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8766);
153fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe3), ==, 0x87);
154fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe2), ==, 0x66);
155fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe1), ==, 0x44);
156fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe0), ==, 0x22);
1578fefa31bSPaolo Bonzini 
158fdba0d09SThomas Huth     isa_outb(qts, test, 0xe2, 0x65);
159fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87654422);
160fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8765);
161fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4422);
162fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe3), ==, 0x87);
163fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe2), ==, 0x65);
164fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe1), ==, 0x44);
165fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe0), ==, 0x22);
1668fefa31bSPaolo Bonzini 
167fdba0d09SThomas Huth     isa_outb(qts, test, 0xe1, 0x43);
168fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87654322);
169fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8765);
170fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4322);
171fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe3), ==, 0x87);
172fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe2), ==, 0x65);
173fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe1), ==, 0x43);
174fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe0), ==, 0x22);
1758fefa31bSPaolo Bonzini 
176fdba0d09SThomas Huth     isa_outb(qts, test, 0xe0, 0x21);
177fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87654321);
178fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8765);
179fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4321);
180fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe3), ==, 0x87);
181fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe2), ==, 0x65);
182fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe1), ==, 0x43);
183fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe0), ==, 0x21);
184fdba0d09SThomas Huth     qtest_quit(qts);
1858fefa31bSPaolo Bonzini }
1868fefa31bSPaolo Bonzini 
187d2f5ea97SPaolo Bonzini static void test_endianness_split(gconstpointer data)
188d2f5ea97SPaolo Bonzini {
189d2f5ea97SPaolo Bonzini     const TestCase *test = data;
190fdba0d09SThomas Huth     QTestState *qts;
191d2f5ea97SPaolo Bonzini 
192fdba0d09SThomas Huth     qts = qtest_initf("-M %s%s%s -device pc-testdev", test->machine,
193d2f5ea97SPaolo Bonzini                       test->superio ? " -device " : "",
194d2f5ea97SPaolo Bonzini                       test->superio ?: "");
195fdba0d09SThomas Huth     isa_outl(qts, test, 0xe8, 0x87654321);
196fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87654321);
197fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8765);
198fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4321);
199d2f5ea97SPaolo Bonzini 
200fdba0d09SThomas Huth     isa_outw(qts, test, 0xea, 0x8866);
201fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x88664321);
202fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8866);
203fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4321);
204d2f5ea97SPaolo Bonzini 
205fdba0d09SThomas Huth     isa_outw(qts, test, 0xe8, 0x4422);
206fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x88664422);
207fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8866);
208fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4422);
209d2f5ea97SPaolo Bonzini 
210fdba0d09SThomas Huth     isa_outb(qts, test, 0xeb, 0x87);
211fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87664422);
212fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8766);
213d2f5ea97SPaolo Bonzini 
214fdba0d09SThomas Huth     isa_outb(qts, test, 0xea, 0x65);
215fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87654422);
216fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8765);
217fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4422);
218d2f5ea97SPaolo Bonzini 
219fdba0d09SThomas Huth     isa_outb(qts, test, 0xe9, 0x43);
220fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87654322);
221fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8765);
222fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4322);
223d2f5ea97SPaolo Bonzini 
224fdba0d09SThomas Huth     isa_outb(qts, test, 0xe8, 0x21);
225fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87654321);
226fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8765);
227fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4321);
228fdba0d09SThomas Huth     qtest_quit(qts);
229d2f5ea97SPaolo Bonzini }
230d2f5ea97SPaolo Bonzini 
231d2f5ea97SPaolo Bonzini static void test_endianness_combine(gconstpointer data)
232d2f5ea97SPaolo Bonzini {
233d2f5ea97SPaolo Bonzini     const TestCase *test = data;
234fdba0d09SThomas Huth     QTestState *qts;
235d2f5ea97SPaolo Bonzini 
236fdba0d09SThomas Huth     qts = qtest_initf("-M %s%s%s -device pc-testdev", test->machine,
237d2f5ea97SPaolo Bonzini                       test->superio ? " -device " : "",
238d2f5ea97SPaolo Bonzini                       test->superio ?: "");
239fdba0d09SThomas Huth     isa_outl(qts, test, 0xe0, 0x87654321);
240fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe8), ==, 0x87654321);
241fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xea), ==, 0x8765);
242fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe8), ==, 0x4321);
243d2f5ea97SPaolo Bonzini 
244fdba0d09SThomas Huth     isa_outw(qts, test, 0xe2, 0x8866);
245fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe8), ==, 0x88664321);
246fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xea), ==, 0x8866);
247fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe8), ==, 0x4321);
248d2f5ea97SPaolo Bonzini 
249fdba0d09SThomas Huth     isa_outw(qts, test, 0xe0, 0x4422);
250fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe8), ==, 0x88664422);
251fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xea), ==, 0x8866);
252fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe8), ==, 0x4422);
253d2f5ea97SPaolo Bonzini 
254fdba0d09SThomas Huth     isa_outb(qts, test, 0xe3, 0x87);
255fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe8), ==, 0x87664422);
256fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xea), ==, 0x8766);
257d2f5ea97SPaolo Bonzini 
258fdba0d09SThomas Huth     isa_outb(qts, test, 0xe2, 0x65);
259fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe8), ==, 0x87654422);
260fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xea), ==, 0x8765);
261fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe8), ==, 0x4422);
262d2f5ea97SPaolo Bonzini 
263fdba0d09SThomas Huth     isa_outb(qts, test, 0xe1, 0x43);
264fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe8), ==, 0x87654322);
265fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xea), ==, 0x8765);
266fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe8), ==, 0x4322);
267d2f5ea97SPaolo Bonzini 
268fdba0d09SThomas Huth     isa_outb(qts, test, 0xe0, 0x21);
269fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe8), ==, 0x87654321);
270fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xea), ==, 0x8765);
271fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe8), ==, 0x4321);
272fdba0d09SThomas Huth     qtest_quit(qts);
273d2f5ea97SPaolo Bonzini }
274d2f5ea97SPaolo Bonzini 
2758fefa31bSPaolo Bonzini int main(int argc, char **argv)
2768fefa31bSPaolo Bonzini {
2778fefa31bSPaolo Bonzini     const char *arch = qtest_get_arch();
2788fefa31bSPaolo Bonzini     int i;
2798fefa31bSPaolo Bonzini 
2808fefa31bSPaolo Bonzini     g_test_init(&argc, &argv, NULL);
2818fefa31bSPaolo Bonzini 
2828fefa31bSPaolo Bonzini     for (i = 0; test_cases[i].arch; i++) {
2838fefa31bSPaolo Bonzini         gchar *path;
284*9cbd6602SThomas Huth 
285*9cbd6602SThomas Huth         if (!g_str_equal(test_cases[i].arch, arch) ||
286*9cbd6602SThomas Huth             !qtest_has_machine(test_cases[i].machine) ||
287*9cbd6602SThomas Huth             (test_cases[i].superio && !qtest_has_device(test_cases[i].superio))) {
2888fefa31bSPaolo Bonzini             continue;
2898fefa31bSPaolo Bonzini         }
29053f77e45SAndreas Färber         path = g_strdup_printf("endianness/%s",
29153f77e45SAndreas Färber                                test_cases[i].machine);
29253f77e45SAndreas Färber         qtest_add_data_func(path, &test_cases[i], test_endianness);
293f3f8e811SMarc-André Lureau         g_free(path);
294d2f5ea97SPaolo Bonzini 
29553f77e45SAndreas Färber         path = g_strdup_printf("endianness/split/%s",
29653f77e45SAndreas Färber                                test_cases[i].machine);
29753f77e45SAndreas Färber         qtest_add_data_func(path, &test_cases[i], test_endianness_split);
298f3f8e811SMarc-André Lureau         g_free(path);
299d2f5ea97SPaolo Bonzini 
30053f77e45SAndreas Färber         path = g_strdup_printf("endianness/combine/%s",
30153f77e45SAndreas Färber                                test_cases[i].machine);
30253f77e45SAndreas Färber         qtest_add_data_func(path, &test_cases[i], test_endianness_combine);
303f3f8e811SMarc-André Lureau         g_free(path);
3048fefa31bSPaolo Bonzini     }
3058fefa31bSPaolo Bonzini 
3069be38598SEduardo Habkost     return g_test_run();
3078fefa31bSPaolo Bonzini }
308