11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciconst assert = require('assert'); 41cb0ef41Sopenharmony_ciconst path = require('path'); 51cb0ef41Sopenharmony_ciconst fs = require('fs'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ciconst tmpdir = require('../common/tmpdir'); 81cb0ef41Sopenharmony_citmpdir.refresh(); 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ci// fs.write with length > INT32_MAX 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_cicommon.skipIf32Bits(); 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_cilet buf; 151cb0ef41Sopenharmony_citry { 161cb0ef41Sopenharmony_ci buf = Buffer.allocUnsafe(0x7FFFFFFF + 1); 171cb0ef41Sopenharmony_ci} catch (e) { 181cb0ef41Sopenharmony_ci // If the exception is not due to memory confinement then rethrow it. 191cb0ef41Sopenharmony_ci if (e.message !== 'Array buffer allocation failed') throw (e); 201cb0ef41Sopenharmony_ci common.skip('skipped due to memory requirements'); 211cb0ef41Sopenharmony_ci} 221cb0ef41Sopenharmony_ci 231cb0ef41Sopenharmony_ciconst filename = path.join(tmpdir.path, 'write9.txt'); 241cb0ef41Sopenharmony_cifs.open(filename, 'w', 0o644, common.mustSucceed((fd) => { 251cb0ef41Sopenharmony_ci assert.throws(() => { 261cb0ef41Sopenharmony_ci fs.write(fd, 271cb0ef41Sopenharmony_ci buf, 281cb0ef41Sopenharmony_ci 0, 291cb0ef41Sopenharmony_ci 0x7FFFFFFF + 1, 301cb0ef41Sopenharmony_ci 0, 311cb0ef41Sopenharmony_ci common.mustNotCall()); 321cb0ef41Sopenharmony_ci }, { 331cb0ef41Sopenharmony_ci code: 'ERR_OUT_OF_RANGE', 341cb0ef41Sopenharmony_ci name: 'RangeError', 351cb0ef41Sopenharmony_ci message: 'The value of "length" is out of range. ' + 361cb0ef41Sopenharmony_ci 'It must be >= 0 && <= 2147483647. Received 2147483648' 371cb0ef41Sopenharmony_ci }); 381cb0ef41Sopenharmony_ci 391cb0ef41Sopenharmony_ci fs.closeSync(fd); 401cb0ef41Sopenharmony_ci})); 41