From 84d321ec30ed1d104e5397ffc27d4e9cda398401 Mon Sep 17 00:00:00 2001 From: Wataru Otsubo Date: Tue, 23 Jul 2024 14:41:08 +0900 Subject: [PATCH] update: add QAQC runid for master log parsing - for master version v0.2.0 --- src/main.rs | 2 ++ src/masterlog.rs | 32 +++++++++++++++++++ tests/cli.rs | 8 ++--- .../valid/{20240720_171418.log => 7.log} | 1 + .../valid/{20240720_171419.log => 84.log} | 31 +++++++++--------- 5 files changed, 55 insertions(+), 19 deletions(-) rename tests/example_logs/valid/{20240720_171418.log => 7.log} (99%) rename tests/example_logs/valid/{20240720_171419.log => 84.log} (68%) diff --git a/src/main.rs b/src/main.rs index cc17a9f..d196560 100644 --- a/src/main.rs +++ b/src/main.rs @@ -175,6 +175,7 @@ pub struct PsbQaqcResult { pll_lock_reset: u16, qaqc_result: u32, lvds_tx_skew: Option, + runid: u32, timestamp: DateTime, qaqc_log_file: String, shiftscript_ver: Version, @@ -203,6 +204,7 @@ impl PsbQaqcResult { pll_lock_reset: boardresult.reset, qaqc_result: boardresult.result.into(), lvds_tx_skew: None, + runid: result.runid, timestamp: result.datetime, qaqc_log_file: result.filename.clone(), shiftscript_ver: result.version.clone(), diff --git a/src/masterlog.rs b/src/masterlog.rs index 1d3caa5..0900cdf 100644 --- a/src/masterlog.rs +++ b/src/masterlog.rs @@ -29,6 +29,7 @@ pub struct MasterBoardResult { pub struct MasterLogResult { pub version: Version, pub datetime: DateTime, + pub runid: u32, pub shifter: String, pub board_results: BTreeMap, pub filename: String, @@ -43,6 +44,15 @@ fn extract_version(line: &str) -> Result { .parse()?) } +/// Get runid. +fn extract_runid_line(line: &str) -> Result { + let re = Regex::new(r"^QAQC runid: (\d+)$").unwrap(); + let caps = re.captures(line).unwrap(); + trace!("Regex {:?}", caps); + let runid = u32::from_str(caps.get(1).unwrap().into())?; + Ok(runid) +} + /// Get shifters from shifter line fn extract_shifter_line(line: &str) -> Result { let re = Regex::new(r"^Shifters: (.+)$").unwrap(); @@ -81,6 +91,13 @@ impl MasterLogResult { .to_utc() }; + let runid: u32 = { + let line = lines + .next() + .context("Invalid log format(no runid line)")??; + extract_runid_line(&line)? + }; + let shifter = { let line = lines .next() @@ -238,6 +255,7 @@ impl MasterLogResult { Ok(MasterLogResult { version, datetime, + runid, shifter, board_results, filename, @@ -249,6 +267,8 @@ impl MasterLogResult { mod test { use semver::Version; + use crate::masterlog::extract_runid_line; + use super::{Position, PositionLayer, PsbId}; use super::{extract_position_id, extract_shifter_line, extract_version}; @@ -261,6 +281,18 @@ mod test { ) } + #[test] + fn parse_runid_line() { + assert_eq!( + extract_runid_line("QAQC runid: 7").unwrap(), + 7 + ); + assert_eq!( + extract_runid_line("QAQC runid: 12345").unwrap(), + 12345 + ); + } + #[test] fn parse_shifter_line() { assert_eq!(extract_shifter_line("Shifters: foo").unwrap(), "foo"); diff --git a/tests/cli.rs b/tests/cli.rs index dce902e..7edc011 100644 --- a/tests/cli.rs +++ b/tests/cli.rs @@ -18,7 +18,7 @@ mod integrated_test { let mut cmd = Command::cargo_bin("psb-qaqc")?; cmd.current_dir("tests") .arg("add-master-log") - .arg("./example_logs/valid/20240720_171418.log") + .arg("./example_logs/valid/7.log") .arg(test_out.as_path()) .assert() .success() @@ -34,7 +34,7 @@ mod integrated_test { line .unwrap() .contains( - "8866,,A-0-0,0,1,1,0,1,8,1,,2024-07-20T17:15:46Z,20240720_171418.log,0.1.0,alice,,,," + "8866,,A-0-0,0,1,1,0,1,8,1,,7,2024-07-20T17:15:46Z,7.log,0.1.0,alice,,,," ) })); } @@ -43,7 +43,7 @@ mod integrated_test { let mut cmd = Command::cargo_bin("psb-qaqc")?; cmd.current_dir("tests") .arg("add-master-log") - .arg("./example_logs/valid/20240720_171418.log") + .arg("./example_logs/valid/7.log") .arg(test_out.as_path()) .assert() .success(); @@ -67,7 +67,7 @@ mod integrated_test { let mut cmd = Command::cargo_bin("psb-qaqc")?; cmd.current_dir("tests") .arg("add-master-log") - .arg("./example_logs/valid/20240720_171419.log") + .arg("./example_logs/valid/84.log") .arg(test_out.as_path()) .assert() .success() diff --git a/tests/example_logs/valid/20240720_171418.log b/tests/example_logs/valid/7.log similarity index 99% rename from tests/example_logs/valid/20240720_171418.log rename to tests/example_logs/valid/7.log index abb6a49..5451837 100644 --- a/tests/example_logs/valid/20240720_171418.log +++ b/tests/example_logs/valid/7.log @@ -1,6 +1,7 @@ Shift script: 0.1.0 ---------------------- Date: 2024-07-20T17:15:46+0000 +QAQC runid: 7 Shifters: alice ---------------------- PBS Assignment: diff --git a/tests/example_logs/valid/20240720_171419.log b/tests/example_logs/valid/84.log similarity index 68% rename from tests/example_logs/valid/20240720_171419.log rename to tests/example_logs/valid/84.log index 81b9e16..3919413 100644 --- a/tests/example_logs/valid/20240720_171419.log +++ b/tests/example_logs/valid/84.log @@ -1,23 +1,24 @@ Shift script: 0.1.0 ---------------------- -Date: 2024-07-20T17:15:46+0000 +Date: 2024-07-20T17:15:47+0000 +QAQC runid: 84 Shifters: alice ---------------------- PBS Assignment: -Position / assigned-ID : A-0-0 / PS008866 -Position / assigned-ID : A-1-0 / PS008866 -Position / assigned-ID : A-0-2 / PS008866 -Position / assigned-ID : A-1-2 / PS008866 -Position / assigned-ID : A-0-3 / PS008866 -Position / assigned-ID : A-1-3 / PS008866 -Position / assigned-ID : A-0-4 / PS008866 -Position / assigned-ID : A-1-4 / PS008866 -Position / assigned-ID : A-1-5 / PS008866 -Position / assigned-ID : A-0-6 / PS008866 -Position / assigned-ID : A-1-6 / PS008866 -Position / assigned-ID : A-0-7 / PS008866 -Position / assigned-ID : A-0-8 / PS008866 -Position / assigned-ID : A-1-8 / PS008866 +Position / assigned-ID : A-0-0 / PS008867 +Position / assigned-ID : A-1-0 / PS008868 +Position / assigned-ID : A-0-2 / PS008869 +Position / assigned-ID : A-1-2 / PS008810 +Position / assigned-ID : A-0-3 / PS008811 +Position / assigned-ID : A-1-3 / PS008812 +Position / assigned-ID : A-0-4 / PS008813 +Position / assigned-ID : A-1-4 / PS008814 +Position / assigned-ID : A-1-5 / PS008815 +Position / assigned-ID : A-0-6 / PS008816 +Position / assigned-ID : A-1-6 / PS008817 +Position / assigned-ID : A-0-7 / PS008818 +Position / assigned-ID : A-0-8 / PS008819 +Position / assigned-ID : A-1-8 / PS008820 ====================== QAQC status| QSPIp | Recov | Power | Clock | ASDTP | Reset | Result | ----------------------------------------------------------------------