commit: Make base read-only if there is an early failure
[qemu/ar7.git] / tests / rtas-test.c
blobee888676ed298013e263bf7fc110da6532ad0908
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 test_rtas_get_time_of_day(void)
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("-machine pseries");
17 global_qtest = qs->qts;
19 t1 = time(NULL);
20 ret = qrtas_get_time_of_day(qs->qts, &qs->alloc, &tm, &ns);
21 g_assert_cmpint(ret, ==, 0);
22 t2 = mktimegm(&tm);
23 g_assert(t2 - t1 < 5); /* 5 sec max to run the test */
25 qtest_shutdown(qs);
28 int main(int argc, char *argv[])
30 const char *arch = qtest_get_arch();
32 g_test_init(&argc, &argv, NULL);
34 if (strcmp(arch, "ppc64")) {
35 g_printerr("RTAS requires ppc64-softmmu/qemu-system-ppc64\n");
36 exit(EXIT_FAILURE);
38 qtest_add_func("rtas/get-time-of-day", test_rtas_get_time_of_day);
40 return g_test_run();