Commit 9a7e151f authored by Clemens Backes's avatar Clemens Backes Committed by V8 LUCI CQ

[wasm][test] Clean up grow-memory tests

Call test functions immediately, and make them print their name before
execution.

R=thibaudm@chromium.org

Change-Id: I2057e2b3c2032c342a86705dbda8992aa54493e5
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3793612
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarThibaud Michaud <thibaudm@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82077}
parent 00a652a3
......@@ -107,18 +107,22 @@ function testMemoryGrowReadWriteBase(size, load_fn, store_fn) {
}
(function testMemoryGrowReadWrite32() {
print(arguments.callee.name);
testMemoryGrowReadWriteBase(4, "load", "store");
})();
(function testMemoryGrowReadWrite16() {
print(arguments.callee.name);
testMemoryGrowReadWriteBase(2, "load16", "store16");
})();
(function testMemoryGrowReadWrite8() {
print(arguments.callee.name);
testMemoryGrowReadWriteBase(1, "load8", "store8");
})();
function testMemoryGrowZeroInitialSize() {
(function testMemoryGrowZeroInitialSize() {
print(arguments.callee.name);
var builder = genMemoryGrowBuilder();
builder.addMemory(0, undefined, false);
var module = builder.instantiate();
......@@ -155,9 +159,7 @@ function testMemoryGrowZeroInitialSize() {
}
poke(20);
assertEquals(20, peek());
}
testMemoryGrowZeroInitialSize();
})();
function testMemoryGrowZeroInitialSizeBase(size, load_fn, store_fn) {
var builder = genMemoryGrowBuilder();
......@@ -193,38 +195,40 @@ function testMemoryGrowZeroInitialSizeBase(size, load_fn, store_fn) {
}
(function testMemoryGrowZeroInitialSize32() {
print(arguments.callee.name);
testMemoryGrowZeroInitialSizeBase(4, "load", "store");
})();
(function testMemoryGrowZeroInitialSize16() {
print(arguments.callee.name);
testMemoryGrowZeroInitialSizeBase(2, "load16", "store16");
})();
(function testMemoryGrowZeroInitialSize8() {
print(arguments.callee.name);
testMemoryGrowZeroInitialSizeBase(1, "load8", "store8");
})();
function testMemoryGrowTrapMaxPagesZeroInitialMemory() {
(function testMemoryGrowTrapMaxPagesZeroInitialMemory() {
print(arguments.callee.name);
var builder = genMemoryGrowBuilder();
builder.addMemory(0, undefined, false);
var module = builder.instantiate();
function growMem(pages) { return module.exports.grow_memory(pages); }
assertEquals(-1, growMem(kV8MaxPages + 1));
}
testMemoryGrowTrapMaxPagesZeroInitialMemory();
})();
function testMemoryGrowTrapMaxPages() {
(function testMemoryGrowTrapMaxPages() {
print(arguments.callee.name);
var builder = genMemoryGrowBuilder();
builder.addMemory(1, 1, false);
var module = builder.instantiate();
function growMem(pages) { return module.exports.grow_memory(pages); }
assertEquals(-1, growMem(kV8MaxPages));
}
testMemoryGrowTrapMaxPages();
})();
function testMemoryGrowTrapsWithNonSmiInput() {
(function testMemoryGrowTrapsWithNonSmiInput() {
print(arguments.callee.name);
var builder = genMemoryGrowBuilder();
builder.addMemory(0, undefined, false);
var module = builder.instantiate();
......@@ -232,11 +236,10 @@ function testMemoryGrowTrapsWithNonSmiInput() {
// The parameter of grow_memory is unsigned. Therefore -1 stands for
// UINT32_MIN, which cannot be represented as SMI.
assertEquals(-1, growMem(-1));
};
testMemoryGrowTrapsWithNonSmiInput();
})();
function testMemoryGrowCurrentMemory() {
(function testMemoryGrowCurrentMemory() {
print(arguments.callee.name);
var builder = genMemoryGrowBuilder();
builder.addMemory(1, undefined, false);
builder.addFunction("memory_size", kSig_i_v)
......@@ -248,9 +251,7 @@ function testMemoryGrowCurrentMemory() {
assertEquals(1, MemSize());
assertEquals(1, growMem(1));
assertEquals(2, MemSize());
}
testMemoryGrowCurrentMemory();
})();
function testMemoryGrowPreservesDataMemOpBase(size, load_fn, store_fn) {
var builder = genMemoryGrowBuilder();
......@@ -291,18 +292,22 @@ function testMemoryGrowPreservesDataMemOpBase(size, load_fn, store_fn) {
}
(function testMemoryGrowPreservesDataMemOp32() {
print(arguments.callee.name);
testMemoryGrowPreservesDataMemOpBase(4, "load", "store");
})();
(function testMemoryGrowPreservesDataMemOp16() {
print(arguments.callee.name);
testMemoryGrowPreservesDataMemOpBase(2, "load16", "store16");
})();
(function testMemoryGrowPreservesDataMemOp8() {
print(arguments.callee.name);
testMemoryGrowPreservesDataMemOpBase(1, "load8", "store8");
})();
function testMemoryGrowOutOfBoundsOffset() {
(function testMemoryGrowOutOfBoundsOffset() {
print(arguments.callee.name);
var builder = genMemoryGrowBuilder();
builder.addMemory(1, undefined, false);
var module = builder.instantiate();
......@@ -335,11 +340,10 @@ function testMemoryGrowOutOfBoundsOffset() {
for (offset = 4*kPageSize - 3; offset <= 4*kPageSize + 4; offset++) {
assertTraps(kTrapMemOutOfBounds, poke);
}
}
testMemoryGrowOutOfBoundsOffset();
})();
function testMemoryGrowOutOfBoundsOffset2() {
(function testMemoryGrowOutOfBoundsOffset2() {
print(arguments.callee.name);
var builder = new WasmModuleBuilder();
builder.addMemory(16, 128, false);
builder.addFunction("main", kSig_v_v)
......@@ -352,11 +356,10 @@ function testMemoryGrowOutOfBoundsOffset2() {
.exportAs("main");
var module = builder.instantiate();
assertTraps(kTrapMemOutOfBounds, module.exports.main);
}
testMemoryGrowOutOfBoundsOffset2();
})();
function testMemoryGrowDeclaredMaxTraps() {
(function testMemoryGrowDeclaredMaxTraps() {
print(arguments.callee.name);
var builder = genMemoryGrowBuilder();
builder.addMemory(1, 16, false);
var module = builder.instantiate();
......@@ -364,11 +367,10 @@ function testMemoryGrowDeclaredMaxTraps() {
assertEquals(1, growMem(5));
assertEquals(6, growMem(5));
assertEquals(-1, growMem(6));
}
testMemoryGrowDeclaredMaxTraps();
})();
(function testMemoryGrowInternalMaxTraps() {
print(arguments.callee.name);
// This test checks that grow_memory does not grow past the internally
// defined maximum memory size.
var builder = genMemoryGrowBuilder();
......@@ -380,6 +382,7 @@ testMemoryGrowDeclaredMaxTraps();
})();
(function testMemoryGrow4Gb() {
print(arguments.callee.name);
var builder = genMemoryGrowBuilder();
builder.addMemory(1, undefined, false);
var module = builder.instantiate();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment