summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Allsopp <david.allsopp@metastack.com>2017-05-20 09:44:16 +0100
committerDavid Allsopp <david.allsopp@metastack.com>2017-05-21 12:09:31 +0100
commit3659ed2dedefe9bd0aaa8f234aa9ca1122d44a80 (patch)
tree43116b89948223fb28eba3acf3f467c57549fdd2
parent2529a2dc861786c596b505693ca1e30e53a975cf (diff)
downloadocaml-3659ed2dedefe9bd0aaa8f234aa9ca1122d44a80.tar.gz
Fix cloexec test on 64-bit Windows
This test was passing because handles on 64-bit Windows tend to use the low 32-bits only... but there's no guarantee!
-rw-r--r--testsuite/tests/lib-unix/cloexec.ml9
-rw-r--r--testsuite/tests/lib-unix/fdstatus.c4
2 files changed, 10 insertions, 3 deletions
diff --git a/testsuite/tests/lib-unix/cloexec.ml b/testsuite/tests/lib-unix/cloexec.ml
index 462882b1be..d7e1e29245 100644
--- a/testsuite/tests/lib-unix/cloexec.ml
+++ b/testsuite/tests/lib-unix/cloexec.ml
@@ -6,7 +6,11 @@
let string_of_fd (fd: Unix.file_descr) : string =
match Sys.os_type with
| "Unix" | "Cygwin" -> string_of_int (Obj.magic fd : int)
- | "Win32" -> Int32.to_string (Obj.magic fd : int32)
+ | "Win32" ->
+ if Sys.word_size = 32 then
+ Int32.to_string (Obj.magic fd : int32)
+ else
+ Int64.to_string (Obj.magic fd : int64)
| _ -> assert false
let _ =
@@ -33,7 +37,7 @@ let _ =
try Unix.(socketpair ~cloexec:true PF_UNIX SOCK_STREAM 0)
with Invalid_argument _ -> (p2, p2') in
- let fds = [| f0;f1;f2; d0;d1;d2;
+ let fds = [| f0;f1;f2; d0;d1;d2;
p0;p0';p1;p1';p2;p2';
s0;s1;s2;
x0;x0';x1;x1';x2;x2' |] in
@@ -45,4 +49,3 @@ let _ =
ignore (Unix.waitpid [] pid);
Array.iter (fun fd -> try Unix.close fd with Unix.Unix_error _ -> ()) fds;
Sys.remove "tmp.txt"
-
diff --git a/testsuite/tests/lib-unix/fdstatus.c b/testsuite/tests/lib-unix/fdstatus.c
index 6a052d6e6c..be8c6e5ca7 100644
--- a/testsuite/tests/lib-unix/fdstatus.c
+++ b/testsuite/tests/lib-unix/fdstatus.c
@@ -16,7 +16,11 @@ void process_fd(char * s)
HANDLE h;
DWORD flags;
+#ifdef _WIN64
+ h = (HANDLE) _atoi64(s);
+#else
h = (HANDLE) atoi(s);
+#endif
if (GetHandleInformation(h, &flags)) {
printf("open\n");
} else if (GetLastError() == ERROR_INVALID_HANDLE) {