Skip to content

Commit 893a50d

Browse files
nasahlpaandreaskurth
authored andcommitted
[pentest] Filter state & counter for lc_ctrl_fi test
Depending on the SKU config, the target could be in a different life cycle state and life cycle counter. Hence, it does not make sense to compare these two values with the testvector. However, if there would be a mismatch between LC state & counter before and after the FI trigger window, the "res" field indicates this. Signed-off-by: Pascal Nasahl <[email protected]> (cherry picked from commit 741a840)
1 parent 8985bc7 commit 893a50d

File tree

1 file changed

+15
-2
lines changed
  • sw/host/tests/penetrationtests/fi_lc_ctrl/src

1 file changed

+15
-2
lines changed

sw/host/tests/penetrationtests/fi_lc_ctrl/src/main.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@ struct FiLcCtrlTestCase {
4444
expected_output: Vec<String>,
4545
}
4646

47+
fn filter_response(response: serde_json::Value) -> serde_json::Map<String, serde_json::Value> {
48+
// Filter common items.
49+
let response_common_filtered = filter_response_common(response.clone());
50+
// Filter test-specifc items.
51+
let mut map: serde_json::Map<String, serde_json::Value> = response_common_filtered.clone();
52+
// Depending on the SKU, the life cycle state and counter could be different.
53+
// Hence, filter it.
54+
map.remove("state");
55+
map.remove("counter");
56+
57+
map
58+
}
59+
4760
fn run_fi_lc_ctrl_testcase(
4861
test_case: &FiLcCtrlTestCase,
4962
opts: &Opts,
@@ -80,12 +93,12 @@ fn run_fi_lc_ctrl_testcase(
8093
)?;
8194
// Only check non empty JSON responses.
8295
if output.as_object().is_some() {
83-
let output_received = filter_response_common(output.clone());
96+
let output_received = filter_response(output.clone());
8497

8598
// Filter expected output.
8699
let exp_output: serde_json::Value =
87100
serde_json::from_str(exp_output.as_str()).unwrap();
88-
let output_expected = filter_response_common(exp_output.clone());
101+
let output_expected = filter_response(exp_output.clone());
89102

90103
// Check received with expected output.
91104
if output_expected != output_received {

0 commit comments

Comments
 (0)