2
0

sleep.c 512 B

1234567891011121314151617181920
  1. #include <time.h>
  2. #include <unistd.h>
  3. #include <stdio.h>
  4. #include "test_helpers.h"
  5. int main(void) {
  6. // sleep has no error codes and doesn't set errno
  7. unsigned int unslept = sleep(2);
  8. printf("unslept: %u\n", unslept);
  9. int us_status = usleep(1000);
  10. ERROR_IF(usleep, us_status, == -1);
  11. UNEXP_IF(usleep, us_status, != 0);
  12. struct timespec tm = {0, 10000};
  13. int ns_status = nanosleep(&tm, NULL);
  14. ERROR_IF(nanosleep, ns_status, == -1);
  15. UNEXP_IF(nanosleep, ns_status, != 0);
  16. }