Unverified Commit fd91fb5c by Melvin Klimke Committed by GitHub

Extended cconv tests (#69)

parent 111ab158
......@@ -79,7 +79,9 @@ let get_register_list (project : Project.t) (context : string) : string list =
let arch = match bap_arch with
| "i386" | "i686" -> "x86"
| "powerpc" -> "ppc"
| _ -> bap_arch in
| "powerpc64" -> "ppc64"
| "powerpc64le" -> "ppc64le"
| _ -> bap_arch in
match Stdlib.List.mem arch (get_supported_architectures ()) with
| true -> begin
let json_bin = Json_utils.get_bin_format_from_json (get_json ()) (extract_bin_format project) in
......
......@@ -2,7 +2,13 @@ all:
bapbundle remove unit_tests_cwe_checker.plugin
bapbuild -r -Is analysis,checkers,utils unit_tests_cwe_checker.plugin -pkgs alcotest,yojson,unix,ppx_jane,cwe_checker_core
bapbundle install unit_tests_cwe_checker.plugin
bap tmp/arrays_gcc.out --pass=unit-tests-cwe-checker --unit-tests-cwe-checker-tests=MemRegion,Cconv,TypeInference,CWE476
bap tmp/arrays_x86_64-w64-mingw32_gcc.out --pass=unit-tests-cwe-checker --unit-tests-cwe-checker-tests=Cconv
bap tmp/arrays_i686-w64-mingw32_gcc.out --pass=unit-tests-cwe-checker --unit-tests-cwe-checker-tests=Cconv
bap tmp/arrays_x86_clang.out --pass=unit-tests-cwe-checker --unit-tests-cwe-checker-tests=Cconv
bap tmp/arrays_arm_gcc.out --pass=unit-tests-cwe-checker --unit-tests-cwe-checker-tests=Cconv
bap tmp/arrays_mips64_gcc.out --pass=unit-tests-cwe-checker --unit-tests-cwe-checker-tests=Cconv
bap tmp/arrays_powerpc_gcc.out --pass=unit-tests-cwe-checker --unit-tests-cwe-checker-tests=Cconv
bap tmp/arrays_gcc.out --pass=unit-tests-cwe-checker --unit-tests-cwe-checker-tests=MemRegion,TypeInference,CWE476
bap tmp/c_constructs_gcc.out --pass=unit-tests-cwe-checker --unit-tests-cwe-checker-tests=CWE560,AddrTrans
bapbundle remove unit_tests_cwe_checker.plugin
......
......@@ -37,11 +37,32 @@ let unit_test_list = [
]
let check_for_cconv (project : Project.t) (arch : string) =
match arch with
| "i386" | "i686" -> Cconv_test.example_cconv := Project.get project Bap_abi.name
| _ -> ()
let get_test_bin_format (project : Project.t) =
let filename = match (Project.get project filename) with
| Some(f) -> f
| _ -> failwith "Test file has no file name" in
match String.is_substring filename ~substring:"mingw32" with
| true -> "pe"
| false -> "elf"
let set_example_project (project : Project.t) (tests : string list) =
let arch = Arch.to_string (Project.arch project) in
List.iter tests ~f:(fun test ->
match test with
| "TypeInference" -> Type_inference_test.example_project := Some(project)
| "Cconv" -> Cconv_test.example_project := Some(project)
| "Cconv" -> begin
Cconv_test.example_project := Some(project);
Cconv_test.example_arch := Some(arch);
check_for_cconv project arch;
Cconv_test.example_bin_format := Some(get_test_bin_format project)
end
| "CWE476" -> Cwe_476_test.example_project := Some(project)
| _ -> ()
)
......
......@@ -4,4 +4,10 @@ open Core_kernel
val example_project: Project.t option ref
val example_cconv: string option ref
val example_arch: string option ref
val example_bin_format: string option ref
val tests: unit Alcotest.test_case list
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment