test-network: try to stop test-modem-manager-mock.service only when necessary

Otherwise, all test cases that does not create/start the service emits
the following error:
```
Failed to stop test-modem-manager-mock.service: Unit test-modem-manager-mock.service not loaded.
```

Moreover, without this change, extra 'systemctl daemon-reload' is triggered after
all test cases. That's super heavy, especially when the test is running on
sanitizers.

Follow-up for abe3d570f8.
This commit is contained in:
Yu Watanabe
2026-05-20 23:40:51 +09:00
parent ba13cd1245
commit 18f2e9bcfa

View File

@@ -1210,7 +1210,6 @@ def tear_down_common():
stop_dnsmasq()
stop_isc_dhcpd()
stop_radvd()
stop_modem_manager_mock()
# 2. remove modules
call_quiet('rmmod netdevsim')
@@ -10884,6 +10883,7 @@ class NetworkdWWANTests(unittest.TestCase, Utilities):
setup_common()
def tearDown(self):
stop_modem_manager_mock()
tear_down_common()
def test_wwan_ipv4v6_static(self):