Skip to content

Commit b249db8

Browse files
committed
add fast api test
1 parent 895d3f0 commit b249db8

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

test/parallel/test-dgram-fast.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Flags: --expose-internals --no-warnings --allow-natives-syntax --test-udp-no-try-send
2+
'use strict';
3+
4+
const common = require('../common');
5+
const assert = require('assert');
6+
const dgram = require('dgram');
7+
8+
const { internalBinding } = require('internal/test/binding');
9+
10+
function testFastDgram() {
11+
const server = dgram.createSocket('udp4');
12+
const client = dgram.createSocket('udp4');
13+
14+
server.bind(0, common.mustCall(() => {
15+
client.connect(server.address().port, common.mustCall(() => {
16+
// Send some packets to queue them up (using --test-udp-no-try-send flag)
17+
client.send('Hello');
18+
client.send('World');
19+
20+
assert.strictEqual(typeof client.getSendQueueSize(), 'number');
21+
assert.strictEqual(typeof client.getSendQueueCount(), 'number');
22+
23+
client.close();
24+
server.close();
25+
}));
26+
}));
27+
}
28+
29+
eval('%PrepareFunctionForOptimization(testFastDgram)');
30+
testFastDgram();
31+
eval('%OptimizeFunctionOnNextCall(testFastDgram)');
32+
testFastDgram();
33+
34+
if (common.isDebug) {
35+
const { getV8FastApiCallCount } = internalBinding('debug');
36+
assert.strictEqual(getV8FastApiCallCount('udp.getSendQueueSize'), 1);
37+
assert.strictEqual(getV8FastApiCallCount('udp.getSendQueueCount'), 1);
38+
}

0 commit comments

Comments
 (0)