Skip to content

Commit 0f09984

Browse files
committed
Tweak Travis to use GCE
Travis CI has new infrastructure using the Google Compute Engine which has both faster CPUs and more memory, and we've been encouraged to switch as it should help our build times! The only downside currently, however, is that IPv6 is disabled, causing a number of standard library tests to fail. Consequently this commit tweaks our travis config in a few ways: * ccache is disabled as it's not working on GCE just yet * Docker is used to run tests inside which reportedly will get IPv6 working * A system LLVM installation is used instead of building LLVM itself. This is primarily done to reduce build times, but we want automation for this sort of behavior anyway and we can extend this in the future with building from source as well if needed. * gcc-specific logic is removed as the docker image for Ubuntu gives us a recent-enough gcc by default.
1 parent 638b260 commit 0f09984

File tree

8 files changed

+80
-77
lines changed

8 files changed

+80
-77
lines changed

.travis.yml

+16-31
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,22 @@
1-
# ccache support is disabled unless your language is a C-derivative. However
2-
# `language: C` unconditionally sets `CC=compiler`. If we just set it in our
3-
# `env` it will be overwritten by the default (gcc 4.6).
41
language: c
5-
compiler: /usr/bin/gcc-4.7
6-
cache: ccache
7-
sudo: false
2+
sudo: required
3+
services:
4+
- docker
85

9-
# The test suite is in general way too stressful for travis, especially in
10-
# terms of time limit and reliability. In the past we've tried to scale things
11-
# back to only build the stage1 compiler and run a subset of tests, but this
12-
# didn't end up panning out very well.
13-
#
14-
# As a result, we're just using travis to run `make tidy` and *only* build
15-
# stage1 but *not* test it for now (a strict subset of the bootstrap). This will
16-
# catch "obvious" errors like style or not even compiling.
17-
#
18-
# We need gcc4.7 or higher to build LLVM, and travis (well, Ubuntu 12.04)
19-
# currently ships with 4.6. Gotta download our own.
20-
before_script:
21-
- ./configure --enable-ccache
22-
script:
23-
- make tidy && make check -j4
6+
# LLVM takes awhile to check out and otherwise we'll manage the submodules in
7+
# our configure script, so disable auto submodule management.
8+
git:
9+
submodules: false
2410

25-
env:
26-
- CXX=/usr/bin/g++-4.7
27-
28-
addons:
29-
apt:
30-
sources:
31-
- ubuntu-toolchain-r-test
32-
packages:
33-
- gcc-4.7
34-
- g++-4.7
11+
before_install:
12+
- docker build -t rust -f src/etc/Dockerfile src/etc
13+
script:
14+
- docker run --privileged -tv `pwd`:/build rust
15+
sh -c "
16+
./configure --llvm-root=/usr/lib/llvm-3.7 &&
17+
make tidy &&
18+
make check -j4
19+
"
3520
3621
# Real testing happens on http://buildbot.rust-lang.org/
3722
#

src/etc/Dockerfile

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM ubuntu:latest
2+
3+
RUN echo 'deb http://llvm.org/apt/trusty/ llvm-toolchain-trusty-3.7 main' | \
4+
sudo tee -a /etc/apt/sources.list
5+
RUN echo 'deb-src http://llvm.org/apt/trusty/ llvm-toolchain-trusty-3.7 main' | \
6+
sudo tee -a /etc/apt/sources.list
7+
RUN apt-get update
8+
RUN apt-get -y install curl make g++ python2.7 git zlib1g-dev libedit-dev
9+
RUN apt-get -y --force-yes install llvm-3.7-tools
10+
11+
RUN mkdir /build
12+
WORKDIR /build

src/libstd/net/udp.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,13 @@ mod tests {
185185
}
186186
}
187187

