kernel: add /dev/null polling test
Bug: 13965
This commit is contained in:
@@ -51,6 +51,8 @@ SimpleTest port_wakeup_test_9 : port_wakeup_test_9.cpp ;
|
|||||||
|
|
||||||
SimpleTest mmap_resize_test : mmap_resize_test.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 reserved_areas_test : reserved_areas_test.cpp ;
|
||||||
|
|
||||||
SimpleTest select_check : select_check.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;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user