kernel: add /dev/null polling test

Bug: 13965
This commit is contained in:
Xiang Fan
2018-02-26 10:44:22 +00:00
committed by Jérôme Duval
parent a9388f6d39
commit fb6387f2b4
2 changed files with 33 additions and 0 deletions
+2
View File
@@ -51,6 +51,8 @@ SimpleTest port_wakeup_test_9 : port_wakeup_test_9.cpp ;
SimpleTest mmap_resize_test : mmap_resize_test.cpp ;
SimpleTest null_poll_test : null_poll_test.cpp ;
SimpleTest reserved_areas_test : reserved_areas_test.cpp ;
SimpleTest select_check : select_check.cpp ;
@@ -0,0 +1,31 @@
/*
* Copyright 2018, Xiang Fan, [email protected].
* Distributed under the terms of the MIT License.
*/
#include <stdio.h>
#include <poll.h>
int main()
{
FILE* f = fopen("/dev/null", "w");
printf("f=%p\n", f);
int fd = fileno(f);
printf("fd=%d\n", fd);
struct pollfd pfd;
pfd.fd = fd;
pfd.events = POLLOUT;
pfd.revents = 0;
int rv = poll(&pfd, 1, -1);
printf("rv=%d\n", rv);
if (rv <= 0)
return 1;
printf("events=%08x revents=%08x\n", pfd.events, pfd.revents);
if (pfd.revents != POLLOUT)
return 2;
return 0;
}