188-
// FIXME #11530 this fails on android because tests are run as root
189-
#[cfg_attr(any(windows, target_os = "android"), ignore)]
190188
#[test]
191189
fn bind_error() {
192-
let addr = SocketAddrV4::new(Ipv4Addr::new(0, 0, 0, 0), 1);
193-
match UdpSocket::bind(&addr) {
190+
match UdpSocket::bind("1.1.1.1:9999") {
194191
Ok(..) => panic!(),
195-
Err(e) => assert_eq!(e.kind(), ErrorKind::PermissionDenied),
192+
Err(e) => {
193+
assert_eq!(e.kind(), ErrorKind::AddrNotAvailable)
194+
}
196195
}
197196
}
198197

src/libstd/process.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -625,17 +625,20 @@ mod tests {
625625
drop(p.wait());
626626
}
627627

628-
#[cfg(all(unix, not(target_os="android")))]
628+
#[cfg(unix)]
629629
#[test]
630630
fn signal_reported_right() {
631631
use os::unix::process::ExitStatusExt;
632632

633-
let p = Command::new("/bin/sh").arg("-c").arg("kill -9 $$").spawn();
634-
assert!(p.is_ok());
635-
let mut p = p.unwrap();
633+
let mut p = Command::new("/bin/sh")
634+
.arg("-c").arg("read a")
635+
.stdin(Stdio::piped())
636+
.spawn().unwrap();
637+
p.kill().unwrap();
636638
match p.wait().unwrap().signal() {
637639
Some(9) => {},
638-
result => panic!("not terminated by signal 9 (instead, {:?})", result),
640+
result => panic!("not terminated by signal 9 (instead, {:?})",
641+
result),
639642
}
640643
}
641644

src/libstd/sys/unix/process.rs

+22-11
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,15 @@ mod tests {
450450
use slice;
451451
use sys::{self, c, cvt, pipe};
452452

453+
macro_rules! t {
454+
($e:expr) => {
455+
match $e {
456+
Ok(t) => t,
457+
Err(e) => panic!("received error for `{}`: {}", stringify!($e), e),
458+
}
459+
}
460+
}
461+
453462
#[cfg(not(target_os = "android"))]
454463
extern {
455464
#[cfg_attr(target_os = "netbsd", link_name = "__sigaddset14")]
@@ -473,24 +482,26 @@ mod tests {
473482
unsafe {
474483
// Test to make sure that a signal mask does not get inherited.
475484
let cmd = Command::new(OsStr::new("cat"));
476-
let (stdin_read, stdin_write) = sys::pipe::anon_pipe().unwrap();
477-
let (stdout_read, stdout_write) = sys::pipe::anon_pipe().unwrap();
485+
let (stdin_read, stdin_write) = t!(sys::pipe::anon_pipe());
486+
let (stdout_read, stdout_write) = t!(sys::pipe::anon_pipe());
478487

479488
let mut set: c::sigset_t = mem::uninitialized();
480489
let mut old_set: c::sigset_t = mem::uninitialized();
481-
cvt(c::sigemptyset(&mut set)).unwrap();
482-
cvt(sigaddset(&mut set, libc::SIGINT)).unwrap();
483-
cvt(c::pthread_sigmask(c::SIG_SETMASK, &set, &mut old_set)).unwrap();
490+
t!(cvt(c::sigemptyset(&mut set)));
491+
t!(cvt(sigaddset(&mut set, libc::SIGINT)));
492+
t!(cvt(c::pthread_sigmask(c::SIG_SETMASK, &set, &mut old_set)));
484493

485-
let cat = Process::spawn(&cmd, Stdio::Raw(stdin_read.raw()),
486-
Stdio::Raw(stdout_write.raw()),
487-
Stdio::None).unwrap();
494+
let cat = t!(Process::spawn(&cmd, Stdio::Raw(stdin_read.raw()),
495+
Stdio::Raw(stdout_write.raw()),
496+
Stdio::None));
488497
drop(stdin_read);
489498
drop(stdout_write);
490499

491-
cvt(c::pthread_sigmask(c::SIG_SETMASK, &old_set, ptr::null_mut())).unwrap();
500+
t!(cvt(c::pthread_sigmask(c::SIG_SETMASK, &old_set,
501+
ptr::null_mut())));
492502

493-
cvt(libc::funcs::posix88::signal::kill(cat.id() as libc::pid_t, libc::SIGINT)).unwrap();
503+
t!(cvt(libc::funcs::posix88::signal::kill(cat.id() as libc::pid_t,
504+
libc::SIGINT)));
494505
// We need to wait until SIGINT is definitely delivered. The
495506
// easiest way is to write something to cat, and try to read it
496507
// back: if SIGINT is unmasked, it'll get delivered when cat is
@@ -504,7 +515,7 @@ mod tests {
504515
assert!(ret == 0);
505516
}
506517

507-
cat.wait().unwrap();
518+
t!(cat.wait());
508519
}
509520
}
510521
}

src/rustllvm/RustWrapper.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -951,10 +951,5 @@ LLVMRustBuildLandingPad(LLVMBuilderRef Builder,
951951
unsigned NumClauses,
952952
const char* Name,
953953
LLVMValueRef F) {
954-
#if LLVM_VERSION_MINOR >= 7
955-
unwrap<Function>(F)->setPersonalityFn(unwrap<Constant>(PersFn));
956-
return LLVMBuildLandingPad(Builder, Ty, NumClauses, Name);
957-
#else
958954
return LLVMBuildLandingPad(Builder, Ty, PersFn, NumClauses, Name);
959-
#endif
960955
}

src/test/run-pass/core-run-destroy.rs

+17-19
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,25 @@ macro_rules! t {
3030
($e:expr) => (match $e { Ok(e) => e, Err(e) => panic!("error: {}", e) })
3131
}
3232

33+
#[test]
3334
fn test_destroy_once() {
3435
let mut p = sleeper();
35-
match p.kill() {
36-
Ok(()) => {}
37-
Err(e) => panic!("error: {}", e),
38-
}
36+
t!(p.kill());
3937
}
4038

4139
#[cfg(unix)]
4240
pub fn sleeper() -> Child {
43-
Command::new("sleep").arg("1000").spawn().unwrap()
41+
t!(Command::new("sleep").arg("1000").spawn())
4442
}
4543
#[cfg(windows)]
4644
pub fn sleeper() -> Child {
4745
// There's a `timeout` command on windows, but it doesn't like having
4846
// its output piped, so instead just ping ourselves a few times with
4947
// gaps in between so we're sure this process is alive for awhile
50-
Command::new("ping").arg("127.0.0.1").arg("-n").arg("1000").spawn().unwrap()
48+
t!(Command::new("ping").arg("127.0.0.1").arg("-n").arg("1000").spawn())
5149
}
5250

51+
#[test]
5352
fn test_destroy_twice() {
5453
let mut p = sleeper();
5554
t!(p.kill()); // this shouldn't crash...
@@ -58,21 +57,20 @@ fn test_destroy_twice() {
5857

5958
#[test]
6059
fn test_destroy_actually_kills() {
61-
#[cfg(all(unix,not(target_os="android")))]
62-
static BLOCK_COMMAND: &'static str = "cat";
63-
64-
#[cfg(all(unix,target_os="android"))]
65-
static BLOCK_COMMAND: &'static str = "/system/bin/cat";
66-
67-
#[cfg(windows)]
68-
static BLOCK_COMMAND: &'static str = "cmd";
60+
let cmd = if cfg!(windows) {
61+
"cmd"
62+
} else if cfg!(target_os = "android") {
63+
"/system/bin/cat"
64+
} else {
65+
"cat"
66+
};
6967

7068
// this process will stay alive indefinitely trying to read from stdin
71-
let mut p = Command::new(BLOCK_COMMAND)
72-
.stdin(Stdio::piped())
73-
.spawn().unwrap();
69+
let mut p = t!(Command::new(cmd)
70+
.stdin(Stdio::piped())
71+
.spawn());
7472

75-
p.kill().unwrap();
73+
t!(p.kill());
7674

7775
// Don't let this test time out, this should be quick
7876
let (tx, rx) = channel();
@@ -82,7 +80,7 @@ fn test_destroy_actually_kills() {
8280
process::exit(1);
8381
}
8482
});
85-
let code = p.wait().unwrap().code();
83+
let code = t!(p.wait()).code();
8684
if cfg!(windows) {
8785
assert!(code.is_some());
8886
} else {

0 commit comments

Comments
 (0)