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

Use string dependencies in the get method of the solver [TG-2607] #1922

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
a2fab10
Linting corrections in string_refinement
romainbrenguier Mar 7, 2018
5108a72
Fix string constraints printing
romainbrenguier Mar 8, 2018
0139424
Fix linting problem in string_constraint
romainbrenguier Mar 8, 2018
f6a153e
Check type before adding dependencies
romainbrenguier Mar 7, 2018
06dc6b2
Add an evaluation method to builtin functions
romainbrenguier Mar 7, 2018
e308bad
Rename class to string_dependenciest
romainbrenguier Mar 12, 2018
357cb44
Add const node_at function in string dependencies
romainbrenguier Mar 7, 2018
69f31c1
Add eval function to string_dependenciest
romainbrenguier Mar 7, 2018
56cb571
Activate dependency computation in string solver
romainbrenguier Mar 7, 2018
44693e8
Use eval of builtin function in get when available
romainbrenguier Mar 7, 2018
095d57b
Add concat_char builtin function for strings
romainbrenguier Mar 8, 2018
fb676d5
Add a cache for eval in string dependences
romainbrenguier Mar 8, 2018
0b3796e
Declare a nodet class in string_dependencies
romainbrenguier Mar 9, 2018
a89ceb0
Tests for string solver get with new dependencies
romainbrenguier Mar 8, 2018
7bb5aff
Make node point to builtin func they result from
romainbrenguier Mar 9, 2018
d0a8868
Constructor and destructor of builtin functions
romainbrenguier Mar 12, 2018
cb72bb7
Correct insert builtin function construction
romainbrenguier Mar 12, 2018
8d4a057
Decompose if_expr when adding dependencies
romainbrenguier Mar 13, 2018
1a874b3
Add name method to builtin functions
romainbrenguier Mar 13, 2018
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
Binary file added regression/jbmc-strings/StringConcat/Test.class
Binary file not shown.
315 changes: 315 additions & 0 deletions regression/jbmc-strings/StringConcat/Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,315 @@
public class Test {

public String stringDet() {
String s = "a";
s += "b";
s += "c";
s += "d";
s += "e";
s += "f";
s += "g";
s += "h";
s += "i";
s += "j";
s += "k";
s += "l";
s += "m";

assert(false);
return s;
}

public String stringNonDet(String arg) {
String s = arg;
s += "b";
s += "c";
s += "d";
s += "e";
s += "f";
s += arg;
s += "h";
s += "i";
s += "j";
s += "k";
s += "l";
s += arg;

assert(false);
return s;
}

public String bufferDet() {
StringBuffer s = new StringBuffer();
s.append("a");
s.append("b");
s.append("c");
s.append("d");
s.append("e");

s.append("a");
s.append("b");
s.append("c");
s.append("d");
s.append("e");

s.append("a");
s.append("b");
s.append("c");
s.append("d");
s.append("e");

s.append("a");
s.append("b");
s.append("c");
s.append("d");
s.append("e");

s.append("a");
s.append("b");
s.append("c");
s.append("d");
s.append("e");

s.append("a");
s.append("b");
assert(false);
return s.toString();
}

public String charBufferDet() {
StringBuffer s = new StringBuffer();
s.append('a');
s.append('b');
s.append('c');
s.append('d');
s.append('e');

s.append('a');
s.append('b');
s.append('c');
s.append('d');
s.append('e');

s.append('a');
s.append('b');
s.append('c');
s.append('d');
s.append('e');

s.append('a');
s.append('b');
s.append('c');
s.append('d');
s.append('e');

s.append('a');
s.append('b');
s.append('c');
s.append('d');
s.append('e');

s.append('a');
s.append('b');

assert(false);
return s.toString();
}

public String charBufferDetLoop(int width) {
if(width <= 5)
return "";
StringBuffer sb = new StringBuffer();
sb.append('+');
for(int i=1; i < width-1; ++i)
sb.append('-');
sb.append('+');
sb.append('\n');
sb.append('|');

sb.append(' ');
sb.append('c');
int padding = width - 2;
while(padding-- > 0)
sb.append(' ');

sb.append(' ');
sb.append('|');
sb.append('\n');
assert(false);
return sb.toString();
}

public String charBufferDetLoop2(int width, int height) {
if(width <= 0 || height <= 0)
return "";
StringBuffer sb = new StringBuffer();
sb.append('+');
for(int i=1; i < width-1; ++i)
sb.append('-');
sb.append('+');
sb.append('\n');
sb.append('|');

sb.append(' ');
sb.append('c');
int padding = width - 2;
while(padding-- > 0)
sb.append(' ');
sb.append(' ');
sb.append('|');
sb.append('\n');

sb.append('+');
for(int i=1; i<width; ++i)
sb.append('-');
sb.append('+');
sb.append('\n');

for(int i = 0; i < height; ++i) {
sb.append('|');
sb.append(' ');
sb.append('d');
padding = width - 3;
while(padding-- > 0)
sb.append(' ');
sb.append(' ');
sb.append('|');
sb.append('\n');
}

sb.append('+');
for(int i=1; i<width-1; ++i)
sb.append('-');
sb.append('+');
sb.append('\n');

assert(false);
return sb.toString();
}

public String bufferNonDetLoop(int width, String s) {
if(width <= 5 || s.length() >= width || s.length() == 0)
return "";
StringBuffer sb = new StringBuffer();
sb.append('+');
for(int i=1; i < width-1; ++i)
sb.append('-');
sb.append('+');
sb.append('\n');
sb.append('|');

sb.append(' ');
sb.append(s);
int padding = width - s.length();
while(padding-- > 0)
sb.append(' ');
sb.append(' ');
sb.append('|');
sb.append('\n');

assert(false);
return sb.toString();
}

public String bufferNonDetLoop2(int width, String c) {
if(width < 5 || c.length() > width)
return "";

StringBuffer sb = new StringBuffer();
sb.append('+');

for(int i=1; i<width-1; ++i)
sb.append('-');
sb.append('+');
sb.append('\n');
sb.append('|');
for(int i = 0; i < width; ++i) {
sb.append(' ');
sb.append(c);
int padding = width - c.length();
while(padding-- > 0)
sb.append(' ');
sb.append(' ');
sb.append('|');
}
sb.append('\n');

assert(false);
return sb.toString();
}

public String bufferNonDetLoop3(int cols, int columnWidth, String c) {
StringBuffer sb = new StringBuffer();
sb.append('-');
for(int i = 0; i < cols; ++i)
sb.append(c);

assert(false);
return sb.toString();
}
public String bufferNonDetLoop4(int cols, int columnWidth, String c) {
StringBuffer sb = new StringBuffer();
for(int i=1; i < columnWidth-1; ++i)
sb.append('-');
for(int i = 0; i < cols; ++i) {
sb.append(c);
}

assert(false);
return sb.toString();
}

public String bufferNonDetLoop5(int cols, int columnWidth, String c, String data[]) {
if(cols<1)
return "";

StringBuffer sb = new StringBuffer();
sb.append('+');
int totalWidth = columnWidth * cols;
for(int i=1; i<totalWidth-1; ++i)
sb.append('-');
sb.append('+');
sb.append('\n');
sb.append('|');
for(int i = 0; i < cols; ++i) {
sb.append(' ');
sb.append(c);
int padding = columnWidth - c.length();
while(padding-- > 0)
sb.append(' ');
sb.append(' ');
sb.append('|');
}
sb.append('\n');

sb.append('+');
for(int i=1; i<totalWidth-1; ++i)
sb.append('-');
sb.append('+');
sb.append('\n');

for(int i = 0; i < data.length; ++i) {
sb.append('|');
String d = data[i];
sb.append(' ');
sb.append(d);
int padding = columnWidth - d.length();
while(padding-- > 0)
sb.append(' ');
sb.append(' ');
sb.append('|');

if(i % cols == 0)
sb.append('\n');
}

sb.append('+');
for(int i=1; i<totalWidth-1; ++i)
sb.append('-');
sb.append('+');
sb.append('\n');

assert(false);
return sb.toString();
}
}
11 changes: 11 additions & 0 deletions regression/jbmc-strings/StringConcat/test_buffer_det.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CORE
Test.class
--refine-strings --string-max-length 1000 --string-max-input-length 100 --function Test.bufferDet --depth 10000 --verbosity 10
^EXIT=10$
^SIGNAL=0$
^VERIFICATION FAILED$
--
check_SAT: got SAT but the model is not correct
--
Using the string dependences information to compute the model, refinement
should not be needed when the execution is deterministic.
14 changes: 14 additions & 0 deletions regression/jbmc-strings/StringConcat/test_buffer_nondet_loop.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FUTURE
Test.class
--refine-strings --string-max-length 1000 --string-max-input-length 100 --function Test.bufferNonDetLoop --depth 10000 --unwind 5 --verbosity 10 --property "java::Test.bufferNonDetLoop:(ILjava/lang/String;)Ljava/lang/String;.assertion.1"
^EXIT=10$
^SIGNAL=0$
^VERIFICATION FAILED$
--
check_SAT: got SAT but the model is not correct
--
Using the string dependences information to compute the model, refinement
should not be needed when the execution is deterministic.

