Skip to content

Commit

Permalink
Rollup merge of #39400 - alexcrichton:arm-cross-test, r=brson
Browse files Browse the repository at this point in the history
Add support for test suites emulated in QEMU

This commit adds support to the build system to execute test suites that cannot
run natively but can instead run inside of a QEMU emulator. A proof-of-concept
builder was added for the `arm-unknown-linux-gnueabihf` target to show off how
this might work.

In general the architecture is to have a server running inside of the emulator
which a local client connects to. The protocol between the server/client
supports compiling tests on the host and running them on the target inside the
emulator.

Closes #33114
  • Loading branch information
frewsxcv authored Feb 8, 2017
2 parents ce1ad41 + a0151b6 commit ab9a1a4
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ pub struct Config {
// Print one character per test instead of one line
pub quiet: bool,

// where to find the qemu test client process, if we're using it
pub qemu_test_client: Option<PathBuf>,

// Configuration for various run-make tests frobbing things like C compilers
// or querying about various LLVM component information.
pub cc: String,
Expand Down
10 changes: 10 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ pub fn parse_config(args: Vec<String> ) -> Config {
reqopt("", "llvm-components", "list of LLVM components built in", "LIST"),
reqopt("", "llvm-cxxflags", "C++ flags for LLVM", "FLAGS"),
optopt("", "nodejs", "the name of nodejs", "PATH"),
optopt("", "qemu-test-client", "path to the qemu test client", "PATH"),
optflag("h", "help", "show this message")];

let (argv0, args_) = args.split_first().unwrap();
Expand Down Expand Up @@ -196,6 +197,7 @@ pub fn parse_config(args: Vec<String> ) -> Config {
lldb_python_dir: matches.opt_str("lldb-python-dir"),
verbose: matches.opt_present("verbose"),
quiet: matches.opt_present("quiet"),
qemu_test_client: matches.opt_str("qemu-test-client").map(PathBuf::from),

cc: matches.opt_str("cc").unwrap(),
cxx: matches.opt_str("cxx").unwrap(),
Expand Down Expand Up @@ -302,6 +304,14 @@ pub fn run_tests(config: &Config) {
// time.
env::set_var("RUST_TEST_THREADS", "1");
}

DebugInfoGdb => {
if config.qemu_test_client.is_some() {
println!("WARNING: debuginfo tests are not available when \
testing with QEMU");
return
}
}
_ => { /* proceed */ }
}

Expand Down
40 changes: 39 additions & 1 deletion src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,45 @@ actual:\n\
"arm-linux-androideabi" | "armv7-linux-androideabi" | "aarch64-linux-android" => {
self._arm_exec_compiled_test(env)
}
_=> {

// This is pretty similar to below, we're transforming:
//
// program arg1 arg2
//
// into
//
// qemu-test-client run program:support-lib.so arg1 arg2
//
// The test-client program will upload `program` to the emulator
// along with all other support libraries listed (in this case
// `support-lib.so`. It will then execute the program on the
// emulator with the arguments specified (in the environment we give
// the process) and then report back the same result.
_ if self.config.qemu_test_client.is_some() => {
let aux_dir = self.aux_output_dir_name();
let mut args = self.make_run_args();
let mut program = args.prog.clone();
if let Ok(entries) = aux_dir.read_dir() {
for entry in entries {
let entry = entry.unwrap();
if !entry.path().is_file() {
continue
}
program.push_str(":");
program.push_str(entry.path().to_str().unwrap());
}
}
args.args.insert(0, program);
args.args.insert(0, "run".to_string());
args.prog = self.config.qemu_test_client.clone().unwrap()
.into_os_string().into_string().unwrap();
self.compose_and_run(args,
env,
self.config.run_lib_path.to_str().unwrap(),
Some(aux_dir.to_str().unwrap()),
None)
}
_ => {
let aux_dir = self.aux_output_dir_name();
self.compose_and_run(self.make_run_args(),
env,
Expand Down

0 comments on commit ab9a1a4

Please sign in to comment.