Skip to content

Commit d6d4659

Browse files
committed
fixup! fixup! src: fix timing of snapshot serialize callback
1 parent 998b033 commit d6d4659

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

test/parallel/test-buffer-alloc-unsafe-is-initialized-with-zero-fill-flag.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ const { internalBinding } = require('internal/test/binding');
1111
const { getGenericUsageCount } = internalBinding('debug');
1212
const assert = require('assert');
1313

14-
const initialCount = getGenericUsageCount('NodeArrayBufferAllocator.Allocate.ZeroFilled');
14+
const initialUninitializedCount = getGenericUsageCount('NodeArrayBufferAllocator.Allocate.Uninitialized');
15+
const initialZeroFilledCount = getGenericUsageCount('NodeArrayBufferAllocator.Allocate.ZeroFilled');
1516
const buffer = Buffer.allocUnsafe(Buffer.poolSize + 1);
16-
assert.strictEqual(buffer.every((b) => b === 0), true);
17-
const newCount = getGenericUsageCount('NodeArrayBufferAllocator.Allocate.ZeroFilled');
18-
assert.notStrictEqual(newCount, initialCount);
17+
assert(buffer.every((b) => b === 0));
18+
const newUninitializedCount = getGenericUsageCount('NodeArrayBufferAllocator.Allocate.Uninitialized');
19+
const newZeroFilledCount = getGenericUsageCount('NodeArrayBufferAllocator.Allocate.ZeroFilled');
20+
assert.strictEqual(newUninitializedCount, initialUninitializedCount);
21+
assert.notStrictEqual(newZeroFilledCount, initialZeroFilledCount);

test/parallel/test-buffer-alloc-unsafe-is-uninitialized.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ const { internalBinding } = require('internal/test/binding');
1111
const { getGenericUsageCount } = internalBinding('debug');
1212
const assert = require('assert');
1313

14-
const initialCount = getGenericUsageCount('NodeArrayBufferAllocator.Allocate.Uninitialized');
14+
const initialUninitializedCount = getGenericUsageCount('NodeArrayBufferAllocator.Allocate.Uninitialized');
15+
const initialZeroFilledCount = getGenericUsageCount('NodeArrayBufferAllocator.Allocate.ZeroFilled');
1516
Buffer.allocUnsafe(Buffer.poolSize + 1);
1617
// We can't reliably check the contents of the buffer here because the OS or memory allocator
1718
// used might zero-fill memory for us, or they might happen to return reused memory that was
18-
// previously used by a process that zero-filled it.
19-
const newCount = getGenericUsageCount('NodeArrayBufferAllocator.Allocate.Uninitialized');
20-
assert.notStrictEqual(newCount, initialCount);
19+
// previously used by a process that zero-filled it. So instead we just check the usage counts.
20+
const newUninitializedCount = getGenericUsageCount('NodeArrayBufferAllocator.Allocate.Uninitialized');
21+
const newZeroFilledCount = getGenericUsageCount('NodeArrayBufferAllocator.Allocate.ZeroFilled');
22+
assert.notStrictEqual(newUninitializedCount, initialUninitializedCount);
23+
assert.strictEqual(newZeroFilledCount, initialZeroFilledCount);

0 commit comments

Comments
 (0)