From 630dd6a7845c96f6eda44f5feaaabf7db3a2ec2d Mon Sep 17 00:00:00 2001 From: bunnie Date: Sun, 2 Jan 2022 16:41:23 +0800 Subject: [PATCH] make the CI options command line driven --- tools/pddbci.py | 7 +++++-- xtask/src/main.rs | 26 ++++++++++++++++++-------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/tools/pddbci.py b/tools/pddbci.py index 609714103..ca99ca6ad 100644 --- a/tools/pddbci.py +++ b/tools/pddbci.py @@ -23,6 +23,7 @@ def main(): pass_log = {} err_log = [] + timeout = 240 # a bit longer to allow for a compilation to happen for seed in range(0, 501): err_log.append("Starting seed {}".format(seed)) seed_env = os.environ @@ -35,7 +36,7 @@ def main(): passing = 'PASS' proc = subprocess.Popen( - ['cargo', 'xtask', 'run'], + ['cargo', 'xtask', 'pddb-ci'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, #shell=True, @@ -47,7 +48,7 @@ def main(): realtime_output = proc.stdout.readline() if (realtime_output == '' and proc.poll() is not None) or (time.time() - start_time > 20): proc.kill() - if time.time() - start_time > 20: + if time.time() - start_time > timeout: logging.debug("timeout on generation") passing = 'FAIL TIMEOUT' break @@ -81,6 +82,8 @@ def main(): passing = 'FAIL AUTH' proc.kill() + timeout = 20 # reset the timeout after the first run to something shorter, now that any potential compilation step is done + proc = subprocess.Popen( ['python', './tools/pddbdbg.py', '--name', args.name], stdout=subprocess.PIPE, diff --git a/xtask/src/main.rs b/xtask/src/main.rs index bfb67ed52..0a9609514 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -159,7 +159,10 @@ fn main() -> Result<(), Box> { } Some("renode-aes-test") => renode_image(false, &aestest_pkgs, &[])?, Some("renode-image-debug") => renode_image(true, &hw_pkgs, &[])?, - Some("run") => run(false, &hw_pkgs)?, + Some("run") => run(false, &hw_pkgs, None)?, + Some("pddb-ci") => run(false, &hw_pkgs, Some( + &["--features", "pddb/ci", "--features", "pddb/deterministic"] + ))?, Some("hw-image") => { build_hw_image(false, env::args().nth(2), &hw_pkgs, lkey, kkey, None, &[])? } @@ -172,7 +175,7 @@ fn main() -> Result<(), Box> { None, &[], )?, - Some("pddb-hosted") => run(false, &pddb_dev_pkgs)?, + Some("pddb-hosted") => run(false, &pddb_dev_pkgs, None)?, Some("benchmark") => build_hw_image( false, env::args().nth(2), @@ -230,7 +233,7 @@ fn main() -> Result<(), Box> { Some("sr-test") => { build_hw_image(false, env::args().nth(2), &sr_pkgs, lkey, kkey, None, &[])? } - Some("debug") => run(true, &hw_pkgs)?, + Some("debug") => run(true, &hw_pkgs, None)?, Some("burn-kernel") => update_usb(true, false, false, false)?, Some("burn-loader") => update_usb(false, true, false, false)?, Some("nuke-soc") => update_usb(false, false, true, false)?, @@ -380,7 +383,7 @@ fn build_hw_image( let kernel = build_kernel(debug)?; let mut init = vec![]; - let base_path = build(packages, debug, Some(PROGRAM_TARGET), None, extra_args)?; + let base_path = build(packages, debug, Some(PROGRAM_TARGET), None, extra_args, None)?; for pkg in packages { let mut pkg_path = base_path.clone(); pkg_path.push(pkg); @@ -396,7 +399,7 @@ fn build_hw_image( debug, Some(KERNEL_TARGET), Some("loader".into()), - None, + None, None, )?; loader.push(PathBuf::from("loader")); @@ -534,10 +537,10 @@ fn renode_image(debug: bool, packages: &[&str], extra_packages: &[&str]) -> Resu ) } -fn run(debug: bool, init: &[&str]) -> Result<(), DynError> { +fn run(debug: bool, init: &[&str], features: Option<&[&str]>) -> Result<(), DynError> { let stream = if debug { "debug" } else { "release" }; - build(init, debug, None, None, None)?; + build(init, debug, None, None, None, features)?; // Build and run the kernel let mut args = vec!["run"]; @@ -583,7 +586,7 @@ fn build_kernel(debug: bool) -> Result { debug, Some(KERNEL_TARGET), Some("kernel".into()), - None, + None, None, )?; path.push("kernel"); Ok(path) @@ -832,11 +835,18 @@ fn build( target: Option<&str>, directory: Option, extra_args: Option<&[&str]>, + features: Option<&[&str]>, ) -> Result { ensure_compiler(&target)?; let stream = if debug { "debug" } else { "release" }; let mut args = vec!["build"]; print!("Building"); + + if let Some(feature) = features { + for &a in feature { + args.push(a); + } + } for package in packages { print!(" {}", package); args.push("--package");