Misc.c 1.5 KB

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