Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/dev/null #4787

Closed
wants to merge 191 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
191 commits
Select commit Hold shift + click to select a range
d10b710
debugger: also exit when the repl emits 'exit'
fb55 Aug 13, 2015
82e76f1
doc: update irc channels: #node.js and #node-dev
nelsonpecora Sep 8, 2015
5e25c82
module: fix column offsets in errors
tflanagan Sep 14, 2015
1006102
build: Updates for AIX npm support - part 1
mhdawson Sep 29, 2015
930b483
lib,test: update let to const where applicable
thefourtheye Oct 8, 2015
3127666
tools: enable prefer-const eslint rule
thefourtheye Oct 8, 2015
a4bcf03
doc: add TSC meeting minutes 2015-09-30
rvagg Oct 7, 2015
e6cc732
doc: add TSC meeting minutes 2015-10-07
rvagg Oct 14, 2015
e42abf8
util: fix constructor/instanceof checks
mscdex Oct 15, 2015
ae46a23
tools: add tap output to cpplint
jbergstroem Oct 20, 2015
e6b5119
async_wrap: allow some hooks to be optional
trevnorris Oct 20, 2015
ca8b478
async_wrap: new instances get uid
trevnorris Oct 19, 2015
dab862f
async_wrap: call callback in destructor
trevnorris Oct 20, 2015
33474b7
doc: add TSC meeting minutes 2015-10-14
rvagg Oct 21, 2015
fcb67d7
doc: add TSC meeting minutes 2015-10-21
rvagg Oct 22, 2015
15ae55e
test: fix race condition in unrefd interval test
mcornac Oct 27, 2015
39056e2
doc: add final full stop in CONTRIBUTING.md
emilyaviva Oct 29, 2015
cf4a8d5
doc: add CTC meeting minutes 2015-10-28
rvagg Nov 4, 2015
6d9d37f
build: omit -gline-tables-only for --enable-asan
bnoordhuis Nov 5, 2015
595320a
doc: add warning about Windows process groups
r-52 Nov 5, 2015
45df9f7
test: skip instead of fail when mem constrained
mcornac Nov 6, 2015
327b746
tools: Use `throw new Error()` consistently
Trott Nov 8, 2015
d96d07d
tools: enforce `throw new Error()` with lint rule
Trott Nov 8, 2015
92e59e1
doc: Describe FIPSDIR environment variable
stefanmb Nov 6, 2015
00f4312
crypto: disable crypto.createCipher in FIPS mode
stefanmb Nov 9, 2015
e1f2810
test: add OS X to module loading error test
evanlucas Nov 18, 2015
a221308
fs,doc: use `target` instead of `destination`
yorkie Nov 25, 2015
14c6f84
doc: move fs.existsSync() deprecation message
martfors Nov 20, 2015
80d8529
net: small code cleanup
jscissr Nov 20, 2015
50564b5
test: add TAP diagnostic message for retried tests
Trott Nov 21, 2015
3f04261
test: fix time resolution constraint
gireeshpunathil Nov 23, 2015
4290823
doc: s/node.js/Node.js in readme
rvagg Nov 24, 2015
30b306c
buffer: default to UTF8 in byteLength()
tomgco Nov 24, 2015
0f591e6
test: use platform-based timeout for reliability
Trott Nov 25, 2015
89c8450
crypto: fix native module compilation with FIPS
stefanmb Nov 25, 2015
24117ee
doc: add links and backticks around names
Nov 27, 2015
aa1034a
doc: fixup socket.remoteAddress
baloo Dec 8, 2015
6d6e63c
doc: document backlog for server.listen() variants
jscissr Nov 25, 2015
f0cf7d8
timers: optimize callback call: bind -> arrow
bsnote Nov 26, 2015
a3394fc
test: fix http-many-ended-pipelines flakiness
santigimeno Nov 26, 2015
24b6596
test: eliminate multicast test FreeBSD flakiness
Trott Nov 26, 2015
ebfbf55
test: improve cluster-disconnect-handles test
mscdex Dec 1, 2015
f634ab6
test: fix flaky test-net-socket-local-address
Trott Dec 1, 2015
6c2cb45
src: don't print garbage errors
cjihrig Dec 2, 2015
2d18d54
test: skip long path tests on non-Windows
rsp Dec 2, 2015
e7a423f
doc: url.format - true slash postfix behaviour
Dec 2, 2015
f526071
doc: improve child_process.markdown wording
yorkie Dec 3, 2015
2d42b41
doc: add zkat to collaborators
zkat Dec 3, 2015
18ac78d
doc: add JungMinu to collaborators
JungMinu Dec 3, 2015
184d108
doc: add iarna to collaborators
iarna Dec 3, 2015
66d3ab4
doc, test: symbols as event names
bengl Dec 4, 2015
c3df462
build: add "--partly-static" build options
medns Dec 4, 2015
771aaa6
buffer: Prevent Buffer constructor deopt
brycebaril Dec 4, 2015
78dc27b
test: mark test-cluster-shared-leak flaky
Trott Dec 5, 2015
640838c
src: use GetCurrentProcessId() for process.pid
bnoordhuis Dec 4, 2015
1eb5887
node: s/doNTCallbackX/nextTickCallbackWithXArgs/
rvagg Dec 6, 2015
805e8c4
repl: display error message when loading directory
princejwesley Dec 6, 2015
458b06b
doc: add brief Node.js overview to README
Dec 7, 2015
85b624e
doc: change references from node to Node.js
r-52 Dec 7, 2015
21aa749
doc: update AUTHORS list
rvagg Dec 8, 2015
3b50842
doc: copyedit addons doc
Trott Dec 8, 2015
31a9a65
doc: clarify assert.fail doc
Trott Dec 8, 2015
9a646b9
doc: copyedit buffer doc
Trott Dec 8, 2015
435271a
doc: copyedit child_process doc
Trott Dec 8, 2015
10a75c3
tls_wrap: slice buffer properly in `ClearOut`
indutny Dec 8, 2015
a1f7bc7
test: fix tls-inception
santigimeno Dec 8, 2015
76f5a91
test: fix tls-inception flakiness
santigimeno Dec 8, 2015
db15157
configure: fix arm vfpv2
joerg-krause Dec 8, 2015
6a0ec14
test: don't assume openssl s_client supports -ssl3
bnoordhuis Dec 8, 2015
3f77e7b
test: fix domain-top-level-error-handler-throw
santigimeno Dec 20, 2015
b85ac63
doc: harmonize description of `ca` argument
bnoordhuis Dec 9, 2015
21b2f61
doc: add calvinmetcalf to collaborators
calvinmetcalf Dec 9, 2015
4b4581d
doc: add rmg to collaborators
rmg Dec 9, 2015
e674c95
doc: add mcollina to collaborators
mcollina Dec 9, 2015
fa57262
doc: copyedit console doc
Trott Dec 10, 2015
cc0710b
doc: move description of 'equals' method to right place
janriemer Dec 10, 2015
d8f82ce
doc: Fixing broken links to the v8 wiki
tomgco Dec 11, 2015
8256457
test: parallelize test-repl-persistent-history
Fishrock123 Dec 11, 2015
3877079
test: use regular timeout times for ARMv8
Fishrock123 Dec 10, 2015
a1bd345
src: fix line numbers on core errors
cjihrig Dec 11, 2015
032a8f0
doc: fix improper http.get sample code
hidekiy Dec 13, 2015
e5e23b1
node: remove unused variables in AppendExceptionLine
yorkie Dec 13, 2015
d1679fd
tls_wrap: inherit from the `AsyncWrap` first
indutny Dec 14, 2015
b88d1dd
src: fix deprecation message for ErrnoException
gagern Dec 14, 2015
dd9c529
doc: clarify error events in HTTP module documentation
Dec 14, 2015
01da04e
doc: fix, modernize examples in docs
jasnell Dec 14, 2015
9bbad89
test: add test for tls.parseCertString
evanlucas Dec 15, 2015
c765db1
doc: document the cache parameter for fs.realpathSync
JacksonTian Dec 15, 2015
acad415
udp: remove a needless instanceof Buffer check
Dec 16, 2015
d45dfb4
test: fix debug-port-cluster flakiness
bnoordhuis Dec 16, 2015
6f35fef
doc: Typo in buffer.markdown referencing buf.write()
chrisJohn404 Dec 17, 2015
ff5b4a4
doc: fix link in addons.markdown
secretfader Dec 17, 2015
01752ce
doc: catch the WORKING_GROUPS.md bootstrap docs up to date
jasnell Dec 20, 2015
956facb
doc: copyedit releases.md
Trott Dec 21, 2015
093bdcb
src: refactor vcbuild configure args creation
rvagg Oct 16, 2015
c23dea8
deps: upgrade libuv to 1.8.0
saghul Dec 13, 2015
1c81d11
test: try other ipv6 localhost alternatives
mscdex Dec 17, 2015
75fad1c
test: fix flaky test-net-error-twice
mscdex Dec 18, 2015
04d7c0b
test: fix race condition in test-http-client-onerror
dnakamura Dec 18, 2015
062d131
doc: improve assert.markdown copy
jasnell Dec 20, 2015
3e14041
test: use platformTimeout() in more places
mscdex Dec 22, 2015
d196f09
test: refactor test-net-connect-options-ipv6
Trott Dec 23, 2015
4e603c4
doc: fix spelling error in lib/url.js comment
nikolas Dec 22, 2015
cea43b3
doc: improvements to console.markdown copy
jasnell Dec 26, 2015
85052ef
doc: improvements to debugger.markdown copy
jasnell Dec 27, 2015
f30f9ff
doc: improvements to dgram.markdown copy
jasnell Dec 27, 2015
126e054
deps: backport 200315c from V8 upstream
vkurchatkin Dec 3, 2015
a1f4285
util,src: allow lookup of hidden values
cjihrig Nov 23, 2015
75b638e
util: add decorateErrorStack()
cjihrig Nov 25, 2015
4e23b2a
repl: attach location info to syntax errors
cjihrig Nov 25, 2015
a8ac55c
module,repl: remove repl require() hack
bnoordhuis Nov 25, 2015
c16fa6b
util: move .decorateErrorStack to internal/util
bnoordhuis Nov 25, 2015
f64aa34
test: move ArrayStream to common
cjihrig Nov 25, 2015
b5f8a35
util: determine object types in C++
cjihrig Dec 1, 2015
1782577
src: define Is* util functions with macros
cjihrig Dec 2, 2015
82c9778
repl: fix require('3rdparty') regression
bnoordhuis Dec 9, 2015
e9959ab
test: remove unnecessary assignments
Trott Dec 24, 2015
51e0693
test: remove unused `util` imports
Trott Dec 23, 2015
e566843
deps: backport 066747e from upstream V8
ofrobots Jan 11, 2016
dbf6537
repl: use String#repeat instead of Array#join
evanlucas Nov 18, 2015
54bb2fb
util: faster arrayToHash
JacksonTian Nov 22, 2015
fc79e18
child_process: flush consuming streams
Nov 30, 2015
eb55780
repl: Fixed node repl history edge case.
zeusdeux Dec 1, 2015
bb0a964
crypto: load PFX chain the same way as regular one
indutny Dec 5, 2015
44bb763
http: remove excess calls to removeSocket
Dec 6, 2015
1ca43b9
test: add test-domain-exit-dispose-again back
Dec 12, 2015
a9ca039
os: fix crash in GetInterfaceAddresses
martinbark Dec 14, 2015
11526bd
http: Remove an unnecessary assignment
gigabo Dec 17, 2015
8110459
buffer: faster case for create Buffer from new Buffer(0)
JacksonTian Dec 17, 2015
a22b389
assert: typed array deepequal performance fix
claudiorodriguez Dec 17, 2015
b3c9917
buffer: refactor create buffer
JacksonTian Dec 18, 2015
6924b6c
https: use `servername` in agent key
indutny Dec 22, 2015
337d225
repl: remove unused function
Trott Dec 23, 2015
4a7558e
test: remove unused var from test-assert.js
Trott Dec 23, 2015
187ab4a
http: use `self.keepAlive` instead of `self.options.keepAlive`
dschenkelman Dec 23, 2015
a7b58ef
child_process: guard against race condition
Trott Dec 24, 2015
44a1b10
test: remove unused assert module imports
Trott Dec 27, 2015
4520599
doc: add anchors for _transform _flush _writev in stream.markdown
iamchenxin Dec 28, 2015
ec3b699
doc: improvements to dns.markdown copy
jasnell Dec 27, 2015
8ca365b
doc: improvements to errors.markdown copy
jasnell Dec 28, 2015
abf50ac
doc: explain ClientRequest#setTimeout time unit
bripkens Dec 28, 2015
b539ff8
test: improve assert message
Trott Dec 29, 2015
9f23872
doc: improvements to events.markdown copy
jasnell Dec 29, 2015
aa6e704
test: clarify role of domains in test
Trott Dec 31, 2015
4e936b1
test: refactor test-fs-empty-readStream
Trott Dec 30, 2015
596438e
test: remove time check
Trott Dec 31, 2015
0589987
test: inherit JOBS from environment
jbergstroem Dec 31, 2015
749d015
test: fix flaky streams test
Trott Jan 3, 2016
f710028
test: remove flaky designations for tests
Trott Jan 3, 2016
6e531bb
test: fix flaky test-http-agent-keepalive
Trott Jan 4, 2016
a7fddd7
doc: close backtick in process.title description
Jan 5, 2016
3ffc928
doc: stronger suggestion for userland assert
geek Jan 5, 2016
715eb10
doc: fix numbering in stream.markdown
richardsun29 Jan 5, 2016
ac3f1a7
doc: bring releases.md up to date
cjihrig Jan 5, 2016
42f1c90
doc: add missing backtick for readline
mscdex Jan 6, 2016
4bcef3c
doc: add Myles Borins to Release Team
Jan 8, 2016
10ffdaf
doc: add Evan Lucas to Release Team
evanlucas Jan 8, 2016
3a6ab1b
doc: fix description about the latest-codename
JungMinu Jan 8, 2016
70791ae
doc: label http.IncomingMessage as a Class
Sequoia Jan 8, 2016
19f21ab
doc: document http's server.listen return value
Sequoia Jan 8, 2016
909df52
doc: adds usage of readline line-by-line parsing
eljefedelrodeodeljefe Jan 10, 2016
a6483eb
doc: update stylesheet to match frontpage
silverwind Jan 11, 2016
0b70a9a
doc: add branch-diff example to releases.md
Jan 12, 2016
1622bcc
docs: fix npm command in releases.md
Jan 13, 2016
0ccbc1f
docs: update gpg key for Myles Borins
Jan 13, 2016
cf7ebd3
test: fix flaky cluster-disconnect-race
mscdex Dec 28, 2015
df4938e
dns: remove nonexistant exports.ADNAME
silverwind Sep 27, 2015
dba3dc5
test: remove unused modules
Trott Dec 30, 2015
46e3fd6
lib: remove unused modules
Trott Dec 23, 2015
7894f19
test: remove unused vars
Trott Dec 27, 2015
e36811b
test: remove unused vars in ChildProcess tests
Trott Dec 26, 2015
8c094be
test: remove unused variables from net tests
Trott Dec 26, 2015
ba1847d
test: remove unused variables from HTTPS tests
Trott Dec 26, 2015
7c30944
test: remove unused variables from TLS tests
Trott Dec 26, 2015
36d28ce
test: extend timeout in Debug mode
Trott Dec 26, 2015
eb53af2
test: remove unused variables form http tests
Trott Dec 25, 2015
b3b150c
test: remove unused vars from parallel tests
Trott Jan 2, 2016
ef5e9ef
tools: implement no-unused-vars for eslint
Trott Dec 23, 2015
5608267
doc: clarify explanation of first stream section
vccortez Dec 10, 2015
cfb0945
tls_wrap: clear errors on return
indutny Jan 3, 2016
d33279d
test: make temp path customizable
jbergstroem Oct 12, 2015
b3079ef
test: don't assume a certain folder structure
jbergstroem Dec 30, 2015
3fa0d4a
test: write to tmp dir rather than fixture dir
Trott Dec 30, 2015
476ac24
doc: update links to use https where possible
Dec 2, 2015
bb2e2d0
test: don't use cwd for relative path
jbergstroem Dec 30, 2015
7e1564d
doc: clarify protocol default in http.request()
cjihrig Jan 15, 2016
12db976
test: mark test-debug-no-context is flaky
Trott Dec 25, 2015
46b2d2b
assert: accommodate ES6 classes that extend Error
Trott Dec 6, 2015
98a6793
tools: add .editorconfig
ronkorving Sep 22, 2015
fdcf296
module,src: do not wrap modules with -1 lineOffset
cjihrig Dec 15, 2015
39eeca6
test: add test for debugging one line files
cjihrig Dec 15, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: skip instead of fail when mem constrained
The current implementation of tests for strings with length at or
exceeding kStringMaxLength allocate a temporary buffer inside a try
block to skip the test if there is insufficient memory. This commit adds
an invocation of the garbage collector after the temporary buffer is
allocated so that memory is freed for later allocations.

