xref: /qemu/tests/qtest/endianness-test.c (revision b2ce76a0730e48e60633a698cd876d55917ac9bc)
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 
1691f32b0cSStefan Hajnoczi #include "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", "mips", 0x14000000, .bswap = true },
318fefa31bSPaolo Bonzini     { "mips", "malta", 0x10000000, .bswap = true },
328fefa31bSPaolo Bonzini     { "mips64", "magnum", 0x90000000, .bswap = true },
338fefa31bSPaolo Bonzini     { "mips64", "pica61", 0x90000000, .bswap = true },
348fefa31bSPaolo Bonzini     { "mips64", "mips", 0x14000000, .bswap = true },
358fefa31bSPaolo Bonzini     { "mips64", "malta", 0x10000000, .bswap = true },
368fefa31bSPaolo Bonzini     { "mips64el", "fulong2e", 0x1fd00000 },
378fefa31bSPaolo Bonzini     { "ppc", "g3beige", 0xfe000000, .bswap = true, .superio = "i82378" },
38*b2ce76a0SThomas Huth     { "ppc", "40p", 0x80000000, .bswap = true },
398fefa31bSPaolo Bonzini     { "ppc", "bamboo", 0xe8000000, .bswap = true, .superio = "i82378" },
408fefa31bSPaolo Bonzini     { "ppc64", "mac99", 0xf2000000, .bswap = true, .superio = "i82378" },
41357d1e3bSDavid Gibson     { "ppc64", "pseries", (1ULL << 45), .bswap = true, .superio = "i82378" },
42357d1e3bSDavid Gibson     { "ppc64", "pseries-2.7", 0x10080000000ULL,
435cb6be2cSStefan Hajnoczi       .bswap = true, .superio = "i82378" },
448fefa31bSPaolo Bonzini     { "sh4", "r2d", 0xfe240000, .superio = "i82378" },
458fefa31bSPaolo Bonzini     { "sh4eb", "r2d", 0xfe240000, .bswap = true, .superio = "i82378" },
468fefa31bSPaolo Bonzini     { "sparc64", "sun4u", 0x1fe02000000LL, .bswap = true },
478fefa31bSPaolo Bonzini     { "x86_64", "pc", -1 },
488fefa31bSPaolo Bonzini     {}
498fefa31bSPaolo Bonzini };
508fefa31bSPaolo Bonzini 
51fdba0d09SThomas Huth static uint8_t isa_inb(QTestState *qts, const TestCase *test, uint16_t addr)
528fefa31bSPaolo Bonzini {
538fefa31bSPaolo Bonzini     uint8_t value;
548fefa31bSPaolo Bonzini     if (test->isa_base == -1) {
55fdba0d09SThomas Huth         value = qtest_inb(qts, addr);
568fefa31bSPaolo Bonzini     } else {
57fdba0d09SThomas Huth         value = qtest_readb(qts, test->isa_base + addr);
588fefa31bSPaolo Bonzini     }
598fefa31bSPaolo Bonzini     return value;
608fefa31bSPaolo Bonzini }
618fefa31bSPaolo Bonzini 
62fdba0d09SThomas Huth static uint16_t isa_inw(QTestState *qts, const TestCase *test, uint16_t addr)
638fefa31bSPaolo Bonzini {
648fefa31bSPaolo Bonzini     uint16_t value;
658fefa31bSPaolo Bonzini     if (test->isa_base == -1) {
66fdba0d09SThomas Huth         value = qtest_inw(qts, addr);
678fefa31bSPaolo Bonzini     } else {
68fdba0d09SThomas Huth         value = qtest_readw(qts, test->isa_base + addr);
698fefa31bSPaolo Bonzini     }
708fefa31bSPaolo Bonzini     return test->bswap ? bswap16(value) : value;
718fefa31bSPaolo Bonzini }
728fefa31bSPaolo Bonzini 
73fdba0d09SThomas Huth static uint32_t isa_inl(QTestState *qts, const TestCase *test, uint16_t addr)
748fefa31bSPaolo Bonzini {
758fefa31bSPaolo Bonzini     uint32_t value;
768fefa31bSPaolo Bonzini     if (test->isa_base == -1) {
77fdba0d09SThomas Huth         value = qtest_inl(qts, addr);
788fefa31bSPaolo Bonzini     } else {
79fdba0d09SThomas Huth         value = qtest_readl(qts, test->isa_base + addr);
808fefa31bSPaolo Bonzini     }
818fefa31bSPaolo Bonzini     return test->bswap ? bswap32(value) : value;
828fefa31bSPaolo Bonzini }
838fefa31bSPaolo Bonzini 
84fdba0d09SThomas Huth static void isa_outb(QTestState *qts, const TestCase *test, uint16_t addr,
85fdba0d09SThomas Huth                      uint8_t value)
868fefa31bSPaolo Bonzini {
878fefa31bSPaolo Bonzini     if (test->isa_base == -1) {
88fdba0d09SThomas Huth         qtest_outb(qts, addr, value);
898fefa31bSPaolo Bonzini     } else {
90fdba0d09SThomas Huth         qtest_writeb(qts, test->isa_base + addr, value);
918fefa31bSPaolo Bonzini     }
928fefa31bSPaolo Bonzini }
938fefa31bSPaolo Bonzini 
94fdba0d09SThomas Huth static void isa_outw(QTestState *qts, const TestCase *test, uint16_t addr,
95fdba0d09SThomas Huth                      uint16_t value)
968fefa31bSPaolo Bonzini {
978fefa31bSPaolo Bonzini     value = test->bswap ? bswap16(value) : value;
988fefa31bSPaolo Bonzini     if (test->isa_base == -1) {
99fdba0d09SThomas Huth         qtest_outw(qts, addr, value);
1008fefa31bSPaolo Bonzini     } else {
101fdba0d09SThomas Huth         qtest_writew(qts, test->isa_base + addr, value);
1028fefa31bSPaolo Bonzini     }
1038fefa31bSPaolo Bonzini }
1048fefa31bSPaolo Bonzini 
105fdba0d09SThomas Huth static void isa_outl(QTestState *qts, const TestCase *test, uint16_t addr,
106fdba0d09SThomas Huth                      uint32_t value)
1078fefa31bSPaolo Bonzini {
1088fefa31bSPaolo Bonzini     value = test->bswap ? bswap32(value) : value;
1098fefa31bSPaolo Bonzini     if (test->isa_base == -1) {
110fdba0d09SThomas Huth         qtest_outl(qts, addr, value);
1118fefa31bSPaolo Bonzini     } else {
112fdba0d09SThomas Huth         qtest_writel(qts, test->isa_base + addr, value);
1138fefa31bSPaolo Bonzini     }
1148fefa31bSPaolo Bonzini }
1158fefa31bSPaolo Bonzini 
1168fefa31bSPaolo Bonzini 
1178fefa31bSPaolo Bonzini static void test_endianness(gconstpointer data)
1188fefa31bSPaolo Bonzini {
1198fefa31bSPaolo Bonzini     const TestCase *test = data;
120fdba0d09SThomas Huth     QTestState *qts;
1218fefa31bSPaolo Bonzini 
122fdba0d09SThomas Huth     qts = qtest_initf("-M %s%s%s -device pc-testdev", test->machine,
1238fefa31bSPaolo Bonzini                       test->superio ? " -device " : "",
1248fefa31bSPaolo Bonzini                       test->superio ?: "");
125fdba0d09SThomas Huth     isa_outl(qts, test, 0xe0, 0x87654321);
126fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87654321);
127fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8765);
128fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4321);
129fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe3), ==, 0x87);
130fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe2), ==, 0x65);
131fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe1), ==, 0x43);
132fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe0), ==, 0x21);
1338fefa31bSPaolo Bonzini 
134fdba0d09SThomas Huth     isa_outw(qts, test, 0xe2, 0x8866);
135fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x88664321);
136fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8866);
137fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4321);
138fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe3), ==, 0x88);
139fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe2), ==, 0x66);
140fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe1), ==, 0x43);
141fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe0), ==, 0x21);
1428fefa31bSPaolo Bonzini 
143fdba0d09SThomas Huth     isa_outw(qts, test, 0xe0, 0x4422);
144fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x88664422);
145fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8866);
146fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4422);
147fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe3), ==, 0x88);
148fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe2), ==, 0x66);
149fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe1), ==, 0x44);
150fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe0), ==, 0x22);
1518fefa31bSPaolo Bonzini 
152fdba0d09SThomas Huth     isa_outb(qts, test, 0xe3, 0x87);
153fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87664422);
154fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8766);
155fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe3), ==, 0x87);
156fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe2), ==, 0x66);
157fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe1), ==, 0x44);
158fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe0), ==, 0x22);
1598fefa31bSPaolo Bonzini 
160fdba0d09SThomas Huth     isa_outb(qts, test, 0xe2, 0x65);
161fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87654422);
162fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8765);
163fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4422);
164fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe3), ==, 0x87);
165fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe2), ==, 0x65);
166fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe1), ==, 0x44);
167fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe0), ==, 0x22);
1688fefa31bSPaolo Bonzini 
169fdba0d09SThomas Huth     isa_outb(qts, test, 0xe1, 0x43);
170fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87654322);
171fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8765);
172fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4322);
173fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe3), ==, 0x87);
174fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe2), ==, 0x65);
175fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe1), ==, 0x43);
176fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe0), ==, 0x22);
1778fefa31bSPaolo Bonzini 
178fdba0d09SThomas Huth     isa_outb(qts, test, 0xe0, 0x21);
179fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87654321);
180fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8765);
181fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4321);
182fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe3), ==, 0x87);
183fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe2), ==, 0x65);
184fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe1), ==, 0x43);
185fdba0d09SThomas Huth     g_assert_cmphex(isa_inb(qts, test, 0xe0), ==, 0x21);
186fdba0d09SThomas Huth     qtest_quit(qts);
1878fefa31bSPaolo Bonzini }
1888fefa31bSPaolo Bonzini 
189d2f5ea97SPaolo Bonzini static void test_endianness_split(gconstpointer data)
190d2f5ea97SPaolo Bonzini {
191d2f5ea97SPaolo Bonzini     const TestCase *test = data;
192fdba0d09SThomas Huth     QTestState *qts;
193d2f5ea97SPaolo Bonzini 
194fdba0d09SThomas Huth     qts = qtest_initf("-M %s%s%s -device pc-testdev", test->machine,
195d2f5ea97SPaolo Bonzini                       test->superio ? " -device " : "",
196d2f5ea97SPaolo Bonzini                       test->superio ?: "");
197fdba0d09SThomas Huth     isa_outl(qts, test, 0xe8, 0x87654321);
198fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87654321);
199fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8765);
200fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4321);
201d2f5ea97SPaolo Bonzini 
202fdba0d09SThomas Huth     isa_outw(qts, test, 0xea, 0x8866);
203fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x88664321);
204fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8866);
205fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4321);
206d2f5ea97SPaolo Bonzini 
207fdba0d09SThomas Huth     isa_outw(qts, test, 0xe8, 0x4422);
208fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x88664422);
209fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8866);
210fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4422);
211d2f5ea97SPaolo Bonzini 
212fdba0d09SThomas Huth     isa_outb(qts, test, 0xeb, 0x87);
213fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87664422);
214fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8766);
215d2f5ea97SPaolo Bonzini 
216fdba0d09SThomas Huth     isa_outb(qts, test, 0xea, 0x65);
217fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87654422);
218fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8765);
219fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4422);
220d2f5ea97SPaolo Bonzini 
221fdba0d09SThomas Huth     isa_outb(qts, test, 0xe9, 0x43);
222fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87654322);
223fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8765);
224fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4322);
225d2f5ea97SPaolo Bonzini 
226fdba0d09SThomas Huth     isa_outb(qts, test, 0xe8, 0x21);
227fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe0), ==, 0x87654321);
228fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe2), ==, 0x8765);
229fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe0), ==, 0x4321);
230fdba0d09SThomas Huth     qtest_quit(qts);
231d2f5ea97SPaolo Bonzini }
232d2f5ea97SPaolo Bonzini 
233d2f5ea97SPaolo Bonzini static void test_endianness_combine(gconstpointer data)
234d2f5ea97SPaolo Bonzini {
235d2f5ea97SPaolo Bonzini     const TestCase *test = data;
236fdba0d09SThomas Huth     QTestState *qts;
237d2f5ea97SPaolo Bonzini 
238fdba0d09SThomas Huth     qts = qtest_initf("-M %s%s%s -device pc-testdev", test->machine,
239d2f5ea97SPaolo Bonzini                       test->superio ? " -device " : "",
240d2f5ea97SPaolo Bonzini                       test->superio ?: "");
241fdba0d09SThomas Huth     isa_outl(qts, test, 0xe0, 0x87654321);
242fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe8), ==, 0x87654321);
243fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xea), ==, 0x8765);
244fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe8), ==, 0x4321);
245d2f5ea97SPaolo Bonzini 
246fdba0d09SThomas Huth     isa_outw(qts, test, 0xe2, 0x8866);
247fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe8), ==, 0x88664321);
248fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xea), ==, 0x8866);
249fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe8), ==, 0x4321);
250d2f5ea97SPaolo Bonzini 
251fdba0d09SThomas Huth     isa_outw(qts, test, 0xe0, 0x4422);
252fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe8), ==, 0x88664422);
253fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xea), ==, 0x8866);
254fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe8), ==, 0x4422);
255d2f5ea97SPaolo Bonzini 
256fdba0d09SThomas Huth     isa_outb(qts, test, 0xe3, 0x87);
257fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe8), ==, 0x87664422);
258fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xea), ==, 0x8766);
259d2f5ea97SPaolo Bonzini 
260fdba0d09SThomas Huth     isa_outb(qts, test, 0xe2, 0x65);
261fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe8), ==, 0x87654422);
262fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xea), ==, 0x8765);
263fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe8), ==, 0x4422);
264d2f5ea97SPaolo Bonzini 
265fdba0d09SThomas Huth     isa_outb(qts, test, 0xe1, 0x43);
266fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe8), ==, 0x87654322);
267fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xea), ==, 0x8765);
268fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe8), ==, 0x4322);
269d2f5ea97SPaolo Bonzini 
270fdba0d09SThomas Huth     isa_outb(qts, test, 0xe0, 0x21);
271fdba0d09SThomas Huth     g_assert_cmphex(isa_inl(qts, test, 0xe8), ==, 0x87654321);
272fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xea), ==, 0x8765);
273fdba0d09SThomas Huth     g_assert_cmphex(isa_inw(qts, test, 0xe8), ==, 0x4321);
274fdba0d09SThomas Huth     qtest_quit(qts);
275d2f5ea97SPaolo Bonzini }
276d2f5ea97SPaolo Bonzini 
2778fefa31bSPaolo Bonzini int main(int argc, char **argv)
2788fefa31bSPaolo Bonzini {
2798fefa31bSPaolo Bonzini     const char *arch = qtest_get_arch();
2808fefa31bSPaolo Bonzini     int i;
2818fefa31bSPaolo Bonzini 
2828fefa31bSPaolo Bonzini     g_test_init(&argc, &argv, NULL);
2838fefa31bSPaolo Bonzini 
2848fefa31bSPaolo Bonzini     for (i = 0; test_cases[i].arch; i++) {
2858fefa31bSPaolo Bonzini         gchar *path;
2868fefa31bSPaolo Bonzini         if (strcmp(test_cases[i].arch, arch) != 0) {
2878fefa31bSPaolo Bonzini             continue;
2888fefa31bSPaolo Bonzini         }
28953f77e45SAndreas Färber         path = g_strdup_printf("endianness/%s",
29053f77e45SAndreas Färber                                test_cases[i].machine);
29153f77e45SAndreas Färber         qtest_add_data_func(path, &test_cases[i], test_endianness);
292f3f8e811SMarc-André Lureau         g_free(path);
293d2f5ea97SPaolo Bonzini 
29453f77e45SAndreas Färber         path = g_strdup_printf("endianness/split/%s",
29553f77e45SAndreas Färber                                test_cases[i].machine);
29653f77e45SAndreas Färber         qtest_add_data_func(path, &test_cases[i], test_endianness_split);
297f3f8e811SMarc-André Lureau         g_free(path);
298d2f5ea97SPaolo Bonzini 
29953f77e45SAndreas Färber         path = g_strdup_printf("endianness/combine/%s",
30053f77e45SAndreas Färber                                test_cases[i].machine);
30153f77e45SAndreas Färber         qtest_add_data_func(path, &test_cases[i], test_endianness_combine);
302f3f8e811SMarc-André Lureau         g_free(path);
3038fefa31bSPaolo Bonzini     }
3048fefa31bSPaolo Bonzini 
3059be38598SEduardo Habkost     return g_test_run();
3068fefa31bSPaolo Bonzini }
307