Skip to content

Add rumprun CI and get tests passing #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 2, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ env:
matrix:
include:
- os: linux
env: TARGET=arm-linux-androideabi
env: TARGET=arm-linux-androideabi DOCKER=alexcrichton/rust-slave-android:2015-10-21
rust: nightly
- os: linux
env: TARGET=x86_64-unknown-linux-musl
Expand All @@ -45,6 +45,9 @@ matrix:
- os: osx
env: TARGET=x86_64-apple-ios
rust: nightly-2015-09-08
- os: linux
env: TARGET=x86_64-rumprun-netbsd DOCKER=alexcrichton/rust-libc-rumprun:2015-11-27
rust: nightly-2015-09-27
notifications:
email:
on_success: never
Expand Down
12 changes: 12 additions & 0 deletions ci/rumprun/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM ubuntu:15.04

RUN apt-get update
RUN apt-get install -y binutils git g++ make qemu

WORKDIR /build
RUN git clone --recursive http://repo.rumpkernel.org/rumprun
WORKDIR /build/rumprun
RUN CC=cc ./build-rr.sh hw

ENV PATH=$PATH:/build/rumprun/rumprun/bin
WORKDIR /root
49 changes: 24 additions & 25 deletions ci/run-travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,21 @@ if [ "$TARGET" = "" ]; then
fi

MAIN_TARGETS=https://static.rust-lang.org/dist
EXTRA_TARGETS=https://people.mozilla.org/~acrichton/libc-test/2015-09-08
DATE=$(echo $TRAVIS_RUST_VERSION | sed s/nightly-//)
EXTRA_TARGETS=https://people.mozilla.org/~acrichton/libc-test/$DATE

install() {
sudo apt-get update
sudo apt-get install -y $@
}

mkdir -p .cargo
cp ci/cargo-config .cargo/config

case "$TARGET" in
*-apple-ios)
curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib
*-apple-ios | *-rumprun-*)
curl -s $EXTRA_TARGETS/$TARGET.tar.gz | \
tar xzf - -C `rustc --print sysroot`/lib/rustlib
;;

*)
Expand All @@ -44,27 +49,23 @@ case "$TARGET" in

esac

