main.c 591 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include <sys/stat.h>
  2. #include <unistd.h>
  3. #include <fcntl.h>
  4. #include "common.h"
  5. int runTests()
  6. {
  7. int fd = open("filenotfound", O_RDONLY);
  8. _assertEqual(fd, -1);
  9. _assertEqual(open("newFile", O_RDONLY), -1);
  10. fd = open("newFile", O_CREAT, 0x644);
  11. _assertDiff(fd, -1);
  12. close(fd);
  13. _assertDiff((fd = open("newFile", O_RDONLY)), -1);
  14. close(fd);
  15. return 0;
  16. }
  17. void cleanup()
  18. {
  19. unlink("newFile");
  20. unlink("filenotfound");
  21. }
  22. int main(int ac, char **av)
  23. {
  24. cleanup();
  25. if (runTests() == -1)
  26. {
  27. cleanup();
  28. exit(EXIT_FAILURE);
  29. }
  30. cleanup();
  31. printf("Success\n");
  32. exit(EXIT_SUCCESS);
  33. }