32 printf(
"\tOpen existing file - ");
33 int fd = open(
"/usr/bin/bash", O_RDONLY);
38 printf(
"FAIL - errno %d (%s)\n", errno, strerror(errno));
42 printf(
"\tOpen nonexistant file - ");
43 int fd2 = open(
"/usr/bin/does-not-exist", O_RDONLY);
46 printf(
"FAIL - unexpectedly opened missing file\n");
48 }
else if (errno != ENOENT) {
49 printf(
"FAIL - errno %d (%s)\n", errno, strerror(errno));
54 printf(
"\tCreate file - ");
55 int fd3 = open(
"/file-doesnt-exist", O_RDWR | O_CREAT, 0666);
60 printf(
"FAIL - errno %d (%s)\n", errno, strerror(errno));
64 printf(
"\tRecycle descriptors - ");
65 int fd4 = open(
"/usr/bin/bash", O_RDWR);
67 int fd5 = open(
"/usr/bin/bash", O_RDWR);
72 printf(
"FAIL - %d, %d\n", fd4, fd5);
76 int hahaha = open(
"/usr/bin/bash", O_RDWR);
81 printf(
"FAIL - fork failed\n");
87 int rofl = open(
"/usr/bin/bash", O_RDWR);
89 printf(
"%d/%d\n", hahaha, rofl);
104int main(
int argc,
char** argv) {
105 printf(
"argc: %d, argv[0]: %s, &optind: %p\n", argc, argv[0], (
void*)&optind);
106 while (getopt(argc, argv,
"h?ABC:DEFHIKLNOQ:RST:UVWY:abcdefgijklmo:pr:s:tvwxz") != -1) {
109 printf(
"optind: %d\n", optind);
110 printf(
"Syscall test starting...\n");
112 if (test_open() == PASS)