Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: increase dgram ref()/unref() coverage #11240

Merged
merged 1 commit into from
Feb 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion test/parallel/test-dgram-ref.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
'use strict';
require('../common');
const common = require('../common');
const dgram = require('dgram');

// should not hang, see #1282
dgram.createSocket('udp4');
dgram.createSocket('udp6');

{
// Test the case of ref()'ing a socket with no handle.
const s = dgram.createSocket('udp4');

s.close(common.mustCall(() => s.ref()));
}
16 changes: 13 additions & 3 deletions test/parallel/test-dgram-unref.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,18 @@
const common = require('../common');
const dgram = require('dgram');

const s = dgram.createSocket('udp4');
s.bind();
s.unref();
{
// Test the case of unref()'ing a socket with a handle.
const s = dgram.createSocket('udp4');
s.bind();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the call to bind() necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test will run without the bind(), but binding keeps the event loop open and causes the test to timeout if unref'ing doesn't actually work.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. Thanks!

s.unref();
}

{
// Test the case of unref()'ing a socket with no handle.
const s = dgram.createSocket('udp4');

s.close(common.mustCall(() => s.unref()));
}

setTimeout(common.mustNotCall(), 1000).unref();