Skip to content

Commit 3628e54

Browse files
committed
[test] update test case for building native modules(node-dtrace-provider, ref, node-lame)
1 parent e13fa60 commit 3628e54

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

tests/automatic_tests/node/mocha_test.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,35 @@ describe('module', function() {
145145
it('native modules without handle scope', function() {
146146
require('./node_modules/nw_test_loop_without_handle');
147147
});
148+
149+
it('dtrace-provider should work', function() {
150+
var d = require('./node_modules/dtrace-provider');
151+
var dtp = d.createDTraceProvider("nodeapp");
152+
var p1 = dtp.addProbe("probe1", "int", "int");
153+
var p2 = dtp.addProbe("probe2", "char *");
154+
dtp.enable();
155+
});
156+
157+
it('ref should work', function() {
158+
var ref = require('ref')
159+
var buf = new Buffer(4)
160+
buf.writeInt32LE(12345, 0)
161+
console.log(buf.address()) // ← 140362165284824
162+
buf.type = ref.types.int
163+
assert.equal(buf.deref(), 12345) // ← 12345
164+
var one = buf.ref()
165+
assert.equal(one.deref().deref(), 12345) // ← 12345
166+
});
167+
168+
it('lame should work', function() {
169+
var lame = require('lame');
170+
// create the Encoder instance
171+
var encoder = new lame.Encoder({
172+
channels: 2, // 2 channels (left and right)
173+
bitDepth: 16, // 16-bit samples
174+
sampleRate: 44100 // 44,100 Hz sample rate
175+
});
176+
});
148177
});
149178
});
150179

tests/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
"mocha": "1.7.4",
2121
"nw_test_loop": "git+https://github.com/owenc4a4/nw_test_loop_without_handle.git",
2222
"bignum": "git+https://github.com/owenc4a4/bignum.git",
23+
"node-dtrace-provider": "git+https://github.com/chrisa/node-dtrace-provider.git",
24+
"ref": "git+https://github.com/TooTallNate/ref.git",
25+
"node-lame": "git+https://github.com/TooTallNate/node-lame.git",
2326
"fs-extra": "*"
2427
},
2528
"user-agent": "%name/%nwver/%ver/%webkit_ver/%osinfo",

tools/build_native_modules.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
native_modules = ['nw_test_loop_without_handle',
66
'bignum',
7+
'dtrace-provider',
8+
'ref',
9+
'lame',
710
];
811

912
script_dir = os.path.dirname(__file__)

0 commit comments

Comments
 (0)