diff options
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/runner.py | 20 | ||||
-rw-r--r-- | tests/websockets_bi.c | 16 | ||||
-rw-r--r-- | tests/websockets_bi_side.c | 7 |
3 files changed, 27 insertions, 16 deletions
diff --git a/tests/runner.py b/tests/runner.py index 86e97b19..9db26947 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -12919,20 +12919,22 @@ elif 'browser' in str(sys.argv): def test_websockets_bi(self): for datagram in [0,1]: - try: - with self.WebsockHarness(8992, self.make_relay_server(8992, 8994)): - with self.WebsockHarness(8994, no_server=True): - Popen([PYTHON, EMCC, path_from_root('tests', 'websockets_bi_side.c'), '-o', 'side.html', '-DSOCKK=8995', '-DTEST_DGRAM=%d' % datagram]).communicate() - self.btest('websockets_bi.c', expected='2499', args=['-DTEST_DGRAM=%d' % datagram]) - finally: - self.clean_pids() + for fileops in [0,1]: + try: + print >> sys.stderr, 'test_websocket_bi datagram %d, fileops %d' % (datagram, fileops) + with self.WebsockHarness(8992, self.make_relay_server(8992, 8994)): + with self.WebsockHarness(8994, no_server=True): + Popen([PYTHON, EMCC, path_from_root('tests', 'websockets_bi_side.c'), '-o', 'side.html', '-DSOCKK=8995', '-DTEST_DGRAM=%d' % datagram]).communicate() + self.btest('websockets_bi.c', expected='2499', args=['-DSOCKK=8993', '-DTEST_DGRAM=%d' % datagram, '-DTEST_FILE_OPS=%s' % fileops]) + finally: + self.clean_pids() def test_websockets_bi_listen(self): try: with self.WebsockHarness(6992, self.make_relay_server(6992, 6994)): with self.WebsockHarness(6994, no_server=True): Popen([PYTHON, EMCC, path_from_root('tests', 'websockets_bi_side.c'), '-o', 'side.html', '-DSOCKK=6995']).communicate() - self.btest('websockets_bi_listener.c', expected='2499') + self.btest('websockets_bi_listener.c', expected='2499', args=['-DSOCKK=6993']) finally: self.clean_pids() @@ -12948,7 +12950,7 @@ elif 'browser' in str(sys.argv): with self.WebsockHarness(3992, self.make_relay_server(3992, 3994)): with self.WebsockHarness(3994, no_server=True): Popen([PYTHON, EMCC, path_from_root('tests', 'websockets_bi_side_bigdata.c'), '-o', 'side.html', '-DSOCKK=3995', '-s', 'SOCKET_DEBUG=0', '-I' + path_from_root('tests')]).communicate() - self.btest('websockets_bi_bigdata.c', expected='0', args=['-s', 'SOCKET_DEBUG=0', '-I' + path_from_root('tests')]) + self.btest('websockets_bi_bigdata.c', expected='0', args=['-DSOCKK=3993', '-s', 'SOCKET_DEBUG=0', '-I' + path_from_root('tests')]) finally: self.clean_pids() diff --git a/tests/websockets_bi.c b/tests/websockets_bi.c index 18cdd664..fb60177b 100644 --- a/tests/websockets_bi.c +++ b/tests/websockets_bi.c @@ -14,6 +14,10 @@ #define EXPECTED_BYTES 28 +#ifndef SOCKK +#define SOCKK 8992 +#endif + int SocketFD; unsigned int get_all_buf(int sock, char* output, unsigned int maxsize) @@ -25,7 +29,11 @@ unsigned int get_all_buf(int sock, char* output, unsigned int maxsize) char buffer[1024]; int n; unsigned int offset = 0; +#if TEST_FILE_OPS + while((errno = 0, (n = read(sock, buffer, sizeof(buffer)))>0) || +#else while((errno = 0, (n = recv(sock, buffer, sizeof(buffer), 0))>0) || +#endif errno == EINTR) { if(n>0) { @@ -96,13 +104,7 @@ int main(void) memset(&stSockAddr, 0, sizeof(stSockAddr)); stSockAddr.sin_family = AF_INET; - stSockAddr.sin_port = htons( -#if EMSCRIPTEN - 8993 -#else - 8992 -#endif - ); + stSockAddr.sin_port = htons(SOCKK); Res = inet_pton(AF_INET, "127.0.0.1", &stSockAddr.sin_addr); if (0 > Res) { diff --git a/tests/websockets_bi_side.c b/tests/websockets_bi_side.c index 12b790fd..1d557ed8 100644 --- a/tests/websockets_bi_side.c +++ b/tests/websockets_bi_side.c @@ -54,10 +54,17 @@ int main(void) exit(EXIT_FAILURE); } +#if TEST_FILE_OPS + printf("write..\n"); + + char data[] = "hello from the other siide (fileops)\n"; + write(SocketFD, data, sizeof(data)); +#else printf("send..\n"); char data[] = "hello from the other siide\n"; send(SocketFD, data, sizeof(data), 0); +#endif printf("stall..\n"); |