-
Notifications
You must be signed in to change notification settings - Fork 20
3D: Support probes in Z3 test case generation #173
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this more clearly expresses the constraint that the parser must consume all of its input
…` is named `witness<ident><n>`
this option is needed for C++ compilers older than C++20
9fa3984 to
40bf721
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Test case generation for probes
So far the Z3 test case generation for 3D (#101) was unidimensional and did not support probes (#118)
This PR switches to bidimensional test cases. We instruct Z3 to generate each test case as an array of byte arrays, where the probe "pointer" is an index in the array of arrays, parsed as a little-endian unsigned 64-bit integer. Then, in the test case executable, we implement all probe functions uniformly to "follow" those indices accordingly.
Example
Consider the following 3D specification:
Then, here is a C representation of a positive test case for
outer:In this test case, the initial input buffer passed to the
outervalidator iswitness[0].buf, i.e.witness_0. Then, at offset 1, corresponding to the fieldfoo, this input buffer contains an index into thewitnessarray of arrays, as a little-endian unsigned 64-bit integer: here1encoded as 8 little-endian bytes. This instructs the probe function to take the byte array at index 1 inwitness, i.e.witness[1].buf, i.e.witness_1, which in turn contains binary data valid wrt.inner. Oncewitness_1is validated wrt.inner,outerresumes validation ofwitness_0with the remaining 3 bytes for thesuffixfield.Z3 constraints
We constrain Z3 to always construct valid such indices and probe sizes: no negative test cases with invalid such pointers will be produced. The reason is twofold:
Produced binary test files
For each test case
n, we are producing one binary file for the initial input buffer and one binary file for each indirection buffer. Then, the indexiof each such binary file within the array of byte arrays now appears in the name of the file aswitness.n.POS.i.validatorname.args.dat(orwitness.n.NEG.i.validatorname.args.dat)Other fixes
This PR also brings a few more (slightly unrelated) fixes:
--z3_flight_name myflightso that each C test case name starts withwitnessmyflightA, for eachentrypoint probe B.myprobeinA, 3D now adds#include "B_ExternalAPI.h"intoAWrapper.c. With that fix, theprobeexample now also works in--batchmode.ELF.3dandprobe/src/Probe.3dWhat this PR does not fix
This PR does not add support for probes in the test checker executable generated by
--test_checkerthat takes a binary file name as argument. This test checker executable still only supports unidimensional test cases.