-
Notifications
You must be signed in to change notification settings - Fork 25
Docs: snapshot restore interval loop #314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| - [Using Provided Headers](#using-provided-headers) | ||
| - [Multiple Harnesses in One Binary](#multiple-harnesses-in-one-binary) | ||
| - [Alternative Start Harnesses](#alternative-start-harnesses) | ||
| - [Semi-Persistent and Fully Persistent Execution](#semi-persistent-and-fully-persistent-execution) | ||
| - [Troubleshooting](#troubleshooting) | ||
| - [Compile Errors About Temporaries](#compile-errors-about-temporaries) | ||
|
|
||
|
|
@@ -148,6 +149,35 @@ different target software to be used with as little modification as possible. | |
| not initially have `*size_ptr` set to the maximum size, but still needs to | ||
| read the actual buffer size. | ||
|
|
||
| ## Semi-Persistent and Fully Persistent Execution | ||
|
|
||
| When `snapshot_restore_interval` is set to a value other than `1`, the snapshot is not | ||
| restored at every iteration boundary. The target harness must therefore be structured as | ||
| a loop, with `HARNESS_START` and `HARNESS_STOP` inside it: | ||
|
|
||
| ```c | ||
| #include "tsffs.h" | ||
|
|
||
| int main() { | ||
| char buffer[20]; | ||
| size_t size = sizeof(buffer); | ||
|
|
||
| while (1) { | ||
| // Snapshot is taken here. TSFFS writes the testcase into buffer and size. | ||
| HARNESS_START(buffer, &size); | ||
|
|
||
| function_under_test(buffer, size); | ||
|
|
||
| HARNESS_STOP(); | ||
| } | ||
|
Comment on lines
+154
to
+172
|
||
| } | ||
| ``` | ||
|
|
||
| For `snapshot_restore_interval = N` (semi-persistent), the snapshot is restored every N | ||
| iterations. For `snapshot_restore_interval = 0` (fully persistent), the snapshot is | ||
| never restored; any per-iteration state (allocated memory, open handles, etc.) must be | ||
| cleaned up manually inside the loop. | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### Compile Errors About Temporaries | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This note links to the new section, but it may mislead readers into thinking
HARNESS_STARTmust be repeated every iteration. In semi/fully persistent mode, what’s required is that the harness’s control flow loops so execution can reach the next iteration without relying on a snapshot restore;HARNESS_STARTcan be a one-time setup before the loop. Consider clarifying this wording to avoid unnecessary start-trigger stops each iteration.