|
44 | 44 | TEST_ROOT, |
45 | 45 | WEBIDL_BINDER, |
46 | 46 | RunnerCore, |
| 47 | + check_node_version, |
47 | 48 | copy_asset, |
48 | 49 | copytree, |
49 | 50 | create_file, |
@@ -6454,22 +6455,39 @@ def test_file_packager_huge(self): |
6454 | 6455 | self.assertContained(MESSAGE, err) |
6455 | 6456 | self.clear() |
6456 | 6457 |
|
| 6458 | + @crossplatform |
6457 | 6459 | @also_with_wasm2js |
6458 | 6460 | def test_memory_growth(self): |
6459 | 6461 | create_file('main.c', r''' |
6460 | 6462 | #include <assert.h> |
6461 | 6463 | #include <stdlib.h> |
| 6464 | +#include <string.h> |
| 6465 | +#include <emscripten/em_asm.h> |
| 6466 | +#include <emscripten/console.h> |
6462 | 6467 |
|
6463 | 6468 | int main() { |
6464 | | - void* x = malloc(10 * 1024 * 1024); |
| 6469 | + // Report whether `toResizableBuffer` is availble on the wasm memory. |
| 6470 | + EM_ASM(out('resizable memory buffers:', Boolean(wasmMemory.toResizableBuffer))); |
| 6471 | + |
| 6472 | + char* x = malloc(10 * 1024 * 1024); |
6465 | 6473 | assert(x != NULL); |
| 6474 | + // Have JS use some of the memory in the expanded range. |
| 6475 | + char* str = x + 9 * 1024 * 1024; |
| 6476 | + strcpy(str, "Hello, world!"); |
| 6477 | + emscripten_out(str); |
6466 | 6478 | return 0; |
6467 | 6479 | } |
6468 | 6480 | ''') |
6469 | | - output = self.do_runf('main.c', cflags=['-sALLOW_MEMORY_GROWTH', '-sINITIAL_HEAP=1mb']) |
| 6481 | + output = self.do_runf('main.c', 'Hello, world!\n', cflags=['-sALLOW_MEMORY_GROWTH', '-sINITIAL_HEAP=1mb']) |
6470 | 6482 | if self.is_wasm2js(): |
6471 | 6483 | self.assertContained('Warning: Enlarging memory arrays, this is not fast! 1179648,10616832\n', output) |
6472 | 6484 |
|
| 6485 | + # Node versions older than 26 do not support toResizableBuffer |
| 6486 | + if self.is_wasm2js() or (self.engine_is_node() and not check_node_version(26)): |
| 6487 | + self.assertContained('resizable memory buffers: false\n', output) |
| 6488 | + else: |
| 6489 | + self.assertContained('resizable memory buffers: true\n', output) |
| 6490 | + |
6473 | 6491 | @also_with_wasm2js |
6474 | 6492 | @parameterized({ |
6475 | 6493 | '': (False,), |
@@ -8587,7 +8605,7 @@ def test_exceptions_stack_trace_and_message(self): |
8587 | 8605 | ''' |
8588 | 8606 | self.cflags += ['-g'] |
8589 | 8607 |
|
8590 | | - if '-fwasm-exceptions' in self.cflags and engine_is_node(self.js_engines[0]): |
| 8608 | + if '-fwasm-exceptions' in self.cflags and self.engine_is_node(): |
8591 | 8609 | if not self.try_require_node_version(24): |
8592 | 8610 | # Node versions prior to v24 do not implement the new 'traceStack' option in |
8593 | 8611 | # WebAssembly.Exception constructor. |
@@ -8707,7 +8725,7 @@ def test_exceptions_rethrow_stack_trace_and_message(self): |
8707 | 8725 | return 0; |
8708 | 8726 | } |
8709 | 8727 | ''' |
8710 | | - if '-fwasm-exceptions' in self.cflags and engine_is_node(self.js_engines[0]): |
| 8728 | + if '-fwasm-exceptions' in self.cflags and self.engine_is_node(): |
8711 | 8729 | if not self.try_require_node_version(24): |
8712 | 8730 | # Node versions prior to v24 do not implement the new 'traceStack' option in |
8713 | 8731 | # WebAssembly.Exception constructor. |
|
0 commit comments