mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-29 20:59:45 +01:00
Add android build on travis (#1981)
* Add build for android in travis CI. * Fix review findings. Change from __ANDORID__ to POCO_ANDROID * Add android test * Fix compile issue after rebase * Ignore test big ping when its failing
This commit is contained in:
committed by
Aleksandar Fabijanic
parent
d162110e67
commit
9feabc7723
@@ -39,199 +39,271 @@ NetworkInterfaceTest::~NetworkInterfaceTest()
|
||||
|
||||
void NetworkInterfaceTest::testMap()
|
||||
{
|
||||
NetworkInterface::Map m = NetworkInterface::map(false, false);
|
||||
assert (!m.empty());
|
||||
for (NetworkInterface::Map::const_iterator it = m.begin(); it != m.end(); ++it)
|
||||
try
|
||||
{
|
||||
std::cout << std::endl << "=============" << std::endl;
|
||||
|
||||
std::cout << "Index: " << it->second.index() << std::endl;
|
||||
std::cout << "Name: " << it->second.name() << std::endl;
|
||||
std::cout << "DisplayName: " << it->second.displayName() << std::endl;
|
||||
std::cout << "Status: " << (it->second.isUp() ? "Up" : "Down") << std::endl;
|
||||
|
||||
NetworkInterface::MACAddress mac(it->second.macAddress());
|
||||
if (!mac.empty() && (it->second.type() != NetworkInterface::NI_TYPE_SOFTWARE_LOOPBACK))
|
||||
std::cout << "MAC Address: (" << it->second.type() << ") " << mac << std::endl;
|
||||
|
||||
typedef NetworkInterface::AddressList List;
|
||||
const List& ipList = it->second.addressList();
|
||||
List::const_iterator ipIt = ipList.begin();
|
||||
List::const_iterator ipEnd = ipList.end();
|
||||
for (int counter = 0; ipIt != ipEnd; ++ipIt, ++counter)
|
||||
NetworkInterface::Map m = NetworkInterface::map(false, false);
|
||||
assert (!m.empty());
|
||||
for (NetworkInterface::Map::const_iterator it = m.begin(); it != m.end(); ++it)
|
||||
{
|
||||
std::cout << std::endl << "----------" << std::endl;
|
||||
std::cout << "Address " << counter << std::endl;
|
||||
std::cout << "----------" << std::endl;
|
||||
std::cout << "Address: " << ipIt->get<NetworkInterface::IP_ADDRESS>() << std::endl;
|
||||
IPAddress addr = ipIt->get<NetworkInterface::SUBNET_MASK>();
|
||||
if (!addr.isWildcard()) std::cout << "Subnet: " << addr << " (/" << addr.prefixLength() << ")" << std::endl;
|
||||
addr = ipIt->get<NetworkInterface::BROADCAST_ADDRESS>();
|
||||
if (!addr.isWildcard()) std::cout << "Broadcast: " << addr << std::endl;
|
||||
}
|
||||
std::cout << std::endl << "=============" << std::endl;
|
||||
|
||||
std::cout << "=============" << std::endl << std::endl;
|
||||
std::cout << "Index: " << it->second.index() << std::endl;
|
||||
std::cout << "Name: " << it->second.name() << std::endl;
|
||||
std::cout << "DisplayName: " << it->second.displayName() << std::endl;
|
||||
std::cout << "Status: " << (it->second.isUp() ? "Up" : "Down") << std::endl;
|
||||
|
||||
NetworkInterface::MACAddress mac(it->second.macAddress());
|
||||
if (!mac.empty() && (it->second.type() != NetworkInterface::NI_TYPE_SOFTWARE_LOOPBACK))
|
||||
std::cout << "MAC Address: (" << it->second.type() << ") " << mac << std::endl;
|
||||
|
||||
typedef NetworkInterface::AddressList List;
|
||||
const List& ipList = it->second.addressList();
|
||||
List::const_iterator ipIt = ipList.begin();
|
||||
List::const_iterator ipEnd = ipList.end();
|
||||
for (int counter = 0; ipIt != ipEnd; ++ipIt, ++counter)
|
||||
{
|
||||
std::cout << std::endl << "----------" << std::endl;
|
||||
std::cout << "Address " << counter << std::endl;
|
||||
std::cout << "----------" << std::endl;
|
||||
std::cout << "Address: " << ipIt->get<NetworkInterface::IP_ADDRESS>() << std::endl;
|
||||
IPAddress addr = ipIt->get<NetworkInterface::SUBNET_MASK>();
|
||||
if (!addr.isWildcard()) std::cout << "Subnet: " << addr << " (/" << addr.prefixLength() << ")" << std::endl;
|
||||
addr = ipIt->get<NetworkInterface::BROADCAST_ADDRESS>();
|
||||
if (!addr.isWildcard()) std::cout << "Broadcast: " << addr << std::endl;
|
||||
}
|
||||
|
||||
std::cout << "=============" << std::endl << std::endl;
|
||||
}
|
||||
}
|
||||
catch(Poco::NotImplementedException e)
|
||||
{
|
||||
#ifndef POCO_ANDROID
|
||||
throw e;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NetworkInterfaceTest::testList()
|
||||
{
|
||||
NetworkInterface::List list = NetworkInterface::list(false, false);
|
||||
assert (!list.empty());
|
||||
for (NetworkInterface::List::const_iterator it = list.begin(); it != list.end(); ++it)
|
||||
try
|
||||
{
|
||||
std::cout << std::endl << "==============" << std::endl;
|
||||
|
||||
std::cout << "Index: " << it->index() << std::endl;
|
||||
std::cout << "Name: " << it->name() << std::endl;
|
||||
std::cout << "DisplayName: " << it->displayName() << std::endl;
|
||||
std::cout << "Status: " << (it->isUp() ? "Up" : "Down") << std::endl;
|
||||
|
||||
NetworkInterface::MACAddress mac(it->macAddress());
|
||||
if (!mac.empty() && (it->type() != NetworkInterface::NI_TYPE_SOFTWARE_LOOPBACK))
|
||||
std::cout << "MAC Address: (" << it->type() << ") " << mac << std::endl;
|
||||
|
||||
typedef NetworkInterface::AddressList AddrList;
|
||||
const AddrList& ipList = it->addressList();
|
||||
AddrList::const_iterator ipIt = ipList.begin();
|
||||
AddrList::const_iterator ipEnd = ipList.end();
|
||||
for (int counter = 0; ipIt != ipEnd; ++ipIt, ++counter)
|
||||
NetworkInterface::List list = NetworkInterface::list(false, false);
|
||||
assert (!list.empty());
|
||||
for (NetworkInterface::List::const_iterator it = list.begin(); it != list.end(); ++it)
|
||||
{
|
||||
std::cout << "IP Address: " << ipIt->get<NetworkInterface::IP_ADDRESS>() << std::endl;
|
||||
IPAddress addr = ipIt->get<NetworkInterface::SUBNET_MASK>();
|
||||
if (!addr.isWildcard()) std::cout << "Subnet: " << ipIt->get<NetworkInterface::SUBNET_MASK>() << " (/" << ipIt->get<NetworkInterface::SUBNET_MASK>().prefixLength() << ")" << std::endl;
|
||||
addr = ipIt->get<NetworkInterface::BROADCAST_ADDRESS>();
|
||||
if (!addr.isWildcard()) std::cout << "Broadcast: " << ipIt->get<NetworkInterface::BROADCAST_ADDRESS>() << std::endl;
|
||||
}
|
||||
std::cout << std::endl << "==============" << std::endl;
|
||||
|
||||
std::cout << "==============" << std::endl << std::endl;
|
||||
std::cout << "Index: " << it->index() << std::endl;
|
||||
std::cout << "Name: " << it->name() << std::endl;
|
||||
std::cout << "DisplayName: " << it->displayName() << std::endl;
|
||||
std::cout << "Status: " << (it->isUp() ? "Up" : "Down") << std::endl;
|
||||
|
||||
NetworkInterface::MACAddress mac(it->macAddress());
|
||||
if (!mac.empty() && (it->type() != NetworkInterface::NI_TYPE_SOFTWARE_LOOPBACK))
|
||||
std::cout << "MAC Address: (" << it->type() << ") " << mac << std::endl;
|
||||
|
||||
typedef NetworkInterface::AddressList AddrList;
|
||||
const AddrList& ipList = it->addressList();
|
||||
AddrList::const_iterator ipIt = ipList.begin();
|
||||
AddrList::const_iterator ipEnd = ipList.end();
|
||||
for (int counter = 0; ipIt != ipEnd; ++ipIt, ++counter)
|
||||
{
|
||||
std::cout << "IP Address: " << ipIt->get<NetworkInterface::IP_ADDRESS>() << std::endl;
|
||||
IPAddress addr = ipIt->get<NetworkInterface::SUBNET_MASK>();
|
||||
if (!addr.isWildcard()) std::cout << "Subnet: " << ipIt->get<NetworkInterface::SUBNET_MASK>() << " (/" << ipIt->get<NetworkInterface::SUBNET_MASK>().prefixLength() << ")" << std::endl;
|
||||
addr = ipIt->get<NetworkInterface::BROADCAST_ADDRESS>();
|
||||
if (!addr.isWildcard()) std::cout << "Broadcast: " << ipIt->get<NetworkInterface::BROADCAST_ADDRESS>() << std::endl;
|
||||
}
|
||||
|
||||
std::cout << "==============" << std::endl << std::endl;
|
||||
}
|
||||
}
|
||||
catch(Poco::NotImplementedException e)
|
||||
{
|
||||
#ifndef POCO_ANDROID
|
||||
throw e;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NetworkInterfaceTest::testForName()
|
||||
{
|
||||
NetworkInterface::Map map = NetworkInterface::map();
|
||||
for (NetworkInterface::Map::const_iterator it = map.begin(); it != map.end(); ++it)
|
||||
try
|
||||
{
|
||||
NetworkInterface ifc = NetworkInterface::forName(it->second.name());
|
||||
assert (ifc.name() == it->second.name());
|
||||
NetworkInterface::Map map = NetworkInterface::map();
|
||||
for (NetworkInterface::Map::const_iterator it = map.begin(); it != map.end(); ++it)
|
||||
{
|
||||
NetworkInterface ifc = NetworkInterface::forName(it->second.name());
|
||||
assert (ifc.name() == it->second.name());
|
||||
}
|
||||
}
|
||||
catch(Poco::NotImplementedException e)
|
||||
{
|
||||
#ifndef POCO_ANDROID
|
||||
throw e;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NetworkInterfaceTest::testForAddress()
|
||||
{
|
||||
NetworkInterface::Map map = NetworkInterface::map();
|
||||
for (NetworkInterface::Map::const_iterator it = map.begin(); it != map.end(); ++it)
|
||||
try
|
||||
{
|
||||
// not all interfaces have IP configured
|
||||
if (it->second.addressList().empty()) continue;
|
||||
|
||||
if (it->second.supportsIPv4())
|
||||
NetworkInterface::Map map = NetworkInterface::map();
|
||||
for (NetworkInterface::Map::const_iterator it = map.begin(); it != map.end(); ++it)
|
||||
{
|
||||
NetworkInterface ifc = NetworkInterface::forAddress(it->second.firstAddress(IPAddress::IPv4));
|
||||
assert (ifc.firstAddress(IPAddress::IPv4) == it->second.firstAddress(IPAddress::IPv4));
|
||||
// not all interfaces have IP configured
|
||||
if (it->second.addressList().empty()) continue;
|
||||
|
||||
IPAddress addr(IPAddress::IPv4);
|
||||
assert (addr.isWildcard());
|
||||
it->second.firstAddress(addr, IPAddress::IPv4);
|
||||
assert (!addr.isWildcard());
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
if (it->second.supportsIPv4())
|
||||
{
|
||||
it->second.firstAddress(IPAddress::IPv4);
|
||||
fail ("must throw");
|
||||
}
|
||||
catch (NotFoundException&) { }
|
||||
NetworkInterface ifc = NetworkInterface::forAddress(it->second.firstAddress(IPAddress::IPv4));
|
||||
assert (ifc.firstAddress(IPAddress::IPv4) == it->second.firstAddress(IPAddress::IPv4));
|
||||
|
||||
IPAddress addr(IPAddress::IPv4);
|
||||
assert (addr.isWildcard());
|
||||
it->second.firstAddress(addr, IPAddress::IPv4);
|
||||
assert (addr.isWildcard());
|
||||
IPAddress addr(IPAddress::IPv4);
|
||||
assert (addr.isWildcard());
|
||||
it->second.firstAddress(addr, IPAddress::IPv4);
|
||||
assert (!addr.isWildcard());
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
it->second.firstAddress(IPAddress::IPv4);
|
||||
fail ("must throw");
|
||||
}
|
||||
catch (NotFoundException&) { }
|
||||
|
||||
IPAddress addr(IPAddress::IPv4);
|
||||
assert (addr.isWildcard());
|
||||
it->second.firstAddress(addr, IPAddress::IPv4);
|
||||
assert (addr.isWildcard());
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Poco::NotImplementedException e)
|
||||
{
|
||||
#ifndef POCO_ANDROID
|
||||
throw e;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NetworkInterfaceTest::testForIndex()
|
||||
{
|
||||
NetworkInterface::Map map = NetworkInterface::map();
|
||||
for (NetworkInterface::Map::const_iterator it = map.begin(); it != map.end(); ++it)
|
||||
try
|
||||
{
|
||||
NetworkInterface ifc = NetworkInterface::forIndex(it->second.index());
|
||||
assert (ifc.index() == it->second.index());
|
||||
NetworkInterface::Map map = NetworkInterface::map();
|
||||
for (NetworkInterface::Map::const_iterator it = map.begin(); it != map.end(); ++it)
|
||||
{
|
||||
NetworkInterface ifc = NetworkInterface::forIndex(it->second.index());
|
||||
assert (ifc.index() == it->second.index());
|
||||
}
|
||||
}
|
||||
catch(Poco::NotImplementedException e)
|
||||
{
|
||||
#ifndef POCO_ANDROID
|
||||
throw e;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NetworkInterfaceTest::testMapIpOnly()
|
||||
{
|
||||
NetworkInterface::Map m = NetworkInterface::map(true, false);
|
||||
assert (!m.empty());
|
||||
|
||||
std::cout << std::endl;
|
||||
for (NetworkInterface::Map::const_iterator it = m.begin(); it != m.end(); ++it)
|
||||
try
|
||||
{
|
||||
assert(it->second.supportsIPv4() || it->second.supportsIPv6());
|
||||
std::cout << "Interface: (" << it->second.index() << ")" << std::endl;
|
||||
std::cout << "Address: " << it->second.address() << std::endl;
|
||||
NetworkInterface::MACAddress mac(it->second.macAddress());
|
||||
if (!mac.empty() && (it->second.type() != NetworkInterface::NI_TYPE_SOFTWARE_LOOPBACK))
|
||||
std::cout << "MAC Address:" << mac << std::endl;
|
||||
NetworkInterface::Map m = NetworkInterface::map(true, false);
|
||||
assert (!m.empty());
|
||||
|
||||
std::cout << std::endl;
|
||||
for (NetworkInterface::Map::const_iterator it = m.begin(); it != m.end(); ++it)
|
||||
{
|
||||
assert(it->second.supportsIPv4() || it->second.supportsIPv6());
|
||||
std::cout << "Interface: (" << it->second.index() << ")" << std::endl;
|
||||
std::cout << "Address: " << it->second.address() << std::endl;
|
||||
NetworkInterface::MACAddress mac(it->second.macAddress());
|
||||
if (!mac.empty() && (it->second.type() != NetworkInterface::NI_TYPE_SOFTWARE_LOOPBACK))
|
||||
std::cout << "MAC Address:" << mac << std::endl;
|
||||
}
|
||||
}
|
||||
catch(Poco::NotImplementedException e)
|
||||
{
|
||||
#ifndef POCO_ANDROID
|
||||
throw e;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NetworkInterfaceTest::testMapUpOnly()
|
||||
{
|
||||
NetworkInterface::Map m = NetworkInterface::map(false, true);
|
||||
assert (!m.empty());
|
||||
for (NetworkInterface::Map::const_iterator it = m.begin(); it != m.end(); ++it)
|
||||
try
|
||||
{
|
||||
assert(it->second.isUp());
|
||||
NetworkInterface::Map m = NetworkInterface::map(false, true);
|
||||
assert (!m.empty());
|
||||
for (NetworkInterface::Map::const_iterator it = m.begin(); it != m.end(); ++it)
|
||||
{
|
||||
assert(it->second.isUp());
|
||||
}
|
||||
}
|
||||
catch(Poco::NotImplementedException e)
|
||||
{
|
||||
#ifndef POCO_ANDROID
|
||||
throw e;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NetworkInterfaceTest::testListMapConformance()
|
||||
{
|
||||
NetworkInterface::Map m = NetworkInterface::map(false, false);
|
||||
assert (!m.empty());
|
||||
NetworkInterface::List l = NetworkInterface::list(false, false);
|
||||
assert (!l.empty());
|
||||
|
||||
int counter = 0;
|
||||
NetworkInterface::Map::const_iterator mapIt = m.begin();
|
||||
NetworkInterface::List::const_iterator listIt = l.begin();
|
||||
for (; mapIt != m.end(); ++mapIt)
|
||||
try
|
||||
{
|
||||
NetworkInterface::MACAddress mac(mapIt->second.macAddress());
|
||||
NetworkInterface::Map m = NetworkInterface::map(false, false);
|
||||
assert (!m.empty());
|
||||
NetworkInterface::List l = NetworkInterface::list(false, false);
|
||||
assert (!l.empty());
|
||||
|
||||
typedef NetworkInterface::AddressList List;
|
||||
const List& ipList = mapIt->second.addressList();
|
||||
if (ipList.size() > 0)
|
||||
int counter = 0;
|
||||
NetworkInterface::Map::const_iterator mapIt = m.begin();
|
||||
NetworkInterface::List::const_iterator listIt = l.begin();
|
||||
for (; mapIt != m.end(); ++mapIt)
|
||||
{
|
||||
List::const_iterator ipIt = ipList.begin();
|
||||
List::const_iterator ipEnd = ipList.end();
|
||||
for(; ipIt != ipEnd; ++ipIt, ++counter, ++listIt)
|
||||
NetworkInterface::MACAddress mac(mapIt->second.macAddress());
|
||||
|
||||
typedef NetworkInterface::AddressList List;
|
||||
const List& ipList = mapIt->second.addressList();
|
||||
if (ipList.size() > 0)
|
||||
{
|
||||
if(listIt == l.end()) fail("wrong number of list items");
|
||||
NetworkInterface::MACAddress lmac = listIt->macAddress();
|
||||
assert (lmac == mac);
|
||||
List::const_iterator ipIt = ipList.begin();
|
||||
List::const_iterator ipEnd = ipList.end();
|
||||
for(; ipIt != ipEnd; ++ipIt, ++counter, ++listIt)
|
||||
{
|
||||
if(listIt == l.end()) fail("wrong number of list items");
|
||||
NetworkInterface::MACAddress lmac = listIt->macAddress();
|
||||
assert (lmac == mac);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
++listIt;
|
||||
++counter;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
++listIt;
|
||||
++counter;
|
||||
}
|
||||
}
|
||||
|
||||
assert (counter == l.size());
|
||||
assert (counter == l.size());
|
||||
}
|
||||
catch(Poco::NotImplementedException e)
|
||||
{
|
||||
#ifndef POCO_ANDROID
|
||||
throw e;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user