@@ -11,10 +11,10 @@ pub mod ffi {
11
11
// API Functions
12
12
fn new_api_session ( ) -> UniquePtr < api_sessiont > ;
13
13
fn get_api_version ( & self ) -> UniquePtr < CxxString > ;
14
- fn load_model_from_files ( & self , files : & CxxVector < CxxString > ) ;
15
- fn verify_model ( & self ) ;
16
- fn validate_goto_model ( & self ) ;
17
- fn drop_unused_functions ( & self ) ;
14
+ fn load_model_from_files ( & self , files : & CxxVector < CxxString > ) -> Result < ( ) > ;
15
+ fn verify_model ( & self ) -> Result < ( ) > ;
16
+ fn validate_goto_model ( & self ) -> Result < ( ) > ;
17
+ fn drop_unused_functions ( & self ) -> Result < ( ) > ;
18
18
19
19
// Helper/Utility functions
20
20
fn translate_vector_of_string ( elements : Vec < String > ) -> & ' static CxxVector < CxxString > ;
@@ -37,11 +37,12 @@ fn print_response(vec: &CxxVector<CxxString>) {
37
37
}
38
38
}
39
39
40
- // To test run "CBMC_LIB_DIR=<path_to_build/libs> cargo test -- --test-threads=1 --nocapture"
40
+ // To test run "CBMC_LIB_DIR=<path_to_build/libs> SAT_IMPL=minisat2 cargo test -- --test-threads=1 --nocapture"
41
41
#[ cfg( test) ]
42
42
mod tests {
43
43
use super :: * ;
44
44
use cxx:: let_cxx_string;
45
+ use std:: process;
45
46
46
47
#[ test]
47
48
fn it_works ( ) {
@@ -75,7 +76,11 @@ mod tests {
75
76
76
77
// Invoke load_model_from_files and see if the model
77
78
// has been loaded.
78
- client. load_model_from_files ( vect) ;
79
+ if let Err ( _) = client. load_model_from_files ( vect) {
80
+ eprintln ! ( "Failed to load model from files: {:?}" , vect) ;
81
+ process:: exit ( 1 ) ;
82
+ }
83
+
79
84
// Validate integrity of passed goto-model.
80
85
client. validate_goto_model ( ) ;
81
86
@@ -90,12 +95,19 @@ mod tests {
90
95
let vec: Vec < String > = vec ! [ "other/example.c" . to_owned( ) ] ;
91
96
92
97
let vect = ffi:: translate_vector_of_string ( vec) ;
93
- client. load_model_from_files ( vect) ;
98
+
99
+ if let Err ( _) = client. load_model_from_files ( vect) {
100
+ eprintln ! ( "Failed to load model from files: {:?}" , vect) ;
101
+ process:: exit ( 1 ) ;
102
+ }
94
103
95
104
// Validate integrity of goto-model
96
105
client. validate_goto_model ( ) ;
97
106
98
- client. verify_model ( ) ;
107
+ if let Err ( _) = client. verify_model ( ) {
108
+ eprintln ! ( "Failed to verify model from files: {:?}" , vect) ;
109
+ process:: exit ( 1 ) ;
110
+ }
99
111
100
112
let msgs = ffi:: get_messages ( ) ;
101
113
print_response ( msgs) ;
@@ -114,10 +126,17 @@ mod tests {
114
126
let vect = ffi:: translate_vector_of_string ( vec) ;
115
127
assert_eq ! ( vect. len( ) , 1 ) ;
116
128
117
- client. load_model_from_files ( vect) ;
129
+ if let Err ( _) = client. load_model_from_files ( vect) {
130
+ eprintln ! ( "Failed to load model from files: {:?}" , vect) ;
131
+ process:: exit ( 1 ) ;
132
+ }
118
133
// Perform a drop of any unused functions.
119
- client. drop_unused_functions ( ) ;
134
+ if let Err ( err) = client. drop_unused_functions ( ) {
135
+ eprintln ! ( "Error during client call: {:?}" , err) ;
136
+ process:: exit ( 1 ) ;
137
+ }
120
138
139
+ println ! ( "Just before we print the messages" ) ;
121
140
let msgs = ffi:: get_messages ( ) ;
122
141
print_response ( msgs) ;
123
142
}
0 commit comments