Skip to content

Commit 568d614

Browse files
danbevgibfahn
authored andcommitted
test: allow tests to pass without internet
Currently when running the test without an internet connection there are two JavaScript test failures and one cctest. The cctest only fails on Mac as far as I know. (I've only tested using Mac and Linux thus far). This commit moves the two JavaScript tests to test/internet. The details for test_inspector_socket_server.cc: [ RUN ] InspectorSocketServerTest.FailsToBindToNodejsHost make[1]: *** [cctest] Segmentation fault: 11 make: *** [test] Error 2 lldb output: [ RUN ] InspectorSocketServerTest.FailsToBindToNodejsHost Process 63058 stopped * thread #1: tid = 0x7b175, 0x00007fff96d04384 * libsystem_info.dylib`_gai_simple + 87, queue = * 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, * address=0x0) frame #0: 0x00007fff96d04384 libsystem_info.dylib`_gai_simple + 87 libsystem_info.dylib`_gai_simple: -> 0x7fff96d04384 <+87>: movw (%rdx), %ax 0x7fff96d04387 <+90>: movw %ax, -0x2a(%rbp) 0x7fff96d0438b <+94>: movq %r13, -0x38(%rbp) 0x7fff96d0438f <+98>: movq 0x18(%rbp), %rcx (lldb) bt * thread #1: tid = 0x7b175, 0x00007fff96d04384 * libsystem_info.dylib`_gai_simple + 87, queue = * 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, * address=0x0) * frame #0: 0x00007fff96d04384 libsystem_info.dylib`_gai_simple + 87 frame #1: 0x00007fff96cfe98b libsystem_info.dylib`search_addrinfo + 179 frame #2: 0x00007fff96cfafef libsystem_info.dylib`si_addrinfo + 2255 frame #3: 0x00007fff96cfa67b libsystem_info.dylib`getaddrinfo + 179 frame #4: 0x00000001017d8888 cctest`uv__getaddrinfo_work(w=0x00007fff5fbfe210) + 72 at getaddrinfo.c:102 frame #5: 0x00000001017d880e cctest`uv_getaddrinfo(loop=0x000000010287cb80, req=0x00007fff5fbfe1c8, cb=0x0000000000000000, hostname="nodejs.org", service="0", hints=0x00007fff5fbfe268) + 734 at getaddrinfo.c:192 frame #6: 0x000000010171f781 cctest`node::inspector::InspectorSocketServer::Start(this=0x00007fff5fbfe658) + 801 at inspector_socket_server.cc:398 frame #7: 0x00000001016ed590 cctest`InspectorSocketServerTest_FailsToBindToNodejsHost_Test::TestBody(this=0x0000000105001fd0) + 288 at test_inspector_socket_server.cc:593 I'm not sure about the exact cause for this but when using a standalone c program to simulate this it seems like when the ai_flags `AI_NUMERICSERV` is set, which is done in inspector_socket_server.cc line 394, the servname (the port in the FailsToBindToNodejsHost test) is expected to be a numeric port string to avoid looking it up in /etc/services. When the port is 0 as is it was before this commit the segment fault occurs but not if it is non-zero. PR-URL: #16255 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 465540c commit 568d614

4 files changed

+38
-30
lines changed

test/cctest/test_inspector_socket_server.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ TEST_F(InspectorSocketServerTest, TerminatingSessionReportsDone) {
589589

590590
TEST_F(InspectorSocketServerTest, FailsToBindToNodejsHost) {
591591
TestInspectorServerDelegate delegate;
592-
ServerHolder server(&delegate, &loop, "nodejs.org", 0, nullptr);
592+
ServerHolder server(&delegate, &loop, "nodejs.org", 80, nullptr);
593593
ASSERT_FALSE(server->Start());
594594
SPIN_WHILE(uv_loop_alive(&loop));
595595
}
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
'use strict';
2+
3+
require('../common');
4+
const assert = require('assert');
5+
const dgram = require('dgram');
6+
const multicastAddress = '224.0.0.114';
7+
8+
const setup = dgram.createSocket.bind(dgram, { type: 'udp4', reuseAddr: true });
9+
10+
// addMembership() with valid socket and multicast address should not throw
11+
{
12+
const socket = setup();
13+
assert.doesNotThrow(() => { socket.addMembership(multicastAddress); });
14+
socket.close();
15+
}
16+
17+
// dropMembership() without previous addMembership should throw
18+
{
19+
const socket = setup();
20+
assert.throws(
21+
() => { socket.dropMembership(multicastAddress); },
22+
/^Error: dropMembership EADDRNOTAVAIL$/
23+
);
24+
socket.close();
25+
}
26+
27+
// dropMembership() after addMembership() should not throw
28+
{
29+
const socket = setup();
30+
assert.doesNotThrow(
31+
() => {
32+
socket.addMembership(multicastAddress);
33+
socket.dropMembership(multicastAddress);
34+
}
35+
);
36+
socket.close();
37+
}

test/parallel/test-dgram-membership.js

-29
Original file line numberDiff line numberDiff line change
@@ -76,32 +76,3 @@ const setup = dgram.createSocket.bind(dgram, { type: 'udp4', reuseAddr: true });
7676
/^Error: dropMembership EINVAL$/);
7777
socket.close();
7878
}
79-
80-
// addMembership() with valid socket and multicast address should not throw
81-
{
82-
const socket = setup();
83-
assert.doesNotThrow(() => { socket.addMembership(multicastAddress); });
84-
socket.close();
85-
}
86-
87-
// dropMembership() without previous addMembership should throw
88-
{
89-
const socket = setup();
90-
assert.throws(
91-
() => { socket.dropMembership(multicastAddress); },
92-
/^Error: dropMembership EADDRNOTAVAIL$/
93-
);
94-
socket.close();
95-
}
96-
97-
// dropMembership() after addMembership() should not throw
98-
{
99-
const socket = setup();
100-
assert.doesNotThrow(
101-
() => {
102-
socket.addMembership(multicastAddress);
103-
socket.dropMembership(multicastAddress);
104-
}
105-
);
106-
socket.close();
107-
}

0 commit comments

Comments
 (0)