https://bugs.winehq.org/show_bug.cgi?id=53677
--- Comment #2 from xantares xantares09@hotmail.com --- here is the testcase:
``` #include <stdio.h> #include <errno.h> #include <sys/stat.h> #include <fcntl.h>
#ifndef _WIN32 #include <unistd.h> #define POSIX(call) call #else #include <io.h> #define POSIX(call) _##call #endif
int main() { // create a file a write into if const char * path = "test-file"; FILE* fp = fopen(path, "w"); fputs("long live the king", fp); fclose(fp);
// open file in write-only mode int oflag = POSIX(O_WRONLY); #ifndef _WIN32 int perm = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; #else int perm = _S_IREAD | _S_IWRITE; #endif int fd = POSIX(open(path, oflag, perm)); if (fd < 0) { printf("ERROR open failed\n"); return 1; }
// it should fail to read char buffer = 0; unsigned count = 1; int result = POSIX(read(fd, &buffer, count)); if (result >= 0) { printf("ERROR read should fail\n"); return 1; }
// compare error code mingw->EACCES, linux->EBADF printf("EBADF=%d EACCES=%d\n", EBADF, EACCES); printf("errno=%d\n", errno); if (errno != EBADF) { printf("errno should be EBADF\n"); return 1; }
return 0; } ```