@@ -754,15 +754,21 @@ mod tests {
754754 }
755755 }
756756
757- fn run_esbmc_gbf ( input_gbf : & str , args : & [ & str ] , status : i32 , library_gbf : & str ) {
757+ fn run_esbmc_gbf (
758+ input_gbf : & str ,
759+ args : & [ & str ] ,
760+ status : i32 ,
761+ library_gbf : & str ,
762+ entrypoint : & str ,
763+ ) {
758764 let esbmc = match std:: env:: var ( "ESBMC" ) {
759765 Ok ( v) => v,
760766 Err ( err) => panic ! ( "Could not get ESBMC bin. {}" , err) ,
761767 } ;
762768 let output = Command :: new ( esbmc)
763769 . arg ( "--cprover" )
764770 . arg ( "--function" )
765- . arg ( "main" )
771+ . arg ( entrypoint )
766772 . arg ( "--binary" )
767773 . arg ( "/home/rafaelsa/repos/goto-transcoder/resources/library.goto" )
768774 . arg ( input_gbf)
@@ -803,7 +809,13 @@ mod tests {
803809 generate_cbmc_gbf ( test_path. to_str ( ) . unwrap ( ) , cbmc_gbf. as_str ( ) ) ;
804810 cbmc2esbmc ( cbmc_gbf. as_str ( ) , esbmc_gbf. as_str ( ) ) ;
805811 let library_path = std:: path:: Path :: new ( & cargo_dir) . join ( "resources/library.goto" ) ;
806- run_esbmc_gbf ( & esbmc_gbf, args, expected, library_path. to_str ( ) . unwrap ( ) ) ;
812+ run_esbmc_gbf (
813+ & esbmc_gbf,
814+ args,
815+ expected,
816+ library_path. to_str ( ) . unwrap ( ) ,
817+ "main" ,
818+ ) ;
807819 std:: fs:: remove_file ( & cbmc_gbf) . ok ( ) ;
808820 std:: fs:: remove_file ( & esbmc_gbf) . ok ( ) ;
809821 }
@@ -819,7 +831,35 @@ mod tests {
819831 let esbmc_gbf = format ! ( "{}.goto" , input_goto) ; // TODO: generate UUID!
820832 cbmc2esbmc ( test_path. to_str ( ) . unwrap ( ) , esbmc_gbf. as_str ( ) ) ;
821833 let library_path = std:: path:: Path :: new ( & cargo_dir) . join ( "resources/library.goto" ) ;
822- run_esbmc_gbf ( & esbmc_gbf, args, expected, library_path. to_str ( ) . unwrap ( ) ) ;
834+ run_esbmc_gbf (
835+ & esbmc_gbf,
836+ args,
837+ expected,
838+ library_path. to_str ( ) . unwrap ( ) ,
839+ "__CPROVER__start" ,
840+ ) ;
841+
842+ std:: fs:: remove_file ( & esbmc_gbf) . ok ( ) ;
843+ }
844+
845+ fn run_goto_test_2 ( input_goto : & str , args : & [ & str ] , expected : i32 , entrypoint : & str ) {
846+ let cargo_dir = match std:: env:: var ( "CARGO_MANIFEST_DIR" ) {
847+ Ok ( v) => v,
848+ Err ( err) => panic ! ( "Could not open cargo folder. {}" , err) ,
849+ } ;
850+ let test_path =
851+ std:: path:: Path :: new ( & cargo_dir) . join ( format ! ( "resources/test/{}" , input_goto) ) ;
852+
853+ let esbmc_gbf = format ! ( "{}.goto" , input_goto) ; // TODO: generate UUID!
854+ cbmc2esbmc ( test_path. to_str ( ) . unwrap ( ) , esbmc_gbf. as_str ( ) ) ;
855+ let library_path = std:: path:: Path :: new ( & cargo_dir) . join ( "resources/library.goto" ) ;
856+ run_esbmc_gbf (
857+ & esbmc_gbf,
858+ args,
859+ expected,
860+ library_path. to_str ( ) . unwrap ( ) ,
861+ entrypoint,
862+ ) ;
823863
824864 std:: fs:: remove_file ( & esbmc_gbf) . ok ( ) ;
825865 }
@@ -948,40 +988,41 @@ mod tests {
948988 run_test ( "struct_array_fail.c" , & [ "--incremental-bmc" ] , 1 ) ;
949989 }
950990
951- // #[test]
952- // #[ignore]
953- // fn goto_test() {
954- // run_goto_test("mul.goto", &["--goto-functions-only"], 0);
955- // }
991+ #[ test]
992+ #[ ignore]
993+ fn goto_test ( ) {
994+ run_goto_test ( "mul.goto" , & [ "--goto-functions-only" ] , 0 ) ;
995+ }
956996
957997 // ////////////////
958998 // // KANI TESTS //
959999 // ////////////////
9601000 // // TODO: Integrate Kani into the test framework
9611001
962- // #[test]
963- // #[ignore]
964- // fn hello_rust_book() {
965- // run_goto_test("hello_world.rs.goto", &["--goto-functions-only"], 0);
966- // run_goto_test("hello_world.rs.goto", &["--incremental-bmc"], 1);
967- // }
968-
969- // #[test]
970- // #[ignore]
971- // fn first_steps_book() {
972- // run_goto_test("first_steps.rs.goto", &["--goto-functions-only"], 0);
973- // run_goto_test("first_steps.rs.goto", &["--incremental-bmc"], 1);
974- // run_goto_test("first-steps-pass.goto", &["--incremental-bmc"], 0);
975- // }
976-
977- // #[test]
978- // #[ignore]
979- // fn unchecked_add_contract() {
980- // // Disabled because ESBMC does not support: object_size, overflow_result-+
981- // run_goto_test(
982- // "checked_unchecked_add_i8.goto",
983- // &["--goto-functions-only"],
984- // 0,
985- // );
986- // }
1002+ #[ test]
1003+ #[ ignore]
1004+ fn hello_rust_book ( ) {
1005+ run_goto_test ( "hello_world.rs.goto" , & [ "--goto-functions-only" ] , 0 ) ;
1006+ run_goto_test ( "hello_world.rs.goto" , & [ "--incremental-bmc" ] , 1 ) ;
1007+ }
1008+
1009+ #[ test]
1010+ #[ ignore]
1011+ fn first_steps_book ( ) {
1012+ run_goto_test ( "first_steps.rs.goto" , & [ "--goto-functions-only" ] , 0 ) ;
1013+ run_goto_test ( "first_steps.rs.goto" , & [ "--incremental-bmc" ] , 1 ) ;
1014+ run_goto_test ( "first-steps-pass.goto" , & [ "--incremental-bmc" ] , 0 ) ;
1015+ }
1016+
1017+ #[ test]
1018+ #[ ignore]
1019+ fn unchecked_add_contract ( ) {
1020+ // Disabled because ESBMC does not support: object_size, overflow_result-+
1021+ run_goto_test_2 (
1022+ "checked_unchecked_add_i8.goto" ,
1023+ & [ "--goto-functions-only" ] ,
1024+ 0 ,
1025+ "_RNvNtNtCsesPP5EAma4_4core3num6verify24checked_unchecked_add_i8" ,
1026+ ) ;
1027+ }
9871028}
0 commit comments