Skip to content

Commit 1bfce75

Browse files
author
Thomas Moore (CHAKRA)
committed
Update params.js test to not kill the process during execution
The call to WScript.Quit caused the process to terminate while script was executing, which now breaks some of the cleanup work added with this set of changes. The fix is to make an else block for the work that would have been short-circuited, which allows the stack to unwind safely.
1 parent 7dc720d commit 1bfce75

File tree

1 file changed

+30
-31
lines changed

1 file changed

+30
-31
lines changed

test/wasm/params.js

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -71,38 +71,37 @@ const [forceTest] = WScript.Arguments;
7171
if (forceTest !== undefined) {
7272
const res = test(forceTest);
7373
print(res ? "Module is valid" : "Module is invalid");
74-
WScript.Quit(0);
75-
}
74+
} else {
75+
let nParams = 9000;
76+
let inc = 1000;
77+
let direction = true;
7678

77-
let nParams = 9000;
78-
let inc = 1000;
79-
let direction = true;
79+
while (inc !== 0) {
80+
if (test(nParams)) {
81+
if (direction) {
82+
nParams += inc;
83+
} else {
84+
direction = true;
85+
inc >>= 1;
86+
nParams += inc;
87+
}
88+
} else {
89+
if (!direction) {
90+
nParams -= inc;
91+
} else {
92+
direction = false;
93+
inc >>= 1;
94+
// make sure the last test is a passing one
95+
inc = inc || 1;
96+
nParams -= inc;
97+
}
98+
}
8099

81-
while (inc !== 0) {
82-
if (test(nParams)) {
83-
if (direction) {
84-
nParams += inc;
85-
} else {
86-
direction = true;
87-
inc >>= 1;
88-
nParams += inc;
89-
}
90-
} else {
91-
if (!direction) {
92-
nParams -= inc;
93-
} else {
94-
direction = false;
95-
inc >>= 1;
96-
// make sure the last test is a passing one
97-
inc = inc || 1;
98-
nParams -= inc;
100+
if (nParams > 100000 || nParams < 0) {
101+
print(`FAILED. Params reached ${nParams} long. Expected an error by now`);
102+
break;
103+
}
99104
}
100-
}
101-
102-
if (nParams > 100000 || nParams < 0) {
103-
print(`FAILED. Params reached ${nParams} long. Expected an error by now`);
104-
break;
105-
}
106-
}
107105

108-
print(`Support at most ${nParams} params`);
106+
print(`Support at most ${nParams} params`);
107+
}

0 commit comments

Comments
 (0)