From ae29be2daae0264ba7a528359ca9a058d5890037 Mon Sep 17 00:00:00 2001 From: Wataru Otsubo Date: Thu, 25 Jul 2024 20:07:28 +0900 Subject: [PATCH] update: auto distinguish boards to retest - automatically print --- src/main.rs | 13 ++++++++- src/masterlog.rs | 30 ++++++++++++++++++++ tests/cli.rs | 4 +-- tests/example_logs/valid/44.log | 49 +++++++++++++++++++++++++++++++++ 4 files changed, 93 insertions(+), 3 deletions(-) create mode 100644 tests/example_logs/valid/44.log diff --git a/src/main.rs b/src/main.rs index 156a5e8..73f24c6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -194,6 +194,7 @@ impl PsbQaqcResult { pub fn from_masterlogresult(result: MasterLogResult) -> Vec { let mut converted = vec![]; for (pos, boardresult) in result.board_results { + let isretest = boardresult.is_need_retest().is_some(); let new = PsbQaqcResult { motherboard_id: boardresult.id.id, daughterboard_id: None, @@ -214,7 +215,7 @@ impl PsbQaqcResult { firmware_ver: None, parameter_ver: None, fpga_dna: None, - retest: false, + retest: isretest, comment: "".to_string(), }; converted.push(new); @@ -366,6 +367,16 @@ fn main() -> Result<()> { }; debug!("{:?}", result); + // Print boards to retest + for (pos, boardresult) in &result.board_results { + if let Some(reason) = boardresult.is_need_retest() { + println!( + "Board {} at {} need retest for {}", + boardresult.id.id, pos, reason + ); + } + } + let expanded_results = PsbQaqcResult::from_masterlogresult(result); let mut wtr = match outfile.exists() { diff --git a/src/masterlog.rs b/src/masterlog.rs index 7aab53a..67d684b 100644 --- a/src/masterlog.rs +++ b/src/masterlog.rs @@ -24,6 +24,36 @@ pub struct MasterBoardResult { pub result: u8, } +impl MasterBoardResult { + /// Check the board needs to be retested with reason. + /// + /// None if it doesn't need retest. + pub fn is_need_retest(&self) -> Option { + let mut result = false; + let mut reasons = vec![]; + if self.qspip != 1 { + result = true; + reasons.push(format!("QSPIp is not 1({})", self.qspip)); + } + if self.recov != 1 { + result = true; + reasons.push(format!("Recov is not 1({})", self.recov)); + } + if self.power != 1 { + result = true; + reasons.push(format!("Power is not 1({})", self.qspip)); + } + if self.clock != 1 { + result = true; + reasons.push(format!("Clock is not 1({})", self.clock)); + } + match result { + true => Some(reasons.join(", ")), + false => None, + } + } +} + /// Full result for a single QAQC run from a log file on JATHub master. #[derive(Debug)] pub struct MasterLogResult { diff --git a/tests/cli.rs b/tests/cli.rs index 4f7dba0..cae07cf 100644 --- a/tests/cli.rs +++ b/tests/cli.rs @@ -19,7 +19,7 @@ mod integrated_test { let mut cmd = Command::cargo_bin("psb-qaqc")?; cmd.current_dir("tests") .arg("add-master-log") - .arg("./example_logs/valid/7.log") + .arg("./example_logs/valid/44.log") .arg(test_out.as_path()) .assert() .success() @@ -32,7 +32,7 @@ mod integrated_test { let r = BufReader::new(f); assert!(r.lines().any(|line| { line.unwrap().eq( - "8866,,B-0-1,0,1,1,0,1,8,1,,7,2024-07-20T17:15:46Z,7.log,0.1.0,alice,,,,false,", + "214,,B-0-1,1,1,1,1,1,0,1,,44,2024-07-25T08:41:27Z,44.log,1.0.1,Bob,,,,false,", ) })); } diff --git a/tests/example_logs/valid/44.log b/tests/example_logs/valid/44.log new file mode 100644 index 0000000..dcdff11 --- /dev/null +++ b/tests/example_logs/valid/44.log @@ -0,0 +1,49 @@ +Shift script: 1.0.1 +---------------------- +Date: 2024-07-25T08:41:27+0000 +QAQC runid: 44 +Shifters: Bob +---------------------- +PBS Assignment: +Position / assigned-ID : B-0-1 / PS000214 +Position / assigned-ID : B-1-1 / PS000215 +Position / assigned-ID : B-0-2 / PS000213 +Position / assigned-ID : B-1-2 / PS000211 +Position / assigned-ID : B-0-3 / PS000212 +Position / assigned-ID : B-1-3 / PS000210 +Position / assigned-ID : B-0-4 / PS000207 +Position / assigned-ID : B-1-4 / PS000209 +Position / assigned-ID : B-0-5 / PS000208 +Position / assigned-ID : B-1-5 / PS000206 +Position / assigned-ID : B-0-6 / PS000205 +Position / assigned-ID : B-1-6 / PS000204 +Position / assigned-ID : B-0-7 / PS000203 +Position / assigned-ID : B-1-7 / PS000202 +Position / assigned-ID : B-0-8 / PS000201 +Position / assigned-ID : B-1-8 / PS000239 +Position / assigned-ID : B-0-9 / PS000238 +Position / assigned-ID : B-1-9 / PS000237 +====================== + QAQC status| QSPIp | Recov | Power | Clock | ASDTP | Reset | Result | + ---------------------------------------------------------------------- + Station0 + JATHub_ 1| 1| 1| 1| 1| 1| 0| 1| + JATHub_ 2| 1| 1| 1| 1| 1| 0| 1| + JATHub_ 3| 1| 1| 1| 1| 1| 0| 1| + JATHub_ 4| 1| 1| 1| 2| 1| 4| 2| + JATHub_ 5| 1| 1| 1| 1| 1| 0| 1| + JATHub_ 6| 1| 1| 1| 1| 1| 1| 1| + JATHub_ 7| 1| 1| 1| 1| 1| 0| 1| + JATHub_ 8| 1| 1| 1| 1| 1| 0| 1| + JATHub_ 9| 1| 1| 1| 2| 1| 0| 2| + Station1 + JATHub_11| 2| 1| 2| 1| 2| 1| 2| + JATHub_12| 1| 1| 1| 1| 1| 0| 1| + JATHub_13| 1| 1| 1| 2| 1| 0| 2| + JATHub_14| 1| 1| 1| 2| 1| 0| 2| + JATHub_15| 1| 1| 1| 2| 1| 0| 2| + JATHub_16| 1| 1| 2| 1| 1| 1| 2| + JATHub_17| 1| 1| 1| 1| 1| 0| 1| + JATHub_18| 1| 1| 1| 1| 1| 3| 1| + JATHub_19| 1| 1| 1| 1| 1| 0| 1| +======================