Skip to content

Commit

Permalink
test: move long-running test to sequential
Browse files Browse the repository at this point in the history
  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 <santiago.gimeno@gmail.com>
  Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  Reviewed-By: Italo A. Casas <me@italoacasas.com>

Backport-Of: #10161
PR-URL: #11176
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
Trott authored and jasnell committed Mar 3, 2017
1 parent 82a008b commit 4e90a13
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 41 deletions.
41 changes: 0 additions & 41 deletions test/parallel/test-buffer-creation-regression.js

This file was deleted.

36 changes: 36 additions & 0 deletions test/sequential/test-buffer-creation-regression.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'use strict';

const common = require('../common');
const assert = require('assert');

function test(arrayBuffer, offset, length) {
const uint8Array = new Uint8Array(arrayBuffer, offset, length);
for (let i = 0; i < length; i += 1) {
uint8Array[i] = 1;
}

const buffer = Buffer.from(arrayBuffer, offset, length);
for (let i = 0; i < length; i += 1) {
assert.strictEqual(buffer[i], 1);
}
}

const acceptableOOMErrors = [
'Array buffer allocation failed',
'Invalid array buffer length'
];

const size = 8589934592; /* 1 << 33 */
const offset = 4294967296; /* 1 << 32 */
const length = 1000;
let arrayBuffer;

try {
arrayBuffer = new ArrayBuffer(size);
} catch (e) {
if (e instanceof RangeError && acceptableOOMErrors.includes(e.message))
return common.skip(`Unable to allocate ${size} bytes for ArrayBuffer`);
throw e;
}

test(arrayBuffer, offset, length);

0 comments on commit 4e90a13

Please sign in to comment.