Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Allow to provide arguments through cargo xtask test #308

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions xtask/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ pub(crate) struct Options {
/// Space or comma separated list of kernel versions to use in architest/QEMU.
#[clap(long, default_value = "6.6", value_delimiter = ',')]
kernel_versions: Vec<String>,

/// Arguments to pass to the test suite
#[clap(name = "args")]
test_args: Vec<String>,
}

fn download_tarball<P>(url: &str, tarball_path: P) -> Result<()>
Expand Down Expand Up @@ -105,6 +109,7 @@ fn test_architest(sh: Shell, options: Options, binary_file: &str) -> Result<()>
target,
preserve_tempdir,
kernel_versions,
test_args,
..
} = options;

Expand Down Expand Up @@ -175,7 +180,8 @@ fn test_architest(sh: Shell, options: Options, binary_file: &str) -> Result<()>
std::thread::sleep(std::time::Duration::from_secs(12));

cmd!(sh, "scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -P 3366 {binary_file} root@localhost:/tmp/").run()?;
cmd!(sh, "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@localhost -p 3366 /tmp/test-suite").run()?;
let test_args = test_args.clone();
cmd!(sh, "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@localhost -p 3366 /tmp/test-suite {test_args...}").run()?;

qemu_process.kill()?;
qemu_process.wait()?;
Expand All @@ -198,6 +204,7 @@ pub(crate) fn run(options: Options) -> Result<()> {
release,
features,
force_architest,
test_args,
..
} = &options;
let mut args = Vec::new();
Expand Down Expand Up @@ -225,7 +232,7 @@ pub(crate) fn run(options: Options) -> Result<()> {
if *force_architest || !target.starts_with(arch) {
test_architest(sh, options, &binary_file)?;
} else {
cmd!(sh, "sudo -E {binary_file}").run()?;
cmd!(sh, "sudo -E {binary_file} {test_args...}").run()?;
}

Ok(())
Expand Down