| 1234567891011121314151617181920212223242526272829303132333435363738 |
- #include <sys/stat.h>
- #include <unistd.h>
- #include <fcntl.h>
- #include "common.h"
- int runTests()
- {
- int fd = open("filenotfound", O_RDONLY);
- _assertEqual(fd, -1);
- _assertEqual(open("newFile", O_RDONLY), -1);
- fd = open("newFile", O_CREAT, 0x644);
- _assertDiff(fd, -1);
- close(fd);
- _assertDiff((fd = open("newFile", O_RDONLY)), -1);
- close(fd);
- return 0;
- }
- void cleanup()
- {
- unlink("newFile");
- unlink("filenotfound");
- }
- int main(int ac, char **av)
- {
- cleanup();
- if (runTests() == -1)
- {
- cleanup();
- exit(EXIT_FAILURE);
- }
- cleanup();
- printf("Success\n");
- exit(EXIT_SUCCESS);
- }
|