waserror.c 488 B

123456789101112131415161718192021222324252627
  1. // Ensure that many calls to waserror:
  2. // -- return an error
  3. // -- complete
  4. // Since we're going to improve waserror
  5. #include <u.h>
  6. #include <lib9.h>
  7. void
  8. main(void)
  9. {
  10. char buf[1];
  11. int i;
  12. // Just to be sure.
  13. if (close(3) >= 0) {
  14. print("waserror: close of 3 did not get an error\n");
  15. exits("FAIL");
  16. }
  17. for(i = 0; i < 100000; i++) {
  18. if (read(3, buf, 1) >= 0){
  19. print("waserror: read of 3 did not get an error\n");
  20. exits("FAIL");
  21. }
  22. }
  23. print("PASS\n");
  24. exits("PASS");
  25. }