| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d969c09 commit 9d16729
9 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,6 +22,8 @@ exports.isLinuxPPCBE = (process.platform === 'linux') && | |||
| 22 | 22 | exports.isSunOS = process.platform === 'sunos'; | |
| 23 | 23 | exports.isFreeBSD = process.platform === 'freebsd'; | |
| 24 | 24 | ||
| 25 | + exports.enoughTestMem = os.totalmem() > 0x20000000; /* 512MB */ | ||
| 26 | + | ||
| 25 | 27 | function rimrafSync(p) { | |
| 26 | 28 | try { | |
| 27 | 29 | var st = fs.lstatSync(p); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,22 +1,32 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | + // Flags: --expose-gc | ||
| 2 | 3 | ||
| 3 | - require('../common'); | ||
| 4 | + const common = require('../common'); | ||
| 4 | 5 | const assert = require('assert'); | |
| 5 | 6 | ||
| 6 | 7 | // v8 fails silently if string length > v8::String::kMaxLength | |
| 7 | 8 | // v8::String::kMaxLength defined in v8.h | |
| 8 | 9 | const kStringMaxLength = process.binding('buffer').kStringMaxLength; | |
| 9 | 10 | ||
| 11 | + const skipMessage = | ||
| 12 | + '1..0 # Skipped: intensive toString tests due to memory confinements'; | ||
| 13 | + if (!common.enoughTestMem) { | ||
| 14 | + console.log(skipMessage); | ||
| 15 | + return; | ||
| 16 | + } | ||
| 17 | + assert(typeof gc === 'function', 'Run this test with --expose-gc'); | ||
| 18 | + | ||
| 10 | 19 | try { | |
| 11 | - new Buffer(kStringMaxLength * 3); | ||
| 20 | + var buf = new Buffer(kStringMaxLength); | ||
| 21 | + // Try to allocate memory first then force gc so future allocations succeed. | ||
| 22 | + new Buffer(2 * kStringMaxLength); | ||
| 23 | + gc(); | ||
| 12 | 24 | } catch(e) { | |
| 13 | - assert.equal(e.message, 'Invalid array buffer length'); | ||
| 14 | - console.log( | ||
| 15 | - '1..0 # Skipped: intensive toString tests due to memory confinements'); | ||
| 25 | + // If the exception is not due to memory confinement then rethrow it. | ||
| 26 | + if (e.message !== 'Invalid array buffer length') throw (e); | ||
| 27 | + console.log(skipMessage); | ||
| 16 | 28 | return; | |
| 17 | 29 | } | |
| 18 | 30 | ||
| 19 | - const buf = new Buffer(kStringMaxLength); | ||
| 20 | - | ||
| 21 | 31 | const maxString = buf.toString('binary'); | |
| 22 | 32 | assert.equal(maxString.length, kStringMaxLength); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,23 +1,33 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | + // Flags: --expose-gc | ||
| 2 | 3 | ||
| 3 | - require('../common'); | ||
| 4 | + const common = require('../common'); | ||
| 4 | 5 | const assert = require('assert'); | |
| 5 | 6 | ||
| 7 | + const skipMessage = | ||
| 8 | + '1..0 # Skipped: intensive toString tests due to memory confinements'; | ||
| 9 | + if (!common.enoughTestMem) { | ||
| 10 | + console.log(skipMessage); | ||
| 11 | + return; | ||
| 12 | + } | ||
| 13 | + assert(typeof gc === 'function', 'Run this test with --expose-gc'); | ||
| 14 | + | ||
| 6 | 15 | // v8 fails silently if string length > v8::String::kMaxLength | |
| 7 | 16 | // v8::String::kMaxLength defined in v8.h | |
| 8 | 17 | const kStringMaxLength = process.binding('buffer').kStringMaxLength; | |
| 9 | 18 | ||
| 10 | 19 | try { | |
| 11 | - new Buffer(kStringMaxLength * 3); | ||
| 20 | + var buf = new Buffer(kStringMaxLength + 1); | ||
| 21 | + // Try to allocate memory first then force gc so future allocations succeed. | ||
| 22 | + new Buffer(2 * kStringMaxLength); | ||
| 23 | + gc(); | ||
| 12 | 24 | } catch(e) { | |
| 13 | - assert.equal(e.message, 'Invalid array buffer length'); | ||
| 14 | - console.log( | ||
| 15 | - '1..0 # Skipped: intensive toString tests due to memory confinements'); | ||
| 25 | + // If the exception is not due to memory confinement then rethrow it. | ||
| 26 | + if (e.message !== 'Invalid array buffer length') throw (e); | ||
| 27 | + console.log(skipMessage); | ||
| 16 | 28 | return; | |
| 17 | 29 | } | |
| 18 | 30 | ||
| 19 | - const buf = new Buffer(kStringMaxLength + 1); | ||
| 20 | - | ||
| 21 | 31 | assert.throws(function() { | |
| 22 | 32 | buf.toString('ascii'); | |
| 23 | 33 | }, /toString failed/); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,23 +1,33 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | + // Flags: --expose-gc | ||
| 2 | 3 | ||
| 3 | - require('../common'); | ||
| 4 | + const common = require('../common'); | ||
| 4 | 5 | const assert = require('assert'); | |
| 5 | 6 | ||
| 7 | + const skipMessage = | ||
| 8 | + '1..0 # Skipped: intensive toString tests due to memory confinements'; | ||
| 9 | + if (!common.enoughTestMem) { | ||
| 10 | + console.log(skipMessage); | ||
| 11 | + return; | ||
| 12 | + } | ||
| 13 | + assert(typeof gc === 'function', 'Run this test with --expose-gc'); | ||
| 14 | + | ||
| 6 | 15 | // v8 fails silently if string length > v8::String::kMaxLength | |
| 7 | 16 | // v8::String::kMaxLength defined in v8.h | |
| 8 | 17 | const kStringMaxLength = process.binding('buffer').kStringMaxLength; | |
| 9 | 18 | ||
| 10 | 19 | try { | |
| 11 | - new Buffer(kStringMaxLength * 3); | ||
| 20 | + var buf = new Buffer(kStringMaxLength + 1); | ||
| 21 | + // Try to allocate memory first then force gc so future allocations succeed. | ||
| 22 | + new Buffer(2 * kStringMaxLength); | ||
| 23 | + gc(); | ||
| 12 | 24 | } catch(e) { | |
| 13 | - assert.equal(e.message, 'Invalid array buffer length'); | ||
| 14 | - console.log( | ||
| 15 | - '1..0 # Skipped: intensive toString tests due to memory confinements'); | ||
| 25 | + // If the exception is not due to memory confinement then rethrow it. | ||
| 26 | + if (e.message !== 'Invalid array buffer length') throw (e); | ||
| 27 | + console.log(skipMessage); | ||
| 16 | 28 | return; | |
| 17 | 29 | } | |
| 18 | 30 | ||
| 19 | - const buf = new Buffer(kStringMaxLength + 1); | ||
| 20 | - | ||
| 21 | 31 | assert.throws(function() { | |
| 22 | 32 | buf.toString('base64'); | |
| 23 | 33 | }, /toString failed/); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,23 +1,33 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | + // Flags: --expose-gc | ||
| 2 | 3 | ||
| 3 | - require('../common'); | ||
| 4 | + const common = require('../common'); | ||
| 4 | 5 | const assert = require('assert'); | |
| 5 | 6 | ||
| 7 | + const skipMessage = | ||
| 8 | + '1..0 # Skipped: intensive toString tests due to memory confinements'; | ||
| 9 | + if (!common.enoughTestMem) { | ||
| 10 | + console.log(skipMessage); | ||
| 11 | + return; | ||
| 12 | + } | ||
| 13 | + assert(typeof gc === 'function', 'Run this test with --expose-gc'); | ||
| 14 | + | ||
| 6 | 15 | // v8 fails silently if string length > v8::String::kMaxLength | |
| 7 | 16 | // v8::String::kMaxLength defined in v8.h | |
| 8 | 17 | const kStringMaxLength = process.binding('buffer').kStringMaxLength; | |
| 9 | 18 | ||
| 10 | 19 | try { | |
| 11 | - new Buffer(kStringMaxLength * 3); | ||
| 20 | + var buf = new Buffer(kStringMaxLength + 1); | ||
| 21 | + // Try to allocate memory first then force gc so future allocations succeed. | ||
| 22 | + new Buffer(2 * kStringMaxLength); | ||
| 23 | + gc(); | ||
| 12 | 24 | } catch(e) { | |
| 13 | - assert.equal(e.message, 'Invalid array buffer length'); | ||
| 14 | - console.log( | ||
| 15 | - '1..0 # Skipped: intensive toString tests due to memory confinements'); | ||
| 25 | + // If the exception is not due to memory confinement then rethrow it. | ||
| 26 | + if (e.message !== 'Invalid array buffer length') throw (e); | ||
| 27 | + console.log(skipMessage); | ||
| 16 | 28 | return; | |
| 17 | 29 | } | |
| 18 | 30 | ||
| 19 | - const buf = new Buffer(kStringMaxLength + 1); | ||
| 20 | - | ||
| 21 | 31 | assert.throws(function() { | |
| 22 | 32 | buf.toString('binary'); | |
| 23 | 33 | }, /toString failed/); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,23 +1,33 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | + // Flags: --expose-gc | ||
| 2 | 3 | ||
| 3 | - require('../common'); | ||
| 4 | + const common = require('../common'); | ||
| 4 | 5 | const assert = require('assert'); | |
| 5 | 6 | ||
| 7 | + const skipMessage = | ||
| 8 | + '1..0 # Skipped: intensive toString tests due to memory confinements'; | ||
| 9 | + if (!common.enoughTestMem) { | ||
| 10 | + console.log(skipMessage); | ||
| 11 | + return; | ||
| 12 | + } | ||
| 13 | + assert(typeof gc === 'function', 'Run this test with --expose-gc'); | ||
| 14 | + | ||
| 6 | 15 | // v8 fails silently if string length > v8::String::kMaxLength | |
| 7 | 16 | // v8::String::kMaxLength defined in v8.h | |
| 8 | 17 | const kStringMaxLength = process.binding('buffer').kStringMaxLength; | |
| 9 | 18 | ||
| 10 | 19 | try { | |
| 11 | - new Buffer(kStringMaxLength * 3); | ||
| 20 | + var buf = new Buffer(kStringMaxLength + 1); | ||
| 21 | + // Try to allocate memory first then force gc so future allocations succeed. | ||
| 22 | + new Buffer(2 * kStringMaxLength); | ||
| 23 | + gc(); | ||
| 12 | 24 | } catch(e) { | |
| 13 | - assert.equal(e.message, 'Invalid array buffer length'); | ||
| 14 | - console.log( | ||
| 15 | - '1..0 # Skipped: intensive toString tests due to memory confinements'); | ||
| 25 | + // If the exception is not due to memory confinement then rethrow it. | ||
| 26 | + if (e.message !== 'Invalid array buffer length') throw (e); | ||
| 27 | + console.log(skipMessage); | ||
| 16 | 28 | return; | |
| 17 | 29 | } | |
| 18 | 30 | ||
| 19 | - const buf = new Buffer(kStringMaxLength + 1); | ||
| 20 | - | ||
| 21 | 31 | assert.throws(function() { | |
| 22 | 32 | buf.toString('hex'); | |
| 23 | 33 | }, /toString failed/); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,23 +1,33 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | + // Flags: --expose-gc | ||
| 2 | 3 | ||
| 3 | - require('../common'); | ||
| 4 | + const common = require('../common'); | ||
| 4 | 5 | const assert = require('assert'); | |
| 5 | 6 | ||
| 7 | + const skipMessage = | ||
| 8 | + '1..0 # Skipped: intensive toString tests due to memory confinements'; | ||
| 9 | + if (!common.enoughTestMem) { | ||
| 10 | + console.log(skipMessage); | ||
| 11 | + return; | ||
| 12 | + } | ||
| 13 | + assert(typeof gc === 'function', 'Run this test with --expose-gc'); | ||
| 14 | + | ||
| 6 | 15 | // v8 fails silently if string length > v8::String::kMaxLength | |
| 7 | 16 | // v8::String::kMaxLength defined in v8.h | |
| 8 | 17 | const kStringMaxLength = process.binding('buffer').kStringMaxLength; | |
| 9 | 18 | ||
| 10 | 19 | try { | |
| 11 | - new Buffer(kStringMaxLength * 3); | ||
| 20 | + var buf = new Buffer(kStringMaxLength + 1); | ||
| 21 | + // Try to allocate memory first then force gc so future allocations succeed. | ||
| 22 | + new Buffer(2 * kStringMaxLength); | ||
| 23 | + gc(); | ||
| 12 | 24 | } catch(e) { | |
| 13 | - assert.equal(e.message, 'Invalid array buffer length'); | ||
| 14 | - console.log( | ||
| 15 | - '1..0 # Skipped: intensive toString tests due to memory confinements'); | ||
| 25 | + // If the exception is not due to memory confinement then rethrow it. | ||
| 26 | + if (e.message !== 'Invalid array buffer length') throw (e); | ||
| 27 | + console.log(skipMessage); | ||
| 16 | 28 | return; | |
| 17 | 29 | } | |
| 18 | 30 | ||
| 19 | - const buf = new Buffer(kStringMaxLength + 1); | ||
| 20 | - | ||
| 21 | 31 | assert.throws(function() { | |
| 22 | 32 | buf.toString(); | |
| 23 | 33 | }, /toString failed|Invalid array buffer length/); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,22 +1,32 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | + // Flags: --expose-gc | ||
| 2 | 3 | ||
| 3 | - require('../common'); | ||
| 4 | + const common = require('../common'); | ||
| 4 | 5 | const assert = require('assert'); | |
| 5 | 6 | ||
| 7 | + const skipMessage = | ||
| 8 | + '1..0 # Skipped: intensive toString tests due to memory confinements'; | ||
| 9 | + if (!common.enoughTestMem) { | ||
| 10 | + console.log(skipMessage); | ||
| 11 | + return; | ||
| 12 | + } | ||
| 13 | + assert(typeof gc === 'function', 'Run this test with --expose-gc'); | ||
| 14 | + | ||
| 6 | 15 | // v8 fails silently if string length > v8::String::kMaxLength | |
| 7 | 16 | // v8::String::kMaxLength defined in v8.h | |
| 8 | 17 | const kStringMaxLength = process.binding('buffer').kStringMaxLength; | |
| 9 | 18 | ||
| 10 | 19 | try { | |
| 11 | - new Buffer(kStringMaxLength * 3); | ||
| 20 | + var buf = new Buffer(kStringMaxLength + 2); | ||
| 21 | + // Try to allocate memory first then force gc so future allocations succeed. | ||
| 22 | + new Buffer(2 * kStringMaxLength); | ||
| 23 | + gc(); | ||
| 12 | 24 | } catch(e) { | |
| 13 | - assert.equal(e.message, 'Invalid array buffer length'); | ||
| 14 | - console.log( | ||
| 15 | - '1..0 # Skipped: intensive toString tests due to memory confinements'); | ||
| 25 | + // If the exception is not due to memory confinement then rethrow it. | ||
| 26 | + if (e.message !== 'Invalid array buffer length') throw (e); | ||
| 27 | + console.log(skipMessage); | ||
| 16 | 28 | return; | |
| 17 | 29 | } | |
| 18 | 30 | ||
| 19 | - const buf2 = new Buffer(kStringMaxLength + 2); | ||
| 20 | - | ||
| 21 | - const maxString = buf2.toString('utf16le'); | ||
| 31 | + const maxString = buf.toString('utf16le'); | ||
| 22 | 32 | assert.equal(maxString.length, (kStringMaxLength + 2) / 2); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,23 +1,33 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | + // Flags: --expose-gc | ||
| 2 | 3 | ||
| 3 | - require('../common'); | ||
| 4 | + const common = require('../common'); | ||
| 4 | 5 | const assert = require('assert'); | |
| 5 | 6 | ||
| 7 | + const skipMessage = | ||
| 8 | + '1..0 # Skipped: intensive toString tests due to memory confinements'; | ||
| 9 | + if (!common.enoughTestMem) { | ||
| 10 | + console.log(skipMessage); | ||
| 11 | + return; | ||
| 12 | + } | ||
| 13 | + assert(typeof gc === 'function', 'Run this test with --expose-gc'); | ||
| 14 | + | ||
| 6 | 15 | // v8 fails silently if string length > v8::String::kMaxLength | |
| 7 | 16 | // v8::String::kMaxLength defined in v8.h | |
| 8 | 17 | const kStringMaxLength = process.binding('buffer').kStringMaxLength; | |
| 9 | 18 | ||
| 10 | 19 | try { | |
| 11 | - new Buffer(kStringMaxLength * 3); | ||
| 20 | + var buf = new Buffer(kStringMaxLength * 2 + 2); | ||
| 21 | + // Try to allocate memory first then force gc so future allocations succeed. | ||
| 22 | + new Buffer(2 * kStringMaxLength); | ||
| 23 | + gc(); | ||
| 12 | 24 | } catch(e) { | |
| 13 | - assert.equal(e.message, 'Invalid array buffer length'); | ||
| 14 | - console.log( | ||
| 15 | - '1..0 # Skipped: intensive toString tests due to memory confinements'); | ||
| 25 | + // If the exception is not due to memory confinement then rethrow it. | ||
| 26 | + if (e.message !== 'Invalid array buffer length') throw (e); | ||
| 27 | + console.log(skipMessage); | ||
| 16 | 28 | return; | |
| 17 | 29 | } | |
| 18 | 30 | ||
| 19 | - const buf0 = new Buffer(kStringMaxLength * 2 + 2); | ||
| 20 | - | ||
| 21 | 31 | assert.throws(function() { | |
| 22 | - buf0.toString('utf16le'); | ||
| 32 | + buf.toString('utf16le'); | ||
| 23 | 33 | }, /toString failed/); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments