Skip to content

Commit 5856b1c

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

File tree

18 files changed

+864
-236
lines changed

18 files changed

+864
-236
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: 13 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,15 @@ fn main() {
276280
(musl && struct_ == "glob_t" && field == "gl_flags")
277281
});
278282

279-
cfg.fn_cname(move |a, b| {
283+
if cfg!(feature = "rumprun") {
284+
cfg.cfg("feature", Some("rumprun"));
285+
}
286+
287+
cfg.fn_cname(move |name, cname| {
280288
if windows || android {
281-
b.unwrap_or(a).to_string()
289+
cname.unwrap_or(name).to_string()
282290
} else {
283-
a.to_string()
291+
name.to_string()
284292
}
285293
});
286294

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)

0 commit comments

Comments
 (0)