Skip to content

Commit 1e4d6c4

Browse files
committed
Add rumprun CI and get tests passing
1 parent aad297a commit 1e4d6c4

File tree

18 files changed

+870
-233
lines changed

18 files changed

+870
-233
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

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ other common platform libraries.
1515

1616
[features]
1717
default = []
18+
rumprun = []

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: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,18 @@ 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

2627
case "$TARGET" in
27-
*-apple-ios)
28-
curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib
28+
*-apple-ios | *-rumprun-*)
29+
curl -s $EXTRA_TARGETS/$TARGET.tar.gz | \
30+
tar xzf - -C `rustc --print sysroot`/lib/rustlib
2931
;;
3032

3133
*)
@@ -44,27 +46,27 @@ case "$TARGET" in
4446

4547
esac
4648

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-
;;
49+
# Pull a pre-built docker image for testing android, then run tests entirely
50+
# within that image. Note that this is using the same rustc installation that
51+
# travis has (sharing it via `-v`) and otherwise the tests run entirely within
52+
# the container.
53+
if [ "$DOCKER" != "" ]; then
54+
script="
55+
cp -r /checkout/* .
56+
mkdir .cargo
57+
cp ci/cargo-config .cargo/config
58+
exec sh ci/run.sh $TARGET
59+
"
60+
exec docker run \
61+
--entrypoint bash \
62+
-v `rustc --print sysroot`:/usr/local:ro \
63+
-v `pwd`:/checkout:ro \
64+
-e LD_LIBRARY_PATH=/usr/local/lib \
65+
-it $DOCKER \
66+
-c "$script"
67+
fi
6768

69+
case "$TARGET" in
6870
x86_64-unknown-linux-musl)
6971
install musl-tools
7072
export CC=musl-gcc

ci/run.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ case "$TARGET" in
1212
-C link-args=-mios-simulator-version-min=7.0
1313
;;
1414

15+
*-rumprun-*)
16+
cargo build --manifest-path libc-test/Cargo.toml --target $TARGET \
17+
--features rumprun
18+
;;
19+
1520
*)
1621
cargo build --manifest-path libc-test/Cargo.toml --target $TARGET
1722
;;
@@ -39,8 +44,12 @@ case "$TARGET" in
3944
libc-test/target/$TARGET/debug/libc-test
4045
;;
4146

42-
*-apple-ios)
43-
libc-test/target/$TARGET/debug/libc-test
47+
*-rumprun-netbsd)
48+
rumprun-bake hw_virtio libc-test.img libc-test/target/$TARGET/debug/libc-test
49+
qemu-system-x86_64 -nographic -vga none -m 64 -kernel ./libc-test.img > out &
50+
sleep 5
51+
cat out
52+
grep "^PASSED .* tests" out
4453
;;
4554

4655
*)

libc-test/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ libc = { path = ".." }
99

1010
[build-dependencies]
1111
ctest = { git = "https://github.com/alexcrichton/ctest" }
12+
13+
[features]
14+
rumprun = ["libc/rumprun"]

libc-test/build.rs

Lines changed: 18 additions & 2 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,5 +280,17 @@ fn main() {
276280
(musl && struct_ == "glob_t" && field == "gl_flags")
277281
});
278282

283+
if cfg!(feature = "rumprun") {
284+
cfg.cfg("feature", Some("rumprun"));
285+
}
286+
287+
cfg.fn_cname(move |name, cname| {
288+
if windows {
289+
cname.unwrap_or(name).to_string()
290+
} else {
291+
name.to_string()
292+
}
293+
});
294+
279295
cfg.generate("../src/lib.rs", "all.rs");
280296
}

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(feature = "rumprun", link_name = "__fgetpos50")]
175176
pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int;
177+
#[cfg_attr(feature = "rumprun", 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: 19 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,13 @@ 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+
}
164173
}
165174

166175
pub const EXIT_FAILURE: ::c_int = 1;
@@ -676,7 +685,17 @@ pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
676685

677686
pub const SIGSTKSZ: ::size_t = 131072;
678687

688+
pub const FD_SETSIZE: usize = 1024;
689+
690+
pub const ST_NOSUID: ::c_ulong = 2;
691+
679692
extern {
693+
pub fn mincore(addr: *const ::c_void, len: ::size_t,
694+
vec: *mut c_char) -> ::c_int;
695+
pub fn sysctlnametomib(name: *const c_char,
696+
mibp: *mut ::c_int,
697+
sizep: *mut ::size_t)
698+
-> ::c_int;
680699
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
681700
link_name = "mprotect$UNIX2003")]
682701
pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int)

src/unix/bsd/freebsdlike/mod.rs

Lines changed: 19 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,13 @@ 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+
}
106115
}
107116

108117
pub const EXIT_FAILURE: ::c_int = 1;
@@ -522,7 +531,17 @@ pub const SCHED_FIFO: ::c_int = 1;
522531
pub const SCHED_OTHER: ::c_int = 2;
523532
pub const SCHED_RR: ::c_int = 3;
524533

534+
pub const FD_SETSIZE: usize = 1024;
535+
536+
pub const ST_NOSUID: ::c_ulong = 2;
537+
525538
extern {
539+
pub fn mincore(addr: *const ::c_void, len: ::size_t,
540+
vec: *mut c_char) -> ::c_int;
541+
pub fn sysctlnametomib(name: *const c_char,
542+
mibp: *mut ::c_int,
543+
sizep: *mut ::size_t)
544+
-> ::c_int;
526545
pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int)
527546
-> ::c_int;
528547
pub fn shm_open(name: *const ::c_char, oflag: ::c_int, mode: ::mode_t)

src/unix/bsd/mod.rs

Lines changed: 4 additions & 13 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 {
@@ -21,7 +19,7 @@ s! {
2119
pub sin_family: sa_family_t,
2220
pub sin_port: ::in_port_t,
2321
pub sin_addr: ::in_addr,
24-
pub sin_zero: [::c_char; 8],
22+
pub sin_zero: [::int8_t; 8],
2523
}
2624

2725
pub struct sockaddr_in6 {
@@ -51,7 +49,9 @@ s! {
5149
pub pw_shell: *mut ::c_char,
5250
pub pw_expire: ::time_t,
5351

54-
#[cfg(not(any(target_os = "macos", target_os = "ios")))]
52+
#[cfg(not(any(target_os = "macos",
53+
target_os = "ios",
54+
target_os = "netbsd")))]
5555
pub pw_fields: ::c_int,
5656
}
5757

@@ -102,10 +102,7 @@ pub const SIG_SETMASK: ::c_int = 3;
102102
pub const IPV6_MULTICAST_LOOP: ::c_int = 11;
103103
pub const IPV6_V6ONLY: ::c_int = 27;
104104

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

110107
pub const NI_MAXHOST: ::socklen_t = 1025;
111108

@@ -147,12 +144,6 @@ f! {
147144
}
148145

149146
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;
156147
pub fn setgroups(ngroups: ::c_int,
157148
ptr: *const ::gid_t) -> ::c_int;
158149
pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;

0 commit comments

Comments
 (0)