From fcf6e38f68c22c1f1bbdb5f0f900d46d202d85a1 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 29 Apr 2025 12:22:38 +0200 Subject: Add jsfuzz to npm dev-dependencies. --- .gitignore | 1 + docs/module/fuzzer.md | 19 +++++++++++++++---- package.json | 3 ++- tools/fuzz.js | 6 ++++-- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index b2089b5..7f179fe 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ cookies.txt # Fuzzer output coverage fuzzer +.nyc_output diff --git a/docs/module/fuzzer.md b/docs/module/fuzzer.md index d576693..3b05e70 100644 --- a/docs/module/fuzzer.md +++ b/docs/module/fuzzer.md @@ -17,17 +17,28 @@ Crash dumps are written to the "fuzzer" directory. There are two fuzzers available: -A fuzzer that uses the "jsfuzz" package. +A simple fuzzer that plays completely randomly: + + rtt fuzz-rand TITLE + +A more advanced fuzzer that uses the "jsfuzz" package. With this fuzzer every title gets its own "fuzzer/corpus-title" sub-directory. The corpus helps the fuzzer find interesting game states in future runs. rtt fuzz TITLE -A simple fuzzer that plays completely randomly: +The fuzzer will run until you stop it or it has found too many errors. - rtt fuzz-rand TITLE +## Coverage -The fuzzer will run until you stop it or it has found too many errors. +Jsfuzz will generate a "nyc" coverage report that you can look at, +to see how much of your code has been tested: + + npx nyc coverage + +Or to generate an HTML report in "coverage": + + npx nyc report --reporter=html ## Debug diff --git a/package.json b/package.json index a6282ba..48b84f6 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "ws": "^8.18.1" }, "devDependencies": { - "eslint": "^9.25.1" + "eslint": "^9.25.1", + "jsfuzz": "^1.0.15" } } diff --git a/tools/fuzz.js b/tools/fuzz.js index e9863cb..c82db74 100644 --- a/tools/fuzz.js +++ b/tools/fuzz.js @@ -99,8 +99,9 @@ function list_actions(R, V) { if (V.actions) { for (var act in V.actions) { var arg = V.actions[act] - if (act === "undo") { + if (act === "undo" || act === "ping") { // never undo + // never ping } else if (arg === 0 || arg === false) { // disabled button } else if (arg === 1 || arg === true) { @@ -235,7 +236,8 @@ function log_crash(message, ctx, action) { var dump = `fuzzer/${TITLE}-${hash}.json` fs.writeFileSync(dump, json) - console.log("\trtt import", dump) + console.log("rtt import", dump) + console.log("") if (++errors >= MAX_ERRORS) throw new Error("too many errors") -- cgit v1.2.3