aboutsummaryrefslogtreecommitdiff
path: root/tests/test_sockets.py
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-11-08 16:01:27 -0800
committerAlon Zakai <alonzakai@gmail.com>2013-11-08 16:04:05 -0800
commitb873dc778f52461129b1e28fb12dd3d4a309851c (patch)
treee82913bc549a83104ce8abfb518eca6cb6d8aa83 /tests/test_sockets.py
parent140ea9e81feb09d8f2559995c73d49a39424ef5d (diff)
parente0268fa1035a718341c53921eee9318d4a8033cd (diff)
Merge branch 'incoming' into f32
Conflicts: src/parseTools.js src/preamble.js
Diffstat (limited to 'tests/test_sockets.py')
-rw-r--r--tests/test_sockets.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/test_sockets.py b/tests/test_sockets.py
index d2bc46a2..e1caa150 100644
--- a/tests/test_sockets.py
+++ b/tests/test_sockets.py
@@ -400,3 +400,29 @@ class sockets(BrowserCore):
expected = '1'
self.run_browser(host_outfile, '.', ['/report_result?' + e for e in expected])
+ def test_nodejs_sockets_echo(self):
+ # This test checks that sockets work when the client code is run in Node.js
+ # Run with ./runner.py sockets.test_nodejs_sockets_echo
+ if not NODE_JS in JS_ENGINES:
+ return self.skip('node is not present')
+
+ sockets_include = '-I'+path_from_root('tests', 'sockets')
+
+ # Websockify-proxied servers can't run dgram tests
+ harnesses = [
+ # Websockify doesn't seem to like ws.WebSocket clients TODO check if this is a ws issue or Websockify issue
+ #(WebsockifyServerHarness(os.path.join('sockets', 'test_sockets_echo_server.c'), [sockets_include], 49160), 0),
+ (CompiledServerHarness(os.path.join('sockets', 'test_sockets_echo_server.c'), [sockets_include, '-DTEST_DGRAM=0'], 49161), 0),
+ (CompiledServerHarness(os.path.join('sockets', 'test_sockets_echo_server.c'), [sockets_include, '-DTEST_DGRAM=1'], 49162), 1)
+ ]
+
+ for harness, datagram in harnesses:
+ with harness:
+ Popen([PYTHON, EMCC, path_from_root('tests', 'sockets', 'test_sockets_echo_client.c'), '-o', path_from_root('tests', 'sockets', 'client.js'), '-DSOCKK=%d' % harness.listen_port, '-DREPORT_RESULT=int dummy'], stdout=PIPE, stderr=PIPE).communicate()
+
+ self.assertContained('do_msg_read: read 14 bytes', run_js(path_from_root('tests', 'sockets', 'client.js'), engine=NODE_JS))
+
+ # Tidy up files that might have been created by this test.
+ try_delete(path_from_root('tests', 'sockets', 'client.js'))
+ try_delete(path_from_root('tests', 'sockets', 'client.js.map'))
+