This test seems to fail with AppVeyor, we should make sure it works
once TG-2608 is done.
11 changes: 11 additions & 0 deletions regression/jbmc-strings/StringConcat/test_buffer_nondet_loop2.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FUTURE
Test.class
--refine-strings --string-max-length 1000 --string-max-input-length 100 --function Test.bufferNonDetLoop2 --depth 10000 --unwind 5 --verbosity 10
^EXIT=10$
^SIGNAL=0$
^VERIFICATION FAILED$
--
check_SAT: got SAT but the model is not correct
--
Using the string dependences information to compute the model, refinement
should not be needed when the execution is deterministic.
11 changes: 11 additions & 0 deletions regression/jbmc-strings/StringConcat/test_buffer_nondet_loop3.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CORE
Test.class
--refine-strings --string-max-length 1000 --string-max-input-length 100 --function Test.bufferNonDetLoop3 --depth 10000 --unwind 5 --verbosity 10
^EXIT=10$
^SIGNAL=0$
^VERIFICATION FAILED$
--
check_SAT: got SAT but the model is not correct
--
Using the string dependences information to compute the model, refinement
should not be needed when the execution is deterministic.
14 changes: 14 additions & 0 deletions regression/jbmc-strings/StringConcat/test_buffer_nondet_loop4.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FUTURE
Test.class
--refine-strings --string-max-length 1000 --string-max-input-length 100 --function Test.bufferNonDetLoop4 --depth 10000 --unwind 5 --verbosity 10 --property "java::Test.bufferNonDetLoop4:(IILjava/lang/String;)Ljava/lang/String;.assertion.1"
^EXIT=10$
^SIGNAL=0$
^VERIFICATION FAILED$
--
check_SAT: got SAT but the model is not correct
--
Using the string dependences information to compute the model, refinement
should not be needed when the execution is deterministic.

This test seems to fail with AppVeyor, we should make sure it works
once TG-2608 is done.
11 changes: 11 additions & 0 deletions regression/jbmc-strings/StringConcat/test_buffer_nondet_loop5.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FUTURE
Test.class
--refine-strings --string-max-length 1000 --string-max-input-length 100 --function Test.bufferNonDetLoop5 --depth 10000 --unwind 5 --verbosity 10
^EXIT=10$
^SIGNAL=0$
^VERIFICATION FAILED$
--
check_SAT: got SAT but the model is not correct
--
Using the string dependences information to compute the model, refinement
should not be needed when the execution is deterministic.
Loading