Skip to content

Commit f2c4804

Browse files
Romain Brenguierromainbrenguier
Romain Brenguier
authored andcommitted
Regression test for the string-refine option
We are going to add a string-refine option to CBMC, (instead a pass option as used in previous version of the tests). We changed the test description file accordingly and added a few extra tests (for java char arrays). Also changed the flag in string regression from CORE to FUTURE: Since the string solver is not yet part of this branch, we mark the tests for string functions as FUTURE. They will be changed to CORE once the corresponding features are integrated in CBMC. I also changed the Makefile for being able to test tests marked as future.
1 parent 1029635 commit f2c4804

File tree

61 files changed

+210
-121
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+210
-121
lines changed

regression/strings/Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11

22
test:
3-
../test.pl -c ../../../src/cbmc/cbmc
3+
@../test.pl -c ../../../src/cbmc/cbmc
4+
5+
testfuture:
6+
@../test.pl -c ../../../src/cbmc/cbmc -F

regression/strings/cprover-string-hack.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ typedef unsigned char __CPROVER_char;
5656
******************************************************************************/
5757
extern __CPROVER_char __CPROVER_uninterpreted_string_char_at_func(__CPROVER_string str, int pos);
5858
extern __CPROVER_bool __CPROVER_uninterpreted_string_equal_func(__CPROVER_string str1, __CPROVER_string str2);
59-
extern __CPROVER_string __CPROVER_uninterpreted_string_literal_func();
59+
extern __CPROVER_string __CPROVER_uninterpreted_string_literal_func(char * str);
6060
extern __CPROVER_char __CPROVER_uninterpreted_char_literal_func();
6161
extern __CPROVER_string __CPROVER_uninterpreted_string_concat_func(__CPROVER_string str1, __CPROVER_string str2);
6262
extern int __CPROVER_uninterpreted_string_length_func(__CPROVER_string str);
@@ -68,5 +68,5 @@ extern int __CPROVER_uninterpreted_string_index_of_func(__CPROVER_string str, __
6868
extern int __CPROVER_uninterpreted_string_last_index_of_func(__CPROVER_string str, __CPROVER_char c);
6969
extern __CPROVER_string __CPROVER_uninterpreted_string_char_set_func(__CPROVER_string str, int pos, __CPROVER_char c);
7070
extern __CPROVER_string __CPROVER_uninterpreted_string_copy_func(__CPROVER_string str);
71-
extern unsigned __CPROVER_uninterpreted_string_parse_int_func(__CPROVER_string str);
72-
extern __CPROVER_string __CPROVER_uninterpreted_string_of_int_func(unsigned i);
71+
extern int __CPROVER_uninterpreted_string_parse_int_func(__CPROVER_string str);
72+
extern __CPROVER_string __CPROVER_uninterpreted_string_of_int_func(int i);

regression/strings/java_case/test.desc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
CORE
1+
FUTURE
22
test_case.class
3-
--pass
3+
--string-refine
44
^EXIT=10$
55
^SIGNAL=0$
66
^\[assertion.1\] assertion at file test_case.java line 11: SUCCESS$
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FUTURE
2+
test_char_array.class
3+
--string-refine
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^\[assertion.1\] assertion at file test_char_array.java line 11: SUCCESS$
7+
^\[assertion.2\] assertion at file test_char_array.java line 12: SUCCESS$
8+
^\[assertion.3\] assertion at file test_char_array.java line 13: FAILURE$
9+
--
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
public class test_char_array {
2+
3+
public static void main(String[] argv)
4+
{
5+
String s = "abc";
6+
char [] str = s.toCharArray();
7+
int[] test = new int[312];
8+
char c = str[2];
9+
String t = argv[0];
10+
char d = t.charAt(0);
11+
assert(str.length == 3);
12+
assert(c == 'c');
13+
assert(c == d || d < 'a' || d > 'z' );
14+
}
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FUTURE
2+
test_init.class
3+
--string-refine
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^\[assertion.1\] assertion at file test_init.java line 16: SUCCESS$
7+
^\[assertion.2\] assertion at file test_init.java line 17: SUCCESS$
8+
^\[assertion.3\] assertion at file test_init.java line 18: SUCCESS$
9+
^\[assertion.4\] assertion at file test_init.java line 20: SUCCESS$
10+
^\[assertion.5\] assertion at file test_init.java line 21: FAILURE$
11+
--
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
public class test_init {
2+
3+
public static void main(String[] argv)
4+
{
5+
char [] str = new char[10];
6+
str[0] = 'H';
7+
str[1] = 'e';
8+
str[2] = 'l';
9+
str[3] = 'l';
10+
str[4] = 'o';
11+
String s = new String(str);
12+
String t = new String(str,1,2);
13+
14+
System.out.println(s);
15+
System.out.println(s.length());
16+
assert(s.startsWith("Hello"));
17+
assert(s.length() == 10);
18+
assert(t.equals("el"));
19+
String u = String.valueOf(str,3,2);
20+
assert(u.equals("lo"));
21+
assert(s.equals("Hello") || !t.equals("el") || !u.equals("lo"));
22+
}
23+
}

regression/strings/java_char_at/test.desc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
CORE
1+
FUTURE
22
test_char_at.class
3-
--pass
3+
--string-refine
44
^EXIT=10$
55
^SIGNAL=0$
66
^\[assertion.1\] assertion at file test_char_at.java line 11: SUCCESS$

regression/strings/java_code_point/test.desc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
CORE
1+
FUTURE
22
test_code_point.class
3-
--pass
3+
--string-refine
44
^EXIT=0$
55
^SIGNAL=0$
66
^\[assertion.1\] assertion at file test_code_point.java line 5: SUCCESS$

regression/strings/java_compare/test.desc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
CORE
1+
FUTURE
22
test_compare.class
3-
--pass
3+
--string-refine
44
^EXIT=10$
55
^SIGNAL=0$
66
^\[assertion.1\] assertion at file test_compare.java line 6: SUCCESS$

regression/strings/java_concat/test.desc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
CORE
1+
FUTURE
22
test_concat.class
3-
--pass
3+
--string-refine
44
^EXIT=10$
55
^SIGNAL=0$
66
^\[assertion.1\] assertion at file test_concat.java line 9: SUCCESS$

regression/strings/java_contains/test.desc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
KNOWNBUG
1+
FUTURE
22
test_contains.class
3-
--pass
3+
--string-refine
44
^EXIT=10$
55
^SIGNAL=0$
66
^\[assertion.1\] assertion at file test_contains.java line 7: SUCCESS$

regression/strings/java_delete/test.desc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
KNOWNBUG
1+
FUTURE
22
test_delete.class
3-
--pass
3+
--string-refine
44
^EXIT=10$
55
^SIGNAL=0$
66
^\[assertion.1\] assertion at file test_delete.java line 11: SUCCESS$

regression/strings/java_easychair/test.desc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
KNOWNBUG
1+
FUTURE
22
easychair.class
3-
--pass
3+
--string-refine
44
^EXIT=10$
55
^SIGNAL=0$
66
^\[assertion.1\] assertion at file easychair.java line 29: FAILURE$

regression/strings/java_empty/test.desc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
CORE
1+
FUTURE
22
test_empty.class
3-
--pass
3+
--string-refine
44
^EXIT=10$
55
^SIGNAL=0$
66
^\[assertion.1\] assertion at file test_empty.java line 4: SUCCESS$

regression/strings/java_equal/test.desc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
CORE
1+
FUTURE
22
test_equal.class
3-
--pass
3+
--string-refine
44
^EXIT=10$
55
^SIGNAL=0$
66
^\[assertion.1\] assertion at file test_equal.java line 7: FAILURE$

regression/strings/java_float/test.desc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
CORE
1+
FUTURE
22
test_float.class
3-
--pass
3+
--string-refine
44
^EXIT=10$
55
^SIGNAL=0$
66
^\[assertion.1\] assertion at file test_float.java line 14: SUCCESS$

regression/strings/java_index_of/test.desc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
CORE
1+
FUTURE
22
test_index_of.class
3-
--pass
3+
--string-refine
44
^EXIT=10$
55
^SIGNAL=0$
66
^\[assertion.1\] assertion at file test_index_of.java line 13: SUCCESS$

regression/strings/java_int/test.desc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
CORE
1+
FUTURE
22
test_int.class
3-
--pass
3+
--string-refine
44
^EXIT=10$
55
^SIGNAL=0$
66
^\[assertion.1\] assertion at file test_int.java line 8: SUCCESS$

regression/strings/java_prefix/test.desc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
CORE
1+
FUTURE
22
test_prefix.class
3-
--pass
3+
--string-refine
44
^EXIT=10$
55
^SIGNAL=0$
66
^\[assertion.1\] assertion at file test_prefix.java line 14: SUCCESS$

regression/strings/java_replace/test.desc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
CORE
1+
FUTURE
22
test_replace.class
3-
--pass
3+
--string-refine
44
^EXIT=10$
55
^SIGNAL=0$
66
^\[assertion.1\] assertion at file test_replace.java line 6: SUCCESS$

regression/strings/java_set_length/test.desc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
CORE
1+
FUTURE
22
test_set_length.class
3-
--pass
3+
--string-refine
44
^EXIT=10$
55
^SIGNAL=0$
66
^\[assertion.1\] assertion at file test_set_length.java line 8: SUCCESS$

regression/strings/java_string_builder/test.desc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
CORE
1+
FUTURE
22
test_string_builder.class
3-
--pass
3+
--string-refine
44
^EXIT=10$
55
^SIGNAL=0$
66
^\[assertion.1\] assertion at file test_string_builder.java line 11: SUCCESS$
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FUTURE
2+
test_insert.class
3+
--string-refine
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^\[assertion.1\] assertion at file test_insert.java line 17: SUCCESS$
7+
^\[assertion.2\] assertion at file test_insert.java line 18: FAILURE$
8+
--
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
public class test_insert {
2+
3+
public static void main(String[] argv)
4+
{
5+
char [] str = new char[5];
6+
str[0] = 'H';
7+
str[1] = 'e';
8+
str[2] = 'l';
9+
str[3] = 'l';
10+
str[4] = 'o';
11+
12+
13+
StringBuilder sb = new StringBuilder(" world");
14+
sb.insert(0,str);
15+
String s = sb.toString();
16+
System.out.println(s);
17+
assert(s.equals("Hello world"));
18+
assert(!s.equals("Hello world"));
19+
}
20+
}

regression/strings/java_string_builder_length/test.desc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
CORE
1+
FUTURE
22
test_sb_length.class
3-
--pass
3+
--string-refine
44
^EXIT=10$
55
^SIGNAL=0$
66
\[assertion.1\] assertion at file test_sb_length.java line 6: SUCCESS$

regression/strings/java_strlen/test.desc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
CORE
1+
FUTURE
22
test_length.class
3-
--pass
3+
--string-refine
44
^EXIT=10$
55
^SIGNAL=0$
66
^\[assertion.1\] assertion at file test_length.java line 10: SUCCESS$

regression/strings/java_substring/test.desc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
CORE
1+
FUTURE
22
test_substring.class
3-
--pass
3+
--string-refine
44
^EXIT=10$
55
^SIGNAL=0$
66
^\[assertion.1\] assertion at file test_substring.java line 12: SUCCESS$

regression/strings/java_suffix/test.desc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
CORE
1+
FUTURE
22
test_suffix.class
3-
--pass
3+
--string-refine
44
^EXIT=10$
55
^SIGNAL=0$
66
^\[assertion.1\] assertion at file test_suffix.java line 12: SUCCESS$

regression/strings/java_trim/test.desc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
CORE
1+
FUTURE
22
test_trim.class
3-
--pass
3+
--string-refine
44
^EXIT=10$
55
^SIGNAL=0$
66
^\[assertion.1\] assertion at file test_trim.java line 5: SUCCESS$

regression/strings/test1/test.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
int main()
66
{
77
__CPROVER_string s;
8-
__CPROVER_char c1, c2;
8+
char c1, c2;
99
int i;
1010
int j;
1111
i = 2;
1212
s = __CPROVER_string_literal("pippo");
1313
c1 = __CPROVER_char_at(s, i);
14-
c2 = __CPROVER_char_literal("p");
14+
c2 = 'p';
1515
assert (c1 == c2);
1616
assert (c1 != c2);
1717
return 0;

regression/strings/test1/test.desc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
CORE
1+
FUTURE
22
test.c
3-
--pass
3+
--string-refine
44
^EXIT=10$
55
^SIGNAL=0$
66
^\[main.assertion.1\] assertion c1 == c2: SUCCESS$

regression/strings/test2/test.desc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
CORE
1+
FUTURE
22
test.c
3-
--pass
3+
--string-refine
44
^EXIT=10$
55
^SIGNAL=0$
66
^\[main.assertion.1\] assertion n == 5: SUCCESS$

regression/strings/test3.1/test.desc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
CORE
1+
FUTURE
22
test.c
3-
--pass
3+
--string-refine
44
^EXIT=0$
55
^SIGNAL=0$
66
^VERIFICATION SUCCESSFUL$

regression/strings/test3.2/test.desc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
CORE
1+
FUTURE
22
test.c
3-
--pass
3+
--string-refine
44
^EXIT=0$
55
^SIGNAL=0$
66
^VERIFICATION SUCCESSFUL$

regression/strings/test3.3/test.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ int main()
1616
// proving the assertions individually seems to be much faster
1717
//assert(__CPROVER_string_length(s) == i + 5);
1818
//assert(__CPROVER_string_issuffix(__CPROVER_string_literal("po"), s));
19-
assert(__CPROVER_char_at(s, i) == __CPROVER_char_literal("p"));
19+
assert(__CPROVER_char_at(s, i) == 'p');
2020

2121
return 0;
2222
}

regression/strings/test3.3/test.desc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
CORE
1+
FUTURE
22
test.c
3-
--pass
3+
--string-refine
44
^EXIT=0$
55
^SIGNAL=0$
66
^VERIFICATION SUCCESSFUL$

regression/strings/test3.4/test.desc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
CORE
1+
FUTURE
22
test.c
3-
--pass
3+
--string-refine
44
^EXIT=10$
55
^SIGNAL=0$
66
^VERIFICATION FAILED$

0 commit comments

Comments
 (0)