summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMischa Untaga <99098079+MischaU8@users.noreply.github.com>2024-02-16 15:07:17 +0100
committerMischa Untaga <99098079+MischaU8@users.noreply.github.com>2024-02-16 15:07:17 +0100
commit97818e5080600dc68c65dcf9d1cd05411dd43b20 (patch)
tree34a5125ea4d9ebc9243c0fd6bb93e80fd34825b3
parent744961c1704d969373204ced44e0d19160c7dc21 (diff)
downloadfuzzer-97818e5080600dc68c65dcf9d1cd05411dd43b20.tar.gz
only write game data if it doesn't exist, write crash data if we dont stop on crashes
-rwxr-xr-xrtt-module.js27
1 files changed, 18 insertions, 9 deletions
diff --git a/rtt-module.js b/rtt-module.js
index 4996f75..764e6e0 100755
--- a/rtt-module.js
+++ b/rtt-module.js
@@ -172,7 +172,6 @@ function log_crash(error, ctx, action=undefined, args=undefined) {
// console.log()
// console.log("VIEW", ctx.view)
let line = `ERROR=${error.name}`
- line += " SETUP=" + JSON.stringify(ctx.replay[0][2])
line += ` STEP=${ctx.step} ACTIVE=${ctx.active} STATE=${ctx.state?.state}`
if (action !== undefined) {
line += ` ACTION=${action}`
@@ -190,20 +189,30 @@ function log_crash(error, ctx, action=undefined, args=undefined) {
replay: ctx.replay,
}
- const shasum = crypto.createHash('sha1')
- shasum.update(ctx.data)
- const hash = shasum.digest('hex')
+ const data_checksum = crypto.createHash('sha1')
+ data_checksum.update(ctx.data)
+ const data_hash = data_checksum.digest('hex')
- const out_file = `crash-${hash}.json`
- line += ` DUMP=${out_file}`
- fs.writeFileSync(out_file, JSON.stringify(game))
+ const game_checksum = crypto.createHash('sha1')
+ game_checksum.update(JSON.stringify(game))
+ const game_hash = game_checksum.digest('hex')
+ const crash_file = `crash-${data_hash}`
+ const out_file = `crash-${game_hash}.json`
+ line += " SETUP=" + JSON.stringify(ctx.replay[0][2])
+ line += ` DATA=${data_hash} DUMP=${out_file}`
if (error.message)
line += " MSG=" + JSON.stringify(error.message.replace(/^Error: /, ''))
- console.log(line)
- if (!NO_CRASH)
+ if (!fs.existsSync(out_file)) {
+ fs.writeFileSync(out_file, JSON.stringify(game))
+ console.log(line)
+ if (NO_CRASH)
+ fs.writeFileSync(crash_file, ctx.data)
+ }
+ if (!NO_CRASH) {
throw error
+ }
}
// Custom Error classes, allowing us to ignore expected errors with -x