mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:17:36 +00:00
test_io: Verify that read() on an O_WRONLY fd fails with EBADF
This commit is contained in:
parent
0a1865ebc6
commit
c19f840f32
1 changed files with 12 additions and 0 deletions
|
@ -53,6 +53,17 @@ void test_write_to_directory()
|
|||
ASSERT(rc == 0);
|
||||
}
|
||||
|
||||
void test_read_from_writeonly()
|
||||
{
|
||||
char buffer[BUFSIZ];
|
||||
int fd = open("/tmp/xxxx123", O_CREAT | O_WRONLY);
|
||||
ASSERT(fd >= 0);
|
||||
int rc;
|
||||
EXPECT_ERROR_3(EBADF, read, fd, buffer, sizeof(buffer));
|
||||
rc = close(fd);
|
||||
ASSERT(rc == 0);
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
int rc;
|
||||
|
@ -66,6 +77,7 @@ int main(int, char**)
|
|||
|
||||
test_read_from_directory();
|
||||
test_write_to_directory();
|
||||
test_read_from_writeonly();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue