Skip to content

Commit fc93c24

Browse files
committed
Fix code-wifi pairing
1 parent fdc9a59 commit fc93c24

File tree

5 files changed

+46
-20
lines changed

5 files changed

+46
-20
lines changed

scripts/py_matter_yamltests/matter_yamltests/pseudo_clusters/clusters/accessory_server_bridge.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
_PORT = 9000
2323

2424
if sys.platform == 'linux':
25-
_IP = '10.10.10.5'
25+
_IP = "10.10.12.5"
2626

2727

2828
def _make_url():

scripts/tests/chiptest/accessories.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
PORT = 9000
2929

3030
if sys.platform == 'linux':
31-
IP = '10.10.10.5'
31+
IP = "10.10.12.5"
3232

3333

3434
class AppsRegister:

scripts/tests/chiptest/linux.py

+35-14
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def EnsurePrivateState():
6464
sys.exit(1)
6565

6666

67-
def CreateNamespacesForAppTest():
67+
def CreateNamespacesForAppTest(wifi_ble_config: bool = False):
6868
"""
6969
Creates appropriate namespaces for a tool and app binaries in a simulated
7070
isolated network.
@@ -95,23 +95,33 @@ def CreateNamespacesForAppTest():
9595
"ip netns exec app ip link set dev lo up",
9696
"ip link set dev eth-app-switch up",
9797

98-
"ip netns exec tool ip addr add 10.10.10.2/24 dev eth-tool",
98+
"ip netns exec tool ip addr add 10.10.12.2/24 dev eth-tool",
9999
"ip netns exec tool ip link set dev eth-tool up",
100100
"ip netns exec tool ip link set dev lo up",
101101
"ip link set dev eth-tool-switch up",
102102

103-
# Force IPv6 to use ULAs that we control
104-
"ip netns exec tool ip -6 addr flush eth-tool",
105-
"ip netns exec app ip -6 addr flush eth-app",
106-
"ip netns exec tool ip -6 a add fd00:0:1:1::2/64 dev eth-tool",
107-
"ip netns exec app ip -6 a add fd00:0:1:1::3/64 dev eth-app",
108-
109-
# create link between virtual host 'tool' and the test runner
110103
"ip addr add 10.10.10.5/24 dev eth-ci",
104+
"ip addr add 10.10.12.5/24 dev eth-ci",
111105
"ip link set dev eth-ci up",
112106
"ip link set dev eth-ci-switch up",
113107
]
114108

109+
if not wifi_ble_config:
110+
COMMANDS += [
111+
"ip link add eth-app-direct type veth peer name eth-tool-direct",
112+
"ip link set eth-app-direct netns app",
113+
"ip link set eth-tool-direct netns tool",
114+
"ip netns exec app ip addr add 10.10.15.1/24 dev eth-app-direct",
115+
"ip netns exec app ip link set dev eth-app-direct up",
116+
"ip netns exec tool ip addr add 10.10.15.2/24 dev eth-tool-direct",
117+
"ip netns exec tool ip link set dev eth-tool-direct up",
118+
# Force IPv6 to use ULAs that we control
119+
"ip netns exec tool ip -6 addr flush eth-tool",
120+
"ip netns exec app ip -6 addr flush eth-app",
121+
"ip netns exec tool ip -6 a add fd00:0:1:1::2/64 dev eth-tool-direct",
122+
"ip netns exec app ip -6 a add fd00:0:1:1::3/64 dev eth-app-direct",
123+
]
124+
115125
for command in COMMANDS:
116126
logging.debug("Executing '%s'" % command)
117127
if os.system(command) != 0:
@@ -134,7 +144,7 @@ def CreateNamespacesForAppTest():
134144
logging.warn("Some addresses look to still be tentative")
135145

136146

137-
def RemoveNamespaceForAppTest():
147+
def RemoveNamespaceForAppTest(wifi_ble_config: bool = False):
138148
"""
139149
Removes namespaces for a tool and app binaries previously created to simulate an
140150
isolated network. This tears down what was created in CreateNamespacesForAppTest.
@@ -155,6 +165,14 @@ def RemoveNamespaceForAppTest():
155165
"ip netns del app",
156166
]
157167

