Skip to content

Commit

Permalink
Auto merge of #21774 - ejjeong:enable-test-for-android, r=alexcrichton
Browse files Browse the repository at this point in the history
- Now "make check-stage2-T-aarch64-linux-android-H-x86_64-unknown-linux-gnu" works (#21773)
- Fix & enable debuginfo tests for android (#10381)
- Fix & enable more tests for android (both for arm/aarch64)
- Enable many already-pass tests on android (both for arm/aarch64)
  • Loading branch information
bors committed Feb 17, 2015
2 parents f9aeea7 + 194d96e commit 6c065fc
Show file tree
Hide file tree
Showing 114 changed files with 91 additions and 156 deletions.
12 changes: 7 additions & 5 deletions mk/install.mk
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,13 @@ tmp/empty_dir:
# Android runtime setup
# FIXME: This probably belongs somewhere else

# target platform specific variables
# for arm-linux-androidabi
# target platform specific variables for android
define DEF_ADB_DEVICE_STATUS
CFG_ADB_DEVICE_STATUS=$(1)
endef

$(foreach target,$(CFG_TARGET), \
$(if $(findstring $(target),"arm-linux-androideabi"), \
$(if $(findstring android, $(target)), \
$(if $(findstring adb,$(CFG_ADB)), \
$(if $(findstring device,$(shell $(CFG_ADB) devices 2>/dev/null | grep -E '^[_A-Za-z0-9-]+[[:blank:]]+device')), \
$(info install: install-runtime-target for $(target) enabled \
Expand Down Expand Up @@ -117,8 +116,11 @@ install-runtime-target-$(1)-cleanup:
$$(call ADB_SHELL,rm,$$(CFG_RUNTIME_PUSH_DIR)/$$(call CFG_LIB_GLOB_$(1),$$(crate)));)
endef

$(eval $(call INSTALL_RUNTIME_TARGET_N,arm-linux-androideabi,$(CFG_BUILD)))
$(eval $(call INSTALL_RUNTIME_TARGET_CLEANUP_N,arm-linux-androideabi))
$(foreach target,$(CFG_TARGET), \
$(if $(findstring $(CFG_ADB_DEVICE_STATUS),"true"), \
$(eval $(call INSTALL_RUNTIME_TARGET_N,$(taget),$(CFG_BUILD))) \
$(eval $(call INSTALL_RUNTIME_TARGET_CLEANUP_N,$(target))) \
))

install-runtime-target: \
install-runtime-target-arm-linux-androideabi-cleanup \
Expand Down
4 changes: 1 addition & 3 deletions mk/rt.mk
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,7 @@ ifeq ($$(CFG_WINDOWSY_$(1)), 1)
JEMALLOC_ARGS_$(1) := --enable-lazy-lock
else ifeq ($(OSTYPE_$(1)), apple-ios)
JEMALLOC_ARGS_$(1) := --disable-tls
else ifeq ($(OSTYPE_$(1)), linux-androideabi)
JEMALLOC_ARGS_$(1) := --disable-tls
else ifeq ($(OSTYPE_$(1)), linux-android)
else ifeq ($(findstring android, $(OSTYPE_$(1))), android)
JEMALLOC_ARGS_$(1) := --disable-tls
endif

Expand Down
25 changes: 13 additions & 12 deletions mk/tests.mk
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,13 @@ endef
$(foreach target,$(CFG_TARGET), \
$(eval $(call DEF_TARGET_COMMANDS,$(target))))

# Target platform specific variables
# for arm-linux-androidabi
# Target platform specific variables for android
define DEF_ADB_DEVICE_STATUS
CFG_ADB_DEVICE_STATUS=$(1)
endef

$(foreach target,$(CFG_TARGET), \
$(if $(findstring $(target),"arm-linux-androideabi"), \
$(if $(findstring android, $(target)), \
$(if $(findstring adb,$(CFG_ADB)), \
$(if $(findstring device,$(shell $(CFG_ADB) devices 2>/dev/null | grep -E '^[:_A-Za-z0-9-]+[[:blank:]]+device')), \
$(info check: android device attached) \
Expand All @@ -135,12 +134,14 @@ $(info check: android device test dir $(CFG_ADB_TEST_DIR) ready \
$(shell $(CFG_ADB) remount 1>/dev/null) \
$(shell $(CFG_ADB) shell rm -r $(CFG_ADB_TEST_DIR) >/dev/null) \
$(shell $(CFG_ADB) shell mkdir $(CFG_ADB_TEST_DIR)) \
$(shell $(CFG_ADB) shell mkdir $(CFG_ADB_TEST_DIR)/tmp) \
$(shell $(CFG_ADB) push $(S)src/etc/adb_run_wrapper.sh $(CFG_ADB_TEST_DIR) 1>/dev/null) \
$(foreach crate,$(TARGET_CRATES), \
$(shell $(CFG_ADB) push $(TLIB2_T_arm-linux-androideabi_H_$(CFG_BUILD))/$(call CFG_LIB_GLOB_arm-linux-androideabi,$(crate)) \
$(CFG_ADB_TEST_DIR))) \
)
$(foreach target,$(CFG_TARGET), \
$(if $(findstring android, $(target)), \
$(shell $(CFG_ADB) shell mkdir $(CFG_ADB_TEST_DIR)/$(target)) \
$(foreach crate,$(TARGET_CRATES), \
$(shell $(CFG_ADB) push $(TLIB2_T_$(target)_H_$(CFG_BUILD))/$(call CFG_LIB_GLOB_$(target),$(crate)) \
$(CFG_ADB_TEST_DIR)/$(target))), \
)))
else
CFG_ADB_TEST_DIR=
endif
Expand Down Expand Up @@ -393,14 +394,14 @@ $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
&& touch $$@
endef

define DEF_TEST_CRATE_RULES_arm-linux-androideabi
define DEF_TEST_CRATE_RULES_android
check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))

$$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
$(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2))
@$$(call E, run: $$< via adb)
$$(Q)$(CFG_ADB) push $$< $(CFG_ADB_TEST_DIR)
$$(Q)$(CFG_ADB) shell '(cd $(CFG_ADB_TEST_DIR); LD_LIBRARY_PATH=. \
$$(Q)$(CFG_ADB) shell '(cd $(CFG_ADB_TEST_DIR); LD_LIBRARY_PATH=./$(2) \
./$$(notdir $$<) \
--logfile $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log \
$$(call CRATE_TEST_EXTRA_ARGS,$(1),$(2),$(3),$(4)) $(TESTARGS))' \
Expand Down Expand Up @@ -434,9 +435,9 @@ $(foreach host,$(CFG_HOST), \
$(foreach crate, $(TEST_CRATES), \
$(if $(findstring $(target),$(CFG_BUILD)), \
$(eval $(call DEF_TEST_CRATE_RULES,$(stage),$(target),$(host),$(crate))), \
$(if $(findstring $(target),"arm-linux-androideabi"), \
$(if $(findstring android, $(target)), \
$(if $(findstring $(CFG_ADB_DEVICE_STATUS),"true"), \
$(eval $(call DEF_TEST_CRATE_RULES_arm-linux-androideabi,$(stage),$(target),$(host),$(crate))), \
$(eval $(call DEF_TEST_CRATE_RULES_android,$(stage),$(target),$(host),$(crate))), \
$(eval $(call DEF_TEST_CRATE_RULES_null,$(stage),$(target),$(host),$(crate))) \
), \
$(eval $(call DEF_TEST_CRATE_RULES,$(stage),$(target),$(host),$(crate))) \
Expand Down
20 changes: 10 additions & 10 deletions src/compiletest/compiletest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,12 @@ pub fn parse_config(args: Vec<String> ) -> Config {
lldb_version: extract_lldb_version(matches.opt_str("lldb-version")),
android_cross_path: opt_path(matches, "android-cross-path"),
adb_path: opt_str2(matches.opt_str("adb-path")),
adb_test_dir: opt_str2(matches.opt_str("adb-test-dir")),
adb_test_dir: format!("{}/{}",
opt_str2(matches.opt_str("adb-test-dir")),
opt_str2(matches.opt_str("target"))),
adb_device_status:
"arm-linux-androideabi" ==
opt_str2(matches.opt_str("target")) &&
"(none)" !=
opt_str2(matches.opt_str("adb-test-dir")) &&
opt_str2(matches.opt_str("target")).contains("android") &&
"(none)" != opt_str2(matches.opt_str("adb-test-dir")) &&
!opt_str2(matches.opt_str("adb-test-dir")).is_empty(),
lldb_python_dir: matches.opt_str("lldb-python-dir"),
verbose: matches.opt_present("verbose"),
Expand Down Expand Up @@ -213,17 +213,17 @@ pub fn opt_str2(maybestr: Option<String>) -> String {
}

pub fn run_tests(config: &Config) {
if config.target == "arm-linux-androideabi" {
if config.target.contains("android") {
match config.mode {
DebugInfoGdb => {
println!("arm-linux-androideabi debug-info \
test uses tcp 5039 port. please reserve it");
println!("{} debug-info test uses tcp 5039 port.\
please reserve it", config.target);
}
_ =>{}
}

//arm-linux-androideabi debug-info test uses remote debugger
//so, we test 1 task at once.
// android debug-info test uses remote debugger
// so, we test 1 task at once.
// also trying to isolate problems with adb_run_wrapper.sh ilooping
env::set_var("RUST_TEST_TASKS","1");
}
Expand Down
47 changes: 30 additions & 17 deletions src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use test::MetricMap;
pub fn run(config: Config, testfile: String) {
match &*config.target {

"arm-linux-androideabi" => {
"arm-linux-androideabi" | "aarch64-linux-android" => {
if !config.adb_device_status {
panic!("android device not available");
}
Expand Down Expand Up @@ -382,17 +382,26 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {

let debugger_run_result;
match &*config.target {
"arm-linux-androideabi" => {
"arm-linux-androideabi" | "aarch64-linux-android" => {

cmds = cmds.replace("run", "continue").to_string();
cmds = cmds.replace("run", "continue");

// write debugger script
let script_str = ["set charset UTF-8".to_string(),
format!("file {}", exe_file.as_str().unwrap()
.to_string()),
"target remote :5039".to_string(),
cmds,
"quit".to_string()].connect("\n");
let mut script_str = String::with_capacity(2048);
script_str.push_str("set charset UTF-8\n");
script_str.push_str(&format!("file {}\n", exe_file.as_str().unwrap()));
script_str.push_str("target remote :5039\n");
script_str.push_str(&format!("set solib-search-path \
./{}/stage2/lib/rustlib/{}/lib/\n",
config.host, config.target));
for line in breakpoint_lines.iter() {
script_str.push_str(&format!("break {:?}:{}\n",
testfile.filename_display(),
*line)[]);
}
script_str.push_str(&cmds);
script_str.push_str("quit\n");

debug!("script_str = {}", script_str);
dump_output_file(config,
testfile,
Expand Down Expand Up @@ -425,8 +434,10 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
.expect(&format!("failed to exec `{:?}`", config.adb_path));

let adb_arg = format!("export LD_LIBRARY_PATH={}; \
gdbserver :5039 {}/{}",
gdbserver{} :5039 {}/{}",
config.adb_test_dir.clone(),
if config.target.contains("aarch64")
{"64"} else {""},
config.adb_test_dir.clone(),
str::from_utf8(
exe_file.filename()
Expand Down Expand Up @@ -470,7 +481,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
format!("-command={}", debugger_script.as_str().unwrap()));

let mut gdb_path = tool_path;
gdb_path.push_str("/bin/arm-linux-androideabi-gdb");
gdb_path.push_str(&format!("/bin/{}-gdb", config.target));
let procsrv::Result {
out,
err,
Expand All @@ -484,7 +495,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
.expect(&format!("failed to exec `{:?}`", gdb_path));
let cmdline = {
let cmdline = make_cmdline("",
"arm-linux-androideabi-gdb",
&format!("{}-gdb", config.target),
&debugger_opts);
logv(config, format!("executing {}", cmdline));
cmdline
Expand All @@ -496,7 +507,9 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
stderr: err,
cmdline: cmdline
};
process.signal_kill().unwrap();
if process.signal_kill().is_err() {
println!("Adb process is already finished.");
}
}

_=> {
Expand Down Expand Up @@ -1135,7 +1148,7 @@ fn exec_compiled_test(config: &Config, props: &TestProps,

match &*config.target {

"arm-linux-androideabi" => {
"arm-linux-androideabi" | "aarch64-linux-android" => {
_arm_exec_compiled_test(config, props, testfile, env)
}

Expand Down Expand Up @@ -1200,7 +1213,7 @@ fn compose_and_run_compiler(
}

match &*config.target {
"arm-linux-androideabi" => {
"arm-linux-androideabi" | "aarch64-linux-android" => {
_arm_push_aux_shared_library(config, testfile);
}
_ => {}
Expand Down Expand Up @@ -1499,7 +1512,7 @@ fn _arm_exec_compiled_test(config: &Config,
for (key, val) in env {
runargs.push(format!("{}={}", key, val));
}
runargs.push(format!("{}/adb_run_wrapper.sh", config.adb_test_dir));
runargs.push(format!("{}/../adb_run_wrapper.sh", config.adb_test_dir));
runargs.push(format!("{}", config.adb_test_dir));
runargs.push(format!("{}", prog_short));

Expand Down Expand Up @@ -1595,7 +1608,7 @@ fn _arm_push_aux_shared_library(config: &Config, testfile: &Path) {
file.as_str()
.unwrap()
.to_string(),
config.adb_test_dir.to_string()
config.adb_test_dir.to_string(),
],
vec!(("".to_string(),
"".to_string())),
Expand Down
3 changes: 2 additions & 1 deletion src/etc/adb_run_wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ then
then
shift

# The length of binary path (i.e. ./$RUN) should be shorter than 128 characters.
cd $TEST_PATH
TEST_EXEC_ENV=22 LD_LIBRARY_PATH=$TEST_PATH PATH=$BIN_PATH:$TEST_PATH $TEST_PATH/$RUN $@ 1>$TEST_PATH/$RUN.stdout 2>$TEST_PATH/$RUN.stderr
TEST_EXEC_ENV=22 LD_LIBRARY_PATH=$TEST_PATH PATH=$BIN_PATH:$TEST_PATH ./$RUN $@ 1>$TEST_PATH/$RUN.stdout 2>$TEST_PATH/$RUN.stderr
L_RET=$?

echo $L_RET > $TEST_PATH/$RUN.exitcode
Expand Down
1 change: 1 addition & 0 deletions src/liblibc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5473,6 +5473,7 @@ pub mod funcs {
use types::os::arch::c95::{c_uchar, c_int, size_t};

extern {
#[cfg(not(all(target_os = "android", target_arch = "aarch64")))]
pub fn getdtablesize() -> c_int;
pub fn ioctl(d: c_int, request: c_int, ...) -> c_int;
pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int)
Expand Down
1 change: 1 addition & 0 deletions src/librustc_back/target/aarch64_linux_android.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use target::Target;
pub fn target() -> Target {
let mut base = super::linux_base::opts();
base.pre_link_args.push("-Wl,--allow-multiple-definition".to_string());
base.is_like_android = true;
base.position_independent_executables = true;
Target {
data_layout: "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
Expand Down
1 change: 1 addition & 0 deletions src/librustc_back/target/arm_linux_androideabi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub fn target() -> Target {
// Many of the symbols defined in compiler-rt are also defined in libgcc. Android
// linker doesn't like that by default.
base.pre_link_args.push("-Wl,--allow-multiple-definition".to_string());
base.is_like_android = true;
// FIXME #17437 (and #17448): Android doesn't support position dependent executables anymore.
base.position_independent_executables = false;

Expand Down
9 changes: 7 additions & 2 deletions src/librustc_back/target/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ pub struct TargetOptions {
/// only realy used for figuring out how to find libraries, since Windows uses its own
/// library naming convention. Defaults to false.
pub is_like_windows: bool,
/// Whether the target toolchain is like Android's. Only useful for compiling against Android.
/// Defaults to false.
pub is_like_android: bool,
/// Whether the linker support GNU-like arguments such as -O. Defaults to false.
pub linker_is_gnu: bool,
/// Whether the linker support rpaths or not. Defaults to false.
Expand Down Expand Up @@ -197,6 +200,7 @@ impl Default for TargetOptions {
staticlib_suffix: ".a".to_string(),
is_like_osx: false,
is_like_windows: false,
is_like_android: false,
linker_is_gnu: false,
has_rpath: false,
no_compiler_rt: false,
Expand Down Expand Up @@ -345,11 +349,13 @@ impl Target {
mips_unknown_linux_gnu,
mipsel_unknown_linux_gnu,
powerpc_unknown_linux_gnu,
arm_linux_androideabi,
arm_unknown_linux_gnueabi,
arm_unknown_linux_gnueabihf,
aarch64_unknown_linux_gnu,

arm_linux_androideabi,
aarch64_linux_android,

x86_64_unknown_freebsd,

i686_unknown_dragonfly,
Expand All @@ -363,7 +369,6 @@ impl Target {
i386_apple_ios,
x86_64_apple_ios,
aarch64_apple_ios,
aarch64_linux_android,
armv7_apple_ios,
armv7s_apple_ios,

Expand Down
4 changes: 3 additions & 1 deletion src/librustc_trans/trans/debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,9 @@ pub fn finalize(cx: &CrateContext) {
// instruct LLVM to emit an older version of dwarf, however,
// for OS X to understand. For more info see #11352
// This can be overridden using --llvm-opts -dwarf-version,N.
if cx.sess().target.target.options.is_like_osx {
// Android has the same issue (#22398)
if cx.sess().target.target.options.is_like_osx ||
cx.sess().target.target.options.is_like_android {
llvm::LLVMRustAddModuleFlag(cx.llmod(),
"Dwarf Version\0".as_ptr() as *const _,
2)
Expand Down
10 changes: 9 additions & 1 deletion src/libstd/sys/unix/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,22 @@ impl Process {
K: BytesContainer + Eq + Hash<Hasher>, V: BytesContainer
{
use libc::funcs::posix88::unistd::{fork, dup2, close, chdir, execvp};
use libc::funcs::bsd44::getdtablesize;

mod rustrt {
extern {
pub fn rust_unset_sigprocmask();
}
}

#[cfg(all(target_os = "android", target_arch = "aarch64"))]
unsafe fn getdtablesize() -> c_int {
libc::sysconf(libc::consts::os::sysconf::_SC_OPEN_MAX) as c_int
}
#[cfg(not(all(target_os = "android", target_arch = "aarch64")))]
unsafe fn getdtablesize() -> c_int {
libc::funcs::bsd44::getdtablesize()
}

unsafe fn set_cloexec(fd: c_int) {
let ret = c::ioctl(fd, c::FIOCLEX);
assert_eq!(ret, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

// aux-build:macro_crate_test.rs
// ignore-stage1
// ignore-android
// error-pattern: unknown start of token: \u{0}

// Issue #15750 and #15962 : this test is checking that the standard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

// aux-build:macro_crate_test.rs
// ignore-stage1
// ignore-android

#[macro_use] #[no_link]
extern crate macro_crate_test;
Expand Down
Loading

0 comments on commit 6c065fc

Please sign in to comment.