From d2ce83ccb1106cbb98820a54fbab333b0ed65e98 Mon Sep 17 00:00:00 2001 From: klutzy Date: Sun, 15 Sep 2013 23:10:56 +0900 Subject: [PATCH 1/8] std::rt::io::file: Enable I/O tests on Win32 Enable blocked tests which are now fixed by #9165. Closes #8810. --- src/libstd/rt/io/file.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/libstd/rt/io/file.rs b/src/libstd/rt/io/file.rs index 3bc0e74c782..c24f4eb257e 100644 --- a/src/libstd/rt/io/file.rs +++ b/src/libstd/rt/io/file.rs @@ -168,7 +168,6 @@ fn file_test_smoke_test_impl() { } #[test] -#[ignore(cfg(windows))] // FIXME #8810 fn file_test_io_smoke_test() { file_test_smoke_test_impl(); } @@ -236,7 +235,6 @@ fn file_test_io_non_positional_read_impl() { } #[test] -#[ignore(cfg(windows))] // FIXME #8810 fn file_test_io_non_positional_read() { file_test_io_non_positional_read_impl(); } @@ -268,8 +266,8 @@ fn file_test_io_seeking_impl() { assert!(tell_pos_post_read == message.len() as u64); } } + #[test] -#[ignore(cfg(windows))] // FIXME #8810 fn file_test_io_seek_and_tell_smoke_test() { file_test_io_seeking_impl(); } @@ -300,8 +298,8 @@ fn file_test_io_seek_and_write_impl() { assert!(read_str == final_msg.to_owned()); } } + #[test] -#[ignore(cfg(windows))] // FIXME #8810 fn file_test_io_seek_and_write() { file_test_io_seek_and_write_impl(); } @@ -340,8 +338,8 @@ fn file_test_io_seek_shakedown_impl() { unlink(filename); } } + #[test] -#[ignore(cfg(windows))] // FIXME #8810 fn file_test_io_seek_shakedown() { file_test_io_seek_shakedown_impl(); } From 1e745f16790f22fc10652a6ffae36bf5572255bb Mon Sep 17 00:00:00 2001 From: klutzy Date: Sun, 15 Sep 2013 23:18:47 +0900 Subject: [PATCH 2/8] std::rt::io::support: Fix ignored test on Win32 Assumes drive C: exists. Closes #8812. --- src/libstd/rt/io/support.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libstd/rt/io/support.rs b/src/libstd/rt/io/support.rs index afbff77f988..59db8194963 100644 --- a/src/libstd/rt/io/support.rs +++ b/src/libstd/rt/io/support.rs @@ -33,9 +33,8 @@ mod test { use super::PathLike; #[test] - #[ignore(cfg(windows))] // FIXME #8812 fn path_like_smoke_test() { - let expected = "/home"; + let expected = if cfg!(unix) { "/home" } else { "C:\\" }; let path = Path(expected); path.path_as_str(|p| assert!(p == expected)); path.path_as_str(|p| assert!(p == expected)); From f3c88825337c295850de546bd3d8745c8cad1224 Mon Sep 17 00:00:00 2001 From: klutzy Date: Mon, 16 Sep 2013 00:02:58 +0900 Subject: [PATCH 3/8] std::os: Use unicode for last_os_error() on Win32 FormatMessageA may return non-ascii message, which is encoded as system code page, not utf8. This may cause `assert!(is_utf8(v))` failure on some non-English machines. This patch replaces it with FormatMessageW, which returns utf-16 message. Fixes `make check-stage2-std` failure on my machine. :) --- src/libstd/os.rs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/libstd/os.rs b/src/libstd/os.rs index 5269eca888a..c45f2af8f7e 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -1135,18 +1135,19 @@ pub fn last_os_error() -> ~str { #[fixed_stack_segment]; #[inline(never)]; use libc::types::os::arch::extra::DWORD; - use libc::types::os::arch::extra::LPSTR; + use libc::types::os::arch::extra::LPWSTR; use libc::types::os::arch::extra::LPVOID; + use libc::types::os::arch::extra::WCHAR; #[cfg(target_arch = "x86")] #[link_name = "kernel32"] #[abi = "stdcall"] extern "stdcall" { - fn FormatMessageA(flags: DWORD, + fn FormatMessageW(flags: DWORD, lpSrc: LPVOID, msgId: DWORD, langId: DWORD, - buf: LPSTR, + buf: LPWSTR, nsize: DWORD, args: *c_void) -> DWORD; @@ -1155,11 +1156,11 @@ pub fn last_os_error() -> ~str { #[cfg(target_arch = "x86_64")] #[link_name = "kernel32"] extern { - fn FormatMessageA(flags: DWORD, + fn FormatMessageW(flags: DWORD, lpSrc: LPVOID, msgId: DWORD, langId: DWORD, - buf: LPSTR, + buf: LPWSTR, nsize: DWORD, args: *c_void) -> DWORD; @@ -1173,11 +1174,11 @@ pub fn last_os_error() -> ~str { let langId = 0x0800 as DWORD; let err = errno() as DWORD; - let mut buf = [0 as c_char, ..TMPBUF_SZ]; + let mut buf = [0 as WCHAR, ..TMPBUF_SZ]; unsafe { do buf.as_mut_buf |buf, len| { - let res = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | + let res = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, ptr::mut_null(), err, @@ -1190,9 +1191,7 @@ pub fn last_os_error() -> ~str { } } - do buf.as_imm_buf |buf, _len| { - str::raw::from_c_str(buf) - } + str::from_utf16(buf) } } From 879cfe6049647cf8ecf31682b26e28b905f7d27e Mon Sep 17 00:00:00 2001 From: klutzy Date: Mon, 16 Sep 2013 03:13:42 +0900 Subject: [PATCH 4/8] std::rt::uv::uvll: Fix uv_req_type on Win32 Also enables request_sanity_check() test. Closes #8817 --- src/libstd/rt/uv/uvll.rs | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/libstd/rt/uv/uvll.rs b/src/libstd/rt/uv/uvll.rs index 5bf04110abf..8f3cef4d238 100644 --- a/src/libstd/rt/uv/uvll.rs +++ b/src/libstd/rt/uv/uvll.rs @@ -237,6 +237,7 @@ pub enum uv_handle_type { UV_HANDLE_TYPE_MAX } +#[cfg(unix)] #[deriving(Eq)] pub enum uv_req_type { UV_UNKNOWN_REQ, @@ -251,6 +252,31 @@ pub enum uv_req_type { UV_REQ_TYPE_MAX } +// uv_req_type may have additional fields defined by UV_REQ_TYPE_PRIVATE. +// See UV_REQ_TYPE_PRIVATE at libuv/include/uv-win.h +#[cfg(windows)] +#[deriving(Eq)] +pub enum uv_req_type { + UV_UNKNOWN_REQ, + UV_REQ, + UV_CONNECT, + UV_WRITE, + UV_SHUTDOWN, + UV_UDP_SEND, + UV_FS, + UV_WORK, + UV_GETADDRINFO, + UV_ACCEPT, + UV_FS_EVENT_REQ, + UV_POLL_REQ, + UV_PROCESS_EXIT, + UV_READ, + UV_UDP_RECV, + UV_WAKEUP, + UV_SIGNAL_REQ, + UV_REQ_TYPE_MAX +} + #[deriving(Eq)] pub enum uv_membership { UV_LEAVE_GROUP, @@ -298,10 +324,8 @@ fn handle_sanity_check() { } #[test] -#[ignore(cfg(windows))] // FIXME #8817 -#[fixed_stack_segment] -#[inline(never)] fn request_sanity_check() { + #[fixed_stack_segment]; #[inline(never)]; unsafe { assert_eq!(UV_REQ_TYPE_MAX as uint, rust_uv_req_type_max()); } From 3686c6cbcf6fb5a7a07c852af632a590bc52d74b Mon Sep 17 00:00:00 2001 From: klutzy Date: Mon, 16 Sep 2013 03:45:20 +0900 Subject: [PATCH 5/8] std::rt::io::net::tcp: Fix one tcp test on Win32 Fixes `connect_error` part of #8811. --- src/libstd/rt/io/net/tcp.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/libstd/rt/io/net/tcp.rs b/src/libstd/rt/io/net/tcp.rs index be8a051a066..55abc4ab135 100644 --- a/src/libstd/rt/io/net/tcp.rs +++ b/src/libstd/rt/io/net/tcp.rs @@ -178,12 +178,17 @@ mod test { } #[test] - #[ignore(cfg(windows))] // FIXME #8811 fn connect_error() { do run_in_mt_newsched_task { let mut called = false; do io_error::cond.trap(|e| { - assert_eq!(e.kind, ConnectionRefused); + let expected_error = if cfg!(unix) { + ConnectionRefused + } else { + // On Win32, opening port 1 gives WSAEADDRNOTAVAIL error. + OtherIoError + }; + assert_eq!(e.kind, expected_error); called = true; }).inside { let addr = SocketAddr { ip: Ipv4Addr(0, 0, 0, 0), port: 1 }; From 20e84709535844e3568f756b0fabda90b6160776 Mon Sep 17 00:00:00 2001 From: klutzy Date: Mon, 16 Sep 2013 10:30:00 +0900 Subject: [PATCH 6/8] std::rt::uv::uvio: Enable tests on Win32 Closes #8816. --- src/libstd/rt/uv/uvio.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/libstd/rt/uv/uvio.rs b/src/libstd/rt/uv/uvio.rs index e8af0c749a0..b930ea2437e 100644 --- a/src/libstd/rt/uv/uvio.rs +++ b/src/libstd/rt/uv/uvio.rs @@ -1740,7 +1740,6 @@ fn test_read_read_read() { } #[test] -#[ignore(cfg(windows))] // FIXME #8816 fn test_udp_twice() { do run_in_mt_newsched_task { let server_addr = next_test_ip4(); @@ -1892,7 +1891,6 @@ fn file_test_uvio_full_simple_impl() { } #[test] -#[ignore(cfg(windows))] // FIXME #8816 fn file_test_uvio_full_simple() { do run_in_mt_newsched_task { file_test_uvio_full_simple_impl(); From 6aebf3cc16aa0730b4e636c638c39ad1607b8f39 Mon Sep 17 00:00:00 2001 From: klutzy Date: Mon, 16 Sep 2013 10:55:11 +0900 Subject: [PATCH 7/8] extra::fileinput: Enable tests on Win32 They were blocked by #8810, but it works now. --- src/libextra/fileinput.rs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/libextra/fileinput.rs b/src/libextra/fileinput.rs index edf130fd6c6..23d80362e3c 100644 --- a/src/libextra/fileinput.rs +++ b/src/libextra/fileinput.rs @@ -433,7 +433,6 @@ mod test { } #[test] - #[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree fn test_make_path_option_vec() { let strs = [~"some/path", ~"some/other/path"]; @@ -448,7 +447,6 @@ mod test { } #[test] - #[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree fn test_fileinput_read_byte() { let filenames = make_path_option_vec(vec::from_fn( 3, @@ -479,7 +477,6 @@ mod test { } #[test] - #[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree fn test_fileinput_read() { let filenames = make_path_option_vec(vec::from_fn( 3, @@ -500,7 +497,6 @@ mod test { } #[test] - #[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree fn test_input_vec() { let mut all_lines = ~[]; let filenames = make_path_option_vec(vec::from_fn( @@ -524,7 +520,6 @@ mod test { } #[test] - #[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree fn test_input_vec_state() { let filenames = make_path_option_vec(vec::from_fn( 3, @@ -547,7 +542,6 @@ mod test { } #[test] - #[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree fn test_empty_files() { let filenames = make_path_option_vec(vec::from_fn( 3, @@ -572,7 +566,6 @@ mod test { } #[test] - #[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree fn test_no_trailing_newline() { let f1 = Some(Path("tmp/lib-fileinput-test-no-trailing-newline-1.tmp")); @@ -598,7 +591,6 @@ mod test { #[test] - #[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree fn test_next_file() { let filenames = make_path_option_vec(vec::from_fn( 3, @@ -630,7 +622,6 @@ mod test { #[test] #[should_fail] - #[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree fn test_input_vec_missing_file() { do input_vec(make_path_option_vec([~"this/file/doesnt/exist"], true)) |line| { println(line); From 6d9c399ee2a462f14631fe2df905d16fad9a8143 Mon Sep 17 00:00:00 2001 From: klutzy Date: Mon, 16 Sep 2013 12:01:24 +0900 Subject: [PATCH 8/8] std::rt::uv::file: Enable tests on Win32 Closes #8814. --- src/libstd/rt/uv/file.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/libstd/rt/uv/file.rs b/src/libstd/rt/uv/file.rs index 45a5fce3f1e..e87e2d4b1e4 100644 --- a/src/libstd/rt/uv/file.rs +++ b/src/libstd/rt/uv/file.rs @@ -408,13 +408,11 @@ mod test { } #[test] - #[ignore(cfg(windows))] // FIXME #8814 fn file_test_full_simple() { file_test_full_simple_impl(); } #[test] - #[ignore(cfg(windows))] // FIXME #8814 fn file_test_full_simple_sync() { file_test_full_simple_impl_sync(); }