Skip to content

Commit f1c6cad

Browse files
committed
docs: add cross-link to harness loop docs from snapshot_restore_interval config
1 parent 020ce4f commit f1c6cad

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

docs/src/config/common-options.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,9 @@ breakpoint-triggered solutions, always restore the initial snapshot before
231231
the next iteration resumes if one exists. `snapshot_restore_interval`
232232
controls only the restore behavior for normal iteration boundaries.
233233

234+
When using values other than `1`, the harness must be structured as a loop. See
235+
[Semi-Persistent and Fully Persistent Execution](../harnessing/compiled-in.md#semi-persistent-and-fully-persistent-execution).
236+
234237
### Adding Tokens From Target Software
235238

236239
The fuzzer has a mutator which will insert, remove, and mutate tokens in testcases. This

docs/src/harnessing/compiled-in.md

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- [Using Provided Headers](#using-provided-headers)
55
- [Multiple Harnesses in One Binary](#multiple-harnesses-in-one-binary)
66
- [Alternative Start Harnesses](#alternative-start-harnesses)
7+
- [Semi-Persistent and Fully Persistent Execution](#semi-persistent-and-fully-persistent-execution)
78
- [Troubleshooting](#troubleshooting)
89
- [Compile Errors About Temporaries](#compile-errors-about-temporaries)
910

@@ -150,11 +151,9 @@ different target software to be used with as little modification as possible.
150151

151152
## Semi-Persistent and Fully Persistent Execution
152153

153-
When `snapshot_restore_interval` is set to a value other than `1`, TSFFS does not restore
154-
the initial snapshot at every iteration boundary. Instead, after `HARNESS_STOP` the target
155-
continues executing — TSFFS writes the next testcase into the buffer and resumes from
156-
immediately after `HARNESS_STOP`. The target harness must therefore be structured as a
157-
loop:
154+
When `snapshot_restore_interval` is set to a value other than `1`, the snapshot is not
155+
restored at every iteration boundary. The target harness must therefore be structured as
156+
a loop, with `HARNESS_START` and `HARNESS_STOP` inside it:
158157

159158
```c
160159
#include "tsffs.h"
@@ -163,26 +162,21 @@ int main() {
163162
char buffer[20];
164163
size_t size = sizeof(buffer);
165164

166-
// Snapshot is taken here. TSFFS writes the first testcase into buffer and size.
167-
HARNESS_START(buffer, &size);
168-
169165
while (1) {
166+
// Snapshot is taken here. TSFFS writes the testcase into buffer and size.
167+
HARNESS_START(buffer, &size);
168+
170169
function_under_test(buffer, size);
171170

172-
// Signals end of iteration. TSFFS writes the next testcase into buffer
173-
// and size, then resumes execution here (unless a snapshot restore occurs).
174171
HARNESS_STOP();
175172
}
176-
177-
return 0;
178173
}
179174
```
180175

181176
For `snapshot_restore_interval = N` (semi-persistent), the snapshot is restored every N
182-
iterations, which resets the loop back to `HARNESS_START`. For
183-
`snapshot_restore_interval = 0` (fully persistent), the snapshot is never restored and
184-
the loop runs indefinitely — any per-iteration state (allocated memory, open handles,
185-
etc.) must be cleaned up manually inside the loop.
177+
iterations. For `snapshot_restore_interval = 0` (fully persistent), the snapshot is
178+
never restored; any per-iteration state (allocated memory, open handles, etc.) must be
179+
cleaned up manually inside the loop.
186180

187181
## Troubleshooting
188182

0 commit comments

Comments
 (0)