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: nodejs/node#43510
Refs: nodejs/node#42999
Refs: nodejs/node#43509
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
richardlau authored and guangwong committed Oct 10, 2022
1 parent 4df2187 commit 8089011
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
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
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 8089011

Please sign in to comment.