Skip to content

Commit 0661fdf

Browse files
Trottevanlucas
authored andcommitted
test: add test-benchmark-crypto
Add minimal test for crypto benchmarks. It makes sure that they can run without returning an error code. PR-URL: #12347 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 6998e80 commit 0661fdf

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
5+
if (!common.hasCrypto) {
6+
common.skip('missing crypto');
7+
return;
8+
}
9+
10+
if (common.hasFipsCrypto) {
11+
common.skip('some benchmarks are FIPS-incompatible');
12+
return;
13+
}
14+
15+
// Minimal test for crypto benchmarks. This makes sure the benchmarks aren't
16+
// horribly broken but nothing more than that.
17+
18+
const assert = require('assert');
19+
const fork = require('child_process').fork;
20+
const path = require('path');
21+
22+
const runjs = path.join(__dirname, '..', '..', 'benchmark', 'run.js');
23+
const argv = ['--set', 'n=1',
24+
'--set', 'writes=1',
25+
'--set', 'len=1',
26+
'--set', 'api=stream',
27+
'--set', 'out=buffer',
28+
'--set', 'keylen=1024',
29+
'--set', 'type=buf',
30+
'crypto'];
31+
32+
const child = fork(runjs, argv, {env: {NODEJS_BENCHMARK_ZERO_ALLOWED: 1}});
33+
child.on('exit', (code, signal) => {
34+
assert.strictEqual(code, 0);
35+
assert.strictEqual(signal, null);
36+
});

0 commit comments

Comments
 (0)