Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lobster/tools/core/report/requirements.trlc
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,11 @@ req.System_Requirement_Aspect File_Not_Found {
THEN the tool shall report "file not found <file_path>" and exit with a non-zero return code.
'''
}

req.System_Requirement_Aspect Message_Trace_Coverage {
description = '''
IF an item contains a "message" and traces to another item,
THEN the traced item shall have 100% coverage,
Copy link
Copy Markdown
Member

@phiwuu phiwuu Aug 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong! The traced item may be traced by several items! If there are only two items in total, then the formulation is correct.

Furthermore:

  • it is irrelevant if the item under test traces to another item or not. If there is a message, then the item shall be counted as "not okay".
  • a single item cannot have a coverage. A coverage is allocated to a level, which consists of zero or more items.

So a system requirement can only specify that the item shall be counted as "not okay" if it has got a message. And this rule has precedence over all other traceability rules. So even if the item properly traces to another item (as requested by the tracing policy), the item must still be counted as "not okay" if it has got a message.

However, a justification has even higher priority. An item with "justification" is counted as "okay", even if it has got a "message".

AND the item with the message shall have 0% coverage.
'''
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
requirements "Requirements" {
source: "trlc_message_trace_coverage.lobster";
}

implementation "Code" {
source: "python_message_trace_coverage.lobster";
trace to: "Requirements";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"data": [
{
"tag": "python software.Example",
"location": {
"kind": "file",
"file": ".\\software.py",
"line": 1,
"column": null
},
"name": "software.Example",
"messages": ["trace"],
"just_up": [],
"just_down": [],
"just_global": [],
"refs": [
"req example.adas_100"
],
"language": "Python",
"kind": "Function"
}
],
"generator": "lobster_python",
"schema": "lobster-imp-trace",
"version": 3
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{
"schema": "lobster-report",
"version": 2,
"generator": "lobster_report",
"levels": [
{
"name": "Requirements",
"kind": "requirements",
"items": [
{
"tag": "req example.adas_100",
"location": {
"kind": "file",
"file": "./demo.trlc",
"line": 3,
"column": 13
},
"name": "example.adas_100",
"messages": [],
"just_up": [],
"just_down": [],
"just_global": [],
"ref_up": [],
"ref_down": [
"python software.Example"
],
"tracing_status": "OK",
"framework": "TRLC",
"kind": "Requirement",
"text": "keep the vehicle in lane.",
"status": null
}
],
"coverage": 100.0
},
{
"name": "Code",
"kind": "implementation",
"items": [
{
"tag": "python software.Example",
"location": {
"kind": "file",
"file": "./software.py",
"line": 1,
"column": null
},
"name": "software.Example",
"messages": [
"trace"
],
"just_up": [],
"just_down": [],
"just_global": [],
"ref_up": [
"req example.adas_100"
],
"ref_down": [],
"tracing_status": "PARTIAL",
"language": "Python",
"kind": "Function"
}
],
"coverage": 0.0
}
],
"policy": {
"Requirements": {
"name": "Requirements",
"kind": "requirements",
"traces": [],
"source": [
{
"file": "trlc_message_trace_coverage.lobster"
}
],
"needs_tracing_up": false,
"needs_tracing_down": true,
"breakdown_requirements": [
[
"Code"
]
]
},
"Code": {
"name": "Code",
"kind": "implementation",
"traces": [
"Requirements"
],
"source": [
{
"file": "python_message_trace_coverage.lobster"
}
],
"needs_tracing_up": true,
"needs_tracing_down": false,
"breakdown_requirements": []
}
},
"matrix": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"data": [
{
"tag": "req example.adas_100",
"location": {
"kind": "file",
"file": ".\\demo.trlc",
"line": 3,
"column": 13
},
"name": "example.adas_100",
"messages": [],
"just_up": [],
"just_down": [],
"just_global": [],
"framework": "TRLC",
"kind": "Requirement",
"text": "keep the vehicle in lane.",
"status": null
}
],
"generator": "lobster-trlc",
"schema": "lobster-req-trace",
"version": 4
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
LobsterReportSystemTestCaseBase)


class ReportZeroItemsCoverageTest(LobsterReportSystemTestCaseBase):
class ReportItemsCoverageTest(LobsterReportSystemTestCaseBase):
def setUp(self):
super().setUp()
self._test_runner = self.create_test_runner()
Expand All @@ -30,3 +30,25 @@ def test_zero_items_coverage(self):
asserter.assertNoStdOutText()
asserter.assertExitCode(0)
asserter.assertOutputFiles()

def test_items_message_trace_coverage(self):
# lobster-trace: core_report_req.Message_Trace_Coverage
self._test_runner.declare_input_file(self._data_directory /
"message_trace_coverage.conf")
self._test_runner.declare_input_file(self._data_directory /
"python_message_trace_coverage.lobster")
self._test_runner.declare_input_file(self._data_directory /
"trlc_message_trace_coverage.lobster")

out_file = "report_message_trace_coverage.lobster"
self._test_runner.cmd_args.lobster_config = "message_trace_coverage.conf"
self._test_runner.cmd_args.out = out_file
self._test_runner.declare_output_file(self._data_directory / out_file)

completed_process = self._test_runner.run_tool_test()

asserter = Asserter(self, completed_process, self._test_runner)
asserter.assertNoStdErrText()
asserter.assertNoStdOutText()
asserter.assertExitCode(0)
asserter.assertOutputFiles()
Loading