test: cover the kernel-datapath review fixes

Regression coverage added with the fixes:
- capture-slot semantics: second-port refusal, failed-start rollback, and
  a non-owner port's stop not reaching `capture stop_kernel`;
- QEMU stop/start teardown on a mid-body or pre-launch failure, IOU start
  cleanup and filter guards, Dynamips half-attach undo plus retry;
- switch VLAN reconcile skipping a deferred anchor and rolling the
  ports_mapping back on failure;
- Docker/QEMU occupied-port refusal, probe ctime invalidation, probe
  survival of a failing uBridge start;
- env-marker dialects (mid-line mentions, falsy values) and the agent
  merge rejecting entries without a device_name.

Test-body imports of product modules move to the shared header.
This commit is contained in:
YueGuobin committed 2026-10-06 19:55:31 +08:00
1 parent c3c025ab2a
commit 35cf964882
13 files changed
+438 -40

No files matched your search

+3
View File
@@ -45,8 +45,11 @@ def test_anchor_type_keys_iol_runner_containers_apart():
assert kernel_anchor_type("docker", "GNS3_IOL_RUNNER=1") == "iol_docker"
assert kernel_anchor_type("docker", "GNS3_IOL_STARTUP_CONFIG=cfg.txt\nGNS3_IOL_RUNNER=1") == "iol_docker"
assert kernel_anchor_type("docker", "GNS3_IOL_RUNNER=1,") == "iol_docker"
assert kernel_anchor_type("docker") == "docker"
assert kernel_anchor_type("docker", "GNS3_UNIX_SOCKET_NIO=1") == "docker"
# a mid-line mention is not the marker (mirrors _select_node_class)
assert kernel_anchor_type("docker", "NOTE=GNS3_IOL_RUNNER=1") == "docker"
assert kernel_anchor_type("qemu") == "qemu"
+7 -2
View File
@@ -360,8 +360,13 @@ class TestNetemExtensionFilters:
{"delay": [100, 20, ""], "packet_loss": [10, 0], "corrupt": [2], "bpf": ["icmp"]}
)
assert dropped == set()
# zero correlation and empty distribution are kept as-is (no-ops)
assert clean == {"delay": [100, 20, ""], "packet_loss": [10, 0], "corrupt": [2], "bpf": ["icmp"]}
# Zero correlation and an empty distribution carry no feature, so
# neither is reported as dropped. The packet_loss correlation slot
# is stripped all the same: the relay filter takes exactly one
# argument (ubridge's packet_loss_setup rejects argc != 1), while
# the delay's empty 3rd value is an unquoted empty token that
# tokenizes away — harmless kept as-is.
assert clean == {"delay": [100, 20, ""], "packet_loss": [10], "corrupt": [2], "bpf": ["icmp"]}
def test_kernel_only_features_empty(self):
assert split_kernel_only_features({}) == ({}, set())