Skip to content

Commit d896980

Browse files
Danylo MocherniukV8-internal LUCI CQ
authored andcommitted
[dumpling] Mock some funcs to achieve determinism.
Bug: 441467877 Change-Id: I104bc80f10573790e0a4c81ba99d70dcc1bac99e Reviewed-on: https://chrome-internal-review.googlesource.com/c/v8/fuzzilli/+/9012959 Commit-Queue: Danylo Mocherniuk <mdanylo@google.com> Reviewed-by: Michael Achenbach <machenbach@google.com> Reviewed-by: Dominik Klemba <tacet@google.com>
1 parent 816329e commit d896980

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

Sources/FuzzilliCli/Profiles/V8DumplingProfile.swift

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,33 @@ let v8DumplingProfile = Profile(
6666
timeout: Timeout.interval(300, 900),
6767

6868
codePrefix: """
69+
// --- Determinism Shim ---
70+
(function() {
71+
const originalDate = Date;
72+
const FIXED_TIME = 1767225600000;
73+
const FIXED_STRING = new originalDate(FIXED_TIME).toString();
74+
75+
Date.now = function() { return FIXED_TIME; };
76+
globalThis.Date = new Proxy(originalDate, {
77+
construct(target, args) {
78+
if (args.length === 0) return new target(FIXED_TIME);
79+
return new target(...args);
80+
},
81+
apply(target, thisArg, args) { return FIXED_STRING; }
82+
});
83+
globalThis.Date.prototype = originalDate.prototype;
84+
85+
// Math.random shim
86+
const rng = function() {
87+
let s = 0x12345678;
88+
return function() {
89+
s ^= s << 13; s ^= s >> 17; s ^= s << 5;
90+
return (s >>> 0) / 4294967296;
91+
};
92+
}();
93+
Math.random = rng;
94+
})();
95+
// --- End Determinism Shim ---
6996
""",
7097

7198
codeSuffix: """

0 commit comments

Comments
 (0)