Browse Source

Fix unit tests for android build

Jörg-Christian Böhme 8 năm trước cách đây
mục cha
commit
181fc0eea3

+ 4 - 4
Foundation/testsuite/src/NamedEventTest.cpp

@@ -71,12 +71,12 @@ void NamedEventTest::testNamedEvent()
 	}
 	catch(Poco::NotImplementedException e)
 	{
-#ifndef POCO_ANDROID
+#if POCO_OS != POCO_OS_ANDROID
 		throw e;
 #endif
 	}
 	thr1.join();
-#ifndef POCO_ANDROID
+#if POCO_OS != POCO_OS_ANDROID
 	assert (te.timestamp() > now);
 #endif
 	Thread thr2;
@@ -88,12 +88,12 @@ void NamedEventTest::testNamedEvent()
 	}
 	catch(Poco::NotImplementedException e)
 	{
-#ifndef POCO_ANDROID
+#if POCO_OS != POCO_OS_ANDROID
 		throw e;
 #endif
 	}
 	thr2.join();
-#ifndef POCO_ANDROID
+#if POCO_OS != POCO_OS_ANDROID
 	assert (te.timestamp() > now);
 #endif
 }

+ 3 - 3
Foundation/testsuite/src/NamedMutexTest.cpp

@@ -100,7 +100,7 @@ void NamedMutexTest::testLock()
 	}
 	catch(Poco::NotImplementedException e)
 	{
-#ifndef POCO_ANDROID
+#if POCO_OS != POCO_OS_ANDROID
 		throw e;
 #endif
 	}
@@ -113,7 +113,7 @@ void NamedMutexTest::testTryLock()
 	TestTryLock ttl1;
 	thr1.start(ttl1);
 	thr1.join();
-#ifndef POCO_ANDROID
+#if POCO_OS != POCO_OS_ANDROID
 	assert (ttl1.locked());
 #endif
 	try {
@@ -127,7 +127,7 @@ void NamedMutexTest::testTryLock()
 	}
 	catch(Poco::NotImplementedException e)
 	{
-#ifndef POCO_ANDROID
+#if POCO_OS != POCO_OS_ANDROID
 		throw e;
 #endif
 	}

+ 5 - 5
Foundation/testsuite/src/ProcessTest.cpp

