diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/core/test_poll.in | 30 | ||||
-rw-r--r-- | tests/core/test_poll.out | 7 | ||||
-rw-r--r-- | tests/test_core.py | 42 |
3 files changed, 40 insertions, 39 deletions
diff --git a/tests/core/test_poll.in b/tests/core/test_poll.in new file mode 100644 index 00000000..3fb0ebc9 --- /dev/null +++ b/tests/core/test_poll.in @@ -0,0 +1,30 @@ + + #include <stdio.h> + #include <errno.h> + #include <fcntl.h> + #include <poll.h> + + int main() { + struct pollfd multi[5]; + multi[0].fd = open("/file", O_RDONLY, 0777); + multi[1].fd = open("/device", O_RDONLY, 0777); + multi[2].fd = 123; + multi[3].fd = open("/file", O_RDONLY, 0777); + multi[4].fd = open("/file", O_RDONLY, 0777); + multi[0].events = POLLIN | POLLOUT | POLLNVAL | POLLERR; + multi[1].events = POLLIN | POLLOUT | POLLNVAL | POLLERR; + multi[2].events = POLLIN | POLLOUT | POLLNVAL | POLLERR; + multi[3].events = 0x00; + multi[4].events = POLLOUT | POLLNVAL | POLLERR; + + printf("ret: %d\n", poll(multi, 5, 123)); + printf("errno: %d\n", errno); + printf("multi[0].revents: %d\n", multi[0].revents == (POLLIN | POLLOUT)); + printf("multi[1].revents: %d\n", multi[1].revents == (POLLIN | POLLOUT)); + printf("multi[2].revents: %d\n", multi[2].revents == POLLNVAL); + printf("multi[3].revents: %d\n", multi[3].revents == 0); + printf("multi[4].revents: %d\n", multi[4].revents == POLLOUT); + + return 0; + } +
\ No newline at end of file diff --git a/tests/core/test_poll.out b/tests/core/test_poll.out new file mode 100644 index 00000000..8ffd3264 --- /dev/null +++ b/tests/core/test_poll.out @@ -0,0 +1,7 @@ +ret: 4 +errno: 0 +multi[0].revents: 1 +multi[1].revents: 1 +multi[2].revents: 1 +multi[3].revents: 1 +multi[4].revents: 1 diff --git a/tests/test_core.py b/tests/test_core.py index dc27450d..3f49e926 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -3981,46 +3981,10 @@ def process(filename): ) open(filename, 'w').write(src) ''' - src = r''' - #include <stdio.h> - #include <errno.h> - #include <fcntl.h> - #include <poll.h> - - int main() { - struct pollfd multi[5]; - multi[0].fd = open("/file", O_RDONLY, 0777); - multi[1].fd = open("/device", O_RDONLY, 0777); - multi[2].fd = 123; - multi[3].fd = open("/file", O_RDONLY, 0777); - multi[4].fd = open("/file", O_RDONLY, 0777); - multi[0].events = POLLIN | POLLOUT | POLLNVAL | POLLERR; - multi[1].events = POLLIN | POLLOUT | POLLNVAL | POLLERR; - multi[2].events = POLLIN | POLLOUT | POLLNVAL | POLLERR; - multi[3].events = 0x00; - multi[4].events = POLLOUT | POLLNVAL | POLLERR; - - printf("ret: %d\n", poll(multi, 5, 123)); - printf("errno: %d\n", errno); - printf("multi[0].revents: %d\n", multi[0].revents == (POLLIN | POLLOUT)); - printf("multi[1].revents: %d\n", multi[1].revents == (POLLIN | POLLOUT)); - printf("multi[2].revents: %d\n", multi[2].revents == POLLNVAL); - printf("multi[3].revents: %d\n", multi[3].revents == 0); - printf("multi[4].revents: %d\n", multi[4].revents == POLLOUT); + test_path = path_from_root('tests', 'core', 'test_poll') + src, output = (test_path + s for s in ('.in', '.out')) - return 0; - } - ''' - expected = r''' - ret: 4 - errno: 0 - multi[0].revents: 1 - multi[1].revents: 1 - multi[2].revents: 1 - multi[3].revents: 1 - multi[4].revents: 1 - ''' - self.do_run(src, re.sub('(^|\n)\s+', '\\1', expected), post_build=add_pre_run, extra_emscripten_args=['-H', 'libc/fcntl.h,poll.h']) + self.do_run_from_file(src, output, post_build=add_pre_run, extra_emscripten_args=['-H', 'libc/fcntl.h,poll.h']) def test_statvfs(self): src = r''' |