Skip to content

Commit ce47c21

Browse files
committed
Add rumprun CI and get tests passing
1 parent f25765f commit ce47c21

File tree

16 files changed

+863
-256
lines changed

16 files changed

+863
-256
lines changed

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ env:
2525
matrix:
2626
include:
2727
- os: linux
28-
env: TARGET=arm-linux-androideabi
28+
env: TARGET=arm-linux-androideabi DOCKER=alexcrichton/rust-slave-android:2015-10-21
2929
rust: nightly
3030
- os: linux
3131
env: TARGET=x86_64-unknown-linux-musl
@@ -45,6 +45,9 @@ matrix:
4545
- os: osx
4646
env: TARGET=x86_64-apple-ios
4747
rust: nightly-2015-09-08
48+
- os: linux
49+
env: TARGET=x86_64-rumprun-netbsd DOCKER=alexcrichton/rust-libc-rumprun:2015-11-27
50+
rust: nightly-2015-09-27
4851
notifications:
4952
email:
5053
on_success: never

ci/rumprun/Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM ubuntu:15.04
2+
3+
RUN apt-get update
4+
RUN apt-get install -y binutils git g++ make qemu
5+
6+
WORKDIR /build
7+
RUN git clone --recursive http://repo.rumpkernel.org/rumprun
8+
WORKDIR /build/rumprun
9+
RUN CC=cc ./build-rr.sh hw
10+
11+
ENV PATH=$PATH:/build/rumprun/rumprun/bin
12+
WORKDIR /root

ci/run-travis.sh

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,21 @@ if [ "$TARGET" = "" ]; then
1616
fi
1717

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

2122
install() {
2223
sudo apt-get update
2324
sudo apt-get install -y $@
2425
}
2526

27+
mkdir -p .cargo
28+
cp ci/cargo-config .cargo/config
29+
2630
case "$TARGET" in
27-
*-apple-ios)
28-
curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib
31+
*-apple-ios | *-rumprun-*)
32+
curl -s $EXTRA_TARGETS/$TARGET.tar.gz | \
33+
tar xzf - -C `rustc --print sysroot`/lib/rustlib
2934
;;
3035

3136
*)
@@ -44,27 +49,23 @@ case "$TARGET" in
4449

4550
esac
4651

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

68+
case "$TARGET" in
6869
x86_64-unknown-linux-musl)
6970
install musl-tools
7071
export CC=musl-gcc
@@ -107,8 +108,6 @@ exec sh ci/run.sh $TARGET
107108

108109
esac
109110

110-
mkdir .cargo
111-
cp ci/cargo-config .cargo/config
112111
sh ci/run.sh $TARGET
113112

114113
if [ "$TARGET" = "x86_64-unknown-linux-gnu" ] && \

ci/run.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ case "$TARGET" in
2121
arm-linux-androideabi)
2222
emulator @arm-18 -no-window &
2323
adb wait-for-device
24-
adb push libc-test/target/$TARGET/debug/libc-test /data/libc-test
25-
adb shell /data/libc-test 2>&1 | tee out
26-
grep "^PASSED .* tests" out
24+
adb push /tmp/$TARGET/debug/libc-test /data/libc-test
25+
adb shell /data/libc-test 2>&1 | tee /tmp/out
26+
grep "^PASSED .* tests" /tmp/out
2727
;;
2828

2929
arm-unknown-linux-gnueabihf)
@@ -39,6 +39,14 @@ case "$TARGET" in
3939
libc-test/target/$TARGET/debug/libc-test
4040
;;
4141

42+
*-rumprun-netbsd)
43+
rumprun-bake hw_virtio /tmp/libc-test.img /tmp/$TARGET/debug/libc-test
44+
qemu-system-x86_64 -nographic -vga none -m 64 \
45+
-kernel /tmp/libc-test.img 2>&1 | tee /tmp/out &
46+
sleep 5
47+
grep "^PASSED .* tests" /tmp/out
48+
;;
49+
4250
*-apple-ios)
4351
libc-test/target/$TARGET/debug/libc-test
4452
;;

