aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlan K <github@ack.modeswitch.org>2014-03-16 20:31:11 -0400
committerAlan K <github@ack.modeswitch.org>2014-03-16 20:31:11 -0400
commit7e22558b8a8c108ef3804f05311607724d9f3eab (patch)
tree6f062c11508301aaa01058ca745287d9bec041f4 /tests
parent50ecad0fcae2514333bf2437c85a206d8f4c399a (diff)
Add local broker for webrtc p2p test. Fixes #1974.
Diffstat (limited to 'tests')
m---------tests/sockets/p2p0
-rw-r--r--tests/sockets/webrtc_host.c11
-rw-r--r--tests/sockets/webrtc_peer.c4
-rw-r--r--tests/test_sockets.py12
4 files changed, 17 insertions, 10 deletions
diff --git a/tests/sockets/p2p b/tests/sockets/p2p
new file mode 160000
+Subproject f750484c56c49fb0383d488a9751c466590004b
diff --git a/tests/sockets/webrtc_host.c b/tests/sockets/webrtc_host.c
index e482d4ae..38adb0f2 100644
--- a/tests/sockets/webrtc_host.c
+++ b/tests/sockets/webrtc_host.c
@@ -22,7 +22,7 @@ char buf[BUFLEN];
char expected[] = "emscripten";
struct sockaddr_in si_host,
si_peer;
-struct iovec iov[1];
+struct iovec iov[1];
struct msghdr hdr;
int done = 0;
@@ -38,7 +38,10 @@ void iter() {
close(sock);
#ifdef __EMSCRIPTEN__
- int result = 1;
+ if(strlen((char*)hdr.msg_iov[0].iov_base) == strlen(expected) &&
+ 0 == strncmp((char*)hdr.msg_iov[0].iov_base, expected, strlen(expected))) {
+ result = 1;
+ }
REPORT_RESULT();
exit(EXIT_SUCCESS);
emscripten_cancel_main_loop();
@@ -68,10 +71,10 @@ int main(void)
perror("cannot bind host socket");
exit(EXIT_FAILURE);
}
-
+
iov[0].iov_base = buf;
iov[0].iov_len = sizeof(buf);
-
+
memset (&hdr, 0, sizeof (struct msghdr));
hdr.msg_name = &si_peer;
diff --git a/tests/sockets/webrtc_peer.c b/tests/sockets/webrtc_peer.c
index 327782d6..7b5f3a8a 100644
--- a/tests/sockets/webrtc_peer.c
+++ b/tests/sockets/webrtc_peer.c
@@ -46,7 +46,7 @@ void iter() {
}
int main(void)
-{
+{
memset(&si_host, 0, sizeof(struct sockaddr_in));
si_host.sin_family = AF_INET;
@@ -63,7 +63,7 @@ int main(void)
iov[0].iov_base = buf;
iov[0].iov_len = sizeof(buf);
-
+
memset (&hdr, 0, sizeof (struct msghdr));
hdr.msg_name = &si_host;
diff --git a/tests/test_sockets.py b/tests/test_sockets.py
index 3a5555ed..e781c652 100644
--- a/tests/test_sockets.py
+++ b/tests/test_sockets.py
@@ -345,12 +345,12 @@ class sockets(BrowserCore):
host_outfile = 'host.html'
peer_outfile = 'peer.html'
- host_filepath = path_from_root('tests', 'sockets', host_src)
+ host_filepath = path_from_root('tests', 'sockets', host_src)
temp_host_filepath = os.path.join(self.get_dir(), os.path.basename(host_src))
with open(host_filepath) as f: host_src = f.read()
with open(temp_host_filepath, 'w') as f: f.write(self.with_report_result(host_src))
- peer_filepath = path_from_root('tests', 'sockets', peer_src)
+ peer_filepath = path_from_root('tests', 'sockets', peer_src)
temp_peer_filepath = os.path.join(self.get_dir(), os.path.basename(peer_src))
with open(peer_filepath) as f: peer_src = f.read()
with open(temp_peer_filepath, 'w') as f: f.write(self.with_report_result(peer_src))
@@ -358,7 +358,7 @@ class sockets(BrowserCore):
open(os.path.join(self.get_dir(), 'host_pre.js'), 'w').write('''
var Module = {
webrtc: {
- broker: 'https://mdsw.ch:8080',
+ broker: 'http://localhost:8080',
session: undefined,
onpeer: function(peer, route) {
window.open('http://localhost:8888/peer.html?' + route);
@@ -382,7 +382,7 @@ class sockets(BrowserCore):
open(os.path.join(self.get_dir(), 'peer_pre.js'), 'w').write('''
var Module = {
webrtc: {
- broker: 'https://mdsw.ch:8080',
+ broker: 'http://localhost:8080',
session: window.location.toString().split('?')[1],
onpeer: function(peer, route) {
peer.connect(Module['webrtc']['session']);
@@ -403,9 +403,13 @@ class sockets(BrowserCore):
Popen([PYTHON, EMCC, temp_host_filepath, '-o', host_outfile] + ['-s', 'GL_TESTING=1', '--pre-js', 'host_pre.js', '-s', 'SOCKET_WEBRTC=1', '-s', 'SOCKET_DEBUG=1']).communicate()
Popen([PYTHON, EMCC, temp_peer_filepath, '-o', peer_outfile] + ['-s', 'GL_TESTING=1', '--pre-js', 'peer_pre.js', '-s', 'SOCKET_WEBRTC=1', '-s', 'SOCKET_DEBUG=1']).communicate()
+ broker = Popen([NODE_JS, path_from_root('tests', 'sockets', 'p2p', 'broker', 'p2p-broker.js')]);
+
expected = '1'
self.run_browser(host_outfile, '.', ['/report_result?' + e for e in expected])
+ broker.kill();
+
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