Bug 1175057 - Fix the problem of the script timeout by ensuring it associates to the right ap. r=hchang

This commit is contained in:
Tim Huang 2015-09-03 19:29:00 +02:00
Родитель a94a444a52
Коммит bc034be4a8
2 изменённых файлов: 33 добавлений и 4 удалений

Просмотреть файл

@ -776,7 +776,12 @@ let gTestSuite = (function() {
.then(() => runEmulatorShellSafe(['hostapd', '-B', configFileName]))
.then(function (reply) {
// It may fail at the first time due to the previous ungracefully terminated one.
if (reply[0] === 'bind(PF_UNIX): Address already in use') {
if (reply.length === 0) {
// The hostapd starts successfully
return;
}
if (reply[0].indexOf('bind(PF_UNIX): Address already in use') !== -1) {
return startOneHostapd(aIndex);
}
});

Просмотреть файл

@ -14,6 +14,8 @@ const STATIC_IP_CONFIG = {
dns2: "8.8.4.4",
};
const TESTING_HOSTAPD = [{ ssid: 'ap0' }];
function testAssociateWithStaticIp(aNetwork, aStaticIpConfig) {
return gTestSuite.setStaticIpMode(aNetwork, aStaticIpConfig)
.then(() => gTestSuite.testAssociate(aNetwork))
@ -32,10 +34,32 @@ function testAssociateWithStaticIp(aNetwork, aStaticIpConfig) {
});
}
function findDesireNetwork(aNetworks) {
let i = gTestSuite.getFirstIndexBySsid(TESTING_HOSTAPD[0].ssid, aNetworks);
if (-1 !== i) {
return aNetworks[i];
}
return aNetworks[0];
}
// Start test.
gTestSuite.doTest(function() {
gTestSuite.doTestWithoutStockAp(function() {
return gTestSuite.ensureWifiEnabled(true)
// Start custom hostapd for testing.
.then(() => gTestSuite.startHostapds(TESTING_HOSTAPD))
.then(() => gTestSuite.verifyNumOfProcesses('hostapd',
TESTING_HOSTAPD.length))
// Perform a wifi scan, and then run the static ip test
.then(() => gTestSuite.requestWifiScan())
.then((aNetworks) => testAssociateWithStaticIp(aNetworks[0],
STATIC_IP_CONFIG));
.then((aNetworks) => findDesireNetwork(aNetworks))
.then((aNetwork) => testAssociateWithStaticIp(aNetwork,
STATIC_IP_CONFIG))
// Kill running hostapd.
.then(gTestSuite.killAllHostapd)
.then(() => gTestSuite.verifyNumOfProcesses('hostapd', 0));
});