-
Notifications
You must be signed in to change notification settings - Fork 274
Create harness to initialize memory from snapshot #4150
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
danpoe
merged 7 commits into
diffblue:develop
from
danpoe:feature/memory-snapshot-harness
Mar 15, 2019
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
991061b
Add const iterator to symbol table
danpoe 36983c1
Regression tests for the memory snapshot harness generator
danpoe 20ee8df
Output goto functions in goto-harness regression tests
danpoe b5657a8
Add method to get a const_targett from a location number
danpoe a809e2c
Add harness generator to initialise memory from a memory snapshot
danpoe 9c9da96
Search the JSON for symbol table
7bc616a
Fix based on comments
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
62 changes: 62 additions & 0 deletions
62
regression/goto-harness/load-snapshot-json-snapshots/global-int-x-1-snapshot.json
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{ | ||
"symbolTable": { | ||
"x": { | ||
"baseName": "x", | ||
"isAuxiliary": false, | ||
"isExported": false, | ||
"isExtern": false, | ||
"isFileLocal": false, | ||
"isInput": false, | ||
"isLvalue": true, | ||
"isMacro": false, | ||
"isOutput": false, | ||
"isParameter": false, | ||
"isProperty": false, | ||
"isStateVar": false, | ||
"isStaticLifetime": true, | ||
"isThreadLocal": false, | ||
"isType": false, | ||
"isVolatile": false, | ||
"isWeak": false, | ||
"location": {}, | ||
"mode": "C", | ||
"module": "main", | ||
"name": "x", | ||
"prettyName": "x", | ||
"type": { | ||
"id": "signedbv", | ||
"namedSub": { | ||
"#c_type": { | ||
"id": "signed_int" | ||
}, | ||
"width": { | ||
"id": "32" | ||
} | ||
} | ||
}, | ||
"value": { | ||
"id": "constant", | ||
"namedSub": { | ||
"#base": { | ||
"id": "10" | ||
}, | ||
"#source_location": {}, | ||
"type": { | ||
"id": "signedbv", | ||
"namedSub": { | ||
"#c_type": { | ||
"id": "signed_int" | ||
}, | ||
"width": { | ||
"id": "32" | ||
} | ||
} | ||
}, | ||
"value": { | ||
"id": "1" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
regression/goto-harness/load-snapshot-recursive-static-global-int-01/main.c
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
int x; | ||
int flag; | ||
|
||
int main() | ||
{ | ||
x = 0; | ||
|
||
assert(flag != 0 || x == 1); | ||
assert(flag != 1 || x == 0); | ||
|
||
if(flag == 0) | ||
{ | ||
flag = 1; | ||
main(); | ||
} | ||
|
||
return 0; | ||
} |
8 changes: 8 additions & 0 deletions
8
regression/goto-harness/load-snapshot-recursive-static-global-int-01/test.desc
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CORE | ||
main.c | ||
--harness-type initialise-with-memory-snapshot --memory-snapshot ../load-snapshot-json-snapshots/global-int-x-1-snapshot.json --initial-location main:1 | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
VERIFICATION SUCCESSFUL | ||
-- | ||
^warning: ignoring |
10 changes: 10 additions & 0 deletions
10
regression/goto-harness/load-snapshot-static-global-array-01/main.c
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
int x[] = {1, 2, 3}; | ||
|
||
int main() | ||
{ | ||
assert(x[0] == 4); | ||
assert(x[1] == 5); | ||
assert(x[2] == 6); | ||
|
||
return 0; | ||
} |
181 changes: 181 additions & 0 deletions
181
regression/goto-harness/load-snapshot-static-global-array-01/snapshot.json
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
{ | ||
"symbolTable": { | ||
"x": { | ||
"baseName": "x", | ||
"isAuxiliary": false, | ||
"isExported": false, | ||
"isExtern": false, | ||
"isFileLocal": false, | ||
"isInput": false, | ||
"isLvalue": true, | ||
"isMacro": false, | ||
"isOutput": false, | ||
"isParameter": false, | ||
"isProperty": false, | ||
"isStateVar": false, | ||
"isStaticLifetime": true, | ||
"isThreadLocal": false, | ||
"isType": false, | ||
"isVolatile": false, | ||
"isWeak": false, | ||
"location": {}, | ||
"mode": "C", | ||
"module": "test", | ||
"name": "x", | ||
"prettyName": "x", | ||
"type": { | ||
"id": "array", | ||
"namedSub": { | ||
"#source_location": {}, | ||
"size": { | ||
"id": "constant", | ||
"namedSub": { | ||
"type": { | ||
"id": "signedbv", | ||
"namedSub": { | ||
"#c_type": { | ||
"id": "signed_long_int" | ||
}, | ||
"width": { | ||
"id": "64" | ||
} | ||
} | ||
}, | ||
"value": { | ||
"id": "3" | ||
} | ||
} | ||
} | ||
}, | ||
"sub": [ | ||
{ | ||
"id": "signedbv", | ||
"namedSub": { | ||
"#c_type": { | ||
"id": "signed_int" | ||
}, | ||
"width": { | ||
"id": "32" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"value": { | ||
"id": "array", | ||
"namedSub": { | ||
"#source_location": {}, | ||
"type": { | ||
"id": "array", | ||
"namedSub": { | ||
"#source_location": {}, | ||
"size": { | ||
"id": "constant", | ||
"namedSub": { | ||
"type": { | ||
"id": "signedbv", | ||
"namedSub": { | ||
"#c_type": { | ||
"id": "signed_long_int" | ||
}, | ||
"width": { | ||
"id": "64" | ||
} | ||
} | ||
}, | ||
"value": { | ||
"id": "3" | ||
} | ||
} | ||
} | ||
}, | ||
"sub": [ | ||
{ | ||
"id": "signedbv", | ||
"namedSub": { | ||
"#c_type": { | ||
"id": "signed_int" | ||
}, | ||
"width": { | ||
"id": "32" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
"sub": [ | ||
{ | ||
"id": "constant", | ||
"namedSub": { | ||
"#base": { | ||
"id": "10" | ||
}, | ||
"#source_location": {}, | ||
"type": { | ||
"id": "signedbv", | ||
"namedSub": { | ||
"#c_type": { | ||
"id": "signed_int" | ||
}, | ||
"width": { | ||
"id": "32" | ||
} | ||
} | ||
}, | ||
"value": { | ||
"id": "4" | ||
} | ||
} | ||
}, | ||
{ | ||
"id": "constant", | ||
"namedSub": { | ||
"#base": { | ||
"id": "10" | ||
}, | ||
"#source_location": {}, | ||
"type": { | ||
"id": "signedbv", | ||
"namedSub": { | ||
"#c_type": { | ||
"id": "signed_int" | ||
}, | ||
"width": { | ||
"id": "32" | ||
} | ||
} | ||
}, | ||
"value": { | ||
"id": "5" | ||
} | ||
} | ||
}, | ||
{ | ||
"id": "constant", | ||
"namedSub": { | ||
"#base": { | ||
"id": "10" | ||
}, | ||
"#source_location": {}, | ||
"type": { | ||
"id": "signedbv", | ||
"namedSub": { | ||
"#c_type": { | ||
"id": "signed_int" | ||
}, | ||
"width": { | ||
"id": "32" | ||
} | ||
} | ||
}, | ||
"value": { | ||
"id": "6" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
regression/goto-harness/load-snapshot-static-global-array-01/test.desc
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CORE | ||
main.c | ||
--harness-type initialise-with-memory-snapshot --memory-snapshot snapshot.json --initial-location main:0 | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
VERIFICATION SUCCESSFUL | ||
-- | ||
^warning: ignoring |
8 changes: 8 additions & 0 deletions
8
regression/goto-harness/load-snapshot-static-global-int-01/main.c
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
int x; | ||
|
||
int main() | ||
{ | ||
assert(x == 1); | ||
|
||
return 0; | ||
} |
8 changes: 8 additions & 0 deletions
8
regression/goto-harness/load-snapshot-static-global-int-01/test.desc
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CORE | ||
main.c | ||
--harness-type initialise-with-memory-snapshot --memory-snapshot ../load-snapshot-json-snapshots/global-int-x-1-snapshot.json --initial-location main:0 | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
VERIFICATION SUCCESSFUL | ||
-- | ||
^warning: ignoring |
10 changes: 10 additions & 0 deletions
10
regression/goto-harness/load-snapshot-static-global-int-02/main.c
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
int x; | ||
int y; // snapshot contains no value for y | ||
|
||
int main() | ||
{ | ||
assert(x == 1); | ||
assert(y == 1); | ||
|
||
return 0; | ||
} |
9 changes: 9 additions & 0 deletions
9
regression/goto-harness/load-snapshot-static-global-int-02/test.desc
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CORE | ||
main.c | ||
--harness-type initialise-with-memory-snapshot --memory-snapshot ../load-snapshot-json-snapshots/global-int-x-1-snapshot.json --initial-location main:0 | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
\[main.assertion.1\] line [0-9]+ assertion x == 1: SUCCESS | ||
\[main.assertion.2\] line [0-9]+ assertion y == 1: FAILURE | ||
-- | ||
^warning: ignoring |
14 changes: 14 additions & 0 deletions
14
regression/goto-harness/load-snapshot-static-global-int-03/main.c
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
int x; | ||
|
||
void func() | ||
{ | ||
} | ||
|
||
int main() | ||
{ | ||
func(); | ||
|
||
assert(x == 1); | ||
|
||
return 0; | ||
} |
8 changes: 8 additions & 0 deletions
8
regression/goto-harness/load-snapshot-static-global-int-03/test.desc
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CORE | ||
main.c | ||
--harness-type initialise-with-memory-snapshot --memory-snapshot ../load-snapshot-json-snapshots/global-int-x-1-snapshot.json --initial-location main:0 | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
VERIFICATION SUCCESSFUL | ||
-- | ||
^warning: ignoring |
10 changes: 10 additions & 0 deletions
10
regression/goto-harness/load-snapshot-static-global-int-04/main.c
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
int x; | ||
|
||
int main() | ||
{ | ||
x = 0; // should be skipped | ||
|
||
assert(x == 1); | ||
|
||
return 0; | ||
} |
8 changes: 8 additions & 0 deletions
8
regression/goto-harness/load-snapshot-static-global-int-04/test.desc
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CORE | ||
main.c | ||
--harness-type initialise-with-memory-snapshot --memory-snapshot ../load-snapshot-json-snapshots/global-int-x-1-snapshot.json --initial-location main:1 | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
VERIFICATION SUCCESSFUL | ||
-- | ||
^warning: ignoring |
11 changes: 11 additions & 0 deletions
11
regression/goto-harness/load-snapshot-static-global-pointer-01/main.c
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
int x; | ||
int *p; // has value &x in the snapshot | ||
|
||
int main() | ||
{ | ||
x = 1; | ||
|
||
assert(*p == 1); | ||
|
||
return 0; | ||
} |
Oops, something went wrong.
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.
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.
Do you need this information for the tests or is this just intended to make debugging a bit easier?
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.
Not need, so I guess debugging.