Skip to content

Commit c222159

Browse files
committed
test: fix test-buffer-zero-fill-cli to be effective
1 parent dbe45b7 commit c222159

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

test/parallel/test-buffer-zero-fill-cli.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ function isZeroFilled(buf) {
1414
return true;
1515
}
1616

17+
// We have to consume the data from the pool as otherwise
18+
// we would be testing what's in snapshot, which is zero-filled
19+
// regardless of the flag presence, and we want to test the flag
20+
for (let i = 0; i < 8; i++) {
21+
(isZeroFilled(Buffer.allocUnsafe(1024)));
22+
}
23+
1724
// This can be somewhat unreliable because the
1825
// allocated memory might just already happen to
1926
// contain all zeroes. The test is run multiple
@@ -22,7 +29,8 @@ for (let i = 0; i < 50; i++) {
2229
const bufs = [
2330
Buffer.alloc(20),
2431
Buffer.allocUnsafe(20),
25-
Buffer.allocUnsafeSlow(20),
32+
Buffer.allocUnsafeSlow(20), // Heap
33+
Buffer.allocUnsafeSlow(128), // Alloc
2634
Buffer(20),
2735
];
2836
for (const buf of bufs) {

0 commit comments

Comments
 (0)