diff --git a/tests/cmd/call.py b/tests/cmd/call.py index 68728c0..1e890e7 100644 --- a/tests/cmd/call.py +++ b/tests/cmd/call.py @@ -63,7 +63,7 @@ async def handle_request( return response # Invoke the service without discovery and then run the server for a few seconds to let it process the request. - proc = Subprocess.cli( # Windows compat: -v blocks stderr pipe on Windows. + proc = Subprocess.cli( "-j", "call", "22", @@ -92,7 +92,7 @@ async def handle_request( # Invoke the service with ID discovery and static type. last_metadata = None - proc = Subprocess.cli( # Windows compat: -v blocks stderr pipe on Windows. + proc = Subprocess.cli( "-j", "call", "22", @@ -122,7 +122,7 @@ async def handle_request( # Invoke the service with full discovery. last_metadata = None - proc = Subprocess.cli( # Windows compat: -v blocks stderr pipe on Windows. + proc = Subprocess.cli( "-j", "call", "22", @@ -204,7 +204,7 @@ async def _unittest_call_fixed(transport_factory: TransportFactory, compiled_dsd server_node.start() # Invoke a fixed port-ID service. - proc = Subprocess.cli( # Windows compat: -v blocks stderr pipe on Windows. + proc = Subprocess.cli( "-j", "call", "22", diff --git a/tests/cmd/monitor.py b/tests/cmd/monitor.py index b56e98c..57ede62 100755 --- a/tests/cmd/monitor.py +++ b/tests/cmd/monitor.py @@ -4,6 +4,7 @@ # Author: Pavel Kirienko from typing import Any, Optional, Awaitable +import sys import asyncio import itertools import pytest @@ -13,6 +14,9 @@ from tests.dsdl import OUTPUT_DIR import yakut +if sys.platform.startswith("win"): # pragma: no cover + pytest.skip("These tests do not work reliably on Windows", allow_module_level=True) + # noinspection SpellCheckingInspection @pytest.mark.asyncio diff --git a/tests/cmd/pubsub.py b/tests/cmd/pubsub.py index 88c8501..a98a6e9 100644 --- a/tests/cmd/pubsub.py +++ b/tests/cmd/pubsub.py @@ -53,7 +53,7 @@ def _unittest_pub_sub_regular(transport_factory: TransportFactory, compiled_dsdl ) time.sleep(1.0) # Time to let the background processes finish initialization - proc_pub = Subprocess.cli( # Windows compat: -v blocks stderr pipe on Windows. + proc_pub = Subprocess.cli( "--heartbeat-vssc=54", "--heartbeat-priority=high", "--node-info", @@ -149,21 +149,21 @@ def _unittest_slow_cli_pub_sub_anon(transport_factory: TransportFactory, compile "YAKUT_TRANSPORT": transport_factory(None).expression, "YAKUT_PATH": str(OUTPUT_DIR), } - proc_sub_heartbeat = Subprocess.cli( # Windows compat: -v blocks stderr pipe on Windows. + proc_sub_heartbeat = Subprocess.cli( "-j", "sub", "uavcan.node.heartbeat", "--with-metadata", environment_variables=env, ) - proc_sub_diagnostic_with_meta = Subprocess.cli( # Windows compat: -v blocks stderr pipe on Windows. + proc_sub_diagnostic_with_meta = Subprocess.cli( "-j", "sub", "uavcan.diagnostic.record", "--with-metadata", environment_variables=env, ) - proc_sub_diagnostic_no_meta = Subprocess.cli( # Windows compat: -v blocks stderr pipe on Windows. + proc_sub_diagnostic_no_meta = Subprocess.cli( "-j", "sub", "uavcan.diagnostic.record", @@ -173,53 +173,38 @@ def _unittest_slow_cli_pub_sub_anon(transport_factory: TransportFactory, compile time.sleep(3.0) # Time to let the background processes finish initialization - if transport_factory(None).can_transmit: - proc = Subprocess.cli( - "pub", - "uavcan.diagnostic.record", - "{}", - "--count=2", - "--period=2", - environment_variables=env, - ) - proc.wait(timeout=8) + proc = Subprocess.cli( + "pub", + "uavcan.diagnostic.record", + "{}", + "--count=2", + "--period=2", + environment_variables=env, + ) + proc.wait(timeout=8) - time.sleep(2.0) # Time to sync up + time.sleep(2.0) # Time to sync up - assert ( - proc_sub_heartbeat.wait(1.0, interrupt=True)[1].strip() == "" - ), "Anonymous nodes must not broadcast heartbeat" + assert proc_sub_heartbeat.wait(1.0, interrupt=True)[1].strip() == "", "Anonymous nodes must not broadcast heartbeat" - diagnostics = list( - json.loads(s) for s in proc_sub_diagnostic_with_meta.wait(1.0, interrupt=True)[1].splitlines() - ) - print("diagnostics:", diagnostics) - # Remember that anonymous transfers over redundant transports are NOT deduplicated. - # Hence, to support the case of redundant transports, we use 'greater or equal' here. - assert len(diagnostics) >= 2 - for m in diagnostics: - assert "nominal" in m["8184"]["_meta_"]["priority"].lower() - assert m["8184"]["_meta_"]["transfer_id"] >= 0 - assert m["8184"]["_meta_"]["source_node_id"] is None - assert m["8184"]["timestamp"]["microsecond"] == 0 - assert m["8184"]["text"] == "" + diagnostics = list(json.loads(s) for s in proc_sub_diagnostic_with_meta.wait(1.0, interrupt=True)[1].splitlines()) + print("diagnostics:", diagnostics) + # Remember that anonymous transfers over redundant transports are NOT deduplicated. + # Hence, to support the case of redundant transports, we use 'greater or equal' here. + assert len(diagnostics) >= 2 + for m in diagnostics: + assert "nominal" in m["8184"]["_meta_"]["priority"].lower() + assert m["8184"]["_meta_"]["transfer_id"] >= 0 + assert m["8184"]["_meta_"]["source_node_id"] is None + assert m["8184"]["timestamp"]["microsecond"] == 0 + assert m["8184"]["text"] == "" - diagnostics = list(json.loads(s) for s in proc_sub_diagnostic_no_meta.wait(1.0, interrupt=True)[1].splitlines()) - print("diagnostics:", diagnostics) - assert len(diagnostics) >= 2 # >= because see above - for m in diagnostics: - assert m["8184"]["timestamp"]["microsecond"] == 0 - assert m["8184"]["text"] == "" - else: - proc = Subprocess.cli( # Windows compat: -v blocks stderr pipe on Windows. - "pub", - "uavcan.diagnostic.Record", - "{}", - "--count=2", - "--period=2", - environment_variables=env, - ) - proc.wait(timeout=8, log=False) + diagnostics = list(json.loads(s) for s in proc_sub_diagnostic_no_meta.wait(1.0, interrupt=True)[1].splitlines()) + print("diagnostics:", diagnostics) + assert len(diagnostics) >= 2 # >= because see above + for m in diagnostics: + assert m["8184"]["timestamp"]["microsecond"] == 0 + assert m["8184"]["text"] == "" def _unittest_e2e_discovery_pub(transport_factory: TransportFactory, compiled_dsdl: typing.Any) -> None: @@ -238,7 +223,7 @@ def _unittest_e2e_discovery_pub(transport_factory: TransportFactory, compiled_ds }, ) time.sleep(3.0) # Let the subscriber boot up. - proc_pub = Subprocess.cli( # Windows compat: -v blocks stderr pipe on Windows. + proc_pub = Subprocess.cli( "pub", "1000", # Use discovery. "hello", @@ -260,7 +245,7 @@ def _unittest_e2e_discovery_pub(transport_factory: TransportFactory, compiled_ds def _unittest_e2e_discovery_sub(transport_factory: TransportFactory, compiled_dsdl: typing.Any) -> None: _ = compiled_dsdl - proc_pub = Subprocess.cli( # Windows compat: -v blocks stderr pipe on Windows. + proc_pub = Subprocess.cli( "pub", "1000:uavcan.primitive.string", "hello", diff --git a/tests/cmd/pubsub_sync.py b/tests/cmd/pubsub_sync.py index 9af019c..ca11e4f 100644 --- a/tests/cmd/pubsub_sync.py +++ b/tests/cmd/pubsub_sync.py @@ -27,7 +27,7 @@ def _unittest_monoclust_ts_field_auto(transport_factory: TransportFactory, compi }, ) time.sleep(3.0) - proc_pub = Subprocess.cli( # Windows compat: -v blocks stderr pipe on Windows. + proc_pub = Subprocess.cli( "pub", "1000:uavcan.si.sample.mass.Scalar", "!$ n * 1e6", @@ -72,7 +72,7 @@ def _unittest_monoclust_ts_field_manual(transport_factory: TransportFactory, com }, ) time.sleep(3.0) - proc_pub = Subprocess.cli( # Windows compat: -v blocks stderr pipe on Windows. + proc_pub = Subprocess.cli( "pub", "1000:uavcan.si.sample.mass.Scalar", "!$ n * 1.00 * 1e6", @@ -142,7 +142,7 @@ def _unittest_monoclust_ts_arrival_auto(transport_factory: TransportFactory, com }, ) time.sleep(3.0) - proc_pub = Subprocess.cli( # Windows compat: -v blocks stderr pipe on Windows. + proc_pub = Subprocess.cli( "pub", "1000:uavcan.primitive.String", "!$ str(n)", @@ -179,7 +179,7 @@ def _unittest_transfer_id(transport_factory: TransportFactory, compiled_dsdl: ty }, ) time.sleep(3.0) - proc_pub = Subprocess.cli( # Windows compat: -v blocks stderr pipe on Windows. + proc_pub = Subprocess.cli( "pub", "1000:uavcan.primitive.String", "!$ str(n)", diff --git a/tests/transport.py b/tests/transport.py index eae076e..4e85a6b 100644 --- a/tests/transport.py +++ b/tests/transport.py @@ -20,11 +20,6 @@ class TransportConfig: """ expression: str - """ - Please do not use this in new tests, - consider using the environment variables instead as they are the recommended form now. - """ - can_transmit: bool environment: dict[str, str] @@ -69,7 +64,6 @@ def sudo(cmd: str, ensure_success: bool = True) -> None: def vcan() -> typing.Iterator[TransportFactory]: yield lambda nid: TransportConfig( expression=f"CAN(can.media.socketcan.SocketCANMedia('vcan0',64),local_node_id={nid})", - can_transmit=True, environment=mk_env( nid, UAVCAN__CAN__IFACE="socketcan:vcan0", @@ -86,7 +80,6 @@ def vcan_tmr() -> typing.Iterator[TransportFactory]: for idx, mtu in enumerate([8, 32, 64]) ) ), - can_transmit=True, environment=mk_env( nid, UAVCAN__CAN__IFACE="socketcan:vcan0 socketcan:vcan1 socketcan:vcan2", @@ -114,7 +107,6 @@ def serial_tunneled_via_tcp() -> typing.Iterator[TransportFactory]: assert broker.alive yield lambda nid: TransportConfig( expression=f"Serial('{serial_endpoint}',local_node_id={nid})", - can_transmit=True, environment=mk_env( nid, UAVCAN__SERIAL__IFACE=serial_endpoint, @@ -129,16 +121,6 @@ def udp_loopback() -> typing.Iterator[TransportFactory]: yield lambda nid: ( TransportConfig( expression=f"UDP('127.0.0.1',{nid})", - can_transmit=True, - environment=mk_env( - nid, - UAVCAN__UDP__IFACE="127.0.0.1", - ), - ) - if nid is not None - else TransportConfig( - expression="UDP('127.0.0.1',None)", - can_transmit=False, environment=mk_env( nid, UAVCAN__UDP__IFACE="127.0.0.1", @@ -158,7 +140,6 @@ def heterogeneous_udp_serial() -> typing.Iterator[TransportFactory]: ] ) ), - can_transmit=nid is not None, environment=mk_env( nid, UAVCAN__SERIAL__IFACE=serial_endpoint,