Skip to content

Commit

Permalink
Add minimum version test
Browse files Browse the repository at this point in the history
Signed-off-by: romanodanilo <[email protected]>
  • Loading branch information
romanodanilo authored and hoangtungdinh committed Jun 19, 2024
1 parent 42a7747 commit 6934ad9
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
from qc_openscenario.checks.reference_checker import reference_constants
from collections import deque, defaultdict

MIN_RULE_VERSION = "1.2.0"


def get_catalogs(root: etree._ElementTree) -> List[etree._ElementTree]:
catalogs = []
Expand Down Expand Up @@ -42,11 +44,10 @@ def check_rule(checker_data: models.CheckerData) -> None:
logging.info(f"- Version not found in the file. Skipping check")
return

min_rule_version = "1.2.0"
rule_severity = IssueSeverity.WARNING
if utils.compare_versions(schema_version, min_rule_version) < 0:
if utils.compare_versions(schema_version, MIN_RULE_VERSION) < 0:
logging.info(
f"- Version {schema_version} is less than minimum required version {min_rule_version}. Skipping check"
f"- Version {schema_version} is less than minimum required version {MIN_RULE_VERSION}. Skipping check"
)
return

Expand All @@ -55,7 +56,7 @@ def check_rule(checker_data: models.CheckerData) -> None:
checker_id=reference_constants.CHECKER_ID,
emanating_entity="asam.net",
standard="xosc",
definition_setting="1.2.0",
definition_setting=MIN_RULE_VERSION,
rule_full_name="reference_control.uniquely_resolvable_entity_references",
)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<OpenSCENARIO>
<FileHeader description="Vehicle Catalog" author="ASAM" revMajor="1" revMinor="0"
date="2023-11-15T11:00:00.000000" />
<Catalog name="VehicleCatalog">
<Vehicle name="car_white" vehicleCategory="car">
<BoundingBox>
<Center x="1.4" y="0.0" z="0.9" />
<Dimensions width="2.0" length="5.0" height="1.8" />
</BoundingBox>
<Performance maxSpeed="69" maxDeceleration="30" maxAcceleration="5" />
<Axles>
<FrontAxle maxSteering="30" wheelDiameter="0.8" trackWidth="1.68" positionX="2.98"
positionZ="0.4" />
<RearAxle maxSteering="30" wheelDiameter="0.8" trackWidth="1.68" positionX="0"
positionZ="0.4" />
</Axles>
<Properties>
<Property name="control" value="internal" />
<Property name="model_id" value="0" />
<File
filepath="../../../external/delivery/esmini-noosg/resources/osgb/car_white.osgb" />
</Properties>
</Vehicle>
<Vehicle name="car_white" vehicleCategory="car">
<BoundingBox>
<Center x="1.4" y="0.0" z="0.9" />
<Dimensions width="2.0" length="5.0" height="1.8" />
</BoundingBox>
<Performance maxSpeed="69" maxDeceleration="30" maxAcceleration="5" />
<Axles>
<FrontAxle maxSteering="30" wheelDiameter="0.8" trackWidth="1.68" positionX="2.98"
positionZ="0.4" />
<RearAxle maxSteering="30" wheelDiameter="0.8" trackWidth="1.68" positionX="0"
positionZ="0.4" />
</Axles>
<Properties>
<Property name="control" value="internal" />
<Property name="model_id" value="0" />
<File
filepath="../../../external/delivery/esmini-noosg/resources/osgb/car_white.osgb" />
</Properties>
</Vehicle>
</Catalog>
</OpenSCENARIO>
30 changes: 30 additions & 0 deletions tests/test_reference_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,33 @@ def test_long_catalog_positive(
)
== 0
)


def test_minimum_version(
monkeypatch,
) -> None:
base_path = "tests/data/uniquely_resolvable_entity_references/"
target_file_name = f"vehicle_catalog_negative_v10.xosc"
target_file_path = os.path.join(base_path, target_file_name)

test_utils.create_test_config(target_file_path)

test_utils.launch_main(monkeypatch)

result = Result()
result.load_from_file(test_utils.REPORT_FILE_PATH)

_ = result.get_checker_result(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=reference_constants.CHECKER_ID,
)
# 0 issues because minumum version is not met and the check is not performed
# (even if it is a negative sample)
assert (
len(
result.get_issues_by_rule_uid(
"asam.net:xosc:1.2.0:reference_control.uniquely_resolvable_entity_references"
)
)
== 0
)

0 comments on commit 6934ad9

Please sign in to comment.