@@ -64,7 +64,7 @@ def EnsurePrivateState():
64
64
sys .exit (1 )
65
65
66
66
67
- def CreateNamespacesForAppTest ():
67
+ def CreateNamespacesForAppTest (wifi_ble_config : bool = False ):
68
68
"""
69
69
Creates appropriate namespaces for a tool and app binaries in a simulated
70
70
isolated network.
@@ -95,23 +95,33 @@ def CreateNamespacesForAppTest():
95
95
"ip netns exec app ip link set dev lo up" ,
96
96
"ip link set dev eth-app-switch up" ,
97
97
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" ,
99
99
"ip netns exec tool ip link set dev eth-tool up" ,
100
100
"ip netns exec tool ip link set dev lo up" ,
101
101
"ip link set dev eth-tool-switch up" ,
102
102
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
110
103
"ip addr add 10.10.10.5/24 dev eth-ci" ,
104
+ "ip addr add 10.10.12.5/24 dev eth-ci" ,
111
105
"ip link set dev eth-ci up" ,
112
106
"ip link set dev eth-ci-switch up" ,
113
107
]
114
108
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
+
115
125
for command in COMMANDS :
116
126
logging .debug ("Executing '%s'" % command )
117
127
if os .system (command ) != 0 :
@@ -134,7 +144,7 @@ def CreateNamespacesForAppTest():
134
144
logging .warn ("Some addresses look to still be tentative" )
135
145
136
146
137
- def RemoveNamespaceForAppTest ():
147
+ def RemoveNamespaceForAppTest (wifi_ble_config : bool = False ):
138
148
"""
139
149
Removes namespaces for a tool and app binaries previously created to simulate an
140
150
isolated network. This tears down what was created in CreateNamespacesForAppTest.
@@ -155,6 +165,14 @@ def RemoveNamespaceForAppTest():
155
165
"ip netns del app" ,
156
166
]
157
167
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
+
158
176
for command in COMMANDS :
159
177
logging .debug ("Executing '%s'" % command )
160
178
if os .system (command ) != 0 :
@@ -163,17 +181,17 @@ def RemoveNamespaceForAppTest():
163
181
sys .exit (1 )
164
182
165
183
166
- def PrepareNamespacesForTestExecution (in_unshare : bool ):
184
+ def PrepareNamespacesForTestExecution (in_unshare : bool , wifi_ble_config : bool = False ):
167
185
if not in_unshare :
168
186
EnsureNetworkNamespaceAvailability ()
169
187
elif in_unshare :
170
188
EnsurePrivateState ()
171
189
172
- CreateNamespacesForAppTest ()
190
+ CreateNamespacesForAppTest (wifi_ble_config )
173
191
174
192
175
- def ShutdownNamespaceForTestExecution ():
176
- RemoveNamespaceForAppTest ()
193
+ def ShutdownNamespaceForTestExecution (wifi_ble_config : bool = False ):
194
+ RemoveNamespaceForAppTest (wifi_ble_config )
177
195
178
196
179
197
class DbusTest :
@@ -279,6 +297,9 @@ def start(self):
279
297
logging .info (f"Would run dnsmasq with { dnsmaq_cmd } " )
280
298
logging .info (f"Would run wpa_supplicant with { wpa_cmd } " )
281
299
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\n ctrl_interface_group=root\n update_config=1\n " )
282
303
self ._move_phy_to_netns (self ._get_phy (self ._wlan_app ), "app" )
283
304
self ._move_phy_to_netns (self ._get_phy (self ._wlan_tool ), "tool" )
284
305
self ._set_interface_ip_in_netns ("tool" , self ._wlan_tool , "192.168.200.1/24" )
0 commit comments