Skip to content

Commit 18db6bc

Browse files
committed
docs: document harness loop requirement for non-default snapshot_restore_interval
1 parent cb70514 commit 18db6bc

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

docs/src/harnessing/compiled-in.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,42 @@ different target software to be used with as little modification as possible.
148148
not initially have `*size_ptr` set to the maximum size, but still needs to
149149
read the actual buffer size.
150150

151+
## Semi-Persistent and Fully Persistent Execution
152+
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:
158+
159+
```c
160+
#include "tsffs.h"
161+
162+
int main() {
163+
char buffer[20];
164+
size_t size = sizeof(buffer);
165+
166+
// Snapshot is taken here. TSFFS writes the first testcase into buffer and size.
167+
HARNESS_START(buffer, &size);
168+
169+
while (1) {
170+
function_under_test(buffer, size);
171+
172+
// Signals end of iteration. TSFFS writes the next testcase into buffer
173+
// and size, then resumes execution here (unless a snapshot restore occurs).
174+
HARNESS_STOP();
175+
}
176+
177+
return 0;
178+
}
179+
```
180+
181+
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.
186+
151187
## Troubleshooting
152188

153189
### Compile Errors About Temporaries

0 commit comments

Comments
 (0)