Skip to content

Commit

Permalink
test: allow EOVERFLOW errors in fs position tests
Browse files Browse the repository at this point in the history
Some platforms may return `EOVERFLOW` errors instead of `EFBIG`.

PR-URL: #43510
Refs: #42999
Refs: #43509
Reviewed-By: LiviaMedeiros <[email protected]>
Reviewed-By: Santiago Gimeno <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
richardlau authored and targos committed Jul 31, 2022
1 parent 1da1722 commit 7ce80d8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions test/parallel/test-fs-read-position-validation.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const offset = 0;
const length = buffer.byteLength;

// allowedErrors is an array of acceptable internal errors
// For example, on some platforms read syscall might return -EFBIG
// For example, on some platforms read syscall might return -EFBIG or -EOVERFLOW
async function testValid(position, allowedErrors = []) {
return new Promise((resolve, reject) => {
fs.open(filepath, 'r', common.mustSucceed((fd) => {
Expand Down Expand Up @@ -71,9 +71,9 @@ async function testInvalid(code, position) {
await testValid(1n);
await testValid(9);
await testValid(9n);
await testValid(Number.MAX_SAFE_INTEGER, [ 'EFBIG' ]);
await testValid(Number.MAX_SAFE_INTEGER, [ 'EFBIG', 'EOVERFLOW' ]);

await testValid(2n ** 63n - 1n - BigInt(length), [ 'EFBIG' ]);
await testValid(2n ** 63n - 1n - BigInt(length), [ 'EFBIG', 'EOVERFLOW' ]);
await testInvalid('ERR_OUT_OF_RANGE', 2n ** 63n);

// TODO(LiviaMedeiros): test `2n ** 63n - BigInt(length)`
Expand Down
6 changes: 3 additions & 3 deletions test/parallel/test-fs-readSync-position-validation.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const offset = 0;
const length = buffer.byteLength;

// allowedErrors is an array of acceptable internal errors
// For example, on some platforms read syscall might return -EFBIG
// For example, on some platforms read syscall might return -EFBIG or -EOVERFLOW
function testValid(position, allowedErrors = []) {
let fdSync;
try {
Expand Down Expand Up @@ -57,9 +57,9 @@ function testInvalid(code, position, internalCatch = false) {
testValid(1n);
testValid(9);
testValid(9n);
testValid(Number.MAX_SAFE_INTEGER, [ 'EFBIG' ]);
testValid(Number.MAX_SAFE_INTEGER, [ 'EFBIG', 'EOVERFLOW' ]);

testValid(2n ** 63n - 1n - BigInt(length), [ 'EFBIG' ]);
testValid(2n ** 63n - 1n - BigInt(length), [ 'EFBIG', 'EOVERFLOW' ]);
testInvalid('ERR_OUT_OF_RANGE', 2n ** 63n);

// TODO(LiviaMedeiros): test `2n ** 63n - BigInt(length)`
Expand Down

0 comments on commit 7ce80d8

Please sign in to comment.