Skip to content

Commit

Permalink
Add tests showing the effect on string-max-length
Browse files Browse the repository at this point in the history
These tests show how the result of the solver can depend on the
string-max-input-length and string-max-length parameters.
  • Loading branch information
romainbrenguier committed Apr 13, 2018
1 parent 5315a10 commit 4f023cd
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 0 deletions.
Binary file added regression/jbmc-strings/max-length/Test.class
Binary file not shown.
37 changes: 37 additions & 0 deletions regression/jbmc-strings/max-length/Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
public class Test {

static void checkMaxInputLength(String arg1, String arg2) {
// Filter
if (arg1 == null || arg2 == null)
return;

// The validity of this depends on string-max-input-length
assert arg1.length() + arg2.length() < 1_000_000;
}

static void checkMaxLength(String arg1, String arg2) {
// Filter
if (arg1 == null || arg2 == null)
return;

if(arg1.length() + arg2.length() < 4_001)
return;

// Act
String s = arg1.concat(arg2);

// When string-max-length is smaller than 4_000 this will
// always be the case
assert org.cprover.CProverString.charAt(s, 4_000) == '?';
}

static void main(String argv[]) {
// Filter
if (argv.length < 2)
return;

// Act
checkMaxInputLength(argv[0], argv[1]);
checkMaxLength(argv[0], argv[1]);
}
}
6 changes: 6 additions & 0 deletions regression/jbmc-strings/max-length/test1.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CORE
Test.class
--refine-strings --verbosity 10 --string-max-input-length 499999 --function Test.checkMaxInputLength
^EXIT=0$
^SIGNAL=0$
assertion.* line 9 function java::Test.checkMaxInputLength.* bytecode-index 16: SUCCESS
6 changes: 6 additions & 0 deletions regression/jbmc-strings/max-length/test2.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CORE
Test.class
--refine-strings --verbosity 10 --string-max-input-length 500000 --function Test.checkMaxInputLength
^EXIT=10$
^SIGNAL=0$
assertion.* line 9 function java::Test.checkMaxInputLength.* bytecode-index 16: FAILURE
6 changes: 6 additions & 0 deletions regression/jbmc-strings/max-length/test3.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CORE
Test.class
--refine-strings --verbosity 10 --string-max-length 4001 --function Test.checkMaxLength
^EXIT=10$
^SIGNAL=0$
assertion.* line 25 function java::Test.checkMaxLength.* bytecode-index 26: FAILURE
11 changes: 11 additions & 0 deletions regression/jbmc-strings/max-length/test4.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CORE
Test.class
--refine-strings --verbosity 10 --string-max-length 4000 --function Test.checkMaxLength
^SIGNAL=0$
--
^EXIT=0$
assertion.* line 25 function java::Test.checkMaxLength.* bytecode-index 26: SUCCESS
--
The solver may give an ERROR because the value of string-max-length is too
small to give an answer about the assertion.
So we just check that the answer is not success.

0 comments on commit 4f023cd

Please sign in to comment.