Remove weblogs tests.
[ocaml-ancient.git] / test_ancient_shared.ml
index 7be9712..04b3f1b 100644 (file)
@@ -1,5 +1,5 @@
 (* Very basic tests of Ancient module shared functionality.
- * $Id: test_ancient_shared.ml,v 1.1 2006-09-27 16:01:47 rich Exp $
+ * $Id: test_ancient_shared.ml,v 1.3 2006-09-28 12:40:07 rich Exp $
  *)
 
 open Printf
@@ -65,21 +65,28 @@ and string_of_marital_status status =
   | Married -> "Married"
   | Divorced -> "Divorced"
 
+(* XXX Linux/AMD64-specific hack to avoid bad mmap(2) allocation. *)
+let baseaddr = Nativeint.of_string "0x440000000000"
+
 let () =
   match List.tl (Array.to_list Sys.argv) with
   | ["read"; share_filename; print_filename] ->
       (* Read data in filename and print. *)
       let fd = Unix.openfile share_filename [Unix.O_RDWR] 0 in
-      let data : item array Ancient.ancient = Ancient.attach fd in
+      let md = Ancient.attach fd 0n in
 
       eprintf "After attaching %s ...\n" share_filename;
       gc_compact ();
 
+      let data : item array Ancient.ancient = Ancient.get md 0 in
+      eprintf "After getting ...\n";
+      gc_compact ();
+
       let chan = open_out print_filename in
       output_data chan (Ancient.follow data);
       close_out chan;
 
-      Ancient.detach data;
+      Ancient.detach md;
       eprintf "After detaching ...\n";
       gc_compact ()
 
@@ -107,12 +114,13 @@ let () =
       let fd =
        Unix.openfile share_filename
          [Unix.O_CREAT;Unix.O_TRUNC;Unix.O_RDWR] 0o644 in
+      let md = Ancient.attach fd baseaddr in
 
-      let data = Ancient.share fd data in
+      ignore (Ancient.share md 0 data);
       eprintf "After sharing data to %s ...\n" share_filename;
       gc_compact ();
 
-      Ancient.detach data;
+      Ancient.detach md;
       eprintf "After detaching ...\n";
       gc_compact ()