@@ -37,7 +37,7 @@ void ProcessTest::testLaunch()
 {
 	std::string name("TestApp");
 	std::string cmd;
-#if defined(_DEBUG) && !(defined(POCO_ANDROID))
+#if defined(_DEBUG) && (POCO_OS != POCO_OS_ANDROID)
 	name += "d";
 #endif
 
@@ -67,7 +67,7 @@ void ProcessTest::testLaunchRedirectIn()
 #if !defined(_WIN32_WCE)
 	std::string name("TestApp");
 	std::string cmd;
-#if defined(_DEBUG) && !(defined(POCO_ANDROID))
+#if defined(_DEBUG) && (POCO_OS != POCO_OS_ANDROID)
 	name += "d";
 #endif
 
@@ -96,7 +96,7 @@ void ProcessTest::testLaunchRedirectOut()
 #if !defined(_WIN32_WCE)
 	std::string name("TestApp");
 	std::string cmd;
-#if defined(_DEBUG) && !(defined(POCO_ANDROID))
+#if defined(_DEBUG) && (POCO_OS != POCO_OS_ANDROID)
 	name += "d";
 #endif
 
@@ -127,7 +127,7 @@ void ProcessTest::testLaunchEnv()
 #if !defined(_WIN32_WCE)
 	std::string name("TestApp");
 	std::string cmd;
-#if defined(_DEBUG) && !(defined(POCO_ANDROID))
+#if defined(_DEBUG) && (POCO_OS != POCO_OS_ANDROID)
 	name += "d";
 #endif
 
@@ -213,7 +213,7 @@ void ProcessTest::testIsRunning()
 #if !defined(_WIN32_WCE)
 	std::string name("TestApp");
 	std::string cmd;
-#if defined(_DEBUG) && !(defined(POCO_ANDROID))
+#if defined(_DEBUG) && (POCO_OS != POCO_OS_ANDROID)
 	name += "d";
 #endif
 

+ 3 - 3
MongoDB/testsuite/src/MongoDBTest.cpp

@@ -291,7 +291,7 @@ void MongoDBTest::testBuildInfo()
 
 void MongoDBTest::testConnectionPool()
 {
-#ifdef POCO_ANDROID
+#if POCO_OS == POCO_OS_ANDROID
 		std::string host = "10.0.2.2";
 #else
 		std::string host = "127.0.0.1";
@@ -406,7 +406,7 @@ void MongoDBTest::testConnectURI()
 	Poco::MongoDB::Connection conn;
 	Poco::MongoDB::Connection::SocketFactory sf;
 
-#ifdef POCO_ANDROID
+#if POCO_OS == POCO_OS_ANDROID
 		std::string host = "10.0.2.2";
 #else
 		std::string host = "127.0.0.1";
@@ -454,7 +454,7 @@ void MongoDBTest::testConnectURI()
 
 CppUnit::Test* MongoDBTest::suite()
 {
-#ifdef POCO_ANDROID
+#if POCO_OS == POCO_OS_ANDROID
 		std::string host = "10.0.2.2";
 #else
 		std::string host = "127.0.0.1";

+ 2 - 2
Net/testsuite/src/ICMPClientTest.cpp

@@ -52,7 +52,7 @@ void ICMPClientTest::testPing()
 	registerDelegates(icmpClient);
 
 	assert(icmpClient.ping("127.0.0.1") > 0);
-#ifdef POCO_ANDROID
+#if POCO_OS == POCO_OS_ANDROID
 	assert(icmpClient.ping("10.0.2.15", 4) > 0);
 	assert(icmpClient.ping("10.0.2.2", 4) > 0);
 #else
@@ -77,7 +77,7 @@ void ICMPClientTest::testBigPing()
 	registerDelegates(icmpClient);
 
 	assert(icmpClient.ping("127.0.0.1", 1) > 0);
-#ifdef POCO_ANDROID
+#if POCO_OS == POCO_OS_ANDROID
 	assert(icmpClient.ping("10.0.2.15", 4) > 0);
 	assert(icmpClient.ping("10.0.2.2", 4) > 0);
 #else

+ 1 - 1
Net/testsuite/src/MulticastSocketTest.cpp

@@ -60,7 +60,7 @@ void MulticastSocketTest::testMulticast()
 	}
 	catch(Poco::NotImplementedException e)
 	{
-#ifndef POCO_ANDROID
+#if POCO_OS != POCO_OS_ANDROID
 		throw e;
 #endif
 	}

+ 1 - 1
Net/testsuite/src/NTPClientTest.cpp

@@ -48,7 +48,7 @@ NTPClientTest::~NTPClientTest()
 
 void NTPClientTest::testTimeSync()
 {
-#ifndef POCO_ANDROID
+#if POCO_OS != POCO_OS_ANDROID
 	if (ICMPClient::pingIPv4("pool.ntp.org") <= 0)
 	{
 		std::cerr << "pool.ntp.org not accessibe, test skipped" << std::endl;

+ 8 - 8
Net/testsuite/src/NetworkInterfaceTest.cpp

@@ -77,7 +77,7 @@ void NetworkInterfaceTest::testMap()
 	}
 	catch(Poco::NotImplementedException e)
 	{
-	#ifndef POCO_ANDROID
+	#if POCO_OS != POCO_OS_ANDROID
 		throw e;
 	#endif
 	}
@@ -121,7 +121,7 @@ void NetworkInterfaceTest::testList()
 	}
 	catch(Poco::NotImplementedException e)
 	{
-	#ifndef POCO_ANDROID
+	#if POCO_OS != POCO_OS_ANDROID
 		throw e;
 	#endif
 	}
@@ -141,7 +141,7 @@ void NetworkInterfaceTest::testForName()
 	}
 	catch(Poco::NotImplementedException e)
 	{
-	#ifndef POCO_ANDROID
+	#if POCO_OS != POCO_OS_ANDROID
 		throw e;
 	#endif
 	}
@@ -186,7 +186,7 @@ void NetworkInterfaceTest::testForAddress()
 	}
 	catch(Poco::NotImplementedException e)
 	{
-	#ifndef POCO_ANDROID
+	#if POCO_OS != POCO_OS_ANDROID
 		throw e;
 	#endif
 	}
@@ -206,7 +206,7 @@ void NetworkInterfaceTest::testForIndex()
 	}
 	catch(Poco::NotImplementedException e)
 	{
-	#ifndef POCO_ANDROID
+	#if POCO_OS != POCO_OS_ANDROID
 		throw e;
 	#endif
 	}
@@ -233,7 +233,7 @@ void NetworkInterfaceTest::testMapIpOnly()
 	}
 	catch(Poco::NotImplementedException e)
 	{
-	#ifndef POCO_ANDROID
+	#if POCO_OS != POCO_OS_ANDROID
 		throw e;
 	#endif
 	}
@@ -253,7 +253,7 @@ void NetworkInterfaceTest::testMapUpOnly()
 	}
 	catch(Poco::NotImplementedException e)
 	{
-	#ifndef POCO_ANDROID
+	#if POCO_OS != POCO_OS_ANDROID
 		throw e;
 	#endif
 	}
@@ -300,7 +300,7 @@ void NetworkInterfaceTest::testListMapConformance()
 	}
 	catch(Poco::NotImplementedException e)
 	{
-	#ifndef POCO_ANDROID
+	#if POCO_OS != POCO_OS_ANDROID
 		throw e;
 	#endif
 	}

+ 1 - 1
Net/testsuite/src/SocketTest.cpp

@@ -503,7 +503,7 @@ void SocketTest::testSelect3()
 void SocketTest::testEchoUnixLocal()
 {
 #if defined(POCO_OS_FAMILY_UNIX)
-#if defined(POCO_ANDROID)
+#if POCO_OS == POCO_OS_ANDROID
 	Poco::File socketFile("/data/local/tmp/SocketTest.sock");
 #else
 	Poco::File socketFile("/tmp/SocketTest.sock");

+ 1 - 1
Redis/testsuite/src/RedisTest.cpp

@@ -32,7 +32,7 @@ RedisTest::RedisTest(const std::string& name):
 	_host("localhost"),
 	_port(6379)
 {
-#ifdef POCO_ANDROID
+#if POCO_OS == POCO_OS_ANDROID
 	_host = "10.0.2.2";
 #endif
 	if (!_connected)