Skip to content

Commit c59e4e1

Browse files
committed
process: add test cases requirements
Ref: closes #54
1 parent 97cb80e commit c59e4e1

4 files changed

Lines changed: 102 additions & 101 deletions

File tree

src/extensions/score_metamodel/checks/graph_checks.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,11 @@ def check_metamodel_graph(
137137
# Convert list to dictionary for easy lookup
138138
needs_dict_all = {need["id"]: need for need in all_needs.values()}
139139
needs_local = list(all_needs.filter_is_external(False).values())
140-
print("graph_checks_global:", graph_checks_global)
141140
# Iterate over all graph checks
142141
for check in graph_checks_global.items():
143142
apply, eval = check[1].values()
144-
print(f"Applying check: {check[0]} with apply: {apply} and eval: {eval}")
145143
# Get all needs that match the selection criteria
146144
selected_needs = get_need_selection(needs_local, apply, log)
147-
print(f"Selected needs: {selected_needs}")
148145

149146
for need in selected_needs:
150147
for parent_relation in list(eval.keys()):

src/extensions/score_metamodel/metamodel.yaml

Lines changed: 24 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ feat_plat_saf_dfa:
513513
id: ^gd_guidl__dfa_failure_initiators__[0-9a-z_]*$
514514
violation_id: ^.*$
515515
violation_cause: ^.*$
516-
mitigation: ^(feat_req__[0-9a-z_]*|aou_req_[0-9a-z]*|)$
516+
mitigates: ^(feat_req__[0-9a-z_]*|aou_req_[0-9a-z]*|)$
517517
mitigation_issue: ^https://github.com/.*$
518518
sufficient: ^(yes|no)$
519519
status: ^(valid|invalid)$
@@ -523,23 +523,24 @@ feat_saf_dfa:
523523
prefix: feat_saf_dfa__
524524
mandatory_options:
525525
verifies: ^feat_arc_sta__[0-9a-z_]*$
526-
id: ^feat_saf_dfa__[0-9a-z_]*$
526+
id: ^gd_guidl__dfa_failure_initiators__[0-9a-z_]*$
527527
violation_id: ^.*$
528528
violation_cause: ^.*$
529-
mitigation: ^(feat_req__[0-9a-z_]*|aou_req_[0-9a-z]*|)$
530529
mitigation_issue: ^https://github.com/.*$
531530
sufficient: ^(yes|no)$
532531
status: ^(valid|invalid)$
532+
mandatory_links:
533+
mitigates: ^feat_req__.*$
533534

534535
comp_saf_dfa:
535536
title: DFA
536537
prefix: comp_saf_dfa__
537538
mandatory_options:
538539
verifies: ^comp_arc_sta__[0-9a-z_]*$
539-
id: ^comp_saf_dfa__[0-9a-z_]*$
540+
id: ^gd_guidl__dfa_failure_initiators__[0-9a-z_]*$
540541
violation_id: ^.*$
541542
violation_cause: ^.*$
542-
mitigation: ^(feat_req__[0-9a-z_]*|aou_req_[0-9a-z]*|)$
543+
mitigates: ^(feat_req__[0-9a-z_]*|aou_req_[0-9a-z]*|)$
543544
mitigation_issue: ^https://github.com/.*$
544545
sufficient: ^(yes|no)$
545546
status: ^(valid|invalid)$
@@ -550,10 +551,10 @@ feat_saf_fmea:
550551
prefix: feat_saf_fmea__
551552
mandatory_options:
552553
verifies: ^feat_arc_dyn__[0-9a-z_]*$
553-
id: ^feat_saf_dfa__[0-9a-z_]*$
554+
id: ^gd_guidl__fault_models__[0-9a-z_]*$
554555
violation_id: ^.*$
555556
violation_cause: ^.*$
556-
mitigation: ^(feat_req__[0-9a-z_]*|aou_req_[0-9a-z]*|)$
557+
mitigates: ^(feat_req__[0-9a-z_]*|aou_req_[0-9a-z]*|)$
557558
mitigation_issue: ^https://github.com/.*$
558559
sufficient: ^(yes|no)$
559560
status: ^(valid|invalid)$
@@ -563,10 +564,10 @@ comp_saf_fmea:
563564
prefix: comp_saf_fmea__
564565
mandatory_options:
565566
verifies: ^comp_arc_dyn__[0-9a-z_]*$
566-
id: ^comp_saf_dfa__[0-9a-z_]*$
567+
id: ^gd_guidl__fault_models__[0-9a-z_]*$
567568
violation_id: ^.*$
568569
violation_cause: ^.*$
569-
mitigation: ^(comp_req__[0-9a-z_]*|aou_req_[0-9a-z]*|)$
570+
mitigates: ^(comp_req__[0-9a-z_]*|aou_req_[0-9a-z]*|)$
570571
mitigation_issue: ^https://github.com/.*$
571572
sufficient: ^(yes|no)$
572573
argument: ^.+$
@@ -646,8 +647,8 @@ needs_extra_links:
646647
outgoing: included by
647648

648649
mitigates:
649-
incoming: mitigates
650-
outgoing: mitigated by
650+
incoming: mitigates by
651+
outgoing: mitigated
651652
##############################################################
652653
# Graph Checks
653654
# The graph checks focus on the relation of the needs and their attributes.
@@ -666,40 +667,25 @@ needs_extra_links:
666667
##############################################################
667668
# req- Id: gd_req__req__linkage_architecture
668669
# req- Id: gd_req__req__linkage_safety
669-
# If need-req is `QM`, parent must be `QM`.
670+
671+
# Checks if the child requirement has the at least the same safety level as the parent requirement. It's allowed to "overfill" the safety level of the parent.
672+
# ASIL decomposition is not foreseen in S-CORE. Therefore it's not allowed to have a child requirement with a lower safety level than the parent requirement as
673+
# it is possible in an decomposition case.
674+
# If need-req is `QM`, parent must be `QM`.
675+
graph_checks:
670676
req_safety_linkage_qm:
671677
needs:
672678
include: comp_req, feat_req
673-
condition:
674-
and:
675-
- safety == QM
679+
condition: safety == QM
676680
check:
677-
satisfies:
678-
and:
679-
- safety == QM
681+
satisfies: safety == QM
680682
# If need-req is `ASIL_B`, parent must be `QM` or `ASIL_B`.
681683
req_safety_linkage_asil_b:
682684
needs:
683685
include: comp_req, feat_req
684-
condition:
685-
and:
686-
- safety == ASIL_B
686+
condition: safety == ASIL_B
687687
check:
688-
satisfies:
689-
not:
690-
- safety == ASIL_D
691-
# If need-req is `ASIL_D`, parent can `QM`, `ASIL_B` or `ASIL_D`.
692-
# req_safety_linkage_asil_d:
693-
# needs:
694-
# include: comp_req, feat_req
695-
# condition:
696-
# and:
697-
# - safety == " "
698-
# check:
699-
# satisfies:
700-
# and:
701-
# - safety == ASIL_D
702-
688+
satisfies: safety != ASIL_D
703689
# saf - ID gd_req__saf_linkage_safety
704690
# It shall be checked that Safety Analysis (DFA and FMEA) can only be linked via mitigate against
705691
# - <Feature | Component | AoU> Requirements with the same ASIL or
@@ -708,11 +694,6 @@ needs_extra_links:
708694
saf_linkage_safety:
709695
needs:
710696
include: feat_saf_fmea, comp_saf_fmea, feat_plat_saf_dfa, feat_saf_dfa, comp_saf_dfa, aou_req
711-
condition:
712-
and:
713-
- safety == ASIL_B
697+
condition: safety == ASIL_B
714698
check:
715-
mitigates:
716-
or:
717-
- safety == ASIL_B
718-
- safety == ASIL_D
699+
mitigates: safety == QM

src/extensions/score_metamodel/tests/rst/graph/test_metamodel_graph.rst

Lines changed: 77 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -14,92 +14,115 @@
1414
1515
#CHECK: check_metamodel_graph
1616

17-
.. feat_req:: Parent requirement
18-
:id: feat_req__parent__abcd
19-
:safety: QM
20-
:status: valid
21-
22-
.. Parent requirement has the correct safety level
23-
#EXPECT-NOT: feat_req__child__abce: parent need `feat_req__parent__abcd` does not fulfill condition `{'and': ['safety == QM']}`.
24-
25-
.. feat_req:: Child requirement
26-
:id: feat_req__child__abce
27-
:safety: QM
28-
:satisfies: feat_req__parent__abcd
29-
:status: valid
3017

31-
.. feat_req:: Parent requirement2
32-
:id: feat_req__parent__abcd2
18+
.. Checks if the child requirement has the at least the same safety level as the parent requirement. It's allowed to "overfill" the safety level of the parent.
19+
.. ASIL decomposition is not foreseen in S-CORE. Therefore it's not allowed to have a child requirement with a lower safety level than the parent requirement as
20+
.. it is possible in an decomposition case.
21+
.. feat_req:: Parent requirement QM
22+
:id: feat_req__parent__QM
3323
:safety: QM
3424
:status: valid
3525

36-
.. Parent requirement has the correct safety level
37-
#EXPECT-NOT: feat_req__child__abce2: parent need `feat_req__parent__abcd2` does not fulfill condition `{'and': ['safety == QM']}`.
38-
39-
.. feat_req:: Child requirement2
40-
:id: feat_req__child__abce2
26+
.. feat_req:: Parent requirement ASIL_B
27+
:id: feat_req__parent__ASIL_B
4128
:safety: ASIL_B
42-
:satisfies: feat_req__parent__abcd2
4329
:status: valid
4430

45-
.. feat_req:: Parent requirement3
46-
:id: feat_req__parent3__abcd
47-
:safety: ASIL_B
31+
.. feat_req:: Parent requirement ASIL_D
32+
:id: feat_req__parent__ASIL_D
33+
:safety: ASIL_D
4834
:status: valid
4935

50-
.. Graph check without combined condition (no and or or)
51-
#EXPECT: feat_req__child__abce3: parent need `feat_req__parent3__abcd` does not fulfill condition `safety == QM`.
36+
.. Positive Test: Child requirement QM. Parent requirement has the correct related safety level. Parent requirement is `QM`.
37+
#EXPECT-NOT: feat_req__child__1: parent need `feat_req__parent__QM` does not fulfill condition `safety == QM`.
5238

53-
.. comp_req:: Child requirement3
54-
:id: feat_req__child__abce3
39+
.. feat_req:: Child requirement 1
40+
:id: feat_req__child__1
5541
:safety: QM
56-
:satisfies: feat_req__parent3__abcd
42+
:satisfies: feat_req__parent__QM
5743
:status: valid
5844

45+
.. Positive Test: Child requirement ASIL B. Parent requirement has the correct related safety level. Parent requirement is `QM`.
46+
#EXPECT-NOT: feat_req__child__2: parent need `feat_req__parent__ASIL_B` does not fulfill condition `safety == QM`.
5947

48+
.. feat_req:: Child requirement 2
49+
:id: feat_req__child__2
50+
:safety: ASIL_B
51+
:satisfies: feat_req__parent__ASIL_B
52+
:status: valid
6053

54+
.. Positive Test: Child requirement ASIL D. Parent requirement has the correct related safety level. Parent requirement is `QM`.
55+
#EXPECT-NOT: feat_req__child__3: parent need `feat_req__parent__ASIL_D` does not fulfill condition `safety == QM`.
6156

57+
.. feat_req:: Child requirement 3
58+
:id: feat_req__child__3
59+
:safety: ASIL_D
60+
:satisfies: feat_req__parent__ASIL_D
61+
:status: valid
6262

63+
.. Negative Test: Child requirement QM. Parent requirement is `ASIL_B`. Child cant fulfill the safety level of the parent.
64+
#EXPECT: feat_req__child__4: parent need `feat_req__parent__ASIL_B` does not fulfill condition `safety == QM`.
6365

66+
.. comp_req:: Child requirement 4
67+
:id: feat_req__child__4
68+
:safety: QM
69+
:satisfies: feat_req__parent__ASIL_B
70+
:status: valid
6471

72+
.. Negative Test: Child requirement QM. Parent requirement is `ASIL_D`. Child cant fulfill the safety level of the parent.
73+
#EXPECT: feat_req__child__5: parent need `feat_req__parent__ASIL_D` does not fulfill condition `safety == QM`.
6574

75+
.. comp_req:: Child requirement 5
76+
:id: feat_req__child__5
77+
:safety: QM
78+
:satisfies: feat_req__parent__ASIL_D
79+
:status: valid
6680

81+
.. Positive Test: Child requirement ASIL_B. Parent requirement has the correct related safety level. Parent requirement is `QM`.
82+
#EXPECT-NOT: feat_req__child__6: parent need `feat_req__parent__QM` does not fulfill condition `safety != ASIL_D`.
6783

84+
.. feat_req:: Child requirement 6
85+
:id: feat_req__child__6
86+
:safety: ASIL_B
87+
:satisfies: feat_req__parent__QM
88+
:status: valid
6889

90+
.. Positive Test: Child requirement ASIL_B. Parent requirement has the correct related safety level. Parent requirement is `ASIL_B`.
91+
#EXPECT-NOT: feat_req__child__7: parent need `feat_req__parent__ASIL_B` does not fulfill condition `safety != ASIL_D`.
6992

93+
.. feat_req:: Child requirement 7
94+
:id: feat_req__child__7
95+
:safety: ASIL_B
96+
:satisfies: feat_req__parent__ASIL_B
97+
:status: valid
7098

99+
.. Negative Test: Child requirement ASIL_B. Parent requirement is `ASIL_D`. Child cant fulfill the safety level of the parent.
100+
#EXPECT: feat_req__child__8: parent need `feat_req__parent__ASIL_D` does not fulfill condition `safety != ASIL_D`.
71101

102+
.. comp_req:: Child requirement 8
103+
:id: feat_req__child__8
104+
:safety: ASIL_B
105+
:satisfies: feat_req__parent__ASIL_D
106+
:status: valid
72107

73108

74-
.. .. feat_req:: Parent requirement 2
75-
.. :id: feat_req__parent2__abcd
76-
.. :safety: QM
77109

78-
.. .. Parent requirement has the correct safety level
79-
.. #EXPECT-NOT: feat_req__child2__abce: parent need `feat_req__parent2__abcd` does not fulfill condition
110+
.. Parent requirement does not exist
111+
#EXPECT: feat_req__child__9: Parent need `feat_req__parent0__abcd` not found in needs_dict.
80112

81-
.. .. feat_req:: Child requirement 2
82-
.. :id: feat_req__child2__abce
83-
.. :safety: QM
84-
.. :satisfies: feat_req__parent2__abcd
113+
.. feat_req:: Child requirement 9
114+
:id: feat_req__child__9
115+
:safety: ASIL_B
116+
:status: valid
117+
:satisfies: feat_req__parent0__abcd
85118

86-
.. .. Parent requirement does not exist
87-
.. #EXPECT: feat_req__child3__abce: Parent need `feat_req__parent0__abcd` not found in needs_dict.
88119

89-
.. .. feat_req:: Child requirement 3
90-
.. :id: feat_req__child3__abce
91-
.. :safety: ASIL_B
92-
.. :status: valid
93-
.. :satisfies: feat_req__parent0__abcd
94120

95-
.. .. feat_req:: Parent requirement 3
96-
.. :id: feat_req__parent3__abcd
97-
.. :status: invalid
98121

99-
.. .. Graph check without combined condition (no and or or)
100-
.. #EXPECT: comp_req__parent4__abcd: parent need `feat_req__parent3__abcd` does not fulfill condition `status == valid`.
122+
.. Parent requirement does not exist
123+
#EXPECT: feat_saf_dfa__child__10: Parent need `feat_req__parent__QM` does not fulfill the condition `safety != QM`.
101124

102-
.. .. comp_req:: Child requirement 4
103-
.. :id: comp_req__parent4__abcd
104-
.. :status: valid
105-
.. :satisfies: feat_req__parent3__abcd
125+
.. feat_req:: Child requirement 10
126+
:id: feat_saf_dfa__child__10
127+
:safety: ASIL_B
128+
:mitigates: feat_req__parent__QM

src/extensions/score_metamodel/tests/test_rules_file_based.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def test_rst_files(
185185

186186
# Collect the warnings
187187
warnings = app.warning.getvalue().splitlines()
188-
print(f"Warnings: {warnings}")
188+
#print(f"Warnings: {warnings}")
189189

190190
# Check if the expected warnings are present
191191
for warning_info in rst_data.warning_infos:

0 commit comments

Comments
 (0)