Skip to content

Commit 9fd1a97

Browse files
committed
Auto merge of #21774 - ejjeong:enable-test-for-android, r=alexcrichton
- 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)
2 parents 3ae76d5 + 49a520c commit 9fd1a97

File tree

111 files changed

+85
-153
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+85
-153
lines changed

mk/install.mk

+7-5
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,13 @@ tmp/empty_dir:
5858
# Android runtime setup
5959
# FIXME: This probably belongs somewhere else
6060

61-
# target platform specific variables
62-
# for arm-linux-androidabi
61+
# target platform specific variables for android
6362
define DEF_ADB_DEVICE_STATUS
6463
CFG_ADB_DEVICE_STATUS=$(1)
6564
endef
6665

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

120-
$(eval $(call INSTALL_RUNTIME_TARGET_N,arm-linux-androideabi,$(CFG_BUILD)))
121-
$(eval $(call INSTALL_RUNTIME_TARGET_CLEANUP_N,arm-linux-androideabi))
119+
$(foreach target,$(CFG_TARGET), \
120+
$(if $(findstring $(CFG_ADB_DEVICE_STATUS),"true"), \
121+
$(eval $(call INSTALL_RUNTIME_TARGET_N,$(taget),$(CFG_BUILD))) \
122+
$(eval $(call INSTALL_RUNTIME_TARGET_CLEANUP_N,$(target))) \
123+
))
122124

123125
install-runtime-target: \
124126
install-runtime-target-arm-linux-androideabi-cleanup \

mk/rt.mk

+1-3
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,7 @@ ifeq ($$(CFG_WINDOWSY_$(1)), 1)
139139
JEMALLOC_ARGS_$(1) := --enable-lazy-lock
140140
else ifeq ($(OSTYPE_$(1)), apple-ios)
141141
JEMALLOC_ARGS_$(1) := --disable-tls
142-
else ifeq ($(OSTYPE_$(1)), linux-androideabi)
143-
JEMALLOC_ARGS_$(1) := --disable-tls
144-
else ifeq ($(OSTYPE_$(1)), linux-android)
142+
else ifeq ($(findstring android, $(OSTYPE_$(1))), android)
145143
JEMALLOC_ARGS_$(1) := --disable-tls
146144
endif
147145

mk/tests.mk

+13-12
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,13 @@ endef
107107
$(foreach target,$(CFG_TARGET), \
108108
$(eval $(call DEF_TARGET_COMMANDS,$(target))))
109109

110-
# Target platform specific variables
111-
# for arm-linux-androidabi
110+
# Target platform specific variables for android
112111
define DEF_ADB_DEVICE_STATUS
113112
CFG_ADB_DEVICE_STATUS=$(1)
114113
endef
115114

