Misc.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* -*- mode:c; c-file-style:"k&r"; c-basic-offset: 4; tab-width:4; indent-tabs-mode:nil; mode:auto-fill; fill-column:78; -*- */
  2. /* vim: set ts=4 sw=4 et tw=78 fo=cqt wm=0: */
  3. #include "pal.h"
  4. #include "pal_debug.h"
  5. #include "api.h"
  6. int main (int argc, const char ** argv, const char ** envp)
  7. {
  8. unsigned long time1 = DkSystemTimeQuery();
  9. unsigned long time2 = DkSystemTimeQuery();
  10. pal_printf("Time Query 1: %lld\n", time1);
  11. pal_printf("Time Query 2: %lld\n", time2);
  12. if (time1 <= time2)
  13. pal_printf("Query System Time OK\n");
  14. unsigned long time3 = DkSystemTimeQuery();
  15. DkThreadDelayExecution(10000);
  16. unsigned long time4 = DkSystemTimeQuery();
  17. pal_printf("Sleeped %lld Microseconds\n", time4 - time3);
  18. if (time3 < time4 && time4 - time3 > 10000)
  19. pal_printf("Delay Execution for 10000 Microseconds OK\n");
  20. unsigned long time5 = DkSystemTimeQuery();
  21. DkThreadDelayExecution(3000000);
  22. unsigned long time6 = DkSystemTimeQuery();
  23. pal_printf("Sleeped %lld Microseconds\n", time6 - time5);
  24. if (time5 < time6 && time6 - time5 > 3000000)
  25. pal_printf("Delay Execution for 3 Seconds OK\n");
  26. unsigned long data[100];
  27. memset(data, 0, sizeof(data));
  28. for (int i = 0 ; i < 100 ; i++)
  29. DkRandomBitsRead(&data[i], sizeof(unsigned long));
  30. bool same = false;
  31. for (int i = 1 ; i < 100 ; i++)
  32. for (int j = 0 ; j < i ; j++)
  33. if (data[i] == data[j]) same = true;
  34. if (!same)
  35. pal_printf("Generate Random Bits OK\n");
  36. return 0;
  37. }