summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorNingyuan Wang2017-06-15 13:25:47 -0500
committerNingyuan Wang2017-06-22 18:43:15 -0500
commit793978cb7f2f227f1ab28135caeb75dd4ed48e6c (patch)
treee141927fc6aacac9310c880fa07a2f3458ee4ac4 /tests
parentb8ad0fd50846e1cb8e0cc7419b64a7ffd00e27b7 (diff)
downloadsystem-connectivity-wificond-793978cb7f2f227f1ab28135caeb75dd4ed48e6c.tar.gz
system-connectivity-wificond-793978cb7f2f227f1ab28135caeb75dd4ed48e6c.tar.xz
system-connectivity-wificond-793978cb7f2f227f1ab28135caeb75dd4ed48e6c.zip
Restart wificond on ENODEV scan failure
ENODEV scan failure implies that driver entered a bad state. In order to recover wificond, we should treat it as an fatal error. The crashing of wificond will trigger the restarting of framework, bringing everything back to work. Bug: 36894921 Test: compile, unit tests Test: manual test: Use "iw wlan0 del" to remove kernel interface. Observe that wificond restarts and wifi continues to work. Change-Id: I89f4403bcb570d7f413fa4cc9ca50378de428d3d
Diffstat (limited to 'tests')
-rw-r--r--tests/mock_scan_utils.h5
-rw-r--r--tests/scan_utils_unittest.cpp16
2 files changed, 15 insertions, 6 deletions
diff --git a/tests/mock_scan_utils.h b/tests/mock_scan_utils.h
index 4f9e461..8a60888 100644
--- a/tests/mock_scan_utils.h
+++ b/tests/mock_scan_utils.h
@@ -33,11 +33,12 @@ class MockScanUtils : public ScanUtils {
33 uint32_t interface_index, 33 uint32_t interface_index,
34 std::vector<::com::android::server::wifi::wificond::NativeScanResult>* out_scan_results)); 34 std::vector<::com::android::server::wifi::wificond::NativeScanResult>* out_scan_results));
35 35
36 MOCK_METHOD4(Scan, bool( 36 MOCK_METHOD5(Scan, bool(
37 uint32_t interface_index, 37 uint32_t interface_index,
38 bool random_mac, 38 bool random_mac,
39 const std::vector<std::vector<uint8_t>>& ssids, 39 const std::vector<std::vector<uint8_t>>& ssids,
40 const std::vector<uint32_t>& freqs)); 40 const std::vector<uint32_t>& freqs,
41 int* error_code));
41 42
42 MOCK_METHOD2(SubscribeScanResultNotification,void( 43 MOCK_METHOD2(SubscribeScanResultNotification,void(
43 uint32_t interface_index, 44 uint32_t interface_index,
diff --git a/tests/scan_utils_unittest.cpp b/tests/scan_utils_unittest.cpp
index 3dbfe21..a76ede5 100644
--- a/tests/scan_utils_unittest.cpp
+++ b/tests/scan_utils_unittest.cpp
@@ -130,7 +130,9 @@ TEST_F(ScanUtilsTest, CanSendScanRequest) {
130 WillOnce(Invoke(bind( 130 WillOnce(Invoke(bind(
131 AppendMessageAndReturn, response, true, _1, _2))); 131 AppendMessageAndReturn, response, true, _1, _2)));
132 132
133 EXPECT_TRUE(scan_utils_.Scan(kFakeInterfaceIndex, kFakeUseRandomMAC, {}, {})); 133 int errno_ignored;
134 EXPECT_TRUE(scan_utils_.Scan(kFakeInterfaceIndex, kFakeUseRandomMAC, {}, {},
135 &errno_ignored));
134 // TODO(b/34231420): Add validation of requested scan ssids, threshold, 136 // TODO(b/34231420): Add validation of requested scan ssids, threshold,
135 // and frequencies. 137 // and frequencies.
136} 138}
@@ -143,7 +145,10 @@ TEST_F(ScanUtilsTest, CanHandleScanRequestFailure) {
143 DoesNL80211PacketMatchCommand(NL80211_CMD_TRIGGER_SCAN), _)). 145 DoesNL80211PacketMatchCommand(NL80211_CMD_TRIGGER_SCAN), _)).
144 WillOnce(Invoke(bind( 146 WillOnce(Invoke(bind(
145 AppendMessageAndReturn, response, true, _1, _2))); 147 AppendMessageAndReturn, response, true, _1, _2)));
146 EXPECT_FALSE(scan_utils_.Scan(kFakeInterfaceIndex, kFakeUseRandomMAC, {}, {})); 148 int error_code;
149 EXPECT_FALSE(scan_utils_.Scan(kFakeInterfaceIndex, kFakeUseRandomMAC, {}, {},
150 &error_code));
151 EXPECT_EQ(kFakeErrorCode, error_code);
147} 152}
148 153
149TEST_F(ScanUtilsTest, CanSendSchedScanRequest) { 154TEST_F(ScanUtilsTest, CanSendSchedScanRequest) {
@@ -154,10 +159,11 @@ TEST_F(ScanUtilsTest, CanSendSchedScanRequest) {
154 DoesNL80211PacketMatchCommand(NL80211_CMD_START_SCHED_SCAN), _)). 159 DoesNL80211PacketMatchCommand(NL80211_CMD_START_SCHED_SCAN), _)).
155 WillOnce(Invoke(bind( 160 WillOnce(Invoke(bind(
156 AppendMessageAndReturn, response, true, _1, _2))); 161 AppendMessageAndReturn, response, true, _1, _2)));
162 int errno_ignored;
157 EXPECT_TRUE(scan_utils_.StartScheduledScan( 163 EXPECT_TRUE(scan_utils_.StartScheduledScan(
158 kFakeInterfaceIndex, 164 kFakeInterfaceIndex,
159 kFakeScheduledScanIntervalMs, 165 kFakeScheduledScanIntervalMs,
160 kFakeRssiThreshold, kFakeUseRandomMAC, {}, {}, {})); 166 kFakeRssiThreshold, kFakeUseRandomMAC, {}, {}, {}, &errno_ignored));
161 // TODO(b/34231420): Add validation of requested scan ssids, threshold, 167 // TODO(b/34231420): Add validation of requested scan ssids, threshold,
162 // and frequencies. 168 // and frequencies.
163} 169}
@@ -170,10 +176,12 @@ TEST_F(ScanUtilsTest, CanHandleSchedScanRequestFailure) {
170 DoesNL80211PacketMatchCommand(NL80211_CMD_START_SCHED_SCAN), _)). 176 DoesNL80211PacketMatchCommand(NL80211_CMD_START_SCHED_SCAN), _)).
171 WillOnce(Invoke(bind( 177 WillOnce(Invoke(bind(
172 AppendMessageAndReturn, response, true, _1, _2))); 178 AppendMessageAndReturn, response, true, _1, _2)));
179 int error_code;
173 EXPECT_FALSE(scan_utils_.StartScheduledScan( 180 EXPECT_FALSE(scan_utils_.StartScheduledScan(
174 kFakeInterfaceIndex, 181 kFakeInterfaceIndex,
175 kFakeScheduledScanIntervalMs, 182 kFakeScheduledScanIntervalMs,
176 kFakeRssiThreshold, kFakeUseRandomMAC, {}, {}, {})); 183 kFakeRssiThreshold, kFakeUseRandomMAC, {}, {}, {}, &error_code));
184 EXPECT_EQ(kFakeErrorCode, error_code);
177} 185}
178 186
179} // namespace wificond 187} // namespace wificond