@@ -13,6 +13,8 @@ pub mod ffi {
13
13
fn get_api_version ( & self ) -> UniquePtr < CxxString > ;
14
14
fn load_model_from_files ( & self , files : & CxxVector < CxxString > ) ;
15
15
fn verify_model ( & self ) ;
16
+ fn validate_goto_model ( & self ) ;
17
+ fn drop_unused_functions ( & self ) ;
16
18
17
19
// Helper/Utility functions
18
20
fn translate_vector_of_string ( elements : Vec < String > ) -> & ' static CxxVector < CxxString > ;
@@ -35,7 +37,7 @@ fn print_response(vec: &CxxVector<CxxString>) {
35
37
}
36
38
}
37
39
38
- // To test run "cargo test -- --nocapture"
40
+ // To test run "CBMC_LIB_DIR=<path_to_build/libs> cargo test -- --test-threads=1 --nocapture"
39
41
#[ cfg( test) ]
40
42
mod tests {
41
43
use super :: * ;
@@ -51,7 +53,7 @@ mod tests {
51
53
}
52
54
53
55
#[ test]
54
- fn translate_vector_of_rust_string_to_CPP ( ) {
56
+ fn translate_vector_of_rust_string_to_cpp ( ) {
55
57
let vec: Vec < String > = vec ! [
56
58
"/tmp/example.c" . to_owned( ) ,
57
59
"/tmp/example2.c" . to_owned( ) ] ;
@@ -77,6 +79,11 @@ mod tests {
77
79
// Invoke load_model_from_files and see if the model
78
80
// has been loaded.
79
81
client. load_model_from_files ( vect) ;
82
+ // Validate integrity of passed goto-model.
83
+ client. validate_goto_model ( ) ;
84
+
85
+ let msgs = ffi:: get_messages ( ) ;
86
+ print_response ( msgs) ;
80
87
}
81
88
82
89
#[ test]
@@ -89,9 +96,34 @@ mod tests {
89
96
let vect = ffi:: translate_vector_of_string ( vec) ;
90
97
client. load_model_from_files ( vect) ;
91
98
99
+ // Validate integrity of goto-model
100
+ client. validate_goto_model ( ) ;
101
+
92
102
client. verify_model ( ) ;
93
103
94
104
let msgs = ffi:: get_messages ( ) ;
95
105
print_response ( msgs) ;
96
106
}
107
+
108
+ #[ test]
109
+ fn it_can_drop_unused_functions_from_model ( ) {
110
+ let binding = ffi:: new_api_session ( ) ;
111
+ let client = match binding. as_ref ( ) {
112
+ Some ( api_ref) => api_ref,
113
+ None => panic ! ( "Failed to acquire API session handle" ) ,
114
+ } ;
115
+
116
+ let vec: Vec < String > = vec ! [
117
+ "/tmp/example.c" . to_owned( ) ] ;
118
+
119
+ let vect = ffi:: translate_vector_of_string ( vec) ;
120
+ assert_eq ! ( vect. len( ) , 1 ) ;
121
+
122
+ client. load_model_from_files ( vect) ;
123
+ // Perform a drop of any unused functions.
124
+ client. drop_unused_functions ( ) ;
125
+
126
+ let msgs = ffi:: get_messages ( ) ;
127
+ print_response ( msgs) ;
128
+ }
97
129
}
0 commit comments