test: fix inconsistency write size in test-fs-readfile-tostring-fail

PR-URL: https://github.com/nodejs/node/pull/51141
Refs: https://github.com/nodejs/node/issues/51133
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Deokjin Kim <deokjin81.kim@gmail.com>
This commit is contained in:
Jungku Lee 2023-12-25 12:38:40 +09:00 committed by GitHub
parent a3a4eff0be
commit 26d39e875f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,13 +9,15 @@ const assert = require('assert');
const fs = require('fs'); const fs = require('fs');
const cp = require('child_process'); const cp = require('child_process');
const kStringMaxLength = require('buffer').constants.MAX_STRING_LENGTH; const kStringMaxLength = require('buffer').constants.MAX_STRING_LENGTH;
const size = Math.floor(kStringMaxLength / 200);
if (common.isAIX && (Number(cp.execSync('ulimit -f')) * 512) < kStringMaxLength) if (common.isAIX && (Number(cp.execSync('ulimit -f')) * 512) < kStringMaxLength)
common.skip('intensive toString tests due to file size confinements'); common.skip('intensive toString tests due to file size confinements');
const tmpdir = require('../common/tmpdir'); const tmpdir = require('../common/tmpdir');
tmpdir.refresh(); tmpdir.refresh();
if (!tmpdir.hasEnoughSpace(kStringMaxLength)) { if (!tmpdir.hasEnoughSpace(kStringMaxLength + size)) {
common.skip(`Not enough space in ${tmpdir.path}`); common.skip(`Not enough space in ${tmpdir.path}`);
} }
@ -26,7 +28,6 @@ const stream = fs.createWriteStream(file, {
stream.on('error', (err) => { throw err; }); stream.on('error', (err) => { throw err; });
const size = kStringMaxLength / 200;
const a = Buffer.alloc(size, 'a'); const a = Buffer.alloc(size, 'a');
let expectedSize = 0; let expectedSize = 0;