-
-
Notifications
You must be signed in to change notification settings - Fork 35k
test: parallelize long-running test #3287
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| 'use strict'; | ||
|
|
||
| require('../common'); | ||
| const assert = require('assert'); | ||
|
|
||
| // v8 fails silently if string length > v8::String::kMaxLength | ||
| (function() { | ||
| // v8::String::kMaxLength defined in v8.h | ||
| const kStringMaxLength = process.binding('buffer').kStringMaxLength; | ||
|
|
||
| try { | ||
| new Buffer(kStringMaxLength * 3); | ||
| } catch(e) { | ||
| assert.equal(e.message, 'Invalid array buffer length'); | ||
| console.log( | ||
| '1..0 # Skipped: intensive toString tests due to memory confinements'); | ||
| return; | ||
| } | ||
|
|
||
| const buf = new Buffer(kStringMaxLength); | ||
|
|
||
| var maxString = buf.toString(); | ||
| assert.equal(maxString.length, kStringMaxLength); | ||
|
||
| // Free the memory early instead of at the end of the next assignment | ||
| maxString = undefined; | ||
|
|
||
| maxString = buf.toString('binary'); | ||
| assert.equal(maxString.length, kStringMaxLength); | ||
| maxString = undefined; | ||
|
||
| })(); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| 'use strict'; | ||
|
|
||
| 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; | ||
|
|
||
| try { | ||
| new Buffer(kStringMaxLength * 3); | ||
| } catch(e) { | ||
| assert.equal(e.message, 'Invalid array buffer length'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. when this call throws for me, I get a RangeError with a different message?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup. This has changed since we now allocate Buffer's directly from JS. Thought I fixed all these error string instances.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Trott Can you change this? The error message has changed recently due to a difference in Buffer allocation.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @trevnorris @evanlucas Updated in 3b9e2be |
||
| console.log( | ||
| '1..0 # Skipped: intensive toString tests due to memory confinements'); | ||
| return; | ||
| } | ||
|
|
||
| const buf1 = new Buffer(kStringMaxLength + 1); | ||
|
|
||
| assert.throws(function() { | ||
| buf1.toString(); | ||
| }, /toString failed|Invalid array buffer length/); | ||
|
|
||
| assert.throws(function() { | ||
| buf1.toString('ascii'); | ||
| }, /toString failed/); | ||
|
|
||
| assert.throws(function() { | ||
| buf1.toString('utf8'); | ||
| }, /toString failed/); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interestingly, this will still throw as expected even if there are multibyte characters in the string. It must have something to do with v8 internals. On the side, I don't think that
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nm about the |
||
|
|
||
| assert.throws(function() { | ||
| buf1.toString('binary'); | ||
| }, /toString failed/); | ||
|
|
||
| assert.throws(function() { | ||
| buf1.toString('base64'); | ||
| }, /toString failed/); | ||
|
|
||
| assert.throws(function() { | ||
| buf1.toString('hex'); | ||
| }, /toString failed/); | ||
|
|
||
| var maxString = buf1.toString('binary', 1); | ||
| assert.equal(maxString.length, kStringMaxLength); | ||
| maxString = undefined; | ||
|
|
||
| maxString = buf1.toString('binary', 0, kStringMaxLength); | ||
| assert.equal(maxString.length, kStringMaxLength); | ||
| // Free the memory early instead of at the end of the next assignment | ||
| maxString = undefined; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| 'use strict'; | ||
|
|
||
| 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; | ||
|
|
||
| try { | ||
| new Buffer(kStringMaxLength * 3); | ||
| } catch(e) { | ||
| assert.equal(e.message, 'Invalid array buffer length'); | ||
| console.log( | ||
| '1..0 # Skipped: intensive toString tests due to memory confinements'); | ||
| return; | ||
| } | ||
|
|
||
| const buf2 = new Buffer(kStringMaxLength + 2); | ||
|
|
||
| const maxString = buf2.toString('utf16le'); | ||
| assert.equal(maxString.length, (kStringMaxLength + 2) / 2); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| 'use strict'; | ||
|
|
||
| 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; | ||
|
|
||
| try { | ||
| new Buffer(kStringMaxLength * 3); | ||
| } catch(e) { | ||
| assert.equal(e.message, 'Invalid array buffer length'); | ||
| console.log( | ||
| '1..0 # Skipped: intensive toString tests due to memory confinements'); | ||
| return; | ||
| } | ||
|
|
||
| const buf0 = new Buffer(kStringMaxLength * 2 + 2); | ||
|
|
||
| assert.throws(function() { | ||
| buf0.toString('utf16le'); | ||
| }, /toString failed/); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to allocate this much?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ask mainly because from all of the tests I've run on a Pi 2, this will throw (every time from what I've seen). But it always seemed to get past this part a Pi 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason for the over allocation is to also judge the amount of extra space the heap has available. If we only allocate enough for the test then the
toString()operations may make v8 abort because of unavailable memory.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah that's right