File tree Expand file tree Collapse file tree 9 files changed +140
-58
lines changed Expand file tree Collapse file tree 9 files changed +140
-58
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,8 @@ exports.isLinuxPPCBE = (process.platform === 'linux') &&
2222exports . isSunOS  =  process . platform  ===  'sunos' ; 
2323exports . isFreeBSD  =  process . platform  ===  'freebsd' ; 
2424
25+ exports . enoughTestMem  =  os . totalmem ( )  >  0x20000000 ;  /* 512MB */ 
26+ 
2527function  rimrafSync ( p )  { 
2628  try  { 
2729    var  st  =  fs . lstatSync ( p ) ; 
Original file line number Diff line number Diff line change 11'use strict' ; 
2+ // Flags: --expose-gc 
23
3- require ( '../common' ) ; 
4+ const   common   =   require ( '../common' ) ; 
45const  assert  =  require ( 'assert' ) ; 
56
67// v8 fails silently if string length > v8::String::kMaxLength 
78// v8::String::kMaxLength defined in v8.h 
89const  kStringMaxLength  =  process . binding ( 'buffer' ) . kStringMaxLength ; 
910
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+ 
1019try  { 
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 ( ) ; 
1224}  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 ) ; 
1628  return ; 
1729} 
1830
19- const  buf  =  new  Buffer ( kStringMaxLength ) ; 
20- 
2131const  maxString  =  buf . toString ( 'binary' ) ; 
2232assert . equal ( maxString . length ,  kStringMaxLength ) ; 
Original file line number Diff line number Diff line change 11'use strict' ; 
2+ // Flags: --expose-gc 
23
3- require ( '../common' ) ; 
4+ const   common   =   require ( '../common' ) ; 
45const  assert  =  require ( 'assert' ) ; 
56
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+ 
615// v8 fails silently if string length > v8::String::kMaxLength 
716// v8::String::kMaxLength defined in v8.h 
817const  kStringMaxLength  =  process . binding ( 'buffer' ) . kStringMaxLength ; 
918
1019try  { 
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 ( ) ; 
1224}  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 ) ; 
1628  return ; 
1729} 
1830
19- const  buf  =  new  Buffer ( kStringMaxLength  +  1 ) ; 
20- 
2131assert . throws ( function ( )  { 
2232  buf . toString ( 'ascii' ) ; 
2333} ,  / t o S t r i n g   f a i l e d / ) ; 
Original file line number Diff line number Diff line change 11'use strict' ; 
2+ // Flags: --expose-gc 
23
3- require ( '../common' ) ; 
4+ const   common   =   require ( '../common' ) ; 
45const  assert  =  require ( 'assert' ) ; 
56
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+ 
615// v8 fails silently if string length > v8::String::kMaxLength 
716// v8::String::kMaxLength defined in v8.h 
817const  kStringMaxLength  =  process . binding ( 'buffer' ) . kStringMaxLength ; 
918
1019try  { 
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 ( ) ; 
1224}  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 ) ; 
1628  return ; 
1729} 
1830
19- const  buf  =  new  Buffer ( kStringMaxLength  +  1 ) ; 
20- 
2131assert . throws ( function ( )  { 
2232  buf . toString ( 'base64' ) ; 
2333} ,  / t o S t r i n g   f a i l e d / ) ; 
Original file line number Diff line number Diff line change 11'use strict' ; 
2+ // Flags: --expose-gc 
23
3- require ( '../common' ) ; 
4+ const   common   =   require ( '../common' ) ; 
45const  assert  =  require ( 'assert' ) ; 
56
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+ 
615// v8 fails silently if string length > v8::String::kMaxLength 
716// v8::String::kMaxLength defined in v8.h 
817const  kStringMaxLength  =  process . binding ( 'buffer' ) . kStringMaxLength ; 
918
1019try  { 
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 ( ) ; 
1224}  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 ) ; 
1628  return ; 
1729} 
1830
19- const  buf  =  new  Buffer ( kStringMaxLength  +  1 ) ; 
20- 
2131assert . throws ( function ( )  { 
2232  buf . toString ( 'binary' ) ; 
2333} ,  / t o S t r i n g   f a i l e d / ) ; 
Original file line number Diff line number Diff line change 11'use strict' ; 
2+ // Flags: --expose-gc 
23
3- require ( '../common' ) ; 
4+ const   common   =   require ( '../common' ) ; 
45const  assert  =  require ( 'assert' ) ; 
56
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+ 
615// v8 fails silently if string length > v8::String::kMaxLength 
716// v8::String::kMaxLength defined in v8.h 
817const  kStringMaxLength  =  process . binding ( 'buffer' ) . kStringMaxLength ; 
918
1019try  { 
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 ( ) ; 
1224}  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 ) ; 
1628  return ; 
1729} 
1830
19- const  buf  =  new  Buffer ( kStringMaxLength  +  1 ) ; 
20- 
2131assert . throws ( function ( )  { 
2232  buf . toString ( 'hex' ) ; 
2333} ,  / t o S t r i n g   f a i l e d / ) ; 
Original file line number Diff line number Diff line change 11'use strict' ; 
2+ // Flags: --expose-gc 
23
3- require ( '../common' ) ; 
4+ const   common   =   require ( '../common' ) ; 
45const  assert  =  require ( 'assert' ) ; 
56
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+ 
615// v8 fails silently if string length > v8::String::kMaxLength 
716// v8::String::kMaxLength defined in v8.h 
817const  kStringMaxLength  =  process . binding ( 'buffer' ) . kStringMaxLength ; 
918
1019try  { 
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 ( ) ; 
1224}  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 ) ; 
1628  return ; 
1729} 
1830
19- const  buf  =  new  Buffer ( kStringMaxLength  +  1 ) ; 
20- 
2131assert . throws ( function ( )  { 
2232  buf . toString ( ) ; 
2333} ,  / t o S t r i n g   f a i l e d | I n v a l i d   a r r a y   b u f f e r   l e n g t h / ) ; 
Original file line number Diff line number Diff line change 11'use strict' ; 
2+ // Flags: --expose-gc 
23
3- require ( '../common' ) ; 
4+ const   common   =   require ( '../common' ) ; 
45const  assert  =  require ( 'assert' ) ; 
56
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+ 
615// v8 fails silently if string length > v8::String::kMaxLength 
716// v8::String::kMaxLength defined in v8.h 
817const  kStringMaxLength  =  process . binding ( 'buffer' ) . kStringMaxLength ; 
918
1019try  { 
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 ( ) ; 
1224}  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 ) ; 
1628  return ; 
1729} 
1830
19- const  buf2  =  new  Buffer ( kStringMaxLength  +  2 ) ; 
20- 
21- const  maxString  =  buf2 . toString ( 'utf16le' ) ; 
31+ const  maxString  =  buf . toString ( 'utf16le' ) ; 
2232assert . equal ( maxString . length ,  ( kStringMaxLength  +  2 )  /  2 ) ; 
Original file line number Diff line number Diff line change 11'use strict' ; 
2+ // Flags: --expose-gc 
23
3- require ( '../common' ) ; 
4+ const   common   =   require ( '../common' ) ; 
45const  assert  =  require ( 'assert' ) ; 
56
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+ 
615// v8 fails silently if string length > v8::String::kMaxLength 
716// v8::String::kMaxLength defined in v8.h 
817const  kStringMaxLength  =  process . binding ( 'buffer' ) . kStringMaxLength ; 
918
1019try  { 
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 ( ) ; 
1224}  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 ) ; 
1628  return ; 
1729} 
1830
19- const  buf0  =  new  Buffer ( kStringMaxLength  *  2  +  2 ) ; 
20- 
2131assert . throws ( function ( )  { 
22-   buf0 . toString ( 'utf16le' ) ; 
32+   buf . toString ( 'utf16le' ) ; 
2333} ,  / t o S t r i n g   f a i l e d / ) ; 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments