Misc.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #include "pal.h"
  2. #include "pal_debug.h"
  3. #include "api.h"
  4. int main (int argc, const char ** argv, const char ** envp)
  5. {
  6. unsigned long time1 = DkSystemTimeQuery();
  7. unsigned long time2 = DkSystemTimeQuery();
  8. pal_printf("Time Query 1: %ld\n", time1);
  9. pal_printf("Time Query 2: %ld\n", time2);
  10. if (time1 <= time2)
  11. pal_printf("Query System Time OK\n");
  12. unsigned long time3 = DkSystemTimeQuery();
  13. DkThreadDelayExecution(10000);
  14. unsigned long time4 = DkSystemTimeQuery();
  15. pal_printf("Sleeped %ld Microseconds\n", time4 - time3);
  16. if (time3 < time4 && time4 - time3 > 10000)
  17. pal_printf("Delay Execution for 10000 Microseconds OK\n");
  18. unsigned long time5 = DkSystemTimeQuery();
  19. DkThreadDelayExecution(3000000);
  20. unsigned long time6 = DkSystemTimeQuery();
  21. pal_printf("Sleeped %ld Microseconds\n", time6 - time5);
  22. if (time5 < time6 && time6 - time5 > 3000000)
  23. pal_printf("Delay Execution for 3 Seconds OK\n");
  24. unsigned long data[100];
  25. memset(data, 0, sizeof(data));
  26. for (int i = 0 ; i < 100 ; i++) {
  27. int ret = DkRandomBitsRead(&data[i], sizeof(unsigned long));
  28. if (ret < 0) {
  29. pal_printf("DkRandomBitsRead() failed!\n");
  30. return 1;
  31. }
  32. }
  33. bool same = false;
  34. for (int i = 1 ; i < 100 ; i++)
  35. for (int j = 0 ; j < i ; j++)
  36. if (data[i] == data[j]) same = true;
  37. if (!same)
  38. pal_printf("Generate Random Bits OK\n");
  39. return 0;
  40. }