Garrick Evans | 5486162 | 2019-07-19 09:05:09 +0900 | [diff] [blame] | 1 | // Copyright 2019 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Garrick Evans | 3388a03 | 2020-03-24 11:25:55 +0900 | [diff] [blame] | 5 | #include "patchpanel/arc_service.h" |
Garrick Evans | 5486162 | 2019-07-19 09:05:09 +0900 | [diff] [blame] | 6 | |
Garrick Evans | e94b6de | 2020-02-20 09:19:13 +0900 | [diff] [blame] | 7 | #include <net/if.h> |
| 8 | |
Garrick Evans | 5486162 | 2019-07-19 09:05:09 +0900 | [diff] [blame] | 9 | #include <utility> |
| 10 | #include <vector> |
| 11 | |
| 12 | #include <base/bind.h> |
hscham | 4ce3c99 | 2021-02-19 16:37:23 +0900 | [diff] [blame] | 13 | #include <base/callback_helpers.h> |
Hugo Benichi | 84d96c4 | 2021-02-26 14:20:13 +0900 | [diff] [blame] | 14 | #include <dbus/mock_bus.h> |
Garrick Evans | 5486162 | 2019-07-19 09:05:09 +0900 | [diff] [blame] | 15 | #include <gmock/gmock.h> |
| 16 | #include <gtest/gtest.h> |
| 17 | |
Garrick Evans | 3388a03 | 2020-03-24 11:25:55 +0900 | [diff] [blame] | 18 | #include "patchpanel/address_manager.h" |
| 19 | #include "patchpanel/fake_process_runner.h" |
| 20 | #include "patchpanel/fake_shill_client.h" |
| 21 | #include "patchpanel/mock_datapath.h" |
Jason Jeremy Iman | a7273a3 | 2020-08-04 11:25:31 +0900 | [diff] [blame] | 22 | #include "patchpanel/mock_firewall.h" |
Garrick Evans | 3388a03 | 2020-03-24 11:25:55 +0900 | [diff] [blame] | 23 | #include "patchpanel/net_util.h" |
Garrick Evans | 5486162 | 2019-07-19 09:05:09 +0900 | [diff] [blame] | 24 | |
| 25 | using testing::_; |
Garrick Evans | e94b6de | 2020-02-20 09:19:13 +0900 | [diff] [blame] | 26 | using testing::AnyNumber; |
Garrick Evans | c707112 | 2020-04-17 12:31:57 +0900 | [diff] [blame] | 27 | using testing::Eq; |
Hugo Benichi | 84d96c4 | 2021-02-26 14:20:13 +0900 | [diff] [blame] | 28 | using testing::Invoke; |
Garrick Evans | 209a80a | 2020-11-30 14:42:40 +0900 | [diff] [blame] | 29 | using testing::Pair; |
Garrick Evans | c707112 | 2020-04-17 12:31:57 +0900 | [diff] [blame] | 30 | using testing::Pointee; |
Garrick Evans | 5486162 | 2019-07-19 09:05:09 +0900 | [diff] [blame] | 31 | using testing::Return; |
Garrick Evans | b4eb389 | 2019-11-13 12:07:07 +0900 | [diff] [blame] | 32 | using testing::ReturnRef; |
Garrick Evans | 5486162 | 2019-07-19 09:05:09 +0900 | [diff] [blame] | 33 | using testing::StrEq; |
Garrick Evans | 02e6e87 | 2020-11-30 11:53:13 +0900 | [diff] [blame] | 34 | using testing::UnorderedElementsAre; |
Garrick Evans | 5486162 | 2019-07-19 09:05:09 +0900 | [diff] [blame] | 35 | |
Garrick Evans | 3388a03 | 2020-03-24 11:25:55 +0900 | [diff] [blame] | 36 | namespace patchpanel { |
Garrick Evans | 5486162 | 2019-07-19 09:05:09 +0900 | [diff] [blame] | 37 | namespace { |
Garrick Evans | b4eb389 | 2019-11-13 12:07:07 +0900 | [diff] [blame] | 38 | constexpr pid_t kTestPID = -2; |
Garrick Evans | b4eb389 | 2019-11-13 12:07:07 +0900 | [diff] [blame] | 39 | constexpr uint32_t kTestCID = 2; |
Garrick Evans | 7a1a9ee | 2020-01-28 11:03:57 +0900 | [diff] [blame] | 40 | constexpr uint32_t kArcHostIP = Ipv4Addr(100, 115, 92, 1); |
| 41 | constexpr uint32_t kArcGuestIP = Ipv4Addr(100, 115, 92, 2); |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 42 | constexpr uint32_t kFirstEthHostIP = Ipv4Addr(100, 115, 92, 5); |
| 43 | constexpr uint32_t kFirstEthGuestIP = Ipv4Addr(100, 115, 92, 6); |
Garrick Evans | 86c7d9c | 2020-03-17 09:25:48 +0900 | [diff] [blame] | 44 | constexpr uint32_t kSecondEthHostIP = Ipv4Addr(100, 115, 92, 9); |
| 45 | constexpr uint32_t kFirstWifiHostIP = Ipv4Addr(100, 115, 92, 13); |
| 46 | constexpr uint32_t kSecondWifiHostIP = Ipv4Addr(100, 115, 92, 17); |
| 47 | constexpr uint32_t kFirstCellHostIP = Ipv4Addr(100, 115, 92, 21); |
Garrick Evans | c707112 | 2020-04-17 12:31:57 +0900 | [diff] [blame] | 48 | constexpr MacAddress kArcVmArc0MacAddr = {0x42, 0x37, 0x05, 0x13, 0x17, 0x01}; |
Garrick Evans | 5486162 | 2019-07-19 09:05:09 +0900 | [diff] [blame] | 49 | |
Hugo Benichi | 84d96c4 | 2021-02-26 14:20:13 +0900 | [diff] [blame] | 50 | class MockShillClient : public ShillClient { |
| 51 | public: |
| 52 | explicit MockShillClient(scoped_refptr<dbus::MockBus> bus) |
| 53 | : ShillClient(bus) {} |
| 54 | ~MockShillClient() = default; |
| 55 | |
| 56 | MOCK_METHOD2(GetDeviceProperties, |
| 57 | bool(const std::string& ifname, ShillClient::Device* device)); |
| 58 | }; |
| 59 | |
| 60 | void ExpectGetDeviceProperties(MockShillClient& shill_client, |
| 61 | const std::string& iface, |
| 62 | ShillClient::Device::Type type) { |
| 63 | EXPECT_CALL(shill_client, GetDeviceProperties(StrEq(iface), _)) |
| 64 | .WillRepeatedly( |
| 65 | Invoke([type](const std::string& _, ShillClient::Device* device) { |
| 66 | device->type = type; |
| 67 | return true; |
| 68 | })); |
| 69 | } |
| 70 | |
Garrick Evans | 5486162 | 2019-07-19 09:05:09 +0900 | [diff] [blame] | 71 | } // namespace |
| 72 | |
| 73 | class ArcServiceTest : public testing::Test { |
| 74 | public: |
Garrick Evans | 4ee5ce2 | 2020-03-18 07:05:17 +0900 | [diff] [blame] | 75 | ArcServiceTest() : testing::Test() {} |
Garrick Evans | 5486162 | 2019-07-19 09:05:09 +0900 | [diff] [blame] | 76 | |
| 77 | protected: |
| 78 | void SetUp() override { |
Taoyu Li | 179dcc6 | 2019-10-17 11:21:08 +0900 | [diff] [blame] | 79 | runner_ = std::make_unique<FakeProcessRunner>(); |
Garrick Evans | 5486162 | 2019-07-19 09:05:09 +0900 | [diff] [blame] | 80 | runner_->Capture(false); |
Jason Jeremy Iman | a7273a3 | 2020-08-04 11:25:31 +0900 | [diff] [blame] | 81 | datapath_ = std::make_unique<MockDatapath>(runner_.get(), &firewall_); |
Hugo Benichi | 84d96c4 | 2021-02-26 14:20:13 +0900 | [diff] [blame] | 82 | shill_client_ = std::make_unique<MockShillClient>(shill_helper_.mock_bus()); |
Garrick Evans | 4ee5ce2 | 2020-03-18 07:05:17 +0900 | [diff] [blame] | 83 | addr_mgr_ = std::make_unique<AddressManager>(); |
Garrick Evans | 209a80a | 2020-11-30 14:42:40 +0900 | [diff] [blame] | 84 | guest_devices_.clear(); |
Garrick Evans | 5486162 | 2019-07-19 09:05:09 +0900 | [diff] [blame] | 85 | } |
| 86 | |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 87 | std::unique_ptr<ArcService> NewService(GuestMessage::GuestType guest) { |
Garrick Evans | 209a80a | 2020-11-30 14:42:40 +0900 | [diff] [blame] | 88 | return std::make_unique<ArcService>( |
Hugo Benichi | b9d123e | 2021-02-27 23:37:16 +0900 | [diff] [blame] | 89 | shill_client_.get(), datapath_.get(), addr_mgr_.get(), guest, |
Garrick Evans | 209a80a | 2020-11-30 14:42:40 +0900 | [diff] [blame] | 90 | base::BindRepeating(&ArcServiceTest::DeviceHandler, |
| 91 | base::Unretained(this))); |
| 92 | } |
| 93 | |
| 94 | void DeviceHandler(const Device& device, |
| 95 | Device::ChangeEvent event, |
| 96 | GuestMessage::GuestType guest_type) { |
| 97 | guest_devices_[device.host_ifname()] = event; |
Garrick Evans | 5486162 | 2019-07-19 09:05:09 +0900 | [diff] [blame] | 98 | } |
| 99 | |
Garrick Evans | 69b8587 | 2020-02-04 11:40:26 +0900 | [diff] [blame] | 100 | FakeShillClientHelper shill_helper_; |
Hugo Benichi | 84d96c4 | 2021-02-26 14:20:13 +0900 | [diff] [blame] | 101 | std::unique_ptr<MockShillClient> shill_client_; |
Garrick Evans | 4ee5ce2 | 2020-03-18 07:05:17 +0900 | [diff] [blame] | 102 | std::unique_ptr<AddressManager> addr_mgr_; |
Taoyu Li | 179dcc6 | 2019-10-17 11:21:08 +0900 | [diff] [blame] | 103 | std::unique_ptr<MockDatapath> datapath_; |
| 104 | std::unique_ptr<FakeProcessRunner> runner_; |
Jason Jeremy Iman | a7273a3 | 2020-08-04 11:25:31 +0900 | [diff] [blame] | 105 | MockFirewall firewall_; |
Garrick Evans | 209a80a | 2020-11-30 14:42:40 +0900 | [diff] [blame] | 106 | std::map<std::string, Device::ChangeEvent> guest_devices_; |
Garrick Evans | 5486162 | 2019-07-19 09:05:09 +0900 | [diff] [blame] | 107 | }; |
| 108 | |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 109 | TEST_F(ArcServiceTest, NotStarted_AddDevice) { |
Hugo Benichi | 84d96c4 | 2021-02-26 14:20:13 +0900 | [diff] [blame] | 110 | ExpectGetDeviceProperties(*shill_client_, "eth0", |
| 111 | ShillClient::Device::Type::kEthernet); |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 112 | EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_eth0"), _, _)).Times(0); |
Hugo Benichi | 8d622b5 | 2020-08-13 15:24:12 +0900 | [diff] [blame] | 113 | EXPECT_CALL(*datapath_, |
Hugo Benichi | 93306e5 | 2020-12-04 16:08:00 +0900 | [diff] [blame] | 114 | StartRoutingDevice(StrEq("eth0"), StrEq("arc_eth0"), _, _, false)) |
Hugo Benichi | 8d622b5 | 2020-08-13 15:24:12 +0900 | [diff] [blame] | 115 | .Times(0); |
Garrick Evans | 5486162 | 2019-07-19 09:05:09 +0900 | [diff] [blame] | 116 | |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 117 | auto svc = NewService(GuestMessage::ARC); |
Hugo Benichi | f0f10c7 | 2020-07-09 10:42:45 +0900 | [diff] [blame] | 118 | svc->OnDevicesChanged({"eth0"}, {}); |
| 119 | EXPECT_TRUE(svc->devices_.find("eth0") == svc->devices_.end()); |
| 120 | EXPECT_FALSE(svc->shill_devices_.find("eth0") == svc->shill_devices_.end()); |
Garrick Evans | 5486162 | 2019-07-19 09:05:09 +0900 | [diff] [blame] | 121 | } |
| 122 | |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 123 | TEST_F(ArcServiceTest, NotStarted_AddRemoveDevice) { |
Hugo Benichi | 84d96c4 | 2021-02-26 14:20:13 +0900 | [diff] [blame] | 124 | ExpectGetDeviceProperties(*shill_client_, "eth0", |
| 125 | ShillClient::Device::Type::kEthernet); |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 126 | EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_eth0"), _, _)).Times(0); |
Hugo Benichi | 8d622b5 | 2020-08-13 15:24:12 +0900 | [diff] [blame] | 127 | EXPECT_CALL(*datapath_, |
Hugo Benichi | 93306e5 | 2020-12-04 16:08:00 +0900 | [diff] [blame] | 128 | StartRoutingDevice(StrEq("eth0"), StrEq("arc_eth0"), _, _, false)) |
Hugo Benichi | 8d622b5 | 2020-08-13 15:24:12 +0900 | [diff] [blame] | 129 | .Times(0); |
| 130 | EXPECT_CALL(*datapath_, |
Hugo Benichi | 93306e5 | 2020-12-04 16:08:00 +0900 | [diff] [blame] | 131 | StopRoutingDevice(StrEq("eth0"), StrEq("arc_eth0"), _, _, false)) |
Hugo Benichi | 8d622b5 | 2020-08-13 15:24:12 +0900 | [diff] [blame] | 132 | .Times(0); |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 133 | EXPECT_CALL(*datapath_, RemoveBridge(StrEq("arc_eth0"))).Times(0); |
Garrick Evans | 5486162 | 2019-07-19 09:05:09 +0900 | [diff] [blame] | 134 | |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 135 | auto svc = NewService(GuestMessage::ARC); |
Hugo Benichi | f0f10c7 | 2020-07-09 10:42:45 +0900 | [diff] [blame] | 136 | svc->OnDevicesChanged({"eth0"}, {}); |
| 137 | svc->OnDevicesChanged({}, {"eth0"}); |
Garrick Evans | 6e4eb3b | 2020-03-09 07:18:31 +0900 | [diff] [blame] | 138 | EXPECT_TRUE(svc->devices_.find("eth0") == svc->devices_.end()); |
Hugo Benichi | f0f10c7 | 2020-07-09 10:42:45 +0900 | [diff] [blame] | 139 | EXPECT_TRUE(svc->shill_devices_.find("eth0") == svc->shill_devices_.end()); |
Garrick Evans | 5486162 | 2019-07-19 09:05:09 +0900 | [diff] [blame] | 140 | } |
| 141 | |
Garrick Evans | 86c7d9c | 2020-03-17 09:25:48 +0900 | [diff] [blame] | 142 | TEST_F(ArcServiceTest, VerifyAddrConfigs) { |
Hugo Benichi | 84d96c4 | 2021-02-26 14:20:13 +0900 | [diff] [blame] | 143 | ExpectGetDeviceProperties(*shill_client_, "eth0", |
| 144 | ShillClient::Device::Type::kEthernet); |
| 145 | ExpectGetDeviceProperties(*shill_client_, "eth1", |
| 146 | ShillClient::Device::Type::kEthernet); |
| 147 | ExpectGetDeviceProperties(*shill_client_, "wlan0", |
| 148 | ShillClient::Device::Type::kWifi); |
| 149 | ExpectGetDeviceProperties(*shill_client_, "wlan1", |
| 150 | ShillClient::Device::Type::kWifi); |
| 151 | ExpectGetDeviceProperties(*shill_client_, "wwan0", |
| 152 | ShillClient::Device::Type::kCellular); |
Hugo Benichi | 33860d7 | 2020-07-09 16:34:01 +0900 | [diff] [blame] | 153 | EXPECT_CALL(*datapath_, NetnsAttachName(StrEq("arc_netns"), kTestPID)) |
| 154 | .WillOnce(Return(true)); |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 155 | EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30)) |
| 156 | .WillOnce(Return(true)); |
| 157 | EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_eth0"), kFirstEthHostIP, 30)) |
Garrick Evans | 86c7d9c | 2020-03-17 09:25:48 +0900 | [diff] [blame] | 158 | .WillOnce(Return(true)); |
| 159 | EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_eth1"), kSecondEthHostIP, 30)) |
| 160 | .WillOnce(Return(true)); |
| 161 | EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_wlan0"), kFirstWifiHostIP, 30)) |
| 162 | .WillOnce(Return(true)); |
| 163 | EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_wlan1"), kSecondWifiHostIP, 30)) |
| 164 | .WillOnce(Return(true)); |
| 165 | EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_wwan0"), kFirstCellHostIP, 30)) |
| 166 | .WillOnce(Return(true)); |
Hugo Benichi | 82ed5cf | 2020-09-08 21:30:22 +0900 | [diff] [blame] | 167 | EXPECT_CALL(*datapath_, |
| 168 | ConnectVethPair(kTestPID, StrEq("arc_netns"), _, _, _, _, _, _)) |
Hugo Benichi | f0f10c7 | 2020-07-09 10:42:45 +0900 | [diff] [blame] | 169 | .WillRepeatedly(Return(true)); |
| 170 | EXPECT_CALL(*datapath_, AddToBridge(_, _)).WillRepeatedly(Return(true)); |
Garrick Evans | 86c7d9c | 2020-03-17 09:25:48 +0900 | [diff] [blame] | 171 | |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 172 | auto svc = NewService(GuestMessage::ARC); |
| 173 | svc->Start(kTestPID); |
Hugo Benichi | f0f10c7 | 2020-07-09 10:42:45 +0900 | [diff] [blame] | 174 | svc->OnDevicesChanged({"eth0", "eth1", "wlan0", "wlan1", "wwan0"}, {}); |
Garrick Evans | 86c7d9c | 2020-03-17 09:25:48 +0900 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | TEST_F(ArcServiceTest, VerifyAddrOrder) { |
Hugo Benichi | 84d96c4 | 2021-02-26 14:20:13 +0900 | [diff] [blame] | 178 | ExpectGetDeviceProperties(*shill_client_, "wlan0", |
| 179 | ShillClient::Device::Type::kWifi); |
| 180 | ExpectGetDeviceProperties(*shill_client_, "eth0", |
| 181 | ShillClient::Device::Type::kEthernet); |
Hugo Benichi | 33860d7 | 2020-07-09 16:34:01 +0900 | [diff] [blame] | 182 | EXPECT_CALL(*datapath_, NetnsAttachName(StrEq("arc_netns"), kTestPID)) |
| 183 | .WillOnce(Return(true)); |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 184 | EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30)) |
| 185 | .WillOnce(Return(true)); |
| 186 | EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_eth0"), kFirstEthHostIP, 30)) |
Garrick Evans | 86c7d9c | 2020-03-17 09:25:48 +0900 | [diff] [blame] | 187 | .Times(2) |
| 188 | .WillRepeatedly(Return(true)); |
| 189 | EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_wlan0"), kFirstWifiHostIP, 30)) |
| 190 | .WillOnce(Return(true)); |
Hugo Benichi | 82ed5cf | 2020-09-08 21:30:22 +0900 | [diff] [blame] | 191 | EXPECT_CALL(*datapath_, |
| 192 | ConnectVethPair(kTestPID, StrEq("arc_netns"), _, _, _, _, _, _)) |
Hugo Benichi | f0f10c7 | 2020-07-09 10:42:45 +0900 | [diff] [blame] | 193 | .WillRepeatedly(Return(true)); |
| 194 | EXPECT_CALL(*datapath_, AddToBridge(_, _)).WillRepeatedly(Return(true)); |
Garrick Evans | 86c7d9c | 2020-03-17 09:25:48 +0900 | [diff] [blame] | 195 | |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 196 | auto svc = NewService(GuestMessage::ARC); |
| 197 | svc->Start(kTestPID); |
Hugo Benichi | f0f10c7 | 2020-07-09 10:42:45 +0900 | [diff] [blame] | 198 | svc->OnDevicesChanged({"wlan0"}, {}); |
| 199 | svc->OnDevicesChanged({"eth0"}, {}); |
| 200 | svc->OnDevicesChanged({}, {"eth0"}); |
| 201 | svc->OnDevicesChanged({"eth0"}, {}); |
Garrick Evans | 86c7d9c | 2020-03-17 09:25:48 +0900 | [diff] [blame] | 202 | } |
| 203 | |
Garrick Evans | c707112 | 2020-04-17 12:31:57 +0900 | [diff] [blame] | 204 | TEST_F(ArcServiceTest, StableArcVmMacAddrs) { |
| 205 | EXPECT_CALL(*datapath_, AddTAP(StrEq(""), _, nullptr, StrEq("crosvm"))) |
| 206 | .WillRepeatedly(Return("vmtap")); |
| 207 | EXPECT_CALL(*datapath_, AddBridge(_, _, 30)).WillRepeatedly(Return(true)); |
| 208 | EXPECT_CALL(*datapath_, AddToBridge(_, _)).WillRepeatedly(Return(true)); |
| 209 | |
| 210 | auto svc = NewService(GuestMessage::ARC_VM); |
| 211 | svc->Start(kTestCID); |
| 212 | auto configs = svc->GetDeviceConfigs(); |
| 213 | EXPECT_EQ(configs.size(), 6); |
| 214 | auto mac_addr = kArcVmArc0MacAddr; |
| 215 | for (const auto* config : configs) { |
| 216 | EXPECT_EQ(config->mac_addr(), mac_addr); |
| 217 | mac_addr[5]++; |
| 218 | } |
| 219 | } |
| 220 | |
Garrick Evans | b4eb389 | 2019-11-13 12:07:07 +0900 | [diff] [blame] | 221 | // ContainerImpl |
| 222 | |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 223 | TEST_F(ArcServiceTest, ContainerImpl_Start) { |
Hugo Benichi | 33860d7 | 2020-07-09 16:34:01 +0900 | [diff] [blame] | 224 | EXPECT_CALL(*datapath_, NetnsAttachName(StrEq("arc_netns"), kTestPID)) |
| 225 | .WillOnce(Return(true)); |
Garrick Evans | b4eb389 | 2019-11-13 12:07:07 +0900 | [diff] [blame] | 226 | EXPECT_CALL(*datapath_, |
Hugo Benichi | 82ed5cf | 2020-09-08 21:30:22 +0900 | [diff] [blame] | 227 | ConnectVethPair(kTestPID, StrEq("arc_netns"), StrEq("vetharc0"), |
| 228 | StrEq("arc0"), _, kArcGuestIP, 30, false)) |
Garrick Evans | 2470caa | 2020-03-04 14:15:41 +0900 | [diff] [blame] | 229 | .WillOnce(Return(true)); |
Garrick Evans | 2f581a0 | 2020-05-11 10:43:35 +0900 | [diff] [blame] | 230 | EXPECT_CALL(*datapath_, AddToBridge(StrEq("arcbr0"), StrEq("vetharc0"))) |
Garrick Evans | 2470caa | 2020-03-04 14:15:41 +0900 | [diff] [blame] | 231 | .WillOnce(Return(true)); |
Hugo Benichi | 82ed5cf | 2020-09-08 21:30:22 +0900 | [diff] [blame] | 232 | EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30)) |
| 233 | .WillOnce(Return(true)); |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 234 | |
| 235 | auto svc = NewService(GuestMessage::ARC); |
| 236 | svc->Start(kTestPID); |
Garrick Evans | b4eb389 | 2019-11-13 12:07:07 +0900 | [diff] [blame] | 237 | } |
| 238 | |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 239 | TEST_F(ArcServiceTest, ContainerImpl_FailsToCreateInterface) { |
Hugo Benichi | 33860d7 | 2020-07-09 16:34:01 +0900 | [diff] [blame] | 240 | EXPECT_CALL(*datapath_, NetnsAttachName(StrEq("arc_netns"), kTestPID)) |
| 241 | .WillOnce(Return(true)); |
Garrick Evans | 63378b3 | 2020-01-14 10:36:16 +0900 | [diff] [blame] | 242 | EXPECT_CALL(*datapath_, |
Hugo Benichi | 82ed5cf | 2020-09-08 21:30:22 +0900 | [diff] [blame] | 243 | ConnectVethPair(kTestPID, StrEq("arc_netns"), StrEq("vetharc0"), |
| 244 | StrEq("arc0"), _, kArcGuestIP, 30, false)) |
Garrick Evans | 2470caa | 2020-03-04 14:15:41 +0900 | [diff] [blame] | 245 | .WillOnce(Return(false)); |
Hugo Benichi | f0f10c7 | 2020-07-09 10:42:45 +0900 | [diff] [blame] | 246 | EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30)).Times(0); |
Garrick Evans | 63378b3 | 2020-01-14 10:36:16 +0900 | [diff] [blame] | 247 | EXPECT_CALL(*datapath_, RemoveBridge(_)).Times(0); |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 248 | |
| 249 | auto svc = NewService(GuestMessage::ARC); |
| 250 | svc->Start(kTestPID); |
Garrick Evans | 63378b3 | 2020-01-14 10:36:16 +0900 | [diff] [blame] | 251 | } |
| 252 | |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 253 | TEST_F(ArcServiceTest, ContainerImpl_FailsToAddInterfaceToBridge) { |
Hugo Benichi | 33860d7 | 2020-07-09 16:34:01 +0900 | [diff] [blame] | 254 | EXPECT_CALL(*datapath_, NetnsAttachName(StrEq("arc_netns"), kTestPID)) |
| 255 | .WillOnce(Return(true)); |
Hugo Benichi | 82ed5cf | 2020-09-08 21:30:22 +0900 | [diff] [blame] | 256 | EXPECT_CALL(*datapath_, |
| 257 | ConnectVethPair(kTestPID, StrEq("arc_netns"), StrEq("vetharc0"), |
| 258 | StrEq("arc0"), _, kArcGuestIP, 30, false)) |
| 259 | .WillOnce(Return(true)); |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 260 | EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30)) |
| 261 | .WillOnce(Return(true)); |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 262 | EXPECT_CALL(*datapath_, AddToBridge(StrEq("arcbr0"), StrEq("vetharc0"))) |
| 263 | .WillOnce(Return(false)); |
| 264 | |
| 265 | EXPECT_CALL(*datapath_, RemoveInterface(StrEq("vetharc0"))); |
| 266 | EXPECT_CALL(*datapath_, RemoveBridge(_)).Times(0); |
| 267 | |
| 268 | auto svc = NewService(GuestMessage::ARC); |
| 269 | svc->Start(kTestPID); |
| 270 | } |
| 271 | |
| 272 | TEST_F(ArcServiceTest, ContainerImpl_OnStartDevice) { |
Hugo Benichi | 84d96c4 | 2021-02-26 14:20:13 +0900 | [diff] [blame] | 273 | ExpectGetDeviceProperties(*shill_client_, "eth0", |
| 274 | ShillClient::Device::Type::kEthernet); |
Hugo Benichi | 33860d7 | 2020-07-09 16:34:01 +0900 | [diff] [blame] | 275 | EXPECT_CALL(*datapath_, NetnsAttachName(StrEq("arc_netns"), kTestPID)) |
| 276 | .WillOnce(Return(true)); |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 277 | // Expectations for arc0 setup. |
Hugo Benichi | 82ed5cf | 2020-09-08 21:30:22 +0900 | [diff] [blame] | 278 | EXPECT_CALL(*datapath_, |
| 279 | ConnectVethPair(kTestPID, StrEq("arc_netns"), StrEq("vetharc0"), |
| 280 | StrEq("arc0"), _, kArcGuestIP, 30, false)) |
| 281 | .WillOnce(Return(true)); |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 282 | EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30)) |
| 283 | .WillOnce(Return(true)); |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 284 | EXPECT_CALL(*datapath_, AddToBridge(StrEq("arcbr0"), StrEq("vetharc0"))) |
| 285 | .WillOnce(Return(true)); |
| 286 | // Expectations for eth0 setup. |
Garrick Evans | b4eb389 | 2019-11-13 12:07:07 +0900 | [diff] [blame] | 287 | EXPECT_CALL(*datapath_, |
Hugo Benichi | 82ed5cf | 2020-09-08 21:30:22 +0900 | [diff] [blame] | 288 | ConnectVethPair(kTestPID, StrEq("arc_netns"), StrEq("vetheth0"), |
| 289 | StrEq("eth0"), _, kFirstEthGuestIP, 30, false)) |
Garrick Evans | b4eb389 | 2019-11-13 12:07:07 +0900 | [diff] [blame] | 290 | .WillOnce(Return(true)); |
Hugo Benichi | 82ed5cf | 2020-09-08 21:30:22 +0900 | [diff] [blame] | 291 | EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_eth0"), kFirstEthHostIP, 30)) |
Garrick Evans | 2470caa | 2020-03-04 14:15:41 +0900 | [diff] [blame] | 292 | .WillOnce(Return(true)); |
Garrick Evans | 2f581a0 | 2020-05-11 10:43:35 +0900 | [diff] [blame] | 293 | EXPECT_CALL(*datapath_, AddToBridge(StrEq("arc_eth0"), StrEq("vetheth0"))) |
Garrick Evans | 2470caa | 2020-03-04 14:15:41 +0900 | [diff] [blame] | 294 | .WillOnce(Return(true)); |
Hugo Benichi | 8d622b5 | 2020-08-13 15:24:12 +0900 | [diff] [blame] | 295 | EXPECT_CALL(*datapath_, |
| 296 | StartRoutingDevice(StrEq("eth0"), StrEq("arc_eth0"), |
Hugo Benichi | 93306e5 | 2020-12-04 16:08:00 +0900 | [diff] [blame] | 297 | kFirstEthGuestIP, TrafficSource::ARC, false)); |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 298 | |
| 299 | auto svc = NewService(GuestMessage::ARC); |
| 300 | svc->Start(kTestPID); |
Hugo Benichi | f0f10c7 | 2020-07-09 10:42:45 +0900 | [diff] [blame] | 301 | svc->OnDevicesChanged({"eth0"}, {}); |
| 302 | } |
| 303 | |
Garrick Evans | 02e6e87 | 2020-11-30 11:53:13 +0900 | [diff] [blame] | 304 | TEST_F(ArcServiceTest, ContainerImpl_ScanDevices) { |
Hugo Benichi | 84d96c4 | 2021-02-26 14:20:13 +0900 | [diff] [blame] | 305 | ExpectGetDeviceProperties(*shill_client_, "eth0", |
| 306 | ShillClient::Device::Type::kEthernet); |
| 307 | ExpectGetDeviceProperties(*shill_client_, "wlan0", |
| 308 | ShillClient::Device::Type::kWifi); |
Garrick Evans | 02e6e87 | 2020-11-30 11:53:13 +0900 | [diff] [blame] | 309 | EXPECT_CALL(*datapath_, NetnsAttachName(_, _)).WillRepeatedly(Return(true)); |
| 310 | EXPECT_CALL(*datapath_, ConnectVethPair(_, _, _, _, _, _, _, _)) |
| 311 | .WillRepeatedly(Return(true)); |
| 312 | EXPECT_CALL(*datapath_, AddBridge(_, _, _)).WillRepeatedly(Return(true)); |
| 313 | EXPECT_CALL(*datapath_, AddToBridge(_, _)).WillRepeatedly(Return(true)); |
| 314 | |
| 315 | auto svc = NewService(GuestMessage::ARC); |
| 316 | svc->Start(kTestPID); |
| 317 | svc->OnDevicesChanged({"eth0", "wlan0"}, {}); |
| 318 | |
| 319 | std::vector<std::string> devs; |
| 320 | svc->ScanDevices(base::BindRepeating( |
| 321 | [](std::vector<std::string>* list, const Device& device) { |
| 322 | list->push_back(device.host_ifname()); |
| 323 | }, |
| 324 | &devs)); |
| 325 | |
| 326 | EXPECT_EQ(devs.size(), 2); |
| 327 | EXPECT_THAT(devs, |
| 328 | UnorderedElementsAre(StrEq("arc_eth0"), StrEq("arc_wlan0"))); |
| 329 | } |
| 330 | |
Garrick Evans | 209a80a | 2020-11-30 14:42:40 +0900 | [diff] [blame] | 331 | TEST_F(ArcServiceTest, ContainerImpl_DeviceHandler) { |
Hugo Benichi | 84d96c4 | 2021-02-26 14:20:13 +0900 | [diff] [blame] | 332 | ExpectGetDeviceProperties(*shill_client_, "eth0", |
| 333 | ShillClient::Device::Type::kEthernet); |
| 334 | ExpectGetDeviceProperties(*shill_client_, "wlan0", |
| 335 | ShillClient::Device::Type::kWifi); |
Garrick Evans | 209a80a | 2020-11-30 14:42:40 +0900 | [diff] [blame] | 336 | EXPECT_CALL(*datapath_, NetnsAttachName(_, _)).WillRepeatedly(Return(true)); |
| 337 | EXPECT_CALL(*datapath_, ConnectVethPair(_, _, _, _, _, _, _, _)) |
| 338 | .WillRepeatedly(Return(true)); |
| 339 | EXPECT_CALL(*datapath_, AddBridge(_, _, _)).WillRepeatedly(Return(true)); |
| 340 | EXPECT_CALL(*datapath_, AddToBridge(_, _)).WillRepeatedly(Return(true)); |
| 341 | |
| 342 | auto svc = NewService(GuestMessage::ARC); |
| 343 | svc->Start(kTestPID); |
| 344 | |
| 345 | svc->OnDevicesChanged({"eth0", "wlan0"}, {}); |
| 346 | EXPECT_EQ(guest_devices_.size(), 2); |
| 347 | EXPECT_THAT(guest_devices_, |
| 348 | UnorderedElementsAre( |
| 349 | Pair(StrEq("arc_eth0"), Device::ChangeEvent::ADDED), |
| 350 | Pair(StrEq("arc_wlan0"), Device::ChangeEvent::ADDED))); |
| 351 | |
| 352 | svc->OnDevicesChanged({}, {"wlan0"}); |
| 353 | EXPECT_THAT(guest_devices_, |
| 354 | UnorderedElementsAre( |
| 355 | Pair(StrEq("arc_eth0"), Device::ChangeEvent::ADDED), |
| 356 | Pair(StrEq("arc_wlan0"), Device::ChangeEvent::REMOVED))); |
| 357 | |
| 358 | guest_devices_.clear(); |
| 359 | svc->OnDevicesChanged({"wlan0"}, {}); |
| 360 | EXPECT_THAT(guest_devices_, |
| 361 | UnorderedElementsAre( |
| 362 | Pair(StrEq("arc_wlan0"), Device::ChangeEvent::ADDED))); |
| 363 | } |
| 364 | |
Hugo Benichi | f0f10c7 | 2020-07-09 10:42:45 +0900 | [diff] [blame] | 365 | TEST_F(ArcServiceTest, ContainerImpl_StartAfterDevice) { |
Hugo Benichi | 84d96c4 | 2021-02-26 14:20:13 +0900 | [diff] [blame] | 366 | ExpectGetDeviceProperties(*shill_client_, "eth0", |
| 367 | ShillClient::Device::Type::kEthernet); |
Hugo Benichi | f0f10c7 | 2020-07-09 10:42:45 +0900 | [diff] [blame] | 368 | EXPECT_CALL(*datapath_, NetnsAttachName(StrEq("arc_netns"), kTestPID)) |
| 369 | .WillOnce(Return(true)); |
| 370 | // Expectations for arc0 setup. |
Hugo Benichi | 82ed5cf | 2020-09-08 21:30:22 +0900 | [diff] [blame] | 371 | EXPECT_CALL(*datapath_, |
| 372 | ConnectVethPair(kTestPID, StrEq("arc_netns"), StrEq("vetharc0"), |
| 373 | StrEq("arc0"), _, kArcGuestIP, 30, false)) |
| 374 | .WillOnce(Return(true)); |
Hugo Benichi | f0f10c7 | 2020-07-09 10:42:45 +0900 | [diff] [blame] | 375 | EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30)) |
| 376 | .WillOnce(Return(true)); |
Hugo Benichi | f0f10c7 | 2020-07-09 10:42:45 +0900 | [diff] [blame] | 377 | EXPECT_CALL(*datapath_, AddToBridge(StrEq("arcbr0"), StrEq("vetharc0"))) |
| 378 | .WillOnce(Return(true)); |
| 379 | // Expectations for eth0 setup. |
Hugo Benichi | f0f10c7 | 2020-07-09 10:42:45 +0900 | [diff] [blame] | 380 | EXPECT_CALL(*datapath_, |
Hugo Benichi | 82ed5cf | 2020-09-08 21:30:22 +0900 | [diff] [blame] | 381 | ConnectVethPair(kTestPID, StrEq("arc_netns"), StrEq("vetheth0"), |
| 382 | StrEq("eth0"), _, kFirstEthGuestIP, 30, false)) |
Hugo Benichi | f0f10c7 | 2020-07-09 10:42:45 +0900 | [diff] [blame] | 383 | .WillOnce(Return(true)); |
Hugo Benichi | 82ed5cf | 2020-09-08 21:30:22 +0900 | [diff] [blame] | 384 | EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_eth0"), kFirstEthHostIP, 30)) |
Hugo Benichi | f0f10c7 | 2020-07-09 10:42:45 +0900 | [diff] [blame] | 385 | .WillOnce(Return(true)); |
| 386 | EXPECT_CALL(*datapath_, AddToBridge(StrEq("arc_eth0"), StrEq("vetheth0"))) |
| 387 | .WillOnce(Return(true)); |
Hugo Benichi | 8d622b5 | 2020-08-13 15:24:12 +0900 | [diff] [blame] | 388 | EXPECT_CALL(*datapath_, |
| 389 | StartRoutingDevice(StrEq("eth0"), StrEq("arc_eth0"), |
Hugo Benichi | 93306e5 | 2020-12-04 16:08:00 +0900 | [diff] [blame] | 390 | kFirstEthGuestIP, TrafficSource::ARC, false)); |
Hugo Benichi | f0f10c7 | 2020-07-09 10:42:45 +0900 | [diff] [blame] | 391 | |
| 392 | auto svc = NewService(GuestMessage::ARC); |
| 393 | svc->OnDevicesChanged({"eth0"}, {}); |
| 394 | svc->Start(kTestPID); |
Garrick Evans | b4eb389 | 2019-11-13 12:07:07 +0900 | [diff] [blame] | 395 | } |
| 396 | |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 397 | TEST_F(ArcServiceTest, ContainerImpl_Stop) { |
Hugo Benichi | 33860d7 | 2020-07-09 16:34:01 +0900 | [diff] [blame] | 398 | EXPECT_CALL(*datapath_, NetnsAttachName(StrEq("arc_netns"), kTestPID)) |
| 399 | .WillOnce(Return(true)); |
| 400 | EXPECT_CALL(*datapath_, NetnsDeleteName(StrEq("arc_netns"))) |
| 401 | .WillOnce(Return(true)); |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 402 | // Expectations for arc0 setup. |
Hugo Benichi | 82ed5cf | 2020-09-08 21:30:22 +0900 | [diff] [blame] | 403 | EXPECT_CALL(*datapath_, |
| 404 | ConnectVethPair(kTestPID, StrEq("arc_netns"), StrEq("vetharc0"), |
| 405 | StrEq("arc0"), _, kArcGuestIP, 30, false)) |
| 406 | .WillOnce(Return(true)); |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 407 | EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30)) |
| 408 | .WillOnce(Return(true)); |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 409 | EXPECT_CALL(*datapath_, AddToBridge(StrEq("arcbr0"), StrEq("vetharc0"))) |
| 410 | .WillOnce(Return(true)); |
| 411 | // Expectations for arc0 teardown. |
| 412 | EXPECT_CALL(*datapath_, |
| 413 | MaskInterfaceFlags(StrEq("arcbr0"), IFF_DEBUG, IFF_UP)) |
| 414 | .WillOnce(Return(true)); |
Garrick Evans | 2f581a0 | 2020-05-11 10:43:35 +0900 | [diff] [blame] | 415 | EXPECT_CALL(*datapath_, RemoveInterface(StrEq("vetharc0"))); |
Garrick Evans | e94b6de | 2020-02-20 09:19:13 +0900 | [diff] [blame] | 416 | |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 417 | auto svc = NewService(GuestMessage::ARC); |
| 418 | svc->Start(kTestPID); |
| 419 | svc->Stop(kTestPID); |
Garrick Evans | b4eb389 | 2019-11-13 12:07:07 +0900 | [diff] [blame] | 420 | } |
| 421 | |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 422 | TEST_F(ArcServiceTest, ContainerImpl_OnStopDevice) { |
Hugo Benichi | 84d96c4 | 2021-02-26 14:20:13 +0900 | [diff] [blame] | 423 | ExpectGetDeviceProperties(*shill_client_, "eth0", |
| 424 | ShillClient::Device::Type::kEthernet); |
Hugo Benichi | 33860d7 | 2020-07-09 16:34:01 +0900 | [diff] [blame] | 425 | EXPECT_CALL(*datapath_, NetnsAttachName(StrEq("arc_netns"), kTestPID)) |
| 426 | .WillOnce(Return(true)); |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 427 | // Expectations for arc0 setup. |
Hugo Benichi | 82ed5cf | 2020-09-08 21:30:22 +0900 | [diff] [blame] | 428 | EXPECT_CALL(*datapath_, |
| 429 | ConnectVethPair(kTestPID, StrEq("arc_netns"), StrEq("vetharc0"), |
| 430 | StrEq("arc0"), _, kArcGuestIP, 30, false)) |
| 431 | .WillOnce(Return(true)); |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 432 | EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30)) |
| 433 | .WillOnce(Return(true)); |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 434 | EXPECT_CALL(*datapath_, AddToBridge(StrEq("arcbr0"), StrEq("vetharc0"))) |
| 435 | .WillOnce(Return(true)); |
| 436 | // Expectations for eth0 setup. |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 437 | EXPECT_CALL(*datapath_, |
Hugo Benichi | 82ed5cf | 2020-09-08 21:30:22 +0900 | [diff] [blame] | 438 | ConnectVethPair(kTestPID, StrEq("arc_netns"), StrEq("vetheth0"), |
| 439 | StrEq("eth0"), _, kFirstEthGuestIP, 30, false)) |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 440 | .WillOnce(Return(true)); |
Hugo Benichi | 82ed5cf | 2020-09-08 21:30:22 +0900 | [diff] [blame] | 441 | EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_eth0"), kFirstEthHostIP, 30)) |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 442 | .WillOnce(Return(true)); |
| 443 | EXPECT_CALL(*datapath_, AddToBridge(StrEq("arc_eth0"), StrEq("vetheth0"))) |
| 444 | .WillOnce(Return(true)); |
| 445 | // Expectations for eth0 teardown. |
Hugo Benichi | 93306e5 | 2020-12-04 16:08:00 +0900 | [diff] [blame] | 446 | EXPECT_CALL(*datapath_, StopRoutingDevice(StrEq("eth0"), StrEq("arc_eth0"), |
| 447 | Ipv4Addr(100, 115, 92, 6), |
| 448 | TrafficSource::ARC, false)); |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 449 | EXPECT_CALL(*datapath_, RemoveBridge(StrEq("arc_eth0"))); |
Garrick Evans | e94b6de | 2020-02-20 09:19:13 +0900 | [diff] [blame] | 450 | |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 451 | auto svc = NewService(GuestMessage::ARC); |
| 452 | svc->Start(kTestPID); |
Hugo Benichi | f0f10c7 | 2020-07-09 10:42:45 +0900 | [diff] [blame] | 453 | svc->OnDevicesChanged({"eth0"}, {}); |
| 454 | svc->OnDevicesChanged({}, {"eth0"}); |
Garrick Evans | b4eb389 | 2019-11-13 12:07:07 +0900 | [diff] [blame] | 455 | } |
| 456 | |
Garrick Evans | b4eb389 | 2019-11-13 12:07:07 +0900 | [diff] [blame] | 457 | // VM Impl |
| 458 | |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 459 | TEST_F(ArcServiceTest, VmImpl_Start) { |
| 460 | // Expectations for tap devices pre-creation. |
Garrick Evans | c707112 | 2020-04-17 12:31:57 +0900 | [diff] [blame] | 461 | EXPECT_CALL(*datapath_, AddTAP(StrEq(""), _, nullptr, StrEq("crosvm"))) |
Garrick Evans | 2961c7c | 2020-04-03 11:34:40 +0900 | [diff] [blame] | 462 | .WillOnce(Return("vmtap0")) |
| 463 | .WillOnce(Return("vmtap1")) |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 464 | .WillOnce(Return("vmtap2")) |
| 465 | .WillOnce(Return("vmtap3")) |
| 466 | .WillOnce(Return("vmtap4")) |
| 467 | .WillOnce(Return("vmtap5")); |
| 468 | // Expectations for "arc0" setup. |
| 469 | EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30)) |
Garrick Evans | 2961c7c | 2020-04-03 11:34:40 +0900 | [diff] [blame] | 470 | .WillOnce(Return(true)); |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 471 | EXPECT_CALL(*datapath_, AddToBridge(StrEq("arcbr0"), StrEq("vmtap0"))) |
Garrick Evans | 2961c7c | 2020-04-03 11:34:40 +0900 | [diff] [blame] | 472 | .WillOnce(Return(true)); |
| 473 | |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 474 | auto svc = NewService(GuestMessage::ARC_VM); |
| 475 | svc->Start(kTestPID); |
Garrick Evans | 2961c7c | 2020-04-03 11:34:40 +0900 | [diff] [blame] | 476 | } |
| 477 | |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 478 | TEST_F(ArcServiceTest, VmImpl_StartDevice) { |
Hugo Benichi | 84d96c4 | 2021-02-26 14:20:13 +0900 | [diff] [blame] | 479 | ExpectGetDeviceProperties(*shill_client_, "eth0", |
| 480 | ShillClient::Device::Type::kEthernet); |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 481 | // Expectations for tap devices pre-creation. |
Garrick Evans | c707112 | 2020-04-17 12:31:57 +0900 | [diff] [blame] | 482 | EXPECT_CALL(*datapath_, AddTAP(StrEq(""), _, nullptr, StrEq("crosvm"))) |
Garrick Evans | 2961c7c | 2020-04-03 11:34:40 +0900 | [diff] [blame] | 483 | .WillOnce(Return("vmtap0")) |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 484 | .WillOnce(Return("vmtap1")) |
| 485 | .WillOnce(Return("vmtap2")) |
| 486 | .WillOnce(Return("vmtap3")) |
| 487 | .WillOnce(Return("vmtap4")) |
| 488 | .WillOnce(Return("vmtap5")); |
| 489 | // Expectations for "arc0" setup. |
| 490 | EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30)) |
Garrick Evans | 2961c7c | 2020-04-03 11:34:40 +0900 | [diff] [blame] | 491 | .WillOnce(Return(true)); |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 492 | EXPECT_CALL(*datapath_, AddToBridge(StrEq("arcbr0"), StrEq("vmtap0"))) |
| 493 | .WillOnce(Return(true)); |
| 494 | // Expectations for eth0 setup. |
| 495 | EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_eth0"), kFirstEthHostIP, 30)) |
Garrick Evans | 2961c7c | 2020-04-03 11:34:40 +0900 | [diff] [blame] | 496 | .WillOnce(Return(true)); |
| 497 | EXPECT_CALL(*datapath_, AddToBridge(StrEq("arc_eth0"), StrEq("vmtap1"))) |
| 498 | .WillOnce(Return(true)); |
Hugo Benichi | 8d622b5 | 2020-08-13 15:24:12 +0900 | [diff] [blame] | 499 | EXPECT_CALL(*datapath_, StartRoutingDevice(StrEq("eth0"), StrEq("arc_eth0"), |
| 500 | Ipv4Addr(100, 115, 92, 6), |
Hugo Benichi | 93306e5 | 2020-12-04 16:08:00 +0900 | [diff] [blame] | 501 | TrafficSource::ARC, false)); |
Garrick Evans | 2961c7c | 2020-04-03 11:34:40 +0900 | [diff] [blame] | 502 | |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 503 | auto svc = NewService(GuestMessage::ARC_VM); |
| 504 | svc->Start(kTestPID); |
Hugo Benichi | f0f10c7 | 2020-07-09 10:42:45 +0900 | [diff] [blame] | 505 | svc->OnDevicesChanged({"eth0"}, {}); |
Garrick Evans | 2961c7c | 2020-04-03 11:34:40 +0900 | [diff] [blame] | 506 | } |
| 507 | |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 508 | TEST_F(ArcServiceTest, VmImpl_StartMultipleDevices) { |
Hugo Benichi | 84d96c4 | 2021-02-26 14:20:13 +0900 | [diff] [blame] | 509 | ExpectGetDeviceProperties(*shill_client_, "eth0", |
| 510 | ShillClient::Device::Type::kEthernet); |
| 511 | ExpectGetDeviceProperties(*shill_client_, "eth1", |
| 512 | ShillClient::Device::Type::kEthernet); |
| 513 | ExpectGetDeviceProperties(*shill_client_, "wlan0", |
| 514 | ShillClient::Device::Type::kWifi); |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 515 | // Expectations for tap devices pre-creation. |
Garrick Evans | c707112 | 2020-04-17 12:31:57 +0900 | [diff] [blame] | 516 | EXPECT_CALL(*datapath_, AddTAP(StrEq(""), _, nullptr, StrEq("crosvm"))) |
Garrick Evans | 2961c7c | 2020-04-03 11:34:40 +0900 | [diff] [blame] | 517 | .WillOnce(Return("vmtap0")) |
| 518 | .WillOnce(Return("vmtap1")) |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 519 | .WillOnce(Return("vmtap2")) |
| 520 | .WillOnce(Return("vmtap3")) |
| 521 | .WillOnce(Return("vmtap4")) |
| 522 | .WillOnce(Return("vmtap5")); |
| 523 | // Expectations for "arc0" setup. |
| 524 | EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30)) |
Garrick Evans | 2961c7c | 2020-04-03 11:34:40 +0900 | [diff] [blame] | 525 | .WillOnce(Return(true)); |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 526 | EXPECT_CALL(*datapath_, AddToBridge(StrEq("arcbr0"), StrEq("vmtap0"))) |
Garrick Evans | 2961c7c | 2020-04-03 11:34:40 +0900 | [diff] [blame] | 527 | .WillOnce(Return(true)); |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 528 | // Expectations for eth0 setup. |
| 529 | EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_eth0"), kFirstEthHostIP, 30)) |
| 530 | .WillOnce(Return(true)); |
| 531 | EXPECT_CALL(*datapath_, AddToBridge(StrEq("arc_eth0"), StrEq("vmtap1"))) |
| 532 | .WillOnce(Return(true)); |
Hugo Benichi | 8d622b5 | 2020-08-13 15:24:12 +0900 | [diff] [blame] | 533 | EXPECT_CALL(*datapath_, StartRoutingDevice(StrEq("eth0"), StrEq("arc_eth0"), |
| 534 | Ipv4Addr(100, 115, 92, 6), |
Hugo Benichi | 93306e5 | 2020-12-04 16:08:00 +0900 | [diff] [blame] | 535 | TrafficSource::ARC, false)); |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 536 | // Expectations for wlan0 setup. |
| 537 | EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_wlan0"), kFirstWifiHostIP, 30)) |
| 538 | .WillOnce(Return(true)); |
| 539 | EXPECT_CALL(*datapath_, AddToBridge(StrEq("arc_wlan0"), StrEq("vmtap3"))) |
| 540 | .WillOnce(Return(true)); |
Hugo Benichi | 8d622b5 | 2020-08-13 15:24:12 +0900 | [diff] [blame] | 541 | EXPECT_CALL(*datapath_, StartRoutingDevice(StrEq("wlan0"), StrEq("arc_wlan0"), |
| 542 | Ipv4Addr(100, 115, 92, 14), |
Hugo Benichi | 93306e5 | 2020-12-04 16:08:00 +0900 | [diff] [blame] | 543 | TrafficSource::ARC, false)); |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 544 | // Expectations for eth1 setup. |
| 545 | EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_eth1"), kSecondEthHostIP, 30)) |
| 546 | .WillOnce(Return(true)); |
| 547 | EXPECT_CALL(*datapath_, AddToBridge(StrEq("arc_eth1"), StrEq("vmtap2"))) |
| 548 | .WillOnce(Return(true)); |
Hugo Benichi | 8d622b5 | 2020-08-13 15:24:12 +0900 | [diff] [blame] | 549 | EXPECT_CALL(*datapath_, StartRoutingDevice(StrEq("eth1"), StrEq("arc_eth1"), |
| 550 | Ipv4Addr(100, 115, 92, 10), |
Hugo Benichi | 93306e5 | 2020-12-04 16:08:00 +0900 | [diff] [blame] | 551 | TrafficSource::ARC, false)); |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 552 | |
| 553 | auto svc = NewService(GuestMessage::ARC_VM); |
| 554 | svc->Start(kTestPID); |
Hugo Benichi | f0f10c7 | 2020-07-09 10:42:45 +0900 | [diff] [blame] | 555 | svc->OnDevicesChanged({"eth0"}, {}); |
| 556 | svc->OnDevicesChanged({"wlan0"}, {}); |
| 557 | svc->OnDevicesChanged({"eth1"}, {}); |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 558 | } |
| 559 | |
| 560 | TEST_F(ArcServiceTest, VmImpl_Stop) { |
| 561 | // Expectations for tap devices pre-creation. |
| 562 | EXPECT_CALL(*datapath_, AddTAP(StrEq(""), _, nullptr, StrEq("crosvm"))) |
| 563 | .WillOnce(Return("vmtap0")) |
| 564 | .WillOnce(Return("vmtap1")) |
| 565 | .WillOnce(Return("vmtap2")) |
| 566 | .WillOnce(Return("vmtap3")) |
| 567 | .WillOnce(Return("vmtap4")) |
| 568 | .WillOnce(Return("vmtap5")); |
| 569 | // Expectations for "arc0" setup. |
| 570 | EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30)) |
| 571 | .WillOnce(Return(true)); |
| 572 | EXPECT_CALL(*datapath_, AddToBridge(StrEq("arcbr0"), StrEq("vmtap0"))) |
| 573 | .WillOnce(Return(true)); |
| 574 | // Expectations for "arc0" teardown. |
| 575 | EXPECT_CALL(*datapath_, |
| 576 | MaskInterfaceFlags(StrEq("arcbr0"), IFF_DEBUG, IFF_UP)) |
| 577 | .WillOnce(Return(true)); |
| 578 | // Expectations for tap devices teardown |
Garrick Evans | 2961c7c | 2020-04-03 11:34:40 +0900 | [diff] [blame] | 579 | EXPECT_CALL(*datapath_, RemoveInterface(StrEq("vmtap0"))); |
| 580 | EXPECT_CALL(*datapath_, RemoveInterface(StrEq("vmtap1"))); |
| 581 | EXPECT_CALL(*datapath_, RemoveInterface(StrEq("vmtap2"))); |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 582 | EXPECT_CALL(*datapath_, RemoveInterface(StrEq("vmtap3"))); |
| 583 | EXPECT_CALL(*datapath_, RemoveInterface(StrEq("vmtap4"))); |
| 584 | EXPECT_CALL(*datapath_, RemoveInterface(StrEq("vmtap5"))); |
Garrick Evans | 2961c7c | 2020-04-03 11:34:40 +0900 | [diff] [blame] | 585 | |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 586 | auto svc = NewService(GuestMessage::ARC_VM); |
| 587 | svc->Start(kTestPID); |
| 588 | svc->Stop(kTestPID); |
Garrick Evans | 2961c7c | 2020-04-03 11:34:40 +0900 | [diff] [blame] | 589 | } |
| 590 | |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 591 | TEST_F(ArcServiceTest, VmImpl_StopDevice) { |
Hugo Benichi | 84d96c4 | 2021-02-26 14:20:13 +0900 | [diff] [blame] | 592 | ExpectGetDeviceProperties(*shill_client_, "eth0", |
| 593 | ShillClient::Device::Type::kEthernet); |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 594 | // Expectations for tap devices pre-creation. |
Garrick Evans | c707112 | 2020-04-17 12:31:57 +0900 | [diff] [blame] | 595 | EXPECT_CALL(*datapath_, AddTAP(StrEq(""), _, nullptr, StrEq("crosvm"))) |
Garrick Evans | 2961c7c | 2020-04-03 11:34:40 +0900 | [diff] [blame] | 596 | .WillOnce(Return("vmtap0")) |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 597 | .WillOnce(Return("vmtap1")) |
| 598 | .WillOnce(Return("vmtap2")) |
| 599 | .WillOnce(Return("vmtap3")) |
| 600 | .WillOnce(Return("vmtap4")) |
| 601 | .WillOnce(Return("vmtap5")); |
| 602 | // Expectations for "arc0" setup. |
| 603 | EXPECT_CALL(*datapath_, AddBridge(StrEq("arcbr0"), kArcHostIP, 30)) |
Garrick Evans | 2961c7c | 2020-04-03 11:34:40 +0900 | [diff] [blame] | 604 | .WillOnce(Return(true)); |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 605 | EXPECT_CALL(*datapath_, AddToBridge(StrEq("arcbr0"), StrEq("vmtap0"))) |
Garrick Evans | 2961c7c | 2020-04-03 11:34:40 +0900 | [diff] [blame] | 606 | .WillOnce(Return(true)); |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 607 | // Expectations for eth0 setup. |
| 608 | EXPECT_CALL(*datapath_, AddBridge(StrEq("arc_eth0"), kFirstEthHostIP, 30)) |
| 609 | .WillOnce(Return(true)); |
| 610 | EXPECT_CALL(*datapath_, AddToBridge(StrEq("arc_eth0"), StrEq("vmtap1"))) |
| 611 | .WillOnce(Return(true)); |
Hugo Benichi | 8d622b5 | 2020-08-13 15:24:12 +0900 | [diff] [blame] | 612 | EXPECT_CALL(*datapath_, StartRoutingDevice(StrEq("eth0"), StrEq("arc_eth0"), |
| 613 | Ipv4Addr(100, 115, 92, 6), |
Hugo Benichi | 93306e5 | 2020-12-04 16:08:00 +0900 | [diff] [blame] | 614 | TrafficSource::ARC, false)); |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 615 | // Expectations for eth0 teardown. |
Hugo Benichi | 93306e5 | 2020-12-04 16:08:00 +0900 | [diff] [blame] | 616 | EXPECT_CALL(*datapath_, StopRoutingDevice(StrEq("eth0"), StrEq("arc_eth0"), |
| 617 | Ipv4Addr(100, 115, 92, 6), |
| 618 | TrafficSource::ARC, false)); |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 619 | EXPECT_CALL(*datapath_, RemoveBridge(StrEq("arc_eth0"))); |
Garrick Evans | 2961c7c | 2020-04-03 11:34:40 +0900 | [diff] [blame] | 620 | |
Hugo Benichi | ad1bdd9 | 2020-06-12 13:48:37 +0900 | [diff] [blame] | 621 | auto svc = NewService(GuestMessage::ARC_VM); |
| 622 | svc->Start(kTestPID); |
Hugo Benichi | f0f10c7 | 2020-07-09 10:42:45 +0900 | [diff] [blame] | 623 | svc->OnDevicesChanged({"eth0"}, {}); |
| 624 | svc->OnDevicesChanged({}, {"eth0"}); |
Garrick Evans | 2961c7c | 2020-04-03 11:34:40 +0900 | [diff] [blame] | 625 | } |
Garrick Evans | 3388a03 | 2020-03-24 11:25:55 +0900 | [diff] [blame] | 626 | |
Garrick Evans | 02e6e87 | 2020-11-30 11:53:13 +0900 | [diff] [blame] | 627 | TEST_F(ArcServiceTest, VmImpl_ScanDevices) { |
Hugo Benichi | 84d96c4 | 2021-02-26 14:20:13 +0900 | [diff] [blame] | 628 | ExpectGetDeviceProperties(*shill_client_, "eth0", |
| 629 | ShillClient::Device::Type::kEthernet); |
| 630 | ExpectGetDeviceProperties(*shill_client_, "eth1", |
| 631 | ShillClient::Device::Type::kEthernet); |
| 632 | ExpectGetDeviceProperties(*shill_client_, "wlan0", |
| 633 | ShillClient::Device::Type::kWifi); |
Garrick Evans | 02e6e87 | 2020-11-30 11:53:13 +0900 | [diff] [blame] | 634 | // Expectations for tap devices pre-creation. |
| 635 | EXPECT_CALL(*datapath_, AddTAP(StrEq(""), _, nullptr, StrEq("crosvm"))) |
| 636 | .WillOnce(Return("vmtap0")) |
| 637 | .WillOnce(Return("vmtap1")) |
| 638 | .WillOnce(Return("vmtap2")) |
| 639 | .WillOnce(Return("vmtap3")) |
| 640 | .WillOnce(Return("vmtap4")) |
| 641 | .WillOnce(Return("vmtap5")); |
| 642 | EXPECT_CALL(*datapath_, AddBridge(_, _, _)).WillRepeatedly(Return(true)); |
| 643 | EXPECT_CALL(*datapath_, AddToBridge(_, _)).WillRepeatedly(Return(true)); |
| 644 | |
| 645 | auto svc = NewService(GuestMessage::ARC_VM); |
| 646 | svc->Start(kTestPID); |
| 647 | svc->OnDevicesChanged({"eth0", "wlan0", "eth1"}, {}); |
| 648 | |
| 649 | std::vector<std::string> devs; |
| 650 | svc->ScanDevices(base::BindRepeating( |
| 651 | [](std::vector<std::string>* list, const Device& device) { |
| 652 | list->push_back(device.host_ifname()); |
| 653 | }, |
| 654 | &devs)); |
| 655 | |
| 656 | EXPECT_EQ(devs.size(), 3); |
| 657 | EXPECT_THAT(devs, UnorderedElementsAre(StrEq("arc_eth0"), StrEq("arc_wlan0"), |
| 658 | StrEq("arc_eth1"))); |
| 659 | } |
| 660 | |
Garrick Evans | 209a80a | 2020-11-30 14:42:40 +0900 | [diff] [blame] | 661 | TEST_F(ArcServiceTest, VmImpl_DeviceHandler) { |
Hugo Benichi | 84d96c4 | 2021-02-26 14:20:13 +0900 | [diff] [blame] | 662 | ExpectGetDeviceProperties(*shill_client_, "eth0", |
| 663 | ShillClient::Device::Type::kEthernet); |
| 664 | ExpectGetDeviceProperties(*shill_client_, "wlan0", |
| 665 | ShillClient::Device::Type::kWifi); |
Garrick Evans | 209a80a | 2020-11-30 14:42:40 +0900 | [diff] [blame] | 666 | // Expectations for tap devices pre-creation. |
| 667 | EXPECT_CALL(*datapath_, AddTAP(StrEq(""), _, nullptr, StrEq("crosvm"))) |
| 668 | .WillOnce(Return("vmtap0")) |
| 669 | .WillOnce(Return("vmtap1")) |
| 670 | .WillOnce(Return("vmtap2")) |
| 671 | .WillOnce(Return("vmtap3")) |
| 672 | .WillOnce(Return("vmtap4")) |
| 673 | .WillOnce(Return("vmtap5")); |
| 674 | EXPECT_CALL(*datapath_, AddBridge(_, _, _)).WillRepeatedly(Return(true)); |
| 675 | EXPECT_CALL(*datapath_, AddToBridge(_, _)).WillRepeatedly(Return(true)); |
| 676 | |
| 677 | auto svc = NewService(GuestMessage::ARC_VM); |
| 678 | svc->Start(kTestPID); |
| 679 | |
| 680 | svc->OnDevicesChanged({"eth0", "wlan0"}, {}); |
| 681 | EXPECT_EQ(guest_devices_.size(), 2); |
| 682 | EXPECT_THAT(guest_devices_, |
| 683 | UnorderedElementsAre( |
| 684 | Pair(StrEq("arc_eth0"), Device::ChangeEvent::ADDED), |
| 685 | Pair(StrEq("arc_wlan0"), Device::ChangeEvent::ADDED))); |
| 686 | |
| 687 | svc->OnDevicesChanged({}, {"wlan0"}); |
| 688 | EXPECT_THAT(guest_devices_, |
| 689 | UnorderedElementsAre( |
| 690 | Pair(StrEq("arc_eth0"), Device::ChangeEvent::ADDED), |
| 691 | Pair(StrEq("arc_wlan0"), Device::ChangeEvent::REMOVED))); |
| 692 | |
| 693 | guest_devices_.clear(); |
| 694 | svc->OnDevicesChanged({"wlan0"}, {}); |
| 695 | EXPECT_THAT(guest_devices_, |
| 696 | UnorderedElementsAre( |
| 697 | Pair(StrEq("arc_wlan0"), Device::ChangeEvent::ADDED))); |
| 698 | } |
| 699 | |
Garrick Evans | 3388a03 | 2020-03-24 11:25:55 +0900 | [diff] [blame] | 700 | } // namespace patchpanel |