diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 02b93593cbbd4..34153d93d463d 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -575,7 +575,7 @@ pub struct Config { /// /// FIXME: take a look at this; this is piggy-backing off of gdb code paths but only for /// `arm-linux-androideabi` target. - pub adb_path: Utf8PathBuf, + pub adb_path: Option, /// Extra parameter to run test suite on `arm-linux-androideabi`. /// @@ -584,7 +584,7 @@ pub struct Config { /// /// FIXME: take a look at this; this is piggy-backing off of gdb code paths but only for /// `arm-linux-androideabi` target. - pub adb_test_dir: Utf8PathBuf, + pub adb_test_dir: Option, /// Status whether android device available or not. When unavailable, this will cause tests to /// panic when the test binary is attempted to be run. diff --git a/src/tools/compiletest/src/lib.rs b/src/tools/compiletest/src/lib.rs index ff4cd81d33ff6..324ce2eaabeec 100644 --- a/src/tools/compiletest/src/lib.rs +++ b/src/tools/compiletest/src/lib.rs @@ -260,11 +260,9 @@ fn parse_config(args: Vec) -> Config { let android_cross_path = matches.opt_str("android-cross-path").map(Utf8PathBuf::from); - // FIXME: `adb_path` should be an `Option`... - let adb_path = matches.opt_str("adb-path").map(Utf8PathBuf::from).unwrap_or_default(); - // FIXME: `adb_test_dir` should be an `Option`... - let adb_test_dir = matches.opt_str("adb-test-dir").map(Utf8PathBuf::from).unwrap_or_default(); - let adb_device_status = target.contains("android") && !adb_test_dir.as_str().is_empty(); + let adb_path = matches.opt_str("adb-path").map(Utf8PathBuf::from); + let adb_test_dir = matches.opt_str("adb-test-dir").map(Utf8PathBuf::from); + let adb_device_status = target.contains("android") && adb_test_dir.is_some(); // FIXME: `cdb_version` is *derived* from cdb, but it's *not* technically a config! let cdb = debuggers::discover_cdb(matches.opt_str("cdb"), &target); diff --git a/src/tools/compiletest/src/runtest/debuginfo.rs b/src/tools/compiletest/src/runtest/debuginfo.rs index ac935910205b7..83b61b9be57d5 100644 --- a/src/tools/compiletest/src/runtest/debuginfo.rs +++ b/src/tools/compiletest/src/runtest/debuginfo.rs @@ -150,12 +150,16 @@ impl TestCx<'_> { debug!("script_str = {}", script_str); self.dump_output_file(&script_str, "debugger.script"); - let adb_path = &self.config.adb_path; + // Note: when `--android-cross-path` is specified, we expect both `adb_path` and + // `adb_test_dir` to be available. + let adb_path = self.config.adb_path.as_ref().expect("`adb_path` must be specified"); + let adb_test_dir = + self.config.adb_test_dir.as_ref().expect("`adb_test_dir` must be specified"); Command::new(adb_path) .arg("push") .arg(&exe_file) - .arg(&self.config.adb_test_dir) + .arg(adb_test_dir) .status() .unwrap_or_else(|e| panic!("failed to exec `{adb_path:?}`: {e:?}")); @@ -167,9 +171,9 @@ impl TestCx<'_> { let adb_arg = format!( "export LD_LIBRARY_PATH={}; \ gdbserver{} :5039 {}/{}", - self.config.adb_test_dir.clone(), + adb_test_dir, if self.config.target.contains("aarch64") { "64" } else { "" }, - self.config.adb_test_dir.clone(), + adb_test_dir, exe_file.file_name().unwrap() );