Change the corresponding catch block to rethrow the original exception
instead of asserting the exception message to provide more information
about the exception.

Add an additional check before trying to allocate memory to immediately
skip the test on machines with insufficient total memory.

PR-URL: #3697
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
mcornac authored and Myles Borins committed Dec 29, 2015
commit 45df9f7628d070950c8cbe3d5a6b51012d05eee3
2 changes: 2 additions & 0 deletions test/common.js
Original file line number Diff line number Diff line change
@@ -20,6 +20,8 @@ exports.isLinuxPPCBE = (process.platform === 'linux') &&
exports.isSunOS = process.platform === 'sunos';
exports.isFreeBSD = process.platform === 'freebsd';

exports.enoughTestMem = os.totalmem() > 0x20000000; /* 512MB */

function rimrafSync(p) {
try {
var st = fs.lstatSync(p);
24 changes: 17 additions & 7 deletions test/parallel/test-stringbytes-external-at-max.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
'use strict';
// Flags: --expose-gc

require('../common');
const common = require('../common');
const assert = require('assert');

// v8 fails silently if string length > v8::String::kMaxLength
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = process.binding('buffer').kStringMaxLength;

const skipMessage =
'1..0 # Skipped: intensive toString tests due to memory confinements';
if (!common.enoughTestMem) {
console.log(skipMessage);
return;
}
assert(typeof gc === 'function', 'Run this test with --expose-gc');

try {
new Buffer(kStringMaxLength * 3);
var buf = new Buffer(kStringMaxLength);
// Try to allocate memory first then force gc so future allocations succeed.
new Buffer(2 * kStringMaxLength);
gc();
} catch(e) {
assert.equal(e.message, 'Invalid array buffer length');
console.log(
'1..0 # Skipped: intensive toString tests due to memory confinements');
// If the exception is not due to memory confinement then rethrow it.
if (e.message !== 'Invalid array buffer length') throw (e);
console.log(skipMessage);
return;
}

const buf = new Buffer(kStringMaxLength);

const maxString = buf.toString('binary');
assert.equal(maxString.length, kStringMaxLength);
24 changes: 17 additions & 7 deletions test/parallel/test-stringbytes-external-exceed-max-by-1-ascii.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
'use strict';
// Flags: --expose-gc

require('../common');
const common = require('../common');
const assert = require('assert');

const skipMessage =
'1..0 # Skipped: intensive toString tests due to memory confinements';
if (!common.enoughTestMem) {
console.log(skipMessage);
return;
}
assert(typeof gc === 'function', 'Run this test with --expose-gc');

// v8 fails silently if string length > v8::String::kMaxLength
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = process.binding('buffer').kStringMaxLength;

try {
new Buffer(kStringMaxLength * 3);
var buf = new Buffer(kStringMaxLength + 1);
// Try to allocate memory first then force gc so future allocations succeed.
new Buffer(2 * kStringMaxLength);
gc();
} catch(e) {
assert.equal(e.message, 'Invalid array buffer length');
console.log(
'1..0 # Skipped: intensive toString tests due to memory confinements');
// If the exception is not due to memory confinement then rethrow it.
if (e.message !== 'Invalid array buffer length') throw (e);
console.log(skipMessage);
return;
}

const buf = new Buffer(kStringMaxLength + 1);

assert.throws(function() {
buf.toString('ascii');
}, /toString failed/);
24 changes: 17 additions & 7 deletions test/parallel/test-stringbytes-external-exceed-max-by-1-base64.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
'use strict';
// Flags: --expose-gc

require('../common');
const common = require('../common');
const assert = require('assert');

const skipMessage =
'1..0 # Skipped: intensive toString tests due to memory confinements';
if (!common.enoughTestMem) {
console.log(skipMessage);
return;
}
assert(typeof gc === 'function', 'Run this test with --expose-gc');

// v8 fails silently if string length > v8::String::kMaxLength
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = process.binding('buffer').kStringMaxLength;

try {
new Buffer(kStringMaxLength * 3);
var buf = new Buffer(kStringMaxLength + 1);
// Try to allocate memory first then force gc so future allocations succeed.
new Buffer(2 * kStringMaxLength);
gc();
} catch(e) {
assert.equal(e.message, 'Invalid array buffer length');
console.log(
'1..0 # Skipped: intensive toString tests due to memory confinements');
// If the exception is not due to memory confinement then rethrow it.
if (e.message !== 'Invalid array buffer length') throw (e);
console.log(skipMessage);
return;
}

const buf = new Buffer(kStringMaxLength + 1);

assert.throws(function() {
buf.toString('base64');
}, /toString failed/);
24 changes: 17 additions & 7 deletions test/parallel/test-stringbytes-external-exceed-max-by-1-binary.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
'use strict';
// Flags: --expose-gc

require('../common');
const common = require('../common');
const assert = require('assert');

const skipMessage =
'1..0 # Skipped: intensive toString tests due to memory confinements';
if (!common.enoughTestMem) {
console.log(skipMessage);
return;
}
assert(typeof gc === 'function', 'Run this test with --expose-gc');

// v8 fails silently if string length > v8::String::kMaxLength
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = process.binding('buffer').kStringMaxLength;

try {
new Buffer(kStringMaxLength * 3);
var buf = new Buffer(kStringMaxLength + 1);
// Try to allocate memory first then force gc so future allocations succeed.
new Buffer(2 * kStringMaxLength);
gc();
} catch(e) {
assert.equal(e.message, 'Invalid array buffer length');
console.log(
'1..0 # Skipped: intensive toString tests due to memory confinements');
// If the exception is not due to memory confinement then rethrow it.
if (e.message !== 'Invalid array buffer length') throw (e);
console.log(skipMessage);
return;
}

const buf = new Buffer(kStringMaxLength + 1);

assert.throws(function() {
buf.toString('binary');
}, /toString failed/);
24 changes: 17 additions & 7 deletions test/parallel/test-stringbytes-external-exceed-max-by-1-hex.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
'use strict';
// Flags: --expose-gc

require('../common');
const common = require('../common');
const assert = require('assert');

const skipMessage =
'1..0 # Skipped: intensive toString tests due to memory confinements';
if (!common.enoughTestMem) {
console.log(skipMessage);
return;
}
assert(typeof gc === 'function', 'Run this test with --expose-gc');

// v8 fails silently if string length > v8::String::kMaxLength
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = process.binding('buffer').kStringMaxLength;

try {
new Buffer(kStringMaxLength * 3);
var buf = new Buffer(kStringMaxLength + 1);
// Try to allocate memory first then force gc so future allocations succeed.
new Buffer(2 * kStringMaxLength);
gc();
} catch(e) {
assert.equal(e.message, 'Invalid array buffer length');
console.log(
'1..0 # Skipped: intensive toString tests due to memory confinements');
// If the exception is not due to memory confinement then rethrow it.
if (e.message !== 'Invalid array buffer length') throw (e);
console.log(skipMessage);
return;
}

const buf = new Buffer(kStringMaxLength + 1);

assert.throws(function() {
buf.toString('hex');
}, /toString failed/);
24 changes: 17 additions & 7 deletions test/parallel/test-stringbytes-external-exceed-max-by-1-utf8.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
'use strict';
// Flags: --expose-gc

require('../common');
const common = require('../common');
const assert = require('assert');

const skipMessage =
'1..0 # Skipped: intensive toString tests due to memory confinements';
if (!common.enoughTestMem) {
console.log(skipMessage);
return;
}
assert(typeof gc === 'function', 'Run this test with --expose-gc');

// v8 fails silently if string length > v8::String::kMaxLength
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = process.binding('buffer').kStringMaxLength;

try {
new Buffer(kStringMaxLength * 3);
var buf = new Buffer(kStringMaxLength + 1);
// Try to allocate memory first then force gc so future allocations succeed.
new Buffer(2 * kStringMaxLength);
gc();
} catch(e) {
assert.equal(e.message, 'Invalid array buffer length');
console.log(
'1..0 # Skipped: intensive toString tests due to memory confinements');
// If the exception is not due to memory confinement then rethrow it.
if (e.message !== 'Invalid array buffer length') throw (e);
console.log(skipMessage);
return;
}

const buf = new Buffer(kStringMaxLength + 1);

assert.throws(function() {
buf.toString();
}, /toString failed|Invalid array buffer length/);
26 changes: 18 additions & 8 deletions test/parallel/test-stringbytes-external-exceed-max-by-2.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
'use strict';
// Flags: --expose-gc

require('../common');
const common = require('../common');
const assert = require('assert');

const skipMessage =
'1..0 # Skipped: intensive toString tests due to memory confinements';
if (!common.enoughTestMem) {
console.log(skipMessage);
return;
}
assert(typeof gc === 'function', 'Run this test with --expose-gc');

// v8 fails silently if string length > v8::String::kMaxLength
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = process.binding('buffer').kStringMaxLength;

try {
new Buffer(kStringMaxLength * 3);
var buf = new Buffer(kStringMaxLength + 2);
// Try to allocate memory first then force gc so future allocations succeed.
new Buffer(2 * kStringMaxLength);
gc();
} catch(e) {
assert.equal(e.message, 'Invalid array buffer length');
console.log(
'1..0 # Skipped: intensive toString tests due to memory confinements');
// If the exception is not due to memory confinement then rethrow it.
if (e.message !== 'Invalid array buffer length') throw (e);
console.log(skipMessage);
return;
}

const buf2 = new Buffer(kStringMaxLength + 2);

const maxString = buf2.toString('utf16le');
const maxString = buf.toString('utf16le');
assert.equal(maxString.length, (kStringMaxLength + 2) / 2);
26 changes: 18 additions & 8 deletions test/parallel/test-stringbytes-external-exceed-max.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
'use strict';
// Flags: --expose-gc

require('../common');
const common = require('../common');
const assert = require('assert');

const skipMessage =
'1..0 # Skipped: intensive toString tests due to memory confinements';
if (!common.enoughTestMem) {
console.log(skipMessage);
return;
}
assert(typeof gc === 'function', 'Run this test with --expose-gc');

// v8 fails silently if string length > v8::String::kMaxLength
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = process.binding('buffer').kStringMaxLength;

try {
new Buffer(kStringMaxLength * 3);
var buf = new Buffer(kStringMaxLength * 2 + 2);
// Try to allocate memory first then force gc so future allocations succeed.
new Buffer(2 * kStringMaxLength);
gc();
} catch(e) {
assert.equal(e.message, 'Invalid array buffer length');
console.log(
'1..0 # Skipped: intensive toString tests due to memory confinements');
// If the exception is not due to memory confinement then rethrow it.
if (e.message !== 'Invalid array buffer length') throw (e);
console.log(skipMessage);
return;
}

const buf0 = new Buffer(kStringMaxLength * 2 + 2);

assert.throws(function() {
buf0.toString('utf16le');
buf.toString('utf16le');
}, /toString failed/);