Skip to content
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

add trace-constraints test #432

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/TestBase.hs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ doTest mwb cfg _sv fp = do
logs <- IOR.readIORef logsRef
T.assertFailure (msg ++ "\n" ++ (intercalate "\n" (reverse logs)))

(dir, rcfg) <- case argFileExists of
(dir, rcfg) <- case argFileExists && not (isJust mwb) of
True -> do
rawOpts <- readFile (fp <.> "args")
let optsList = filter (\s -> s /= "") $ (concat ((map (splitOn " ") (splitOn "\n" rawOpts))))
Expand Down
5 changes: 5 additions & 0 deletions tests/aarch32/trace-constraints.args
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-o trace-constraints.original.exe
-p trace-constraints.patched.exe
-b trace-constraints.toml
--script trace-constraints.pate
--add-trace-constraints
1 change: 1 addition & 0 deletions tests/aarch32/trace-constraints.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ConditionallyEquivalent
Binary file added tests/aarch32/trace-constraints.original.exe
Binary file not shown.
Binary file added tests/aarch32/trace-constraints.patched.exe
Binary file not shown.
29 changes: 29 additions & 0 deletions tests/aarch32/trace-constraints.pate
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Choose Entry Point
> Function Entry "_start"

Function Entry "_start"
Handle observable difference:
> Avoid difference with equivalence condition

Verification Finished
Continue verification?
> Finish and view final result


Final Result
Assumed Equivalence Conditions
? Function Entry "_start"

Regenerate result with new trace constraints?
> True

Waiting for constraints..
> [ [ { "var": { "symbolic_ident" : 239 }, "op" : "EQ", "const" : "0" }, { "var": { "symbolic_ident" : -904 }, "op" : "EQ", "const" : "0" }, { "var": { "symbolic_ident" : 190 }, "op" : "EQ", "const" : "0" }, { "var": { "symbolic_ident" : 223 }, "op" : "EQ", "const" : "0" } ] ]

// above constraint satisfies the equivalence relation
Assumed Equivalence Conditions
Function Entry "_start"
? true

Regenerate result with new trace constraints?
> False
1 change: 1 addition & 0 deletions tests/aarch32/trace-constraints.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
observable-memory = [ { start-address = 0x0003f000, length=4000 } ]
Binary file not shown.
20 changes: 20 additions & 0 deletions tests/src/trace-constraints.original.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include "util.h"

void _start();

int h;
int f;
int i;
int dump;
int g __attribute__((section(".output"))) = -12;
int j __attribute__((section(".output"))) = -12;

void _start() {
dump = h;
dump = i;

if (h == 0){
g = f;
}
j = i;
}
20 changes: 20 additions & 0 deletions tests/src/trace-constraints.patched-bad.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include "util.h"

void _start();

int h;
int f;
int i;
int dump;
int g __attribute__((section(".output"))) = -12;
int j __attribute__((section(".output"))) = -12;

void _start() {
dump = h;
dump = i;

if (h == 1){
g = f;
}
j = i;
}
20 changes: 20 additions & 0 deletions tests/src/trace-constraints.patched.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include "util.h"

void _start();

int h;
int f;
int i;
int dump;
int g __attribute__((section(".output"))) = -12;
int j __attribute__((section(".output"))) = -12;

void _start() {
dump = h;
dump = i;

if (i == 0){
g = f;
}
j = i;
}
8 changes: 5 additions & 3 deletions tests/template.mk
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ malloc-%.exe: ./build/malloc-%.s ./build/link.ld
diff ./dumps/$(basename $@).original.dump ./dumps/$(basename $@).patched-bad.dump || true

%.test_run: %.original.exe %.patched.exe
../../pate.sh -o $(basename $@).original.exe -p $(basename $@).patched.exe \
`( (test -f $(basename $@).toml && echo "-b $(basename $@).toml") || echo "")` \
`( (test -f $(basename $@).pate && echo "--script $(basename $@).pate") || echo "")` \
../../pate.sh \
`( (!(test -f $(basename $@).args) && echo "-o $(basename $@).original.exe -p $(basename $@).patched.exe") || echo "")` \
`( (!(test -f $(basename $@).args) && (test -f $(basename $@).toml && echo "-b $(basename $@).toml")) || echo "")` \
`( (!(test -f $(basename $@).args) && (test -f $(basename $@).pate && echo "--script $(basename $@).pate")) || echo "")` \
`( (test -f $(basename $@).args && cat $(basename $@).args) || echo "")` \
--no-assume-stack-scope

.PRECIOUS: ./build/%.s ./build/%.i %.exe malloc-%.exe ./unequal/%.original.exe ./unequal/%.patched.exe
Expand Down
Loading