target-i386: Eliminate cpu_init() function
[qemu/ar7.git] / tests / libqos / libqos.c
blobbc8beb281f350dd71bcc81bc62738b41c6a06f86
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <glib.h>
4 #include <unistd.h>
5 #include <fcntl.h>
6 #include <sys/wait.h>
8 #include "libqtest.h"
9 #include "libqos/libqos.h"
10 #include "libqos/pci.h"
12 /*** Test Setup & Teardown ***/
14 /**
15 * Launch QEMU with the given command line,
16 * and then set up interrupts and our guest malloc interface.
18 QOSState *qtest_vboot(QOSOps *ops, const char *cmdline_fmt, va_list ap)
20 char *cmdline;
22 struct QOSState *qs = g_malloc(sizeof(QOSState));
24 cmdline = g_strdup_vprintf(cmdline_fmt, ap);
25 qs->qts = qtest_start(cmdline);
26 qs->ops = ops;
27 qtest_irq_intercept_in(global_qtest, "ioapic");
28 if (ops && ops->init_allocator) {
29 qs->alloc = ops->init_allocator(ALLOC_NO_FLAGS);
32 g_free(cmdline);
33 return qs;
36 /**
37 * Launch QEMU with the given command line,
38 * and then set up interrupts and our guest malloc interface.
40 QOSState *qtest_boot(QOSOps *ops, const char *cmdline_fmt, ...)
42 QOSState *qs;
43 va_list ap;
45 va_start(ap, cmdline_fmt);
46 qs = qtest_vboot(ops, cmdline_fmt, ap);
47 va_end(ap);
49 return qs;
52 /**
53 * Tear down the QEMU instance.
55 void qtest_shutdown(QOSState *qs)
57 if (qs->alloc && qs->ops && qs->ops->uninit_allocator) {
58 qs->ops->uninit_allocator(qs->alloc);
59 qs->alloc = NULL;
61 qtest_quit(qs->qts);
62 g_free(qs);