block-backend: inline bdrv_co_get_geometry
[qemu/ar7.git] / tests / qtest / rtas-test.c
blob1ba42b37d2199156441bf4fd12b3e9ca5fa81c21
1 #include "qemu/osdep.h"
2 #include "qemu/cutils.h"
3 #include "libqtest.h"
5 #include "libqos/libqos-spapr.h"
6 #include "libqos/rtas.h"
8 static void run_test_rtas_get_time_of_day(const char *machine)
10 QOSState *qs;
11 struct tm tm;
12 uint32_t ns;
13 uint64_t ret;
14 time_t t1, t2;
16 qs = qtest_spapr_boot("%s", machine);
18 t1 = time(NULL);
19 ret = qrtas_get_time_of_day(qs->qts, &qs->alloc, &tm, &ns);
20 g_assert_cmpint(ret, ==, 0);
21 t2 = mktimegm(&tm);
22 g_assert(t2 - t1 < 5); /* 5 sec max to run the test */
24 qtest_shutdown(qs);
27 static void test_rtas_get_time_of_day(void)
29 run_test_rtas_get_time_of_day("-machine pseries");
32 static void test_rtas_get_time_of_day_vof(void)
34 run_test_rtas_get_time_of_day("-machine pseries,x-vof=on");
37 int main(int argc, char *argv[])
39 const char *arch = qtest_get_arch();
41 g_test_init(&argc, &argv, NULL);
43 if (strcmp(arch, "ppc64")) {
44 g_printerr("RTAS requires qemu-system-ppc64\n");
45 exit(EXIT_FAILURE);
47 qtest_add_func("rtas/get-time-of-day", test_rtas_get_time_of_day);
48 qtest_add_func("rtas/get-time-of-day-vof", test_rtas_get_time_of_day_vof);
50 return g_test_run();