Commits

Anonymous committed 2b03c09

Submit cf-0.1 release.

Comments (0)

Files changed (1)

 (*---------------------------------------------------------------------------*
   IMPLEMENTATION  t_cf.ml
 
-  Copyright (c) 2003, James H. Woodyatt
+  Copyright (c) 2003-2004, James H. Woodyatt
   All rights reserved.
 
   Redistribution and use in source and binary forms, with or without
         let i = (i :> ('a, int, float) rx) in
         let o = (o :> ('b, int, float) tx) in
         let rec loop () =
-            guard [
+            guard begin
                 i#get begin fun (`I n) ->
                     load >>= fun state ->
                     store (succ state) >>= fun () ->
                     o#put (`O oval) >>= fun () ->
                     loop ()
                 end
-            ]
+            end
         in
         loop ()
     
     let render osnk =
         let osnk = (osnk :> ('a, int, float) rx) in
         let rec loop () =
-            guard [
+            guard begin
                 osnk#get begin fun (`O n) ->
                     write n >>= loop
                 end
-            ]
+            end
         in
         loop ()
     
     open Cf_flow.Op
     
     let test () =
-        let n = 1000 in
+        let n = 100 in
         let i = Cf_seq.limit n (input ()) in
         let o = Cf_seq.limit n (output ()) in
         let divflow = eval (gadget 0) () in
 end
 
 module T11 = struct
+    let len = 100
+
     let test () =
         try
             let bind =
             let bind = listen#getsockname in
             let active = new Cf_tcp4_socket.initiator bind in
             active#connect;
-            let a =
-                new Cf_tcp4_socket.endpoint (let a, _ = listen#accept in a)
-            in
+            let a, _ = listen#accept in
+            let a = new Cf_tcp4_socket.endpoint a in
             let b = new Cf_tcp4_socket.endpoint (active#socket) in
+            let laddr = a#getpeername and raddr = b#getsockname in
+            let lhost, lport = laddr in
+            let rhost, rport = raddr in
+            if lhost <> rhost then
+                failwith "T11 error: host a#getpeername <> b#getsockname";
+            if lport <> rport then
+                failwith "T11 error: port a#getpeername <> b#getsockname";
+            let laddr = a#getsockname and raddr = b#getpeername in
+            let lhost, lport = laddr in
+            let rhost, rport = raddr in
+            if lhost <> rhost then
+                failwith "T11 error: host a#getsockname <> b#getpeername";
+            if lport <> rport then
+                failwith "T11 error: port a#getsockname <> b#getpeername";
+            let tx = String.make len 'x' and rx = String.create len in
+            let n = a#send tx 0 len in
+            if n <> len then failwith "T11 error: tx incomplete!";
+            let n = b#recv rx 0 len in
+            if n <> len then failwith "T11 error: rx incomplete!";
+            if tx <> rx then failwith "T11 error: tx <> rx!";
             a#close;
-            b#close
+            b#close;
+            listen#close
         with
         | Unix.Unix_error (e, fn, _) ->
             failwith (Printf.sprintf "T11 error: %s in %s.\n"
 end
 
 module T12 = struct
+    let len = 100
+
     let test () =
         try
             let bind =
             let bind = listen#getsockname in
             let active = new Cf_tcp6_socket.initiator bind in
             active#connect;
-            let a =
-                new Cf_tcp6_socket.endpoint (let a, _ = listen#accept in a)
-            in
+            let a, _ = listen#accept in
+            let a = new Cf_tcp6_socket.endpoint a in
             let b = new Cf_tcp6_socket.endpoint (active#socket) in
+            a#setsockopt Cf_ip_common.tcp_nodelay true;
+            b#setsockopt Cf_ip_common.tcp_nodelay true;
+            let laddr = a#getpeername and raddr = b#getsockname in
+            let lhost, lport = laddr in
+            let rhost, rport = raddr in
+            if lhost <> rhost then
+                failwith "T12 error: host a#getpeername <> b#getsockname";
+            if lport <> rport then
+                failwith "T12 error: port a#getpeername <> b#getsockname";
+            let laddr = a#getsockname and raddr = b#getpeername in
+            let lhost, lport = laddr in
+            let rhost, rport = raddr in
+            if lhost <> rhost then
+                failwith "T12 error: host a#getsockname <> b#getpeername";
+            if lport <> rport then
+                failwith "T12 error: port a#getsockname <> b#getpeername";
+            let tx = String.make len 'x' and rx = String.create len in
+            let n = a#send tx 0 len in
+            if n <> len then failwith "T12 error: tx incomplete!";
+            let n = b#recv rx 0 len in
+            if n <> len then failwith "T12 error: rx incomplete!";
+            if tx <> rx then failwith "T12 error: tx <> rx!";
             a#close;
-            b#close
+            b#close;
+            listen#close
         with
         | Unix.Unix_error (e, fn, _) ->
-            failwith (Printf.sprintf "T11 error: %s in %s.\n"
+            failwith (Printf.sprintf "T12 error: %s in %s.\n"
                 (Unix.error_message e) fn)
 end
 
     let test i f =
         begin
             try
+                (* let tms0 = Unix.times () in *)
                 f ();
+                (*
+                let tms1 = Unix.times () in
+                let ut = tms1.Unix.tms_utime -. tms0.Unix.tms_utime in
+                let st = tms1.Unix.tms_stime -. tms0.Unix.tms_stime in
+                Printf.printf "ok %d (ut=%f st=%f)\n" i ut st
+                *)
                 Printf.printf "ok %d\n" i
             with
             | Failure(s) ->
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.