168+
if not wifi_ble_config:
169+
COMMANDS += [
170+
"ip link set dev eth-app-direct down",
171+
"ip link set dev eth-tool-direct down",
172+
"ip link delete eth-tool-direct",
173+
"ip link delete eth-app-direct",
174+
]
175+
158176
for command in COMMANDS:
159177
logging.debug("Executing '%s'" % command)
160178
if os.system(command) != 0:
@@ -163,17 +181,17 @@ def RemoveNamespaceForAppTest():
163181
sys.exit(1)
164182

165183

166-
def PrepareNamespacesForTestExecution(in_unshare: bool):
184+
def PrepareNamespacesForTestExecution(in_unshare: bool, wifi_ble_config: bool = False):
167185
if not in_unshare:
168186
EnsureNetworkNamespaceAvailability()
169187
elif in_unshare:
170188
EnsurePrivateState()
171189

172-
CreateNamespacesForAppTest()
190+
CreateNamespacesForAppTest(wifi_ble_config)
173191

174192

175-
def ShutdownNamespaceForTestExecution():
176-
RemoveNamespaceForAppTest()
193+
def ShutdownNamespaceForTestExecution(wifi_ble_config: bool = False):
194+
RemoveNamespaceForAppTest(wifi_ble_config)
177195

178196

179197
class DbusTest:
@@ -279,6 +297,9 @@ def start(self):
279297
logging.info(f"Would run dnsmasq with {dnsmaq_cmd}")
280298
logging.info(f"Would run wpa_supplicant with {wpa_cmd}")
281299
return
300+
# Write clean configuration for wifi to prevent auto wifi connection during next test
301+
with open(self._wpa_supplicant_conf, "w") as f:
302+
f.write("ctrl_interface=DIR=/run/wpa_supplicant\nctrl_interface_group=root\nupdate_config=1\n")
282303
self._move_phy_to_netns(self._get_phy(self._wlan_app), "app")
283304
self._move_phy_to_netns(self._get_phy(self._wlan_tool), "tool")
284305
self._set_interface_ip_in_netns("tool", self._wlan_tool, "192.168.200.1/24")

scripts/tests/chiptest/test_definition.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,13 @@ def Run(self, runner, apps_register, paths: ApplicationPaths, pics_file: str,
378378
pairing_server_args = []
379379
if tool_hci_number is not None:
380380
pairing_cmd = paths.chip_tool_with_python_cmd + [
381-
"pairing", "code-wifi", TEST_NODE_ID, "Virtual_Wifi", "ExamplePassword", "MT:-24J0AFN00KA0648G00"]
381+
"pairing",
382+
"code-wifi",
383+
TEST_NODE_ID,
384+
"Virtual_Wifi",
385+
"ExamplePassword",
386+
"MT:-24J042C00KA0648G00",
387+
]
382388
pairing_server_args = [
383389
"--ble-adapter", str(tool_hci_number)]
384390
else:

scripts/tests/run_test_suite.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,7 @@ def cmd_run(context, iterations, all_clusters_app, lock_app, ota_provider_app, o
359359
)
360360

361361
if sys.platform == 'linux':
362-
chiptest.linux.PrepareNamespacesForTestExecution(
363-
context.obj.in_unshare)
362+
chiptest.linux.PrepareNamespacesForTestExecution(context.obj.in_unshare, ble_wifi)
364363
if ble_wifi:
365364
dbus = chiptest.linux.DbusTest()
366365
dbus.start()
@@ -392,7 +391,7 @@ def cleanup():
392391
virt_wifi.stop()
393392
virt_ble.stop()
394393
dbus.stop()
395-
chiptest.linux.ShutdownNamespaceForTestExecution()
394+
chiptest.linux.ShutdownNamespaceForTestExecution(ble_wifi)
396395

397396
for i in range(iterations):
398397
logging.info("Starting iteration %d" % (i + 1))

0 commit comments

Comments
 (0)