diff options
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/uv.rs | 78 | ||||
| -rw-r--r-- | src/libstd/uvtmp.rs | 130 |
2 files changed, 96 insertions, 112 deletions
diff --git a/src/libstd/uv.rs b/src/libstd/uv.rs index d04331e00b3..27f2a3c54a8 100644 --- a/src/libstd/uv.rs +++ b/src/libstd/uv.rs @@ -107,7 +107,7 @@ fn unref(loop: *loop_t) { fn sanity_check() { fn check_size(t: str, uv: ctypes::size_t, rust: ctypes::size_t) { #debug("size of %s: uv: %u, rust: %u", t, uv, rust); - assert uv == rust; + assert uv <= rust; } check_size("idle_t", helpers::rust_uv_size_of_idle_t(), @@ -144,53 +144,45 @@ fn idle_new() -> idle_t { } } -#[cfg(target_os = "linux")] -#[cfg(target_os = "macos")] -#[cfg(target_os = "freebsd")] -// FIXME: We're out of date on libuv and not testing -// it on windows presently. This needs to change. -mod os { +#[cfg(test)] +mod tests { - #[cfg(test)] - mod tests { + #[test] + fn test_sanity_check() { + sanity_check(); + } + + // From test-ref.c + mod test_ref { + + #[test] + fn ref() { + let loop = loop_new(); + run(loop); + loop_delete(loop); + } #[test] - fn test_sanity_check() { - sanity_check(); + fn idle_ref() { + let loop = loop_new(); + let h = idle_new(); + idle_init(loop, ptr::addr_of(h)); + idle_start(ptr::addr_of(h), ptr::null()); + unref(loop); + run(loop); + loop_delete(loop); } - // From test-ref.c - mod test_ref { - - #[test] - fn ref() { - let loop = loop_new(); - run(loop); - loop_delete(loop); - } - - #[test] - fn idle_ref() { - let loop = loop_new(); - let h = idle_new(); - idle_init(loop, ptr::addr_of(h)); - idle_start(ptr::addr_of(h), ptr::null()); - unref(loop); - run(loop); - loop_delete(loop); - } - - #[test] - fn async_ref() { - /* - let loop = loop_new(); - let h = async_new(); - async_init(loop, ptr::addr_of(h), ptr::null()); - unref(loop); - run(loop); - loop_delete(loop); - */ - } + #[test] + fn async_ref() { + /* + let loop = loop_new(); + let h = async_new(); + async_init(loop, ptr::addr_of(h), ptr::null()); + unref(loop); + run(loop); + loop_delete(loop); + */ } } } diff --git a/src/libstd/uvtmp.rs b/src/libstd/uvtmp.rs index e7de8ec1dc8..d18a59031ea 100644 --- a/src/libstd/uvtmp.rs +++ b/src/libstd/uvtmp.rs @@ -95,82 +95,74 @@ fn get_req_id(cd: connect_data) -> u32 { ret rustrt::rust_uvtmp_get_req_id(cd); } -#[cfg(target_os = "linux")] -#[cfg(target_os = "macos")] -#[cfg(target_os = "freebsd")] -// FIXME: We're out of date on libuv and not testing -// it on windows presently. This needs to change. -mod os { - - #[test] - fn test_start_stop() { - let thread = create_thread(); - start_thread(thread); - join_thread(thread); - delete_thread(thread); - } +#[test] +fn test_start_stop() { + let thread = create_thread(); + start_thread(thread); + join_thread(thread); + delete_thread(thread); +} - #[test] - #[ignore] - fn test_connect() { - let thread = create_thread(); - start_thread(thread); - let port = comm::port(); - let chan = comm::chan(port); - connect(thread, 0u32, "74.125.224.146", chan); - alt comm::recv(port) { - connected(cd) { - close_connection(thread, 0u32); - } - _ { fail "test_connect: port isn't connected"; } - } - join_thread(thread); - delete_thread(thread); +#[test] +#[ignore] +fn test_connect() { + let thread = create_thread(); + start_thread(thread); + let port = comm::port(); + let chan = comm::chan(port); + connect(thread, 0u32, "74.125.224.146", chan); + alt comm::recv(port) { + connected(cd) { + close_connection(thread, 0u32); + } + _ { fail "test_connect: port isn't connected"; } } + join_thread(thread); + delete_thread(thread); +} - #[test] - #[ignore] - fn test_http() { - let thread = create_thread(); - start_thread(thread); - let port = comm::port(); - let chan = comm::chan(port); - connect(thread, 0u32, "74.125.224.146", chan); +#[test] +#[ignore] +fn test_http() { + let thread = create_thread(); + start_thread(thread); + let port = comm::port(); + let chan = comm::chan(port); + connect(thread, 0u32, "74.125.224.146", chan); + alt comm::recv(port) { + connected(cd) { + write(thread, 0u32, str::bytes("GET / HTTP/1.0\n\n"), chan); alt comm::recv(port) { - connected(cd) { - write(thread, 0u32, str::bytes("GET / HTTP/1.0\n\n"), chan); - alt comm::recv(port) { - wrote(cd) { - read_start(thread, 0u32, chan); - let keep_going = true; - while keep_going { - alt comm::recv(port) { - read(_, buf, -1) { - keep_going = false; - delete_buf(buf); - } - read(_, buf, len) { - unsafe { - log(error, len); - let buf = vec::unsafe::from_buf(buf, - len as uint); - let str = str::from_bytes(buf); - #error("read something"); - io::println(str); - } - delete_buf(buf); - } - _ { fail "test_http: protocol error"; } + wrote(cd) { + read_start(thread, 0u32, chan); + let keep_going = true; + while keep_going { + alt comm::recv(port) { + read(_, buf, -1) { + keep_going = false; + delete_buf(buf); + } + read(_, buf, len) { + unsafe { + log(error, len); + let buf = vec::unsafe::from_buf(buf, + len as uint); + let str = str::from_bytes(buf); + #error("read something"); + io::println(str); } + delete_buf(buf); + } + _ { fail "test_http: protocol error"; } } - close_connection(thread, 0u32); - } - _ { fail "test_http: expected `wrote`"; } } + close_connection(thread, 0u32); } - _ { fail "test_http: port not connected"; } + _ { fail "test_http: expected `wrote`"; } } - join_thread(thread); - delete_thread(thread); + } + _ { fail "test_http: port not connected"; } } -} \ No newline at end of file + join_thread(thread); + delete_thread(thread); +} |
