mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 13:30:31 +00:00
test_io: Verify that write() on an O_RDONLY fd fails with EBADF
This commit is contained in:
parent
c19f840f32
commit
93e9a42bf0
Notes:
sideshowbarker
2024-07-19 10:24:17 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/93e9a42bf04
1 changed files with 12 additions and 0 deletions
|
@ -64,6 +64,17 @@ void test_read_from_writeonly()
|
|||
ASSERT(rc == 0);
|
||||
}
|
||||
|
||||
void test_write_to_readonly()
|
||||
{
|
||||
char str[] = "hello";
|
||||
int fd = open("/tmp/abcd123", O_CREAT | O_RDONLY);
|
||||
ASSERT(fd >= 0);
|
||||
int rc;
|
||||
EXPECT_ERROR_3(EBADF, write, fd, str, sizeof(str));
|
||||
rc = close(fd);
|
||||
ASSERT(rc == 0);
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
int rc;
|
||||
|
@ -78,6 +89,7 @@ int main(int, char**)
|
|||
test_read_from_directory();
|
||||
test_write_to_directory();
|
||||
test_read_from_writeonly();
|
||||
test_write_to_readonly();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue