Skip to content

Commit 9b3452e

Browse files
committed
libstd: Fix std test. rs=busted
1 parent ad2fc50 commit 9b3452e

File tree

2 files changed

+111
-86
lines changed

2 files changed

+111
-86
lines changed

src/libstd/c_vec.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,14 @@ mod tests {
161161
use core::libc;
162162

163163
fn malloc(n: size_t) -> CVec<u8> {
164-
let mem = libc::malloc(n);
164+
unsafe {
165+
let mem = libc::malloc(n);
165166

166-
assert mem as int != 0;
167+
assert mem as int != 0;
167168

168-
return unsafe { c_vec_with_dtor(mem as *mut u8, n as uint,
169-
||free(mem)) };
169+
return unsafe { c_vec_with_dtor(mem as *mut u8, n as uint,
170+
|| unsafe { free(mem) }) };
171+
}
170172
}
171173

172174
#[test]

src/libstd/uv_ll.rs

Lines changed: 105 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,125 +1594,148 @@ pub mod test {
15941594
// struct size tests
15951595
#[test]
15961596
fn test_uv_ll_struct_size_uv_tcp_t() {
1597-
let foreign_handle_size =
1598-
::uv_ll::rustrt::rust_uv_helper_uv_tcp_t_size();
1599-
let rust_handle_size = sys::size_of::<uv_tcp_t>();
1600-
let output = fmt!("uv_tcp_t -- foreign: %u rust: %u",
1601-
foreign_handle_size as uint, rust_handle_size);
1602-
log(debug, output);
1603-
assert foreign_handle_size as uint == rust_handle_size;
1597+
unsafe {
1598+
let foreign_handle_size =
1599+
::uv_ll::rustrt::rust_uv_helper_uv_tcp_t_size();
1600+
let rust_handle_size = sys::size_of::<uv_tcp_t>();
1601+
let output = fmt!("uv_tcp_t -- foreign: %u rust: %u",
1602+
foreign_handle_size as uint, rust_handle_size);
1603+
log(debug, output);
1604+
assert foreign_handle_size as uint == rust_handle_size;
1605+
}
16041606
}
16051607
#[test]
16061608
fn test_uv_ll_struct_size_uv_connect_t() {
1607-
let foreign_handle_size =
1608-
::uv_ll::rustrt::rust_uv_helper_uv_connect_t_size();
1609-
let rust_handle_size = sys::size_of::<uv_connect_t>();
1610-
let output = fmt!("uv_connect_t -- foreign: %u rust: %u",
1611-
foreign_handle_size as uint, rust_handle_size);
1612-
log(debug, output);
1613-
assert foreign_handle_size as uint == rust_handle_size;
1609+
unsafe {
1610+
let foreign_handle_size =
1611+
::uv_ll::rustrt::rust_uv_helper_uv_connect_t_size();
1612+
let rust_handle_size = sys::size_of::<uv_connect_t>();
1613+
let output = fmt!("uv_connect_t -- foreign: %u rust: %u",
1614+
foreign_handle_size as uint, rust_handle_size);
1615+
log(debug, output);
1616+
assert foreign_handle_size as uint == rust_handle_size;
1617+
}
16141618
}
16151619
#[test]
16161620
fn test_uv_ll_struct_size_uv_buf_t() {
1617-
let foreign_handle_size =
1618-
::uv_ll::rustrt::rust_uv_helper_uv_buf_t_size();
1619-
let rust_handle_size = sys::size_of::<uv_buf_t>();
1620-
let output = fmt!("uv_buf_t -- foreign: %u rust: %u",
1621-
foreign_handle_size as uint, rust_handle_size);
1622-
log(debug, output);
1623-
assert foreign_handle_size as uint == rust_handle_size;
1621+
unsafe {
1622+
let foreign_handle_size =
1623+
::uv_ll::rustrt::rust_uv_helper_uv_buf_t_size();
1624+
let rust_handle_size = sys::size_of::<uv_buf_t>();
1625+
let output = fmt!("uv_buf_t -- foreign: %u rust: %u",
1626+
foreign_handle_size as uint, rust_handle_size);
1627+
log(debug, output);
1628+
assert foreign_handle_size as uint == rust_handle_size;
1629+
}
16241630
}
16251631
#[test]
16261632
fn test_uv_ll_struct_size_uv_write_t() {
1627-
let foreign_handle_size =
1628-
::uv_ll::rustrt::rust_uv_helper_uv_write_t_size();
1629-
let rust_handle_size = sys::size_of::<uv_write_t>();
1630-
let output = fmt!("uv_write_t -- foreign: %u rust: %u",
1631-
foreign_handle_size as uint, rust_handle_size);
1632-
log(debug, output);
1633-
assert foreign_handle_size as uint == rust_handle_size;
1633+
unsafe {
1634+
let foreign_handle_size =
1635+
::uv_ll::rustrt::rust_uv_helper_uv_write_t_size();
1636+
let rust_handle_size = sys::size_of::<uv_write_t>();
1637+
let output = fmt!("uv_write_t -- foreign: %u rust: %u",
1638+
foreign_handle_size as uint, rust_handle_size);
1639+
log(debug, output);
1640+
assert foreign_handle_size as uint == rust_handle_size;
1641+
}
16341642
}
16351643

16361644
#[test]
16371645
fn test_uv_ll_struct_size_sockaddr_in() {
1638-
let foreign_handle_size =
1639-
::uv_ll::rustrt::rust_uv_helper_sockaddr_in_size();
1640-
let rust_handle_size = sys::size_of::<sockaddr_in>();
1641-
let output = fmt!("sockaddr_in -- foreign: %u rust: %u",
1642-
foreign_handle_size as uint, rust_handle_size);
1643-
log(debug, output);
1644-
assert foreign_handle_size as uint == rust_handle_size;
1646+
unsafe {
1647+
let foreign_handle_size =
1648+
::uv_ll::rustrt::rust_uv_helper_sockaddr_in_size();
1649+
let rust_handle_size = sys::size_of::<sockaddr_in>();
1650+
let output = fmt!("sockaddr_in -- foreign: %u rust: %u",
1651+
foreign_handle_size as uint, rust_handle_size);
1652+
log(debug, output);
1653+
assert foreign_handle_size as uint == rust_handle_size;
1654+
}
16451655
}
16461656
#[test]
16471657
fn test_uv_ll_struct_size_sockaddr_in6() {
1648-
let foreign_handle_size =
1649-
::uv_ll::rustrt::rust_uv_helper_sockaddr_in6_size();
1650-
let rust_handle_size = sys::size_of::<sockaddr_in6>();
1651-
let output = fmt!("sockaddr_in6 -- foreign: %u rust: %u",
1652-
foreign_handle_size as uint, rust_handle_size);
1653-
log(debug, output);
1654-
// FIXME #1645 .. rust appears to pad structs to the nearest byte..?
1655-
// .. can't get the uv::ll::sockaddr_in6 to == 28 :/
1656-
// .. so the type always appears to be 32 in size.. which is
1657-
// good, i guess.. better too big than too little
1658-
assert (4u+foreign_handle_size as uint) == rust_handle_size;
1658+
unsafe {
1659+
let foreign_handle_size =
1660+
::uv_ll::rustrt::rust_uv_helper_sockaddr_in6_size();
1661+
let rust_handle_size = sys::size_of::<sockaddr_in6>();
1662+
let output = fmt!("sockaddr_in6 -- foreign: %u rust: %u",
1663+
foreign_handle_size as uint, rust_handle_size);
1664+
log(debug, output);
1665+
// FIXME #1645 .. rust appears to pad structs to the nearest
1666+
// byte..?
1667+
// .. can't get the uv::ll::sockaddr_in6 to == 28 :/
1668+
// .. so the type always appears to be 32 in size.. which is
1669+
// good, i guess.. better too big than too little
1670+
assert (4u+foreign_handle_size as uint) == rust_handle_size;
1671+
}
16591672
}
16601673
#[test]
16611674
#[ignore(reason = "questionable size calculations")]
16621675
fn test_uv_ll_struct_size_addr_in() {
1663-
let foreign_handle_size =
1664-
::uv_ll::rustrt::rust_uv_helper_addr_in_size();
1665-
let rust_handle_size = sys::size_of::<addr_in>();
1666-
let output = fmt!("addr_in -- foreign: %u rust: %u",
1667-
foreign_handle_size as uint, rust_handle_size);
1668-
log(debug, output);
1669-
// FIXME #1645 .. see note above about struct padding
1670-
assert (4u+foreign_handle_size as uint) == rust_handle_size;
1676+
unsafe {
1677+
let foreign_handle_size =
1678+
::uv_ll::rustrt::rust_uv_helper_addr_in_size();
1679+
let rust_handle_size = sys::size_of::<addr_in>();
1680+
let output = fmt!("addr_in -- foreign: %u rust: %u",
1681+
foreign_handle_size as uint, rust_handle_size);
1682+
log(debug, output);
1683+
// FIXME #1645 .. see note above about struct padding
1684+
assert (4u+foreign_handle_size as uint) == rust_handle_size;
1685+
}
16711686
}
16721687

16731688
#[test]
16741689
fn test_uv_ll_struct_size_uv_async_t() {
1675-
let foreign_handle_size =
1676-
::uv_ll::rustrt::rust_uv_helper_uv_async_t_size();
1677-
let rust_handle_size = sys::size_of::<uv_async_t>();
1678-
let output = fmt!("uv_async_t -- foreign: %u rust: %u",
1679-
foreign_handle_size as uint, rust_handle_size);
1680-
log(debug, output);
1681-
assert foreign_handle_size as uint == rust_handle_size;
1690+
unsafe {
1691+
let foreign_handle_size =
1692+
::uv_ll::rustrt::rust_uv_helper_uv_async_t_size();
1693+
let rust_handle_size = sys::size_of::<uv_async_t>();
1694+
let output = fmt!("uv_async_t -- foreign: %u rust: %u",
1695+
foreign_handle_size as uint, rust_handle_size);
1696+
log(debug, output);
1697+
assert foreign_handle_size as uint == rust_handle_size;
1698+
}
16821699
}
16831700

16841701
#[test]
16851702
fn test_uv_ll_struct_size_uv_timer_t() {
1686-
let foreign_handle_size =
1687-
::uv_ll::rustrt::rust_uv_helper_uv_timer_t_size();
1688-
let rust_handle_size = sys::size_of::<uv_timer_t>();
1689-
let output = fmt!("uv_timer_t -- foreign: %u rust: %u",
1690-
foreign_handle_size as uint, rust_handle_size);
1691-
log(debug, output);
1692-
assert foreign_handle_size as uint == rust_handle_size;
1703+
unsafe {
1704+
let foreign_handle_size =
1705+
::uv_ll::rustrt::rust_uv_helper_uv_timer_t_size();
1706+
let rust_handle_size = sys::size_of::<uv_timer_t>();
1707+
let output = fmt!("uv_timer_t -- foreign: %u rust: %u",
1708+
foreign_handle_size as uint, rust_handle_size);
1709+
log(debug, output);
1710+
assert foreign_handle_size as uint == rust_handle_size;
1711+
}
16931712
}
16941713

16951714
#[test]
16961715
#[ignore(cfg(target_os = "win32"))]
16971716
fn test_uv_ll_struct_size_uv_getaddrinfo_t() {
1698-
let foreign_handle_size =
1699-
::uv_ll::rustrt::rust_uv_helper_uv_getaddrinfo_t_size();
1700-
let rust_handle_size = sys::size_of::<uv_getaddrinfo_t>();
1701-
let output = fmt!("uv_getaddrinfo_t -- foreign: %u rust: %u",
1702-
foreign_handle_size as uint, rust_handle_size);
1703-
log(debug, output);
1704-
assert foreign_handle_size as uint == rust_handle_size;
1717+
unsafe {
1718+
let foreign_handle_size =
1719+
::uv_ll::rustrt::rust_uv_helper_uv_getaddrinfo_t_size();
1720+
let rust_handle_size = sys::size_of::<uv_getaddrinfo_t>();
1721+
let output = fmt!("uv_getaddrinfo_t -- foreign: %u rust: %u",
1722+
foreign_handle_size as uint, rust_handle_size);
1723+
log(debug, output);
1724+
assert foreign_handle_size as uint == rust_handle_size;
1725+
}
17051726
}
17061727
#[test]
17071728
#[ignore(cfg(target_os = "macos"))]
17081729
#[ignore(cfg(target_os = "win32"))]
17091730
fn test_uv_ll_struct_size_addrinfo() {
1710-
let foreign_handle_size =
1711-
::uv_ll::rustrt::rust_uv_helper_addrinfo_size();
1712-
let rust_handle_size = sys::size_of::<addrinfo>();
1713-
let output = fmt!("addrinfo -- foreign: %u rust: %u",
1714-
foreign_handle_size as uint, rust_handle_size);
1715-
log(debug, output);
1716-
assert foreign_handle_size as uint == rust_handle_size;
1731+
unsafe {
1732+
let foreign_handle_size =
1733+
::uv_ll::rustrt::rust_uv_helper_addrinfo_size();
1734+
let rust_handle_size = sys::size_of::<addrinfo>();
1735+
let output = fmt!("addrinfo -- foreign: %u rust: %u",
1736+
foreign_handle_size as uint, rust_handle_size);
1737+
log(debug, output);
1738+
assert foreign_handle_size as uint == rust_handle_size;
1739+
}
17171740
}
17181741
}

0 commit comments

Comments
 (0)