116115
$(foreach target,$(CFG_TARGET), \
117-
$(if $(findstring $(target),"arm-linux-androideabi"), \
116+
$(if $(findstring android, $(target)), \
118117
$(if $(findstring adb,$(CFG_ADB)), \
119118
$(if $(findstring device,$(shell $(CFG_ADB) devices 2>/dev/null | grep -E '^[:_A-Za-z0-9-]+[[:blank:]]+device')), \
120119
$(info check: android device attached) \
@@ -135,12 +134,14 @@ $(info check: android device test dir $(CFG_ADB_TEST_DIR) ready \
135134
$(shell $(CFG_ADB) remount 1>/dev/null) \
136135
$(shell $(CFG_ADB) shell rm -r $(CFG_ADB_TEST_DIR) >/dev/null) \
137136
$(shell $(CFG_ADB) shell mkdir $(CFG_ADB_TEST_DIR)) \
138-
$(shell $(CFG_ADB) shell mkdir $(CFG_ADB_TEST_DIR)/tmp) \
139137
$(shell $(CFG_ADB) push $(S)src/etc/adb_run_wrapper.sh $(CFG_ADB_TEST_DIR) 1>/dev/null) \
140-
$(foreach crate,$(TARGET_CRATES), \
141-
$(shell $(CFG_ADB) push $(TLIB2_T_arm-linux-androideabi_H_$(CFG_BUILD))/$(call CFG_LIB_GLOB_arm-linux-androideabi,$(crate)) \
142-
$(CFG_ADB_TEST_DIR))) \
143-
)
138+
$(foreach target,$(CFG_TARGET), \
139+
$(if $(findstring android, $(target)), \
140+
$(shell $(CFG_ADB) shell mkdir $(CFG_ADB_TEST_DIR)/$(target)) \
141+
$(foreach crate,$(TARGET_CRATES), \
142+
$(shell $(CFG_ADB) push $(TLIB2_T_$(target)_H_$(CFG_BUILD))/$(call CFG_LIB_GLOB_$(target),$(crate)) \
143+
$(CFG_ADB_TEST_DIR)/$(target))), \
144+
)))
144145
else
145146
CFG_ADB_TEST_DIR=
146147
endif
@@ -420,14 +421,14 @@ $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
420421
&& touch $$@
421422
endef
422423

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

426427
$$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
427428
$(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2))
428429
@$$(call E, run: $$< via adb)
429430
$$(Q)$(CFG_ADB) push $$< $(CFG_ADB_TEST_DIR)
430-
$$(Q)$(CFG_ADB) shell '(cd $(CFG_ADB_TEST_DIR); LD_LIBRARY_PATH=. \
431+
$$(Q)$(CFG_ADB) shell '(cd $(CFG_ADB_TEST_DIR); LD_LIBRARY_PATH=./$(2) \
431432
./$$(notdir $$<) \
432433
--logfile $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log \
433434
$$(call CRATE_TEST_EXTRA_ARGS,$(1),$(2),$(3),$(4)) $(TESTARGS))' \
@@ -461,9 +462,9 @@ $(foreach host,$(CFG_HOST), \
461462
$(foreach crate, $(TEST_CRATES), \
462463
$(if $(findstring $(target),$(CFG_BUILD)), \
463464
$(eval $(call DEF_TEST_CRATE_RULES,$(stage),$(target),$(host),$(crate))), \
464-
$(if $(findstring $(target),"arm-linux-androideabi"), \
465+
$(if $(findstring android, $(target)), \
465466
$(if $(findstring $(CFG_ADB_DEVICE_STATUS),"true"), \
466-
$(eval $(call DEF_TEST_CRATE_RULES_arm-linux-androideabi,$(stage),$(target),$(host),$(crate))), \
467+
$(eval $(call DEF_TEST_CRATE_RULES_android,$(stage),$(target),$(host),$(crate))), \
467468
$(eval $(call DEF_TEST_CRATE_RULES_null,$(stage),$(target),$(host),$(crate))) \
468469
), \
469470
$(eval $(call DEF_TEST_CRATE_RULES,$(stage),$(target),$(host),$(crate))) \

src/compiletest/compiletest.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,10 @@ pub fn parse_config(args: Vec<String> ) -> Config {
155155
adb_path: opt_str2(matches.opt_str("adb-path")),
156156
adb_test_dir: opt_str2(matches.opt_str("adb-test-dir")),
157157
adb_device_status:
158-
"arm-linux-androideabi" ==
159-
opt_str2(matches.opt_str("target")).as_slice() &&
158+
("arm-linux-androideabi" ==
159+
opt_str2(matches.opt_str("target")).as_slice() ||
160+
"aarch64-linux-android" ==
161+
opt_str2(matches.opt_str("target")).as_slice()) &&
160162
"(none)" !=
161163
opt_str2(matches.opt_str("adb-test-dir")).as_slice() &&
162164
!opt_str2(matches.opt_str("adb-test-dir")).is_empty(),
@@ -213,17 +215,18 @@ pub fn opt_str2(maybestr: Option<String>) -> String {
213215
}
214216

215217
pub fn run_tests(config: &Config) {
216-
if config.target.as_slice() == "arm-linux-androideabi" {
218+
if config.target.as_slice() == "arm-linux-androideabi" ||
219+
config.target.as_slice() == "aarch64-linux-android" {
217220
match config.mode {
218221
DebugInfoGdb => {
219-
println!("arm-linux-androideabi debug-info \
220-
test uses tcp 5039 port. please reserve it");
222+
println!("{} debug-info test uses tcp 5039 port.\
223+
please reserve it", config.target);
221224
}
222225
_ =>{}
223226
}
224227

225-
//arm-linux-androideabi debug-info test uses remote debugger
226-
//so, we test 1 task at once.
228+
// android debug-info test uses remote debugger
229+
// so, we test 1 task at once.
227230
// also trying to isolate problems with adb_run_wrapper.sh ilooping
228231
env::set_var("RUST_TEST_TASKS","1");
229232
}

src/compiletest/runtest.rs

+30-17
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ use test::MetricMap;
4242
pub fn run(config: Config, testfile: String) {
4343
match config.target.as_slice() {
4444

45-
"arm-linux-androideabi" => {
45+
"arm-linux-androideabi" | "aarch64-linux-android" => {
4646
if !config.adb_device_status {
4747
panic!("android device not available");
4848
}
@@ -383,17 +383,23 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
383383

384384
let debugger_run_result;
385385
match config.target.as_slice() {
386-
"arm-linux-androideabi" => {
386+
"arm-linux-androideabi" | "aarch64-linux-android" => {
387387

388-
cmds = cmds.replace("run", "continue").to_string();
388+
cmds = cmds.replace("run", "continue");
389389

390390
// write debugger script
391-
let script_str = ["set charset UTF-8".to_string(),
392-
format!("file {}", exe_file.as_str().unwrap()
393-
.to_string()),
394-
"target remote :5039".to_string(),
395-
cmds,
396-
"quit".to_string()].connect("\n");
391+
let mut script_str = String::with_capacity(2048);
392+
script_str.push_str("set charset UTF-8\n");
393+
script_str.push_str(format!("file {}\n", exe_file.as_str().unwrap()).as_slice());
394+
script_str.push_str("target remote :5039\n");
395+
for line in breakpoint_lines.iter() {
396+
script_str.push_str(&format!("break {:?}:{}\n",
397+
testfile.filename_display(),
398+
*line)[]);
399+
}
400+
script_str.push_str(cmds.as_slice());
401+
script_str.push_str("quit\n");
402+
397403
debug!("script_str = {}", script_str);
398404
dump_output_file(config,
399405
testfile,
@@ -425,10 +431,14 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
425431
Some("".to_string()))
426432
.expect(format!("failed to exec `{:?}`", config.adb_path).as_slice());
427433

428-
let adb_arg = format!("export LD_LIBRARY_PATH={}; \
429-
gdbserver :5039 {}/{}",
434+
let adb_arg = format!("export LD_LIBRARY_PATH={}:{}/{}; \
435+
gdbserver{} :5039 {}/{}",
430436
config.adb_test_dir.clone(),
431437
config.adb_test_dir.clone(),
438+
config.target.clone(),
439+
if config.target.as_slice() == "aarch64-linux-android"
440+
{"64"} else {""},
441+
config.adb_test_dir.clone(),
432442
str::from_utf8(
433443
exe_file.filename()
434444
.unwrap()).unwrap());
@@ -471,7 +481,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
471481
format!("-command={}", debugger_script.as_str().unwrap()));
472482

473483
let mut gdb_path = tool_path;
474-
gdb_path.push_str("/bin/arm-linux-androideabi-gdb");
484+
gdb_path.push_str(format!("/bin/{}-gdb", config.target).as_slice());
475485
let procsrv::Result {
476486
out,
477487
err,
@@ -485,7 +495,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
485495
.expect(format!("failed to exec `{:?}`", gdb_path).as_slice());
486496
let cmdline = {
487497
let cmdline = make_cmdline("",
488-
"arm-linux-androideabi-gdb",
498+
format!("{}-gdb", config.target).as_slice(),
489499
debugger_opts.as_slice());
490500
logv(config, format!("executing {}", cmdline));
491501
cmdline
@@ -497,7 +507,9 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
497507
stderr: err,
498508
cmdline: cmdline
499509
};
500-
process.signal_kill().unwrap();
510+
if process.signal_kill().is_err() {
511+
println!("Adb process is already finished.");
512+
}
501513
}
502514

503515
_=> {
@@ -1141,7 +1153,7 @@ fn exec_compiled_test(config: &Config, props: &TestProps,
11411153

11421154
match config.target.as_slice() {
11431155

1144-
"arm-linux-androideabi" => {
1156+
"arm-linux-androideabi" | "aarch64-linux-android" => {
11451157
_arm_exec_compiled_test(config, props, testfile, env)
11461158
}
11471159

@@ -1206,7 +1218,7 @@ fn compose_and_run_compiler(
12061218
}
12071219

12081220
match config.target.as_slice() {
1209-
"arm-linux-androideabi" => {
1221+
"arm-linux-androideabi" | "aarch64-linux-android" => {
12101222
_arm_push_aux_shared_library(config, testfile);
12111223
}
12121224
_ => {}
@@ -1508,6 +1520,7 @@ fn _arm_exec_compiled_test(config: &Config,
15081520
}
15091521
runargs.push(format!("{}/adb_run_wrapper.sh", config.adb_test_dir));
15101522
runargs.push(format!("{}", config.adb_test_dir));
1523+
runargs.push(format!("{}", config.target));
15111524
runargs.push(format!("{}", prog_short));
15121525

15131526
for tv in &args.args {
@@ -1602,7 +1615,7 @@ fn _arm_push_aux_shared_library(config: &Config, testfile: &Path) {
16021615
file.as_str()
16031616
.unwrap()
16041617
.to_string(),
1605-
config.adb_test_dir.to_string()
1618+
config.adb_test_dir.to_string(),
16061619
],
16071620
vec!(("".to_string(),
16081621
"".to_string())),

src/etc/adb_run_wrapper.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@
1010
#
1111
# ignore-tidy-linelength
1212
#
13-
# usage : adb_run_wrapper [test dir - where test executables exist] [test executable]
13+
# usage : adb_run_wrapper [test dir - where test executables exist] [lib dir - where libraries exists] [test executable]
1414
#
1515

1616
TEST_PATH=$1
1717
BIN_PATH=/system/bin
1818
if [ -d "$TEST_PATH" ]
1919
then
20+
shift
21+
LIB_PATH=$1
2022
shift
2123
RUN=$1
2224

@@ -25,7 +27,7 @@ then
2527
shift
2628

2729
cd $TEST_PATH
28-
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
30+
TEST_EXEC_ENV=22 LD_LIBRARY_PATH=$TEST_PATH:$LIB_PATH PATH=$BIN_PATH:$TEST_PATH $TEST_PATH/$RUN $@ 1>$TEST_PATH/$RUN.stdout 2>$TEST_PATH/$RUN.stderr
2931
L_RET=$?
3032

3133
echo $L_RET > $TEST_PATH/$RUN.exitcode

src/liblibc/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -5473,6 +5473,7 @@ pub mod funcs {
54735473
use types::os::arch::c95::{c_uchar, c_int, size_t};
54745474

54755475
extern {
5476+
#[cfg(not(all(target_os = "android", target_arch = "aarch64")))]
54765477
pub fn getdtablesize() -> c_int;
54775478
pub fn ioctl(d: c_int, request: c_int, ...) -> c_int;
54785479
pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int)

src/librustc_back/target/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -345,11 +345,13 @@ impl Target {
345345
mips_unknown_linux_gnu,
346346
mipsel_unknown_linux_gnu,
347347
powerpc_unknown_linux_gnu,
348-
arm_linux_androideabi,
349348
arm_unknown_linux_gnueabi,
350349
arm_unknown_linux_gnueabihf,
351350
aarch64_unknown_linux_gnu,
352351

352+
arm_linux_androideabi,
353+
aarch64_linux_android,
354+
353355
x86_64_unknown_freebsd,
354356

355357
i686_unknown_dragonfly,
@@ -363,7 +365,6 @@ impl Target {
363365
i386_apple_ios,
364366
x86_64_apple_ios,
365367
aarch64_apple_ios,
366-
aarch64_linux_android,
367368
armv7_apple_ios,
368369
armv7s_apple_ios,
369370

src/libstd/sys/unix/process.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,23 @@ impl Process {
6464
K: BytesContainer + Eq + Hash<Hasher>, V: BytesContainer
6565
{
6666
use libc::funcs::posix88::unistd::{fork, dup2, close, chdir, execvp};
67-
use libc::funcs::bsd44::getdtablesize;
6867

6968
mod rustrt {
7069
extern {
7170
pub fn rust_unset_sigprocmask();
7271
}
7372
}
7473

74+
#[cfg(all(target_os = "android", target_arch = "aarch64"))]
75+
unsafe fn getdtablesize() -> c_int {
76+
libc::sysconf(libc::consts::os::sysconf::_SC_OPEN_MAX) as c_int
77+
}
78+
79+
#[cfg(not(all(target_os = "android", target_arch = "aarch64")))]
80+
unsafe fn getdtablesize() -> c_int {
81+
libc::funcs::bsd44::getdtablesize()
82+
}
83+
7584
unsafe fn set_cloexec(fd: c_int) {
7685
let ret = c::ioctl(fd, c::FIOCLEX);
7786
assert_eq!(ret, 0);

src/test/compile-fail-fulldeps/macro-crate-cannot-read-embedded-ident.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

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

1615
// Issue #15750 and #15962 : this test is checking that the standard

src/test/compile-fail-fulldeps/macro-crate-doesnt-resolve.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
// aux-build:macro_crate_test.rs
1212
// ignore-stage1
13-
// ignore-android
1413

1514
#[macro_use] #[no_link]
1615
extern crate macro_crate_test;

src/test/compile-fail-fulldeps/macro-crate-unexported-macro.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
// aux-build:macro_crate_test.rs
1212
// ignore-stage1
13-
// ignore-android
1413

1514
#[macro_use] #[no_link]
1615
extern crate macro_crate_test;

src/test/compile-fail-fulldeps/plugin-MacroRulesTT.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
// aux-build:macro_crate_MacroRulesTT.rs
1212
// ignore-stage1
13-
// ignore-android
1413
// error-pattern: plugin tried to register a new MacroRulesTT
1514

1615
#![feature(plugin)]

src/test/debuginfo/associated-types.rs

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// ignore-android: FIXME(#10381)
1211
// min-lldb-version: 310
1312

1413
// compile-flags:-g

src/test/debuginfo/basic-types-globals-metadata.rs

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// ignore-android: FIXME(#10381)
1211
// min-lldb-version: 310
1312

1413
// compile-flags:-g

0 commit comments

Comments
 (0)