summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2025-04-29 12:22:38 +0200
committerTor Andersson <tor@ccxvii.net>2025-05-06 20:00:03 +0200
commitfcf6e38f68c22c1f1bbdb5f0f900d46d202d85a1 (patch)
tree67c4980c5f29fe582f7e9a52833358751652eba8
parent64f345c56447fb01e73c99827c028f6507a1514b (diff)
downloadserver-fcf6e38f68c22c1f1bbdb5f0f900d46d202d85a1.tar.gz
Add jsfuzz to npm dev-dependencies.
-rw-r--r--.gitignore1
-rw-r--r--docs/module/fuzzer.md19
-rw-r--r--package.json3
-rw-r--r--tools/fuzz.js6
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")