mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
test: skip test-fs-largefile if not enough disk space
Fixes: https://github.com/nodejs/build/issues/3071 PR-URL: https://github.com/nodejs/node/pull/45339 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Nitzan Uziely <linkgoron@gmail.com>
This commit is contained in:
@@ -29,21 +29,29 @@ const path = require('path');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
|
||||
const filepath = path.join(tmpdir.path, 'large.txt');
|
||||
const fd = fs.openSync(filepath, 'w+');
|
||||
const offset = 5 * 1024 * 1024 * 1024; // 5GB
|
||||
const message = 'Large File';
|
||||
try {
|
||||
|
||||
fs.ftruncateSync(fd, offset);
|
||||
assert.strictEqual(fs.statSync(filepath).size, offset);
|
||||
const writeBuf = Buffer.from(message);
|
||||
fs.writeSync(fd, writeBuf, 0, writeBuf.length, offset);
|
||||
const readBuf = Buffer.allocUnsafe(writeBuf.length);
|
||||
fs.readSync(fd, readBuf, 0, readBuf.length, offset);
|
||||
assert.strictEqual(readBuf.toString(), message);
|
||||
fs.readSync(fd, readBuf, 0, 1, 0);
|
||||
assert.strictEqual(readBuf[0], 0);
|
||||
const filepath = path.join(tmpdir.path, 'large.txt');
|
||||
const fd = fs.openSync(filepath, 'w+');
|
||||
const offset = 5 * 1024 * 1024 * 1024; // 5GB
|
||||
const message = 'Large File';
|
||||
|
||||
// Verify that floating point positions do not throw.
|
||||
fs.writeSync(fd, writeBuf, 0, writeBuf.length, 42.000001);
|
||||
fs.close(fd, common.mustCall());
|
||||
fs.ftruncateSync(fd, offset);
|
||||
assert.strictEqual(fs.statSync(filepath).size, offset);
|
||||
const writeBuf = Buffer.from(message);
|
||||
fs.writeSync(fd, writeBuf, 0, writeBuf.length, offset);
|
||||
const readBuf = Buffer.allocUnsafe(writeBuf.length);
|
||||
fs.readSync(fd, readBuf, 0, readBuf.length, offset);
|
||||
assert.strictEqual(readBuf.toString(), message);
|
||||
fs.readSync(fd, readBuf, 0, 1, 0);
|
||||
assert.strictEqual(readBuf[0], 0);
|
||||
|
||||
// Verify that floating point positions do not throw.
|
||||
fs.writeSync(fd, writeBuf, 0, writeBuf.length, 42.000001);
|
||||
fs.close(fd, common.mustCall());
|
||||
} catch (e) {
|
||||
if (e.code !== 'ENOSPC') {
|
||||
throw e;
|
||||
}
|
||||
common.skip('insufficient disk space');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user