libc-test/build.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ fn main() {
1414
let musl = target.contains("musl");
1515
let freebsd = target.contains("freebsd");
1616
let mips = target.contains("mips");
17-
let bsdlike = freebsd || apple;
17+
let netbsd = target.contains("netbsd");
18+
let bsdlike = freebsd || apple || netbsd;
1819
let mut cfg = ctest::TestGenerator::new();
1920

2021
// Pull in extra goodies on linux/mingw
@@ -90,8 +91,11 @@ fn main() {
9091
cfg.header("sys/statvfs.h");
9192

9293
if !musl {
93-
cfg.header("execinfo.h");
9494
cfg.header("sys/sysctl.h");
95+
96+
if !netbsd {
97+
cfg.header("execinfo.h");
98+
}
9599
}
96100
}
97101

@@ -276,11 +280,11 @@ fn main() {
276280
(musl && struct_ == "glob_t" && field == "gl_flags")
277281
});
278282

279-
cfg.fn_cname(move |a, b| {
283+
cfg.fn_cname(move |name, cname| {
280284
if windows || android {
281-
b.unwrap_or(a).to_string()
285+
cname.unwrap_or(name).to_string()
282286
} else {
283-
a.to_string()
287+
name.to_string()
284288
}
285289
});
286290

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,9 @@ extern {
172172
pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int;
173173
pub fn ftell(stream: *mut FILE) -> c_long;
174174
pub fn rewind(stream: *mut FILE);
175+
#[cfg_attr(target_os = "netbsd", link_name = "__fgetpos50")]
175176
pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int;
177+
#[cfg_attr(target_os = "netbsd", link_name = "__fsetpos50")]
176178
pub fn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int;
177179
pub fn feof(stream: *mut FILE) -> c_int;
178180
pub fn ferror(stream: *mut FILE) -> c_int;

src/macros.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@ macro_rules! __cfg_if_apply {
3535
}
3636

3737
macro_rules! s {
38-
($(pub struct $i:ident { $($field:tt)* })*) => ($(
38+
($($(#[$attr:meta])* pub struct $i:ident { $($field:tt)* })*) => ($(
3939
__item! {
4040
#[repr(C)]
41+
$(#[$attr])*
4142
pub struct $i { $($field)* }
4243
}
4344
impl ::dox::Copy for $i {}

src/unix/bsd/apple/mod.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ pub type rlim_t = u64;
1414
pub type mach_timebase_info_data_t = mach_timebase_info;
1515
pub type pthread_key_t = c_ulong;
1616
pub type sigset_t = u32;
17+
pub type fsblkcnt_t = ::c_uint;
18+
pub type fsfilcnt_t = ::c_uint;
1719

1820
pub enum timezone {}
1921

@@ -161,6 +163,21 @@ s! {
161163
pub f_flag: ::c_ulong,
162164
pub f_namemax: ::c_ulong,
163165
}
166+
167+
pub struct Dl_info {
168+
pub dli_fname: *const ::c_char,
169+
pub dli_fbase: *mut ::c_void,
170+
pub dli_sname: *const ::c_char,
171+
pub dli_saddr: *mut ::c_void,
172+
}
173+
174+
pub struct sockaddr_in {
175+
pub sin_len: u8,
176+
pub sin_family: ::sa_family_t,
177+
pub sin_port: ::in_port_t,
178+
pub sin_addr: ::in_addr,
179+
pub sin_zero: [::c_char; 8],
180+
}
164181
}
165182

166183
pub const EXIT_FAILURE: ::c_int = 1;
@@ -676,7 +693,17 @@ pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
676693

677694
pub const SIGSTKSZ: ::size_t = 131072;
678695

696+
pub const FD_SETSIZE: usize = 1024;
697+
698+
pub const ST_NOSUID: ::c_ulong = 2;
699+
679700
extern {
701+
pub fn mincore(addr: *const ::c_void, len: ::size_t,
702+
vec: *mut ::c_char) -> ::c_int;
703+
pub fn sysctlnametomib(name: *const ::c_char,
704+
mibp: *mut ::c_int,
705+
sizep: *mut ::size_t)
706+
-> ::c_int;
680707
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
681708
link_name = "mprotect$UNIX2003")]
682709
pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int)

src/unix/bsd/freebsdlike/mod.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ pub type pthread_mutexattr_t = *mut ::c_void;
1212
pub type pthread_cond_t = *mut ::c_void;
1313
pub type pthread_rwlock_t = *mut ::c_void;
1414
pub type pthread_key_t = ::c_int;
15+
pub type fsblkcnt_t = ::c_uint;
16+
pub type fsfilcnt_t = ::c_uint;
1517

1618
pub enum timezone {}
1719

@@ -103,6 +105,21 @@ s! {
103105
pub struct sched_param {
104106
pub sched_priority: ::c_int,
105107
}
108+
109+
pub struct Dl_info {
110+
pub dli_fname: *const ::c_char,
111+
pub dli_fbase: *mut ::c_void,
112+
pub dli_sname: *const ::c_char,
113+
pub dli_saddr: *mut ::c_void,
114+
}
115+
116+
pub struct sockaddr_in {
117+
pub sin_len: u8,
118+
pub sin_family: ::sa_family_t,
119+
pub sin_port: ::in_port_t,
120+
pub sin_addr: ::in_addr,
121+
pub sin_zero: [::c_char; 8],
122+
}
106123
}
107124

108125
pub const EXIT_FAILURE: ::c_int = 1;
@@ -522,7 +539,17 @@ pub const SCHED_FIFO: ::c_int = 1;
522539
pub const SCHED_OTHER: ::c_int = 2;
523540
pub const SCHED_RR: ::c_int = 3;
524541

542+
pub const FD_SETSIZE: usize = 1024;
543+
544+
pub const ST_NOSUID: ::c_ulong = 2;
545+
525546
extern {
547+
pub fn mincore(addr: *const ::c_void, len: ::size_t,
548+
vec: *mut c_char) -> ::c_int;
549+
pub fn sysctlnametomib(name: *const c_char,
550+
mibp: *mut ::c_int,
551+
sizep: *mut ::size_t)
552+
-> ::c_int;
526553
pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int)
527554
-> ::c_int;
528555
pub fn shm_open(name: *const ::c_char, oflag: ::c_int, mode: ::mode_t)

src/unix/bsd/mod.rs

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ pub type blkcnt_t = i64;
66
pub type socklen_t = u32;
77
pub type sa_family_t = u8;
88
pub type pthread_t = ::uintptr_t;
9-
pub type fsblkcnt_t = ::c_uint;
10-
pub type fsfilcnt_t = ::c_uint;
119

1210
s! {
1311
pub struct sockaddr {
@@ -16,14 +14,6 @@ s! {
1614
pub sa_data: [::c_char; 14],
1715
}
1816

19-
pub struct sockaddr_in {
20-
pub sin_len: u8,
21-
pub sin_family: sa_family_t,
22-
pub sin_port: ::in_port_t,
23-
pub sin_addr: ::in_addr,
24-
pub sin_zero: [::c_char; 8],
25-
}
26-
2717
pub struct sockaddr_in6 {
2818
pub sin6_len: u8,
2919
pub sin6_family: sa_family_t,
@@ -51,7 +41,9 @@ s! {
5141
pub pw_shell: *mut ::c_char,
5242
pub pw_expire: ::time_t,
5343

54-
#[cfg(not(any(target_os = "macos", target_os = "ios")))]
44+
#[cfg(not(any(target_os = "macos",
45+
target_os = "ios",
46+
target_os = "netbsd")))]
5547
pub pw_fields: ::c_int,
5648
}
5749

@@ -102,10 +94,7 @@ pub const SIG_SETMASK: ::c_int = 3;
10294
pub const IPV6_MULTICAST_LOOP: ::c_int = 11;
10395
pub const IPV6_V6ONLY: ::c_int = 27;
10496

105-
pub const FD_SETSIZE: usize = 1024;
106-
10797
pub const ST_RDONLY: ::c_ulong = 1;
108-
pub const ST_NOSUID: ::c_ulong = 2;
10998

11099
pub const NI_MAXHOST: ::socklen_t = 1025;
111100

@@ -147,12 +136,6 @@ f! {
147136
}
148137

149138
extern {
150-
pub fn mincore(addr: *const ::c_void, len: ::size_t,
151-
vec: *mut c_char) -> ::c_int;
152-
pub fn sysctlnametomib(name: *const c_char,
153-
mibp: *mut ::c_int,
154-
sizep: *mut ::size_t)
155-
-> ::c_int;
156139
pub fn setgroups(ngroups: ::c_int,
157140
ptr: *const ::gid_t) -> ::c_int;
158141
pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;

0 commit comments

Comments
 (0)