case "$TARGET" in
# Pull a pre-built docker image for testing android, then run tests entirely
# within that image. Note that this is using the same rustc installation that
# travis has (sharing it via `-v`) and otherwise the tests run entirely within
# the container.
arm-linux-androideabi)
script="
cp -r /checkout/* .
mkdir .cargo
cp ci/cargo-config .cargo/config
exec sh ci/run.sh $TARGET
"
exec docker run \
--entrypoint bash \
-v $HOME/rust:/usr/local:ro \
-v `pwd`:/checkout:ro \
-e LD_LIBRARY_PATH=/usr/local/lib \
-it alexcrichton/rust-slave-android:2015-10-21 \
-c "$script"
;;
# Pull a pre-built docker image for testing android, then run tests entirely
# within that image. Note that this is using the same rustc installation that
# travis has (sharing it via `-v`) and otherwise the tests run entirely within
# the container.
if [ "$DOCKER" != "" ]; then
exec docker run \
--entrypoint bash \
-v `rustc --print sysroot`:/usr/local:ro \
-v `pwd`:/checkout \
-e LD_LIBRARY_PATH=/usr/local/lib \
-e CARGO_TARGET_DIR=/tmp \
-w /checkout \
-it $DOCKER \
ci/run.sh $TARGET
fi

case "$TARGET" in
x86_64-unknown-linux-musl)
install musl-tools
export CC=musl-gcc
Expand Down Expand Up @@ -107,8 +108,6 @@ exec sh ci/run.sh $TARGET

esac

mkdir .cargo
cp ci/cargo-config .cargo/config
sh ci/run.sh $TARGET

if [ "$TARGET" = "x86_64-unknown-linux-gnu" ] && \
Expand Down
14 changes: 11 additions & 3 deletions ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ case "$TARGET" in
arm-linux-androideabi)
emulator @arm-18 -no-window &
adb wait-for-device
adb push libc-test/target/$TARGET/debug/libc-test /data/libc-test
adb shell /data/libc-test 2>&1 | tee out
grep "^PASSED .* tests" out
adb push /tmp/$TARGET/debug/libc-test /data/libc-test
adb shell /data/libc-test 2>&1 | tee /tmp/out
grep "^PASSED .* tests" /tmp/out
;;

arm-unknown-linux-gnueabihf)
Expand All @@ -39,6 +39,14 @@ case "$TARGET" in
libc-test/target/$TARGET/debug/libc-test
;;

*-rumprun-netbsd)
rumprun-bake hw_virtio /tmp/libc-test.img /tmp/$TARGET/debug/libc-test
qemu-system-x86_64 -nographic -vga none -m 64 \
-kernel /tmp/libc-test.img 2>&1 | tee /tmp/out &
sleep 5
grep "^PASSED .* tests" /tmp/out
;;

*-apple-ios)
libc-test/target/$TARGET/debug/libc-test
;;
Expand Down
27 changes: 22 additions & 5 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ fn main() {
let musl = target.contains("musl");
let freebsd = target.contains("freebsd");
let mips = target.contains("mips");
let bsdlike = freebsd || apple;
let netbsd = target.contains("netbsd");
let rumprun = target.contains("rumprun");
let bsdlike = freebsd || apple || netbsd;
let mut cfg = ctest::TestGenerator::new();

// Pull in extra goodies on linux/mingw
Expand Down Expand Up @@ -90,8 +92,11 @@ fn main() {
cfg.header("sys/statvfs.h");

if !musl {
cfg.header("execinfo.h");
cfg.header("sys/sysctl.h");

if !netbsd {
cfg.header("execinfo.h");
}
}
}

Expand Down Expand Up @@ -254,6 +259,18 @@ fn main() {
// Rust, but is close enough to *mut
"timegm" if apple => true,

// These functions presumably exist on netbsd but don't look like
// they're implemented on rumprun yet, just let them slide for now.
// Some of them look like they have headers but then don't have
// corresponding actual definitions either...
"backtrace" |
"pthread_main_np" |
"pthread_set_name_np" |
"pthread_stackseg_np" |
"shm_open" |
"shm_unlink" |
"sigaltstack" if rumprun => true,

_ => false,
}
});
Expand All @@ -276,11 +293,11 @@ fn main() {
(musl && struct_ == "glob_t" && field == "gl_flags")
});

cfg.fn_cname(move |a, b| {
cfg.fn_cname(move |name, cname| {
if windows || android {
b.unwrap_or(a).to_string()
cname.unwrap_or(name).to_string()
} else {
a.to_string()
name.to_string()
}
});

Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ extern {
pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int;
pub fn ftell(stream: *mut FILE) -> c_long;
pub fn rewind(stream: *mut FILE);
#[cfg_attr(target_os = "netbsd", link_name = "__fgetpos50")]
pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int;
#[cfg_attr(target_os = "netbsd", link_name = "__fsetpos50")]
pub fn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int;
pub fn feof(stream: *mut FILE) -> c_int;
pub fn ferror(stream: *mut FILE) -> c_int;
Expand Down
3 changes: 2 additions & 1 deletion src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ macro_rules! __cfg_if_apply {
}

macro_rules! s {
($(pub struct $i:ident { $($field:tt)* })*) => ($(
($($(#[$attr:meta])* pub struct $i:ident { $($field:tt)* })*) => ($(
__item! {
#[repr(C)]
$(#[$attr])*
pub struct $i { $($field)* }
}
impl ::dox::Copy for $i {}
Expand Down
27 changes: 27 additions & 0 deletions src/unix/bsd/apple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ pub type rlim_t = u64;
pub type mach_timebase_info_data_t = mach_timebase_info;
pub type pthread_key_t = c_ulong;
pub type sigset_t = u32;
pub type fsblkcnt_t = ::c_uint;
pub type fsfilcnt_t = ::c_uint;

pub enum timezone {}

Expand Down Expand Up @@ -161,6 +163,21 @@ s! {
pub f_flag: ::c_ulong,
pub f_namemax: ::c_ulong,
}

pub struct Dl_info {
pub dli_fname: *const ::c_char,
pub dli_fbase: *mut ::c_void,
pub dli_sname: *const ::c_char,
pub dli_saddr: *mut ::c_void,
}

pub struct sockaddr_in {
pub sin_len: u8,
pub sin_family: ::sa_family_t,
pub sin_port: ::in_port_t,
pub sin_addr: ::in_addr,
pub sin_zero: [::c_char; 8],
}
}

pub const EXIT_FAILURE: ::c_int = 1;
Expand Down Expand Up @@ -676,7 +693,17 @@ pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {

pub const SIGSTKSZ: ::size_t = 131072;

pub const FD_SETSIZE: usize = 1024;

pub const ST_NOSUID: ::c_ulong = 2;

extern {
pub fn mincore(addr: *const ::c_void, len: ::size_t,
vec: *mut ::c_char) -> ::c_int;
pub fn sysctlnametomib(name: *const ::c_char,
mibp: *mut ::c_int,
sizep: *mut ::size_t)
-> ::c_int;
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
link_name = "mprotect$UNIX2003")]
pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int)
Expand Down
27 changes: 27 additions & 0 deletions src/unix/bsd/freebsdlike/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ pub type pthread_mutexattr_t = *mut ::c_void;
pub type pthread_cond_t = *mut ::c_void;
pub type pthread_rwlock_t = *mut ::c_void;
pub type pthread_key_t = ::c_int;
pub type fsblkcnt_t = ::c_uint;
pub type fsfilcnt_t = ::c_uint;

pub enum timezone {}

Expand Down Expand Up @@ -103,6 +105,21 @@ s! {
pub struct sched_param {
pub sched_priority: ::c_int,
}

pub struct Dl_info {
pub dli_fname: *const ::c_char,
pub dli_fbase: *mut ::c_void,
pub dli_sname: *const ::c_char,
pub dli_saddr: *mut ::c_void,
}

pub struct sockaddr_in {
pub sin_len: u8,
pub sin_family: ::sa_family_t,
pub sin_port: ::in_port_t,
pub sin_addr: ::in_addr,
pub sin_zero: [::c_char; 8],
}
}

pub const EXIT_FAILURE: ::c_int = 1;
Expand Down Expand Up @@ -522,7 +539,17 @@ pub const SCHED_FIFO: ::c_int = 1;
pub const SCHED_OTHER: ::c_int = 2;
pub const SCHED_RR: ::c_int = 3;

pub const FD_SETSIZE: usize = 1024;

pub const ST_NOSUID: ::c_ulong = 2;

extern {
pub fn mincore(addr: *const ::c_void, len: ::size_t,
vec: *mut c_char) -> ::c_int;
pub fn sysctlnametomib(name: *const c_char,
mibp: *mut ::c_int,
sizep: *mut ::size_t)
-> ::c_int;
pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int)
-> ::c_int;
pub fn shm_open(name: *const ::c_char, oflag: ::c_int, mode: ::mode_t)
Expand Down
23 changes: 3 additions & 20 deletions src/unix/bsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ pub type blkcnt_t = i64;
pub type socklen_t = u32;
pub type sa_family_t = u8;
pub type pthread_t = ::uintptr_t;
pub type fsblkcnt_t = ::c_uint;
pub type fsfilcnt_t = ::c_uint;

s! {
pub struct sockaddr {
Expand All @@ -16,14 +14,6 @@ s! {
pub sa_data: [::c_char; 14],
}

pub struct sockaddr_in {
pub sin_len: u8,
pub sin_family: sa_family_t,
pub sin_port: ::in_port_t,
pub sin_addr: ::in_addr,
pub sin_zero: [::c_char; 8],
}

pub struct sockaddr_in6 {
pub sin6_len: u8,
pub sin6_family: sa_family_t,
Expand Down Expand Up @@ -51,7 +41,9 @@ s! {
pub pw_shell: *mut ::c_char,
pub pw_expire: ::time_t,

#[cfg(not(any(target_os = "macos", target_os = "ios")))]
#[cfg(not(any(target_os = "macos",
target_os = "ios",
target_os = "netbsd")))]
pub pw_fields: ::c_int,
}

Expand Down Expand Up @@ -102,10 +94,7 @@ pub const SIG_SETMASK: ::c_int = 3;
pub const IPV6_MULTICAST_LOOP: ::c_int = 11;
pub const IPV6_V6ONLY: ::c_int = 27;

pub const FD_SETSIZE: usize = 1024;

pub const ST_RDONLY: ::c_ulong = 1;
pub const ST_NOSUID: ::c_ulong = 2;

pub const NI_MAXHOST: ::socklen_t = 1025;

Expand Down Expand Up @@ -147,12 +136,6 @@ f! {
}

extern {
pub fn mincore(addr: *const ::c_void, len: ::size_t,
vec: *mut c_char) -> ::c_int;
pub fn sysctlnametomib(name: *const c_char,
mibp: *mut ::c_int,
sizep: *mut ::size_t)
-> ::c_int;
pub fn setgroups(ngroups: ::c_int,
ptr: *const ::gid_t) -> ::c_int;
pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
Expand Down
Loading