diff options
author | Xavier Clerc <xavier.clerc@inria.fr> | 2010-04-08 12:46:15 +0000 |
---|---|---|
committer | Xavier Clerc <xavier.clerc@inria.fr> | 2010-04-08 12:46:15 +0000 |
commit | 1f0b25c1d3762182f2a9d7cc9377c31c35dc7508 (patch) | |
tree | d76e5a9bfaaed3d5866a30f8c5548a452472a995 /test | |
parent | 7c905c2292a21a072ea43e14862a87af7607e08e (diff) | |
download | ocaml-1f0b25c1d3762182f2a9d7cc9377c31c35dc7508.tar.gz |
Tests moved to 'gc-roots'
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@10254 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'test')
-rw-r--r-- | test/Moretest/globroots.ml | 80 | ||||
-rw-r--r-- | test/Moretest/globrootsprim.c | 56 |
2 files changed, 0 insertions, 136 deletions
diff --git a/test/Moretest/globroots.ml b/test/Moretest/globroots.ml deleted file mode 100644 index 6d1948d7eb..0000000000 --- a/test/Moretest/globroots.ml +++ /dev/null @@ -1,80 +0,0 @@ -module type GLOBREF = sig - type t - val register: string -> t - val get: t -> string - val set: t -> string -> unit - val remove: t -> unit -end - -module Classic : GLOBREF = struct - type t - external register: string -> t = "gb_classic_register" - external get: t -> string = "gb_get" - external set: t -> string -> unit = "gb_classic_set" - external remove: t -> unit = "gb_classic_remove" -end - -module Generational : GLOBREF = struct - type t - external register: string -> t = "gb_generational_register" - external get: t -> string = "gb_get" - external set: t -> string -> unit = "gb_generational_set" - external remove: t -> unit = "gb_generational_remove" -end - -module Test(G: GLOBREF) = struct - - let size = 1024 - - let vals = Array.init size string_of_int - - let a = Array.init size (fun i -> G.register (string_of_int i)) - - let check () = - for i = 0 to size - 1 do - if G.get a.(i) <> vals.(i) then begin - print_string "Error on "; print_int i; print_string ": "; - print_string (String.escaped (G.get a.(i))); print_newline() - end - done - - let change () = - match Random.int 37 with - | 0 -> - Gc.full_major() - | 1|2|3|4 -> - Gc.minor() - | 5|6|7|8|9|10|11|12 -> (* update with young value *) - let i = Random.int size in - G.set a.(i) (string_of_int i) - | 13|14|15|16|17|18|19|20 -> (* update with old value *) - let i = Random.int size in - G.set a.(i) vals.(i) - | 21|22|23|24|25|26|27|28 -> (* re-register young value *) - let i = Random.int size in - G.remove a.(i); - a.(i) <- G.register (string_of_int i) - | (*29|30|31|32|33|34|35|36*) _ -> (* re-register old value *) - let i = Random.int size in - G.remove a.(i); - a.(i) <- G.register vals.(i) - - let test n = - for i = 1 to n do - change(); - print_string "."; flush stdout - done -end - -module TestClassic = Test(Classic) -module TestGenerational = Test(Generational) - -let _ = - let n = - if Array.length Sys.argv < 2 then 10000 else int_of_string Sys.argv.(1) in - print_string "Non-generational API\n"; - TestClassic.test n; - print_newline(); - print_string "Generational API\n"; - TestGenerational.test n; - print_newline() diff --git a/test/Moretest/globrootsprim.c b/test/Moretest/globrootsprim.c deleted file mode 100644 index f58fff1cc3..0000000000 --- a/test/Moretest/globrootsprim.c +++ /dev/null @@ -1,56 +0,0 @@ -/* For testing global root registration */ - -#include "mlvalues.h" -#include "memory.h" -#include "alloc.h" - -struct block { value v; }; - -#define Block_val(v) ((struct block *) (v)) - -value gb_get(value vblock) -{ - return Block_val(vblock)->v; -} - -value gb_classic_register(value v) -{ - struct block * b = stat_alloc(sizeof(struct block)); - b->v = v; - caml_register_global_root(&(b->v)); - return (value) b; -} - -value gb_classic_set(value vblock, value newval) -{ - Block_val(vblock)->v = newval; - return Val_unit; -} - -value gb_classic_remove(value vblock) -{ - caml_remove_global_root(&(Block_val(vblock)->v)); - return Val_unit; -} - -value gb_generational_register(value v) -{ - struct block * b = stat_alloc(sizeof(struct block)); - b->v = v; - caml_register_generational_global_root(&(b->v)); - return (value) b; -} - -value gb_generational_set(value vblock, value newval) -{ - caml_modify_generational_global_root(&(Block_val(vblock)->v), newval); - return Val_unit; -} - -value gb_generational_remove(value vblock) -{ - caml_remove_generational_global_root(&(Block_val(vblock)->v)); - return Val_unit; -} - - |