From e34f8c718a8807d8ae62ccd1d52b9bcec9786bc6 Mon Sep 17 00:00:00 2001 From: Tobias Reiher Date: Fri, 9 Feb 2024 19:08:57 +0100 Subject: [PATCH] Add end-to-end tests to test CLI output Ref. eng/recordflux/RecordFlux#860 --- Makefile | 7 +- tests/README.md | 4 + tests/const.py | 1 + tests/end-to-end/__init__.py | 0 tests/end-to-end/cli_test.py | 215 +++++++++++++++++++++++++++++++++++ tests/unit/validator_test.py | 170 ++++++++++++++------------- 6 files changed, 314 insertions(+), 83 deletions(-) create mode 100644 tests/end-to-end/__init__.py create mode 100644 tests/end-to-end/cli_test.py diff --git a/Makefile b/Makefile index 16ac42331..bf5c428d8 100644 --- a/Makefile +++ b/Makefile @@ -131,11 +131,11 @@ check_doc: poetry run tools/check_grammar.py --document doc/language_reference/language_reference.rst --verbal-map doc/language_reference/verbal_mapping.json examples/specs/*.rflx examples/apps/*/specs/*.rflx tests/data/specs/*.rflx tests/data/specs/parse_only/*.rflx poetry run tools/check_grammar.py --invalid --document doc/language_reference/language_reference.rst --verbal-map doc/language_reference/verbal_mapping.json tests/data/specs/invalid/{incorrect_comment_only,incorrect_empty_file,incorrect_specification}.rflx -.PHONY: test test_rflx test_examples test_coverage test_unit_coverage test_property test_tools test_ide test_optimized test_compilation test_binary_size test_installation test_specs test_apps +.PHONY: test test_rflx test_examples test_coverage test_unit_coverage test_language_coverage test_end_to_end test_property test_tools test_ide test_optimized test_compilation test_binary_size test_installation test_specs test_apps test: test_rflx test_examples -test_rflx: test_coverage test_unit_coverage test_language_coverage test_property test_tools test_ide test_optimized test_compilation test_binary_size test_installation +test_rflx: test_coverage test_unit_coverage test_language_coverage test_end_to_end test_property test_tools test_ide test_optimized test_compilation test_binary_size test_installation test_examples: test_specs test_apps @@ -154,6 +154,9 @@ test_unit_coverage: test_language_coverage: timeout -k 60 7200 $(PYTEST) --cov=rflx/lang --cov-branch --cov-fail-under=73.8 --cov-report=term-missing:skip-covered tests/language +test_end_to_end: + $(PYTEST) tests/end-to-end + test_property: $(PYTEST) tests/property diff --git a/tests/README.md b/tests/README.md index 2350087c5..9ed4de6ed 100644 --- a/tests/README.md +++ b/tests/README.md @@ -29,6 +29,10 @@ The executability and provability tests require the definition of a session call Session functions can be defined by putting a custom implementation of the `Session` package inside the `src` directory. +### End-to-End Tests (`tests/end-to-end`) + +End-to-end tests verify the functionality of the entire application. These tests ensure that the application behaves as intended, particularly focusing on its primary use cases. + ### Property Tests (`tests/property`) Property-based testing based on [Hypothesis](https://hypothesis.readthedocs.io/). diff --git a/tests/const.py b/tests/const.py index f43a7efe4..486dc66d5 100644 --- a/tests/const.py +++ b/tests/const.py @@ -8,6 +8,7 @@ IDE_DIR = TEST_DIR / "ide" GENERATED_DIR = TEST_DIR / "spark" / "generated" FEATURE_DIR = TEST_DIR / "feature" +VALIDATOR_DIR = DATA_DIR / "validator" EX_SPEC_DIR = Path("examples/specs") MAIN = "main.adb" diff --git a/tests/end-to-end/__init__.py b/tests/end-to-end/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/end-to-end/cli_test.py b/tests/end-to-end/cli_test.py new file mode 100644 index 000000000..ca575d8a9 --- /dev/null +++ b/tests/end-to-end/cli_test.py @@ -0,0 +1,215 @@ +import subprocess +import textwrap +from pathlib import Path + +from tests.const import DATA_DIR, SPEC_DIR, VALIDATOR_DIR + + +def test_check() -> None: + p = subprocess.run( + ["rflx", "--no-caching", "check", SPEC_DIR / "ethernet.rflx"], + capture_output=True, + ) + assert p.returncode == 0 + assert p.stdout.decode("utf-8") == "" + assert p.stderr.decode("utf-8") == textwrap.dedent( + """\ + Parsing tests/data/specs/ethernet.rflx + Processing Ethernet + Verifying __BUILTINS__::Boolean + Verifying __INTERNAL__::Opaque + Verifying Ethernet::Address + Verifying Ethernet::Type_Length + Verifying Ethernet::TPID + Verifying Ethernet::TCI + Verifying Ethernet::Frame + """, + ) + + +def test_check_no_verification() -> None: + p = subprocess.run( + [ + "rflx", + "--no-caching", + "--unsafe", + "--no-verification", + "check", + SPEC_DIR / "ethernet.rflx", + ], + capture_output=True, + ) + assert p.returncode == 0 + assert p.stdout.decode("utf-8") == "model: warning: model verification skipped\n" + assert p.stderr.decode("utf-8") == textwrap.dedent( + """\ + Parsing tests/data/specs/ethernet.rflx + Processing Ethernet + """, + ) + + +def test_generate(tmp_path: Path) -> None: + p = subprocess.run( + [ + "rflx", + "--no-caching", + "generate", + "-d", + tmp_path, + SPEC_DIR / "ethernet.rflx", + ], + capture_output=True, + ) + assert p.returncode == 0 + assert p.stdout.decode("utf-8") == "" + assert p.stderr.decode("utf-8") == textwrap.dedent( + f"""\ + Parsing tests/data/specs/ethernet.rflx + Processing Ethernet + Verifying __BUILTINS__::Boolean + Verifying __INTERNAL__::Opaque + Verifying Ethernet::Address + Verifying Ethernet::Type_Length + Verifying Ethernet::TPID + Verifying Ethernet::TCI + Verifying Ethernet::Frame + Generating Ethernet::Address + Generating Ethernet::Type_Length + Generating Ethernet::TPID + Generating Ethernet::TCI + Generating Ethernet::Frame + Creating {tmp_path}/rflx-ethernet.ads + Creating {tmp_path}/rflx-ethernet-frame.ads + Creating {tmp_path}/rflx-ethernet-frame.adb + Creating {tmp_path}/rflx-rflx_arithmetic.ads + Creating {tmp_path}/rflx-rflx_builtin_types-conversions.ads + Creating {tmp_path}/rflx-rflx_builtin_types.ads + Creating {tmp_path}/rflx-rflx_generic_types.ads + Creating {tmp_path}/rflx-rflx_generic_types-generic_operators.ads + Creating {tmp_path}/rflx-rflx_generic_types-generic_operations.ads + Creating {tmp_path}/rflx-rflx_message_sequence.ads + Creating {tmp_path}/rflx-rflx_scalar_sequence.ads + Creating {tmp_path}/rflx-rflx_types.ads + Creating {tmp_path}/rflx-rflx_types-operators.ads + Creating {tmp_path}/rflx-rflx_types-operations.ads + Creating {tmp_path}/rflx-rflx_arithmetic.adb + Creating {tmp_path}/rflx-rflx_generic_types-generic_operations.adb + Creating {tmp_path}/rflx-rflx_message_sequence.adb + Creating {tmp_path}/rflx-rflx_scalar_sequence.adb + Creating {tmp_path}/rflx.ads + """, + ) + assert (tmp_path / "rflx.ads").is_file() + + +def test_graph(tmp_path: Path) -> None: + p = subprocess.run( + [ + "rflx", + "--no-caching", + "graph", + "-d", + tmp_path, + SPEC_DIR / "ethernet.rflx", + ], + capture_output=True, + ) + assert p.returncode == 0 + assert p.stdout.decode("utf-8") == "" + assert p.stderr.decode("utf-8") == textwrap.dedent( + f"""\ + Parsing tests/data/specs/ethernet.rflx + Processing Ethernet + Verifying __BUILTINS__::Boolean + Verifying __INTERNAL__::Opaque + Verifying Ethernet::Address + Verifying Ethernet::Type_Length + Verifying Ethernet::TPID + Verifying Ethernet::TCI + Verifying Ethernet::Frame + Creating {tmp_path}/Ethernet_Frame.svg + """, + ) + assert (tmp_path / "Ethernet_Frame.svg").is_file() + + +def test_validate() -> None: + p = subprocess.run( + [ + "rflx", + "--no-caching", + "validate", + "-v", + VALIDATOR_DIR / "ethernet" / "frame" / "valid", + SPEC_DIR / "ethernet.rflx", + "Ethernet::Frame", + ], + capture_output=True, + ) + assert p.returncode == 0 + assert p.stdout.decode("utf-8") == textwrap.dedent( + """\ + tests/data/validator/ethernet/frame/valid/802.3-LLC-CDP.raw PASSED + tests/data/validator/ethernet/frame/valid/EII-802.1AD-802.1Q-IPv4.raw PASSED + tests/data/validator/ethernet/frame/valid/EII-802.1Q-802.1Q-IPv4-ICMP.raw PASSED + tests/data/validator/ethernet/frame/valid/EII-802.1Q-LLC-CDP.raw PASSED + tests/data/validator/ethernet/frame/valid/EII-802.1Q-LLC-STP.raw PASSED + tests/data/validator/ethernet/frame/valid/ethernet_802.3.raw PASSED + tests/data/validator/ethernet/frame/valid/ethernet_double_vlan_tag.raw PASSED + tests/data/validator/ethernet/frame/valid/ethernet_ipv4_udp.raw PASSED + tests/data/validator/ethernet/frame/valid/ethernet_vlan_tag.raw PASSED + """, + ) + assert p.stderr.decode("utf-8") == textwrap.dedent( + """\ + Parsing tests/data/specs/ethernet.rflx + Processing Ethernet + Verifying __BUILTINS__::Boolean + Verifying __INTERNAL__::Opaque + Verifying Ethernet::Address + Verifying Ethernet::Type_Length + Verifying Ethernet::TPID + Verifying Ethernet::TCI + Verifying Ethernet::Frame + """, + ) + + +def test_install(tmp_path: Path) -> None: + p = subprocess.run( + ["rflx", "install", "gnatstudio", "--gnat-studio-dir", tmp_path], + capture_output=True, + ) + assert p.returncode == 0 + assert p.stdout.decode("utf-8") == textwrap.dedent( + f"""\ + Installing RecordFlux plugin into "{tmp_path}/plug-ins" + """, + ) + assert p.stderr.decode("utf-8") == "" + assert (tmp_path / "plug-ins" / "recordflux.py").is_file() + + +def test_convert(tmp_path: Path) -> None: + p = subprocess.run( + ["rflx", "convert", "iana", "-d", tmp_path, DATA_DIR / "bootp-dhcp-parameters.xml"], + capture_output=True, + ) + assert p.returncode == 0 + assert p.stdout.decode("utf-8") == "" + assert p.stderr.decode("utf-8") == "" + assert (tmp_path / "bootp_dhcp_parameters.rflx").is_file() + + +def test_run_ls() -> None: + p = subprocess.run(["rflx", "run_ls"], capture_output=True, input="") + assert p.returncode == 0 + assert p.stdout.decode("utf-8") == "" + assert p.stderr.decode("utf-8") == textwrap.dedent( + """\ + Starting IO server + Shutting down the server + Closing the event loop. + """, + ) diff --git a/tests/unit/validator_test.py b/tests/unit/validator_test.py index 1c3f93883..6e1e17665 100644 --- a/tests/unit/validator_test.py +++ b/tests/unit/validator_test.py @@ -10,9 +10,8 @@ from rflx.model import NeverVerify from rflx.pyrflx import PyRFLX from rflx.validator import ValidationError, Validator -from tests.const import SPEC_DIR +from tests.const import SPEC_DIR, VALIDATOR_DIR -TEST_DIR = Path("tests/data/validator") CHECKSUM_MODULE = "tests.data.validator.checksum" @@ -167,7 +166,12 @@ def test_validate_error_msg_not_in_package() -> None: ValidationError, match=r'^message "Message" could not be found in package "Ethernet"$', ): - validator.validate(ID("Ethernet::Message"), [TEST_DIR / "ethernet/frame/valid"], None, None) + validator.validate( + ID("Ethernet::Message"), + [VALIDATOR_DIR / "ethernet/frame/valid"], + None, + None, + ) def test_validate_no_raw_files_in_valid_dir(tmp_path: Path) -> None: @@ -188,10 +192,10 @@ def test_validate_no_raw_files_in_valid_dir(tmp_path: Path) -> None: validator.validate( ID("Ethernet::Frame"), [ - TEST_DIR / "ethernet/frame/valid", + VALIDATOR_DIR / "ethernet/frame/valid", tmp_path, ], - [TEST_DIR / "ethernet/frame/invalid"], + [VALIDATOR_DIR / "ethernet/frame/invalid"], ) @@ -212,9 +216,9 @@ def test_validate_no_raw_files_in_invalid_dir(tmp_path: Path) -> None: ): validator.validate( ID("Ethernet::Frame"), - [TEST_DIR / "ethernet/frame/valid"], + [VALIDATOR_DIR / "ethernet/frame/valid"], [ - TEST_DIR / "ethernet/frame/invalid", + VALIDATOR_DIR / "ethernet/frame/invalid", tmp_path, ], ) @@ -271,7 +275,7 @@ def test_validate_output_is_a_dir(tmp_path: Path) -> None: ): validator.validate( ID("Ethernet::Frame"), - [TEST_DIR / "ethernet/frame/valid"], + [VALIDATOR_DIR / "ethernet/frame/valid"], None, tmp_path, ) @@ -312,7 +316,7 @@ def test_validate_output_not_writable(tmp_path: Path) -> None: ): validator.validate( ID("Ethernet::Frame"), - [TEST_DIR / "ethernet/frame/valid"], + [VALIDATOR_DIR / "ethernet/frame/valid"], None, output_file, ) @@ -328,15 +332,15 @@ def test_validate_abort_on_error() -> None: ValidationError, match=( r"^" - rf"aborted: message {TEST_DIR}/ethernet/frame/invalid.+\.raw " + rf"aborted: message {VALIDATOR_DIR}/ethernet/frame/invalid.+\.raw " r"was classified incorrectly" r"$" ), ): validator.validate( ID("Ethernet::Frame"), - [TEST_DIR / "ethernet/frame/valid"], - [TEST_DIR / "ethernet/frame/invalid"], + [VALIDATOR_DIR / "ethernet/frame/valid"], + [VALIDATOR_DIR / "ethernet/frame/invalid"], abort_on_error=True, ) @@ -365,7 +369,7 @@ def test_validate_positive_only() -> None: validator.validate( ID("Ethernet::Frame"), None, - [TEST_DIR / "ethernet/frame/valid"], + [VALIDATOR_DIR / "ethernet/frame/valid"], ) @@ -384,26 +388,28 @@ def test_validate_positive_output(tmp_path: Path) -> None: validator.validate( ID("Ethernet::Frame"), [ - TEST_DIR / "ethernet/frame/invalid", - TEST_DIR / "ethernet/frame/invalid2", - TEST_DIR / "ethernet/frame/invalid3/ethernet_invalid_too_long.bin", - TEST_DIR / "ethernet/frame/invalid3/ethernet_invalid_too_short.dat", + VALIDATOR_DIR / "ethernet/frame/invalid", + VALIDATOR_DIR / "ethernet/frame/invalid2", + VALIDATOR_DIR / "ethernet/frame/invalid3/ethernet_invalid_too_long.bin", + VALIDATOR_DIR / "ethernet/frame/invalid3/ethernet_invalid_too_short.dat", ], [ - TEST_DIR / "ethernet/frame/valid", - TEST_DIR / "ethernet/frame/valid2", - TEST_DIR / "ethernet/frame/valid3/ethernet_802.3.bin", - TEST_DIR / "ethernet/frame/valid3/ethernet_ipv4_udp.dat", + VALIDATOR_DIR / "ethernet/frame/valid", + VALIDATOR_DIR / "ethernet/frame/valid2", + VALIDATOR_DIR / "ethernet/frame/valid3/ethernet_802.3.bin", + VALIDATOR_DIR / "ethernet/frame/valid3/ethernet_ipv4_udp.dat", ], tmp_path / "output.json", ) - assert (tmp_path / "output.json").read_text() == (TEST_DIR / "output_positive.json").read_text( + assert (tmp_path / "output.json").read_text() == ( + VALIDATOR_DIR / "output_positive.json" + ).read_text( encoding="utf-8", ) def test_validate_negative_only() -> None: - number = len(list((TEST_DIR / "ethernet/frame/invalid").glob("*.raw"))) + number = len(list((VALIDATOR_DIR / "ethernet/frame/invalid").glob("*.raw"))) validator = Validator( [SPEC_DIR / "in_ethernet.rflx"], CHECKSUM_MODULE, @@ -416,7 +422,7 @@ def test_validate_negative_only() -> None: validator.validate( ID("Ethernet::Frame"), None, - [TEST_DIR / "ethernet/frame/invalid"], + [VALIDATOR_DIR / "ethernet/frame/invalid"], ) @@ -428,12 +434,12 @@ def test_validate_negative_output(tmp_path: Path) -> None: collected from multiple directories. The report should contain expected output for each file. """ number = len( - list((TEST_DIR / "ethernet/frame/invalid").glob("*.raw")) - + list((TEST_DIR / "ethernet/frame/invalid2").glob("*.raw")) - + list((TEST_DIR / "ethernet/frame/invalid3").iterdir()) - + list((TEST_DIR / "ethernet/frame/valid").glob("*.raw")) - + list((TEST_DIR / "ethernet/frame/valid2").glob("*.raw")) - + list((TEST_DIR / "ethernet/frame/valid3").iterdir()), + list((VALIDATOR_DIR / "ethernet/frame/invalid").glob("*.raw")) + + list((VALIDATOR_DIR / "ethernet/frame/invalid2").glob("*.raw")) + + list((VALIDATOR_DIR / "ethernet/frame/invalid3").iterdir()) + + list((VALIDATOR_DIR / "ethernet/frame/valid").glob("*.raw")) + + list((VALIDATOR_DIR / "ethernet/frame/valid2").glob("*.raw")) + + list((VALIDATOR_DIR / "ethernet/frame/valid3").iterdir()), ) validator = Validator( [SPEC_DIR / "in_ethernet.rflx"], @@ -447,20 +453,22 @@ def test_validate_negative_output(tmp_path: Path) -> None: validator.validate( ID("Ethernet::Frame"), [ - TEST_DIR / "ethernet/frame/valid", - TEST_DIR / "ethernet/frame/valid2", - TEST_DIR / "ethernet/frame/valid3/ethernet_802.3.bin", - TEST_DIR / "ethernet/frame/valid3/ethernet_ipv4_udp.dat", + VALIDATOR_DIR / "ethernet/frame/valid", + VALIDATOR_DIR / "ethernet/frame/valid2", + VALIDATOR_DIR / "ethernet/frame/valid3/ethernet_802.3.bin", + VALIDATOR_DIR / "ethernet/frame/valid3/ethernet_ipv4_udp.dat", ], [ - TEST_DIR / "ethernet/frame/invalid", - TEST_DIR / "ethernet/frame/invalid2", - TEST_DIR / "ethernet/frame/invalid3/ethernet_invalid_too_long.bin", - TEST_DIR / "ethernet/frame/invalid3/ethernet_invalid_too_short.dat", + VALIDATOR_DIR / "ethernet/frame/invalid", + VALIDATOR_DIR / "ethernet/frame/invalid2", + VALIDATOR_DIR / "ethernet/frame/invalid3/ethernet_invalid_too_long.bin", + VALIDATOR_DIR / "ethernet/frame/invalid3/ethernet_invalid_too_short.dat", ], tmp_path / "output.json", ) - assert (tmp_path / "output.json").read_text() == (TEST_DIR / "output_negative.json").read_text( + assert (tmp_path / "output.json").read_text() == ( + VALIDATOR_DIR / "output_negative.json" + ).read_text( encoding="utf-8", ) @@ -473,25 +481,25 @@ def test_validate_coverage(capsys: pytest.CaptureFixture[str]) -> None: ) validator.validate( ID("Ethernet::Frame"), - [TEST_DIR / "ethernet/frame/invalid"], - [TEST_DIR / "ethernet/frame/valid"], + [VALIDATOR_DIR / "ethernet/frame/invalid"], + [VALIDATOR_DIR / "ethernet/frame/valid"], coverage=True, target_coverage=100, ) expected_output = f"""model: warning: model verification skipped -{TEST_DIR}/ethernet/frame/valid/802.3-LLC-CDP.raw PASSED -{TEST_DIR}/ethernet/frame/valid/EII-802.1AD-802.1Q-IPv4.raw PASSED -{TEST_DIR}/ethernet/frame/valid/EII-802.1Q-802.1Q-IPv4-ICMP.raw PASSED -{TEST_DIR}/ethernet/frame/valid/EII-802.1Q-LLC-CDP.raw PASSED -{TEST_DIR}/ethernet/frame/valid/EII-802.1Q-LLC-STP.raw PASSED -{TEST_DIR}/ethernet/frame/valid/ethernet_802.3.raw PASSED -{TEST_DIR}/ethernet/frame/valid/ethernet_double_vlan_tag.raw PASSED -{TEST_DIR}/ethernet/frame/valid/ethernet_ipv4_udp.raw PASSED -{TEST_DIR}/ethernet/frame/valid/ethernet_vlan_tag.raw PASSED -{TEST_DIR}/ethernet/frame/invalid/ethernet_802.3_invalid_length.raw PASSED -{TEST_DIR}/ethernet/frame/invalid/ethernet_invalid_too_long.raw PASSED -{TEST_DIR}/ethernet/frame/invalid/ethernet_invalid_too_short.raw PASSED -{TEST_DIR}/ethernet/frame/invalid/ethernet_undefined.raw PASSED +{VALIDATOR_DIR}/ethernet/frame/valid/802.3-LLC-CDP.raw PASSED +{VALIDATOR_DIR}/ethernet/frame/valid/EII-802.1AD-802.1Q-IPv4.raw PASSED +{VALIDATOR_DIR}/ethernet/frame/valid/EII-802.1Q-802.1Q-IPv4-ICMP.raw PASSED +{VALIDATOR_DIR}/ethernet/frame/valid/EII-802.1Q-LLC-CDP.raw PASSED +{VALIDATOR_DIR}/ethernet/frame/valid/EII-802.1Q-LLC-STP.raw PASSED +{VALIDATOR_DIR}/ethernet/frame/valid/ethernet_802.3.raw PASSED +{VALIDATOR_DIR}/ethernet/frame/valid/ethernet_double_vlan_tag.raw PASSED +{VALIDATOR_DIR}/ethernet/frame/valid/ethernet_ipv4_udp.raw PASSED +{VALIDATOR_DIR}/ethernet/frame/valid/ethernet_vlan_tag.raw PASSED +{VALIDATOR_DIR}/ethernet/frame/invalid/ethernet_802.3_invalid_length.raw PASSED +{VALIDATOR_DIR}/ethernet/frame/invalid/ethernet_invalid_too_long.raw PASSED +{VALIDATOR_DIR}/ethernet/frame/invalid/ethernet_invalid_too_short.raw PASSED +{VALIDATOR_DIR}/ethernet/frame/invalid/ethernet_undefined.raw PASSED -------------------------------------------------------------------------------- @@ -520,25 +528,25 @@ def test_coverage_threshold_missed(capsys: pytest.CaptureFixture[str]) -> None: ): validator.validate( ID("Ethernet::Frame"), - [TEST_DIR / "ethernet/frame/invalid"], - [TEST_DIR / "ethernet/frame/valid"], + [VALIDATOR_DIR / "ethernet/frame/invalid"], + [VALIDATOR_DIR / "ethernet/frame/valid"], coverage=True, target_coverage=90, ) expected_output = f"""model: warning: model verification skipped -{TEST_DIR}/ethernet/frame/valid/802.3-LLC-CDP.raw PASSED -{TEST_DIR}/ethernet/frame/valid/EII-802.1AD-802.1Q-IPv4.raw PASSED -{TEST_DIR}/ethernet/frame/valid/EII-802.1Q-802.1Q-IPv4-ICMP.raw PASSED -{TEST_DIR}/ethernet/frame/valid/EII-802.1Q-LLC-CDP.raw PASSED -{TEST_DIR}/ethernet/frame/valid/EII-802.1Q-LLC-STP.raw PASSED -{TEST_DIR}/ethernet/frame/valid/ethernet_802.3.raw PASSED -{TEST_DIR}/ethernet/frame/valid/ethernet_double_vlan_tag.raw PASSED -{TEST_DIR}/ethernet/frame/valid/ethernet_ipv4_udp.raw PASSED -{TEST_DIR}/ethernet/frame/valid/ethernet_vlan_tag.raw PASSED -{TEST_DIR}/ethernet/frame/invalid/ethernet_802.3_invalid_length.raw PASSED -{TEST_DIR}/ethernet/frame/invalid/ethernet_invalid_too_long.raw PASSED -{TEST_DIR}/ethernet/frame/invalid/ethernet_invalid_too_short.raw PASSED -{TEST_DIR}/ethernet/frame/invalid/ethernet_undefined.raw PASSED +{VALIDATOR_DIR}/ethernet/frame/valid/802.3-LLC-CDP.raw PASSED +{VALIDATOR_DIR}/ethernet/frame/valid/EII-802.1AD-802.1Q-IPv4.raw PASSED +{VALIDATOR_DIR}/ethernet/frame/valid/EII-802.1Q-802.1Q-IPv4-ICMP.raw PASSED +{VALIDATOR_DIR}/ethernet/frame/valid/EII-802.1Q-LLC-CDP.raw PASSED +{VALIDATOR_DIR}/ethernet/frame/valid/EII-802.1Q-LLC-STP.raw PASSED +{VALIDATOR_DIR}/ethernet/frame/valid/ethernet_802.3.raw PASSED +{VALIDATOR_DIR}/ethernet/frame/valid/ethernet_double_vlan_tag.raw PASSED +{VALIDATOR_DIR}/ethernet/frame/valid/ethernet_ipv4_udp.raw PASSED +{VALIDATOR_DIR}/ethernet/frame/valid/ethernet_vlan_tag.raw PASSED +{VALIDATOR_DIR}/ethernet/frame/invalid/ethernet_802.3_invalid_length.raw PASSED +{VALIDATOR_DIR}/ethernet/frame/invalid/ethernet_invalid_too_long.raw PASSED +{VALIDATOR_DIR}/ethernet/frame/invalid/ethernet_invalid_too_short.raw PASSED +{VALIDATOR_DIR}/ethernet/frame/invalid/ethernet_undefined.raw PASSED -------------------------------------------------------------------------------- @@ -586,8 +594,8 @@ def test_validate_coverage_threshold_invalid() -> None: ): validator.validate( ID("Ethernet::Frame"), - [TEST_DIR / "ethernet/frame/invalid"], - [TEST_DIR / "ethernet/frame/valid"], + [VALIDATOR_DIR / "ethernet/frame/invalid"], + [VALIDATOR_DIR / "ethernet/frame/valid"], coverage=True, target_coverage=110, ) @@ -601,8 +609,8 @@ def test_validate_checksum_positive() -> None: ) validator.validate( ID("Checksum_Message::Message"), - [TEST_DIR / "checksum_message/invalid"], - [TEST_DIR / "checksum_message/valid"], + [VALIDATOR_DIR / "checksum_message/invalid"], + [VALIDATOR_DIR / "checksum_message/valid"], ) @@ -615,8 +623,8 @@ def test_validate_pyrflx_checksum_negative() -> None: with pytest.raises(ValidationError, match=r"^3 messages were classified incorrectly$"): validator.validate( ID("Checksum_Message::Message"), - [TEST_DIR / "checksum_message/valid"], - [TEST_DIR / "checksum_message/invalid"], + [VALIDATOR_DIR / "checksum_message/valid"], + [VALIDATOR_DIR / "checksum_message/invalid"], ) @@ -628,7 +636,7 @@ def test_validate_message_original_and_parsed_not_equal() -> None: .new_message("Frame") ) validation_result = validator._validate_message( # noqa: SLF001 - Path(TEST_DIR / "ethernet/frame/invalid/ethernet_invalid_too_long.raw"), + Path(VALIDATOR_DIR / "ethernet/frame/invalid/ethernet_invalid_too_long.raw"), valid_original_message=True, message_value=ethernet_too_short_value, ) @@ -646,7 +654,7 @@ def test_validate_message_parameterized_message() -> None: .new_message("Message") ) validation_result = validator._validate_message( # noqa: SLF001 - Path(TEST_DIR / "parameterized/message/valid/parameterized_message.raw"), + Path(VALIDATOR_DIR / "parameterized/message/valid/parameterized_message.raw"), valid_original_message=True, message_value=message, ) @@ -806,14 +814,14 @@ def test_parameterized_message_missing_parameter() -> None: ValidationError, match=( r"^" - f"{TEST_DIR}/parameterized/message/invalid/parameterized_message_missing_parameter.raw:" + f"{VALIDATOR_DIR}/parameterized/message/invalid/parameterized_message_missing_parameter.raw:" r" pyrflx: error: missing parameter values: Tag_Mode" r"$" ), ): validator._validate_message( # noqa: SLF001 Path( - TEST_DIR + VALIDATOR_DIR / "parameterized/message/invalid/parameterized_message_missing_parameter.raw", ), valid_original_message=True, @@ -832,14 +840,14 @@ def test_parameterized_message_excess_parameter() -> None: ValidationError, match=( r"^" - f"{TEST_DIR}/parameterized/message/invalid/parameterized_message_excess_parameter.raw:" + f"{VALIDATOR_DIR}/parameterized/message/invalid/parameterized_message_excess_parameter.raw:" r" pyrflx: error: unexpected parameter values: Excess" r"$" ), ): validator._validate_message( # noqa: SLF001 Path( - TEST_DIR + VALIDATOR_DIR / "parameterized/message/invalid/parameterized_message_excess_parameter.raw", ), valid_original_message=True,