Created
November 25, 2014 15:46
-
-
Save rvantonder/dbb09992b296e5a3539e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/.gitignore b/.gitignore | |
index 0d50f56..f8f1975 100644 | |
--- a/.gitignore | |
+++ b/.gitignore | |
@@ -14,3 +14,5 @@ | |
/setup.log | |
/setup.ml | |
META | |
+*.swp | |
+*.merlin | |
diff --git a/.merlin b/.merlin | |
index 14b9427..498559b 100644 | |
--- a/.merlin | |
+++ b/.merlin | |
@@ -14,3 +14,9 @@ S lib/bap_dwarf | |
S lib/bap_elf | |
S lib/bap_image | |
S lib/bap_types | |
+B /home/rvt/ounit-2.0.0/_build/src | |
+S /home/rvt/ounit-2.0.0/src | |
+B /home/rvt/janestreet-core/core/_build/lib | |
+S /home/rvt/janestreet-core/core/lib | |
+S /home/rvt/.opam/system/build/core_kernel.111.28.00/_build/lib/ | |
+B /home/rvt/.opam/system/build/core_kernel.111.28.00/_build/lib/ | |
diff --git a/_tags.in b/_tags.in | |
index 1dedc5c..b414d60 100644 | |
--- a/_tags.in | |
+++ b/_tags.in | |
@@ -1 +1,2 @@ | |
true: short_paths | |
+true: annot, bin_annot | |
diff --git a/lib_test/bap_image/test_image.ml b/lib_test/bap_image/test_image.ml | |
index 665b48c..f69914b 100644 | |
--- a/lib_test/bap_image/test_image.ml | |
+++ b/lib_test/bap_image/test_image.ml | |
@@ -136,6 +136,29 @@ let assert_cont ~word_size img = | |
(a1 <> a2 ==> Addr.is_zero diff) in | |
a2) |> return | |
+let empty_table = Bap_table.empty | |
+ | |
+let create_mem ?(addr_size=W32) ?(start_addr=0x00) ?(size=0x08) () = | |
+ let addr = create_addr W32 start_addr in | |
+ let contents = Bigstring.init size ~f:(fun i -> char_of_int (i+0x61)) in | |
+ ok_exn (Bap_memory.create LittleEndian addr contents) | |
+ | |
+let table = | |
+ let mem = create_mem () in | |
+ ok_exn (Bap_table.add empty_table mem "Memory Tag") | |
+ | |
+let test_table_len ctxt = | |
+ assert_equal 0 (Bap_table.length empty_table) | |
+ | |
+let test_table_len2 ctxt = | |
+ assert_equal 1 (Bap_table.length table) | |
+ | |
+let test_find ctxt = | |
+ let mem_to_find = create_mem () in | |
+ Bap_table.find table mem_to_find |> function | |
+ | Some x -> assert_equal "Memory Tag" x | |
+ | _ -> assert_failure "Wrong" | |
+ | |
let suite = "Image" >::: [ | |
"to_list:0-15/bytes_32LE" >:: to_list ~word_size:`r8 "0-15_32LE" | |
~expect:(List.init 16 ~f:ident); | |
@@ -266,4 +289,8 @@ let suite = "Image" >::: [ | |
let printer = Addr.to_string in | |
assert_equal ~printer Addr.(mn ++ 0x336) mx; | |
return ()); | |
+ | |
+ "table_length" >:: test_table_len; | |
+ "table_length2" >:: test_table_len2; | |
+ "test_find" >:: test_find; | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment