Skip to content

Commit

Permalink
Fix compiler warnings in socket tests (#11829)
Browse files Browse the repository at this point in the history
Keeps the CI output clean.
  • Loading branch information
sbc100 authored Aug 7, 2020
1 parent aaab662 commit 0c667ed
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
10 changes: 5 additions & 5 deletions tests/sockets/test_enet_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ void main_loop() {

break;
case ENET_EVENT_TYPE_RECEIVE:
printf ("A packet of length %u containing %s was received from %s on channel %u.\n",
printf ("A packet of length %zu containing %s was received from %s on channel %u.\n",
event.packet -> dataLength,
event.packet -> data,
event.peer -> data,
(char*)event.packet -> data,
(char*)event.peer -> data,
event.channelID);

int result = strcmp("packetfoo", event.packet->data);
int result = strcmp("packetfoo", (char*)event.packet->data);
#ifdef __EMSCRIPTEN__
REPORT_RESULT(result);
#else
Expand All @@ -51,7 +51,7 @@ void main_loop() {
enet_packet_destroy (event.packet);
break;
case ENET_EVENT_TYPE_DISCONNECT:
printf ("%s disconected.\n", event.peer -> data);
printf ("%s disconected.\n", (char*)event.peer -> data);
/* Reset the peer's client information. */
event.peer -> data = NULL;
enet_host_destroy(host);
Expand Down
10 changes: 5 additions & 5 deletions tests/sockets/test_enet_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void send_msg(ENetPeer *peer) {
/* Extend the packet so and append the string "foo", so it now */
/* contains "packetfoo\0" */
enet_packet_resize (packet, strlen ("packetfoo") + 1);
strcpy (& packet -> data [strlen ("packet")], "foo");
strcpy ((char*)& packet -> data [strlen ("packet")], "foo");
/* Send the packet to the peer over channel id 0. */
/* One could also broadcast the packet by */
/* enet_host_broadcast (host, 0, packet); */
Expand Down Expand Up @@ -64,16 +64,16 @@ printf("enet host, got event of type %d\n", event.type);

break;
case ENET_EVENT_TYPE_RECEIVE:
printf ("A packet of length %u containing %s was received from %s on channel %u.\n",
printf ("A packet of length %zu containing %s was received from %s on channel %u.\n",
event.packet -> dataLength,
event.packet -> data,
event.peer -> data,
(char*)event.packet -> data,
(char*)event.peer -> data,
event.channelID);
/* Clean up the packet now that we're done using it. */
enet_packet_destroy (event.packet);
break;
case ENET_EVENT_TYPE_DISCONNECT:
printf ("%s disconected.\n", event.peer -> data);
printf ("%s disconected.\n", (char*)event.peer -> data);
/* Reset the peer's client information. */
event.peer -> data = NULL;
enet_host_destroy(host);
Expand Down
4 changes: 2 additions & 2 deletions tests/sockets/test_sockets_echo_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ void main_loop() {
// In this test application we want to try and keep as much in common as the timed loop
// version but in a real application the fd can be used instead of needing to select().
void async_main_loop(int fd, void* userData) {
printf("%s callback\n", userData);
printf("%s callback\n", (char*)userData);
main_loop();
}

Expand All @@ -144,7 +144,7 @@ void error_callback(int fd, int err, const char* msg, void* userData) {
socklen_t len = sizeof(error);

int ret = getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len);
printf("%s callback\n", userData);
printf("%s callback\n", (char*)userData);
printf("error message: %s\n", msg);

if (err == error) {
Expand Down
2 changes: 1 addition & 1 deletion tests/sockets/test_sockets_echo_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ void main_loop() {
// In this test application we want to try and keep as much in common as the timed loop
// version but in a real application the fd can be used instead of needing to select().
void async_main_loop(int fd, void* userData) {
printf("%s callback\n", userData);
printf("%s callback\n", (char*)userData);
main_loop();
}

Expand Down
12 changes: 6 additions & 6 deletions tests/test_sockets.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def __enter__(self):
npm_checked = True

# compile the server
proc = run_process([EMCC, path_from_root('tests', self.filename), '-o', 'server.js', '-DSOCKK=%d' % self.listen_port] + self.args)
proc = run_process([EMCC, '-Werror', path_from_root('tests', self.filename), '-o', 'server.js', '-DSOCKK=%d' % self.listen_port] + self.args)
print('Socket server build: out:', proc.stdout or '', '/ err:', proc.stderr or '')

process = Popen(NODE_JS + ['server.js'])
Expand Down Expand Up @@ -398,8 +398,8 @@ def test_webrtc(self): # XXX see src/settings.js, this is disabled pending inves
};
''')

self.run_process([EMCC, temp_host_filepath, '-o', host_outfile] + ['-s', 'GL_TESTING=1', '--pre-js', 'host_pre.js', '-s', 'SOCKET_WEBRTC=1', '-s', 'SOCKET_DEBUG=1'])
self.run_process([EMCC, temp_peer_filepath, '-o', peer_outfile] + ['-s', 'GL_TESTING=1', '--pre-js', 'peer_pre.js', '-s', 'SOCKET_WEBRTC=1', '-s', 'SOCKET_DEBUG=1'])
self.run_process([EMCC, '-Werror', temp_host_filepath, '-o', host_outfile] + ['-s', 'GL_TESTING=1', '--pre-js', 'host_pre.js', '-s', 'SOCKET_WEBRTC=1', '-s', 'SOCKET_DEBUG=1'])
self.run_process([EMCC, '-Werror', temp_peer_filepath, '-o', peer_outfile] + ['-s', 'GL_TESTING=1', '--pre-js', 'peer_pre.js', '-s', 'SOCKET_WEBRTC=1', '-s', 'SOCKET_DEBUG=1'])

# note: you may need to run this manually yourself, if npm is not in the path, or if you need a version that is not in the path
self.run_process([NPM, 'install', path_from_root('tests', 'sockets', 'p2p')])
Expand Down Expand Up @@ -429,7 +429,7 @@ def test_nodejs_sockets_echo(self):
# Basic test of node client against both a Websockified and compiled echo server.
for harness, datagram in harnesses:
with harness:
self.run_process([EMCC, path_from_root('tests', 'sockets', 'test_sockets_echo_client.c'), '-o', 'client.js', '-DSOCKK=%d' % harness.listen_port, '-DTEST_DGRAM=%d' % datagram], stdout=PIPE, stderr=PIPE)
self.run_process([EMCC, '-Werror', path_from_root('tests', 'sockets', 'test_sockets_echo_client.c'), '-o', 'client.js', '-DSOCKK=%d' % harness.listen_port, '-DTEST_DGRAM=%d' % datagram], stdout=PIPE, stderr=PIPE)

out = self.run_js('client.js')
self.assertContained('do_msg_read: read 14 bytes', out)
Expand All @@ -443,7 +443,7 @@ def test_nodejs_sockets_echo(self):
WebsockifyServerHarness(os.path.join('sockets', 'test_sockets_echo_server.c'), [sockets_include], 59166)
]:
with harness:
self.run_process([EMCC, path_from_root('tests', 'sockets', 'test_sockets_echo_client.c'), '-o', 'client.js', '-s', 'SOCKET_DEBUG=1', '-s', 'WEBSOCKET_SUBPROTOCOL="base64, binary"', '-DSOCKK=59166'], stdout=PIPE, stderr=PIPE)
self.run_process([EMCC, '-Werror', path_from_root('tests', 'sockets', 'test_sockets_echo_client.c'), '-o', 'client.js', '-s', 'SOCKET_DEBUG=1', '-s', 'WEBSOCKET_SUBPROTOCOL="base64, binary"', '-DSOCKK=59166'], stdout=PIPE, stderr=PIPE)

out = self.run_js('client.js')
self.assertContained('do_msg_read: read 14 bytes', out)
Expand All @@ -466,7 +466,7 @@ def test_nodejs_sockets_echo(self):
};
''')

self.run_process([EMCC, path_from_root('tests', 'sockets', 'test_sockets_echo_client.c'), '-o', 'client.js', '--pre-js', 'websocket_pre.js', '-s', 'SOCKET_DEBUG=1', '-DSOCKK=12345'], stdout=PIPE, stderr=PIPE)
self.run_process([EMCC, '-Werror', path_from_root('tests', 'sockets', 'test_sockets_echo_client.c'), '-o', 'client.js', '--pre-js', 'websocket_pre.js', '-s', 'SOCKET_DEBUG=1', '-DSOCKK=12345'], stdout=PIPE, stderr=PIPE)

out = self.run_js('client.js')
self.assertContained('do_msg_read: read 14 bytes', out)
Expand Down

0 comments on commit 0c667ed

Please sign in to comment.