rtas-test.c 897 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include "qemu/osdep.h"
  2. #include "qemu/cutils.h"
  3. #include "libqtest.h"
  4. #include "libqos/libqos-spapr.h"
  5. #include "libqos/rtas.h"
  6. static void test_rtas_get_time_of_day(void)
  7. {
  8. QOSState *qs;
  9. struct tm tm;
  10. uint32_t ns;
  11. uint64_t ret;
  12. time_t t1, t2;
  13. qs = qtest_spapr_boot("-machine pseries");
  14. t1 = time(NULL);
  15. ret = qrtas_get_time_of_day(qs->qts, &qs->alloc, &tm, &ns);
  16. g_assert_cmpint(ret, ==, 0);
  17. t2 = mktimegm(&tm);
  18. g_assert(t2 - t1 < 5); /* 5 sec max to run the test */
  19. qtest_shutdown(qs);
  20. }
  21. int main(int argc, char *argv[])
  22. {
  23. const char *arch = qtest_get_arch();
  24. g_test_init(&argc, &argv, NULL);
  25. if (strcmp(arch, "ppc64")) {
  26. g_printerr("RTAS requires ppc64-softmmu/qemu-system-ppc64\n");
  27. exit(EXIT_FAILURE);
  28. }
  29. qtest_add_func("rtas/get-time-of-day", test_rtas_get_time_of_day);
  30. return g_test_run();
  31. }