Skip to content

Commit 01509bc

Browse files
Trottaddaleax
authored andcommitted
test: move long-running test to sequential
test-buffer-creation-regression is flaky on some SmartOS hosts in CI, timing out. Move to sequential so it does not compete with other tests for resources. Reduce three test cases to just the one needed to identify the regression. PR-URL: #10161 Reviewed-By: Santiago Gimeno <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Italo A. Casas <[email protected]>
1 parent d8dc890 commit 01509bc

File tree

2 files changed

+36
-41
lines changed

2 files changed

+36
-41
lines changed

test/parallel/test-buffer-creation-regression.js

-41
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const assert = require('assert');
5+
6+
function test(arrayBuffer, offset, length) {
7+
const uint8Array = new Uint8Array(arrayBuffer, offset, length);
8+
for (let i = 0; i < length; i += 1) {
9+
uint8Array[i] = 1;
10+
}
11+
12+
const buffer = Buffer.from(arrayBuffer, offset, length);
13+
for (let i = 0; i < length; i += 1) {
14+
assert.strictEqual(buffer[i], 1);
15+
}
16+
}
17+
18+
const acceptableOOMErrors = [
19+
'Array buffer allocation failed',
20+
'Invalid array buffer length'
21+
];
22+
23+
const size = 8589934592; /* 1 << 33 */
24+
const offset = 4294967296; /* 1 << 32 */
25+
const length = 1000;
26+
let arrayBuffer;
27+
28+
try {
29+
arrayBuffer = new ArrayBuffer(size);
30+
} catch (e) {
31+
if (e instanceof RangeError && acceptableOOMErrors.includes(e.message))
32+
return common.skip(`Unable to allocate ${size} bytes for ArrayBuffer`);
33+
throw e;
34+
}
35+
36+
test(arrayBuffer, offset, length);

0 commit comments

Comments
 (0)