summaryrefslogtreecommitdiff
path: root/json
diff options
context:
space:
mode:
authorAlisdair McDiarmid <alisdair@users.noreply.github.com>2020-05-14 14:42:50 -0400
committerAlisdair McDiarmid <alisdair@users.noreply.github.com>2020-05-14 15:03:29 -0400
commite899db5b9fcde6e5d6610e27e97dcd485dafa1d2 (patch)
tree3a60e80a27b3e7c4c0bf2d0260ea2347e9a3b72a /json
parentb5f1f971b4788270e03817c15093409a1181915f (diff)
Update other fuzz docs for consistency
Diffstat (limited to 'json')
-rw-r--r--json/fuzz/README.md39
1 files changed, 32 insertions, 7 deletions
diff --git a/json/fuzz/README.md b/json/fuzz/README.md
index 17f8f9f..b4d7fd1 100644
--- a/json/fuzz/README.md
+++ b/json/fuzz/README.md
@@ -3,21 +3,46 @@
This directory contains helper functions and corpuses that can be used to
fuzz-test the HCL JSON parser using [go-fuzz](https://github.com/dvyukov/go-fuzz).
-To fuzz, first install go-fuzz and its build tool in your `GOPATH`:
+## Work directory
+
+`go-fuzz` needs a working directory where it can keep state as it works. This
+should ideally be in a ramdisk for efficiency, and should probably _not_ be on
+an SSD to avoid thrashing it. Here's how to create a ramdisk:
+
+### macOS
+
+```
+$ SIZE_IN_MB=1024
+$ DEVICE=`hdiutil attach -nobrowse -nomount ram://$(($SIZE_IN_MB*2048))`
+$ diskutil erasevolume HFS+ RamDisk $DEVICE
+$ export RAMDISK=/Volumes/RamDisk
+```
+
+### Linux
+
+```
+$ mkdir /mnt/ramdisk
+$ mount -t tmpfs -o size=1024M tmpfs /mnt/ramdisk
+$ export RAMDISK=/mnt/ramdisk
+```
+
+## Running the fuzzer
+
+Next, install `go-fuzz` and its build tool in your `GOPATH`:
```
-$ make tools
+$ make tools FUZZ_WORK_DIR=$RAMDISK
```
-Now you can fuzz one or all of the parsers:
+Now you can fuzz the parser:
```
-$ make fuzz-config FUZZ_WORK_DIR=/tmp/hcl2-fuzz-config
+$ make fuzz-config FUZZ_WORK_DIR=$RAMDISK/json-fuzz-config
```
-In all cases, set `FUZZ_WORK_DIR` to a directory where `go-fuzz` can keep state
-as it works. This should ideally be in a ramdisk for efficiency, and should
-probably _not_ be on an SSD to avoid thrashing it.
+~> Note: `go-fuzz` does not interact well with `goenv`. If you encounter build
+errors where the package `go.fuzz.main` could not be found, you may need to use
+a machine with a direct installation of Go.
## Understanding the result