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:
Joerg-Christian Boehme 2018-02-27 01:54:40 +01:00 committed by Aleksandar Fabijanic
parent d162110e67
commit 9feabc7723
36 changed files with 594 additions and 220 deletions

View File

@ -33,6 +33,99 @@ before_script:
matrix: matrix:
include: include:
- env: TEST_NAME="android API level 19"
language: android
jdk: openjdk8
android:
components:
- tools
- platform-tools
- tools
- build-tools-23.0.3
- extra-android-support
- extra-android-m2repository
- android-19
- android-24
- sys-img-armeabi-v7a-android-24
# Unfortunaly travis use the old android sdk tool instead of using the new sdkmanager.
# In this deprecated android sdk tool there is no ndk-bundle or cmake package!
licenses:
- '.+'
before_install:
- export TERM=dumb
- sudo apt-get update -qq
# I don't understand why redis and mongodb are not installed although services added above !
- sudo apt-get install -qq -y mongodb-server redis-server
- /usr/bin/redis-server &
- sudo /usr/bin/mongod --config /etc/mongodb.conf &
- touch ~/.android/repositories.cfg
- mkdir -p /usr/local/android-sdk/licenses
- echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > /usr/local/android-sdk/licenses/android-sdk-license
- echo -e "\nd56f5187479451eabf01fb78af6dfcb131a6481e" >> /usr/local/android-sdk/licenses/android-sdk-license
# Install NDK and cmake via android sdkmanager.
- /usr/local/android-sdk/tools/bin/sdkmanager --update > /dev/null
- /usr/local/android-sdk/tools/bin/sdkmanager "emulator" "ndk-bundle" "cmake;3.6.4111459" > /dev/null
before_script:
- export TERM=dumb
- export _NO_CHECK_SIGNATURE=true
- echo no | /usr/local/android-sdk/tools/bin/avdmanager create avd -n test -k "system-images;android-24;default;armeabi-v7a"
- /usr/local/android-sdk/emulator/emulator -avd test -no-audio -no-window -dns-server 8.8.8.8 &
- android-wait-for-emulator
- /usr/local/android-sdk/platform-tools/adb shell input keyevent 82 &
script:
# Mandatory cmake parameter to set API level and platform for the android toolchain:
# /usr/local/android-sdk/cmake/3.6.4111459/bin/cmake -DCMAKE_TOOLCHAIN_FILE=/usr/local/android-sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_ABI=armeabi-v7a -DANDROID_PLATFORM=android-22
# See also in /usr/local/android-sdk/ndk-bundle/build/cmake/android.toolchain.cmake
# Using the ninja build command. Is much faster then make build command.
- mkdir cmake-build && cd cmake-build && /usr/local/android-sdk/cmake/3.6.4111459/bin/cmake -G'Android Gradle - Ninja' -DANDROID_ABI=armeabi-v7a -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=/usr/local/android-sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-19 -DCMAKE_MAKE_PROGRAM=/usr/local/android-sdk/cmake/3.6.4111459/bin/ninja -DANDROID_STL="c++_static" -DANDROID_CPP_FEATURES="exceptions rtti" -DENABLE_TESTS=ON -DENABLE_LONG_RUNNING_TESTS=OFF -DOLD_REDIS_VERSION=ON .. && /usr/local/android-sdk/cmake/3.6.4111459/bin/cmake --build . --target all && /usr/local/android-sdk/cmake/3.6.4111459/bin/ctest --output-on-failure
- env: TEST_NAME="android API level 24"
language: android
jdk: openjdk8
android:
components:
- tools
- platform-tools
- tools
- build-tools-23.0.3
- extra-android-support
- extra-android-m2repository
- android-24
- sys-img-armeabi-v7a-android-24
# Unfortunaly travis use the old android sdk tool instead of using the new sdkmanager.
# In this deprecated android sdk tool there is no ndk-bundle or cmake package!
licenses:
- '.+'
before_install:
- export TERM=dumb
- sudo apt-get update -qq
# I don't understand why redis and mongodb are not installed although services added above !
- sudo apt-get install -qq -y mongodb-server redis-server
- /usr/bin/redis-server &
- sudo /usr/bin/mongod --config /etc/mongodb.conf &
- touch ~/.android/repositories.cfg
- mkdir -p /usr/local/android-sdk/licenses
- echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > /usr/local/android-sdk/licenses/android-sdk-license
- echo -e "\nd56f5187479451eabf01fb78af6dfcb131a6481e" >> /usr/local/android-sdk/licenses/android-sdk-license
# Install NDK and cmake via android sdkmanager.
- /usr/local/android-sdk/tools/bin/sdkmanager --update > /dev/null
- /usr/local/android-sdk/tools/bin/sdkmanager "emulator" "ndk-bundle" "cmake;3.6.4111459" > /dev/null
before_script:
- export TERM=dumb
- export _NO_CHECK_SIGNATURE=true
- echo no | /usr/local/android-sdk/tools/bin/avdmanager create avd -n test -k "system-images;android-24;default;armeabi-v7a"
- /usr/local/android-sdk/emulator/emulator -avd test -no-audio -no-window -dns-server 8.8.8.8 &
- android-wait-for-emulator
- /usr/local/android-sdk/platform-tools/adb shell input keyevent 82 &
script:
# Mandatory cmake parameter to set API level and platform for the android toolchain:
# /usr/local/android-sdk/cmake/3.6.4111459/bin/cmake -DCMAKE_TOOLCHAIN_FILE=/usr/local/android-sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_ABI=armeabi-v7a -DANDROID_PLATFORM=android-22
# See also in /usr/local/android-sdk/ndk-bundle/build/cmake/android.toolchain.cmake
# Using the ninja build command. Is much faster then make build command.
- mkdir cmake-build && cd cmake-build && /usr/local/android-sdk/cmake/3.6.4111459/bin/cmake -G'Android Gradle - Ninja' -DANDROID_ABI=armeabi-v7a -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=/usr/local/android-sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-24 -DCMAKE_MAKE_PROGRAM=/usr/local/android-sdk/cmake/3.6.4111459/bin/ninja -DANDROID_STL="c++_static" -DANDROID_CPP_FEATURES="exceptions rtti" -DENABLE_TESTS=ON -DENABLE_LONG_RUNNING_TESTS=OFF -DOLD_REDIS_VERSION=ON .. && /usr/local/android-sdk/cmake/3.6.4111459/bin/cmake --build . --target all && /usr/local/android-sdk/cmake/3.6.4111459/bin/ctest --output-on-failure
- env: TEST_NAME="gcc (make)" - env: TEST_NAME="gcc (make)"
compiler: gcc compiler: gcc
script: script:

View File

@ -141,6 +141,7 @@ else(POCO_STATIC)
endif(POCO_STATIC) endif(POCO_STATIC)
if(ENABLE_TESTS) if(ENABLE_TESTS)
option(ENABLE_LONG_RUNNING_TESTS "Enable long running test" ON)
include(CTest) include(CTest)
enable_testing() enable_testing()
message(STATUS "Building with unittests & samples") message(STATUS "Building with unittests & samples")

View File

@ -13,5 +13,10 @@ POCO_SOURCES_AUTO_PLAT( TEST_SRCS OFF
) )
add_executable( ${TESTUNIT} ${TEST_SRCS} ) add_executable( ${TESTUNIT} ${TEST_SRCS} )
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all) if(ANDROID)
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
COMMAND ${CMAKE_COMMAND} -DANDROID_NDK=${ANDROID_NDK} -DLIBRARY_DIR=${CMAKE_BINARY_DIR}/lib -DUNITTEST=${CMAKE_BINARY_DIR}/bin/${TESTUNIT} -DTEST_PARAMETER=-all -P ${CMAKE_SOURCE_DIR}/cmake/ExecuteOnAndroid.cmake)
else()
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all)
endif()
target_link_libraries( ${TESTUNIT} PocoCppParser PocoFoundation CppUnit ) target_link_libraries( ${TESTUNIT} PocoCppParser PocoFoundation CppUnit )

View File

@ -17,8 +17,13 @@ POCO_SOURCES_AUTO_PLAT( TEST_SRCS WINCE
) )
add_executable( ${TESTUNIT} ${TEST_SRCS} ) add_executable( ${TESTUNIT} ${TEST_SRCS} )
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all) if(ANDROID)
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
COMMAND ${CMAKE_COMMAND} -DANDROID_NDK=${ANDROID_NDK} -DLIBRARY_DIR=${CMAKE_BINARY_DIR}/lib -DUNITTEST=${CMAKE_BINARY_DIR}/bin/${TESTUNIT} -DTEST_PARAMETER=-all -P ${CMAKE_SOURCE_DIR}/cmake/ExecuteOnAndroid.cmake)
else()
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all)
endif()
target_link_libraries( ${TESTUNIT} PocoCrypto PocoNetSSL PocoXML PocoUtil PocoFoundation CppUnit ) target_link_libraries( ${TESTUNIT} PocoCrypto PocoNetSSL PocoXML PocoUtil PocoFoundation CppUnit )
if(UNIX) if(UNIX AND NOT ANDROID)
target_link_libraries( ${TESTUNIT} pthread) target_link_libraries( ${TESTUNIT} pthread)
endif(UNIX) endif(UNIX AND NOT ANDROID)

View File

@ -13,5 +13,10 @@ POCO_SOURCES_AUTO_PLAT( TEST_SRCS OFF
) )
add_executable( ${TESTUNIT} ${TEST_SRCS} ) add_executable( ${TESTUNIT} ${TEST_SRCS} )
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all) if(ANDROID)
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
COMMAND ${CMAKE_COMMAND} -DANDROID_NDK=${ANDROID_NDK} -DLIBRARY_DIR=${CMAKE_BINARY_DIR}/lib -DUNITTEST=${CMAKE_BINARY_DIR}/bin/${TESTUNIT} -DTEST_PARAMETER=-all -P ${CMAKE_SOURCE_DIR}/cmake/ExecuteOnAndroid.cmake)
else()
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all)
endif()
target_link_libraries( ${TESTUNIT} PocoDataMySQL PocoData PocoFoundation CppUnit ) target_link_libraries( ${TESTUNIT} PocoDataMySQL PocoData PocoFoundation CppUnit )

View File

@ -13,5 +13,10 @@ POCO_SOURCES_AUTO_PLAT( TEST_SRCS OFF
) )
add_executable( ${TESTUNIT} ${TEST_SRCS} ) add_executable( ${TESTUNIT} ${TEST_SRCS} )
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all) if(ANDROID)
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
COMMAND ${CMAKE_COMMAND} -DANDROID_NDK=${ANDROID_NDK} -DLIBRARY_DIR=${CMAKE_BINARY_DIR}/lib -DUNITTEST=${CMAKE_BINARY_DIR}/bin/${TESTUNIT} -DTEST_PARAMETER=-all -P ${CMAKE_SOURCE_DIR}/cmake/ExecuteOnAndroid.cmake)
else()
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all)
endif()
target_link_libraries( ${TESTUNIT} PocoDataODBC PocoData PocoFoundation CppUnit ) target_link_libraries( ${TESTUNIT} PocoDataODBC PocoData PocoFoundation CppUnit )

View File

@ -17,5 +17,10 @@ POCO_SOURCES_AUTO_PLAT( TEST_SRCS WINCE
) )
add_executable( ${TESTUNIT} ${TEST_SRCS} ) add_executable( ${TESTUNIT} ${TEST_SRCS} )
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all) if(ANDROID)
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
COMMAND ${CMAKE_COMMAND} -DANDROID_NDK=${ANDROID_NDK} -DLIBRARY_DIR=${CMAKE_BINARY_DIR}/lib -DUNITTEST=${CMAKE_BINARY_DIR}/bin/${TESTUNIT} -DTEST_PARAMETER=-all -P ${CMAKE_SOURCE_DIR}/cmake/ExecuteOnAndroid.cmake)
else()
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all)
endif()
target_link_libraries( ${TESTUNIT} PocoDataSQLite PocoData PocoFoundation CppUnit ) target_link_libraries( ${TESTUNIT} PocoDataSQLite PocoData PocoFoundation CppUnit )

View File

@ -22,5 +22,10 @@ POCO_SOURCES_AUTO_PLAT( TEST_SRCS OFF
) )
add_executable( ${TESTUNIT} ${TEST_SRCS} ) add_executable( ${TESTUNIT} ${TEST_SRCS} )
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all) if(ANDROID)
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
COMMAND ${CMAKE_COMMAND} -DANDROID_NDK=${ANDROID_NDK} -DLIBRARY_DIR=${CMAKE_BINARY_DIR}/lib -DUNITTEST=${CMAKE_BINARY_DIR}/bin/${TESTUNIT} -DTEST_PARAMETER=-all -P ${CMAKE_SOURCE_DIR}/cmake/ExecuteOnAndroid.cmake)
else()
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all)
endif()
target_link_libraries( ${TESTUNIT} PocoData PocoUtil PocoXML PocoFoundation CppUnit) target_link_libraries( ${TESTUNIT} PocoData PocoUtil PocoXML PocoFoundation CppUnit)

View File

@ -17,10 +17,15 @@ POCO_SOURCES_AUTO_PLAT( TEST_SRCS WINCE
) )
add_executable( ${TESTUNIT} ${TEST_SRCS} ) add_executable( ${TESTUNIT} ${TEST_SRCS} )
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all) if(ANDROID)
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
COMMAND ${CMAKE_COMMAND} -DANDROID_NDK=${ANDROID_NDK} "-DTEST_FILES=${CMAKE_CURRENT_SOURCE_DIR}/data;" -DLIBRARY_DIR=${CMAKE_BINARY_DIR}/lib -DUNITTEST=${CMAKE_BINARY_DIR}/bin/${TESTUNIT} -DTEST_PARAMETER=-all -P ${CMAKE_SOURCE_DIR}/cmake/ExecuteOnAndroid.cmake)
else()
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all)
# The test is run in the build directory. So the test data is copied there too
add_custom_command(TARGET ${TESTUNIT} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/data ${CMAKE_CURRENT_BINARY_DIR}/data )
endif()
#set_target_properties( ${TESTUNIT} PROPERTIES COMPILE_FLAGS ${RELEASE_CXX_FLAGS} ) #set_target_properties( ${TESTUNIT} PROPERTIES COMPILE_FLAGS ${RELEASE_CXX_FLAGS} )
target_link_libraries( ${TESTUNIT} PocoEncodings PocoFoundation CppUnit ) target_link_libraries( ${TESTUNIT} PocoEncodings PocoFoundation CppUnit )
# The test is run in the build directory. So the test data is copied there too
add_custom_command(TARGET ${TESTUNIT} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/data ${CMAKE_CURRENT_BINARY_DIR}/data )

View File

@ -25,17 +25,25 @@ POCO_SOURCES_AUTO_PLAT( TEST_SRCS WINCE
) )
add_executable( ${TESTUNIT} ${TEST_SRCS} ) add_executable( ${TESTUNIT} ${TEST_SRCS} )
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND ${TESTUNIT} -all) if(ANDROID)
set_tests_properties(${LIBNAME} PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=.") # The SharedLibaryTest has to look for shared libraries in the working directory add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
COMMAND ${CMAKE_COMMAND} -DANDROID_NDK=${ANDROID_NDK} "-DTEST_FILES=${CMAKE_CURRENT_SOURCE_DIR}/data;TestApp" -DLIBRARY_DIR=${CMAKE_BINARY_DIR}/lib -DUNITTEST=${CMAKE_BINARY_DIR}/bin/${TESTUNIT} -DTEST_PARAMETER=-all -P ${CMAKE_SOURCE_DIR}/cmake/ExecuteOnAndroid.cmake)
else()
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND ${TESTUNIT} -all)
set_tests_properties(${LIBNAME} PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=.") # The SharedLibaryTest has to look for shared libraries in the working directory
# The test is run in the runtime directory. So the test data is copied there too
add_custom_command(TARGET ${TESTUNIT} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/data ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/data )
endif()
target_link_libraries( ${TESTUNIT} PocoFoundation CppUnit ) target_link_libraries( ${TESTUNIT} PocoFoundation CppUnit )
if(UNIX) if(UNIX AND NOT ANDROID)
target_link_libraries( ${TESTUNIT} pthread) target_link_libraries( ${TESTUNIT} pthread)
endif(UNIX) endif(UNIX AND NOT ANDROID)
# The test is run in the runtime directory. So the test data is copied there too if(ENABLE_LONG_RUNNING_TESTS)
add_custom_command(TARGET ${TESTUNIT} POST_BUILD target_compile_definitions( ${TESTUNIT} PRIVATE ENABLE_LONG_RUNNING_TESTS)
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/data ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/data ) endif(ENABLE_LONG_RUNNING_TESTS)
# TestApp # TestApp
if(WINCE) if(WINCE)

View File

@ -203,10 +203,10 @@ void ClassLoaderTest::tearDown()
CppUnit::Test* ClassLoaderTest::suite() CppUnit::Test* ClassLoaderTest::suite()
{ {
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ClassLoaderTest"); CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ClassLoaderTest");
#ifndef POCO_NO_SHAREDMEMORY
CppUnit_addTest(pSuite, ClassLoaderTest, testClassLoader1); CppUnit_addTest(pSuite, ClassLoaderTest, testClassLoader1);
CppUnit_addTest(pSuite, ClassLoaderTest, testClassLoader2); CppUnit_addTest(pSuite, ClassLoaderTest, testClassLoader2);
CppUnit_addTest(pSuite, ClassLoaderTest, testClassLoader3); CppUnit_addTest(pSuite, ClassLoaderTest, testClassLoader3);
#endif
return pSuite; return pSuite;
} }

View File

@ -459,9 +459,9 @@ void GlobTest::testGlob()
#if !defined(_WIN32_WCE) #if !defined(_WIN32_WCE)
// won't work if current directory is root dir // won't work if current directory is root dir
files.clear(); files.clear();
Glob::glob("../*/globtest/*/", files); Glob::glob("globtest/../*/testsuite/*/", files);
translatePaths(files); translatePaths(files);
assert (files.size() == 3); assert (files.size() == 1);
#endif #endif
File dir("globtest"); File dir("globtest");

View File

@ -66,17 +66,36 @@ void NamedEventTest::testNamedEvent()
thr1.start(te); thr1.start(te);
Timestamp now; Timestamp now;
Thread::sleep(2000); Thread::sleep(2000);
testEvent.set(); try {
testEvent.set();
}
catch(Poco::NotImplementedException e)
{
#ifndef POCO_ANDROID
throw e;
#endif
}
thr1.join(); thr1.join();
#ifndef POCO_ANDROID
assert (te.timestamp() > now); assert (te.timestamp() > now);
#endif
Thread thr2; Thread thr2;
thr2.start(te); thr2.start(te);
now.update(); now.update();
Thread::sleep(2000); Thread::sleep(2000);
testEvent.set(); try {
testEvent.set();
}
catch(Poco::NotImplementedException e)
{
#ifndef POCO_ANDROID
throw e;
#endif
}
thr2.join(); thr2.join();
#ifndef POCO_ANDROID
assert (te.timestamp() > now); assert (te.timestamp() > now);
#endif
} }

View File

@ -87,15 +87,23 @@ NamedMutexTest::~NamedMutexTest()
void NamedMutexTest::testLock() void NamedMutexTest::testLock()
{ {
testMutex.lock(); try {
Thread thr; testMutex.lock();
TestLock tl; Thread thr;
thr.start(tl); TestLock tl;
Timestamp now; thr.start(tl);
Thread::sleep(2000); Timestamp now;
testMutex.unlock(); Thread::sleep(2000);
thr.join(); testMutex.unlock();
assert (tl.timestamp() > now); thr.join();
assert (tl.timestamp() > now);
}
catch(Poco::NotImplementedException e)
{
#ifndef POCO_ANDROID
throw e;
#endif
}
} }
@ -105,15 +113,24 @@ void NamedMutexTest::testTryLock()
TestTryLock ttl1; TestTryLock ttl1;
thr1.start(ttl1); thr1.start(ttl1);
thr1.join(); thr1.join();
#ifndef POCO_ANDROID
assert (ttl1.locked()); assert (ttl1.locked());
#endif
testMutex.lock(); try {
Thread thr2; testMutex.lock();
TestTryLock ttl2; Thread thr2;
thr2.start(ttl2); TestTryLock ttl2;
thr2.join(); thr2.start(ttl2);
testMutex.unlock(); thr2.join();
assert (!ttl2.locked()); testMutex.unlock();
assert (!ttl2.locked());
}
catch(Poco::NotImplementedException e)
{
#ifndef POCO_ANDROID
throw e;
#endif
}
} }

View File

@ -74,13 +74,14 @@ void PBKDF2EngineTest::testPBKDF2c()
void PBKDF2EngineTest::testPBKDF2d() void PBKDF2EngineTest::testPBKDF2d()
{ {
// test vector 4 from RFC 6070 // test vector 4 from RFC 6070
#if defined(ENABLE_LONG_RUNNING_TESTS)
std::string p("password"); std::string p("password");
std::string s("salt"); std::string s("salt");
PBKDF2Engine<HMACEngine<SHA1Engine> > pbkdf2(s, 16777216, 20); PBKDF2Engine<HMACEngine<SHA1Engine> > pbkdf2(s, 16777216, 20);
pbkdf2.update(p); pbkdf2.update(p);
std::string dk = DigestEngine::digestToHex(pbkdf2.digest()); std::string dk = DigestEngine::digestToHex(pbkdf2.digest());
assert (dk == "eefe3d61cd4da4e4e9945b3d6ba2158c2634e984"); assert (dk == "eefe3d61cd4da4e4e9945b3d6ba2158c2634e984");
#endif // defined(ENABLE_LONG_RUNNING_TESTS)
} }

View File

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

View File

@ -131,6 +131,7 @@ RWLockTest::~RWLockTest()
void RWLockTest::testLock() void RWLockTest::testLock()
{ {
#if defined(ENABLE_LONG_RUNNING_TESTS)
RWLock lock; RWLock lock;
int counter = 0; int counter = 0;
RWLockRunnable r1(lock, counter); RWLockRunnable r1(lock, counter);
@ -159,11 +160,13 @@ void RWLockTest::testLock()
assert (r3.ok()); assert (r3.ok());
assert (r4.ok()); assert (r4.ok());
assert (r5.ok()); assert (r5.ok());
#endif // defined(ENABLE_LONG_RUNNING_TESTS)
} }
void RWLockTest::testTryLock() void RWLockTest::testTryLock()
{ {
#if defined(ENABLE_LONG_RUNNING_TESTS)
RWLock lock; RWLock lock;
int counter = 0; int counter = 0;
RWTryLockRunnable r1(lock, counter); RWTryLockRunnable r1(lock, counter);
@ -192,6 +195,7 @@ void RWLockTest::testTryLock()
assert (r3.ok()); assert (r3.ok());
assert (r4.ok()); assert (r4.ok());
assert (r5.ok()); assert (r5.ok());
#endif // defined(ENABLE_LONG_RUNNING_TESTS)
} }

View File

@ -140,10 +140,10 @@ void SharedLibraryTest::tearDown()
CppUnit::Test* SharedLibraryTest::suite() CppUnit::Test* SharedLibraryTest::suite()
{ {
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("SharedLibraryTest"); CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("SharedLibraryTest");
#ifndef POCO_NO_SHAREDMEMORY
CppUnit_addTest(pSuite, SharedLibraryTest, testSharedLibrary1); CppUnit_addTest(pSuite, SharedLibraryTest, testSharedLibrary1);
CppUnit_addTest(pSuite, SharedLibraryTest, testSharedLibrary2); CppUnit_addTest(pSuite, SharedLibraryTest, testSharedLibrary2);
CppUnit_addTest(pSuite, SharedLibraryTest, testSharedLibrary3); CppUnit_addTest(pSuite, SharedLibraryTest, testSharedLibrary3);
#endif
return pSuite; return pSuite;
} }

View File

@ -17,9 +17,14 @@ POCO_SOURCES_AUTO_PLAT( TEST_SRCS WINCE
) )
add_executable( ${TESTUNIT} ${TEST_SRCS} ) add_executable( ${TESTUNIT} ${TEST_SRCS} )
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all) if(ANDROID)
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
COMMAND ${CMAKE_COMMAND} -DANDROID_NDK=${ANDROID_NDK} "-DTEST_FILES=${CMAKE_CURRENT_SOURCE_DIR}/data;" -DLIBRARY_DIR=${CMAKE_BINARY_DIR}/lib -DUNITTEST=${CMAKE_BINARY_DIR}/bin/${TESTUNIT} -DTEST_PARAMETER=-all -P ${CMAKE_SOURCE_DIR}/cmake/ExecuteOnAndroid.cmake)
else()
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all)
# The test is run in the build directory. So the test data is copied there too
add_custom_command(TARGET ${TESTUNIT} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/data ${CMAKE_CURRENT_BINARY_DIR}/data )
endif()
target_link_libraries( ${TESTUNIT} PocoJSON PocoFoundation CppUnit ) target_link_libraries( ${TESTUNIT} PocoJSON PocoFoundation CppUnit )
# The test is run in the build directory. So the test data is copied there too
add_custom_command(TARGET ${TESTUNIT} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/data ${CMAKE_CURRENT_BINARY_DIR}/data )

View File

@ -19,5 +19,10 @@ POCO_SOURCES_AUTO_PLAT( TEST_SRCS WINCE
set(TESTUNIT "${LIBNAME}-testrunner") set(TESTUNIT "${LIBNAME}-testrunner")
add_executable( ${TESTUNIT} ${TEST_SRCS} ) add_executable( ${TESTUNIT} ${TEST_SRCS} )
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all) if(ANDROID)
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
COMMAND ${CMAKE_COMMAND} -DANDROID_NDK=${ANDROID_NDK} -DLIBRARY_DIR=${CMAKE_BINARY_DIR}/lib -DUNITTEST=${CMAKE_BINARY_DIR}/bin/${TESTUNIT} -DTEST_PARAMETER=-all -P ${CMAKE_SOURCE_DIR}/cmake/ExecuteOnAndroid.cmake)
else()
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all)
endif()
target_link_libraries( ${TESTUNIT} PocoMongoDB PocoFoundation CppUnit ) target_link_libraries( ${TESTUNIT} PocoMongoDB PocoFoundation CppUnit )

View File

@ -291,7 +291,13 @@ void MongoDBTest::testBuildInfo()
void MongoDBTest::testConnectionPool() void MongoDBTest::testConnectionPool()
{ {
Poco::Net::SocketAddress sa("127.0.0.1", 27017); #ifdef POCO_ANDROID
std::string host = "10.0.2.2";
#else
std::string host = "127.0.0.1";
#endif
Poco::Net::SocketAddress sa(host, 27017);
Poco::PoolableObjectFactory<Poco::MongoDB::Connection, Poco::MongoDB::Connection::Ptr> factory(sa); Poco::PoolableObjectFactory<Poco::MongoDB::Connection, Poco::MongoDB::Connection::Ptr> factory(sa);
Poco::ObjectPool<Poco::MongoDB::Connection, Poco::MongoDB::Connection::Ptr> pool(factory, 10, 15); Poco::ObjectPool<Poco::MongoDB::Connection, Poco::MongoDB::Connection::Ptr> pool(factory, 10, 15);
@ -400,12 +406,18 @@ void MongoDBTest::testConnectURI()
Poco::MongoDB::Connection conn; Poco::MongoDB::Connection conn;
Poco::MongoDB::Connection::SocketFactory sf; Poco::MongoDB::Connection::SocketFactory sf;
conn.connect("mongodb://127.0.0.1", sf); #ifdef POCO_ANDROID
std::string host = "10.0.2.2";
#else
std::string host = "127.0.0.1";
#endif
conn.connect("mongodb://" + host, sf);
conn.disconnect(); conn.disconnect();
try try
{ {
conn.connect("http://127.0.0.1", sf); conn.connect("http://" + host, sf);
fail("invalid URI scheme - must throw"); fail("invalid URI scheme - must throw");
} }
catch (Poco::UnknownURISchemeException&) catch (Poco::UnknownURISchemeException&)
@ -414,19 +426,19 @@ void MongoDBTest::testConnectURI()
try try
{ {
conn.connect("mongodb://127.0.0.1?ssl=true", sf); conn.connect("mongodb://" + host + "?ssl=true", sf);
fail("SSL not supported, must throw"); fail("SSL not supported, must throw");
} }
catch (Poco::NotImplementedException&) catch (Poco::NotImplementedException&)
{ {
} }
conn.connect("mongodb://127.0.0.1/admin?ssl=false&connectTimeoutMS=10000&socketTimeoutMS=10000", sf); conn.connect("mongodb://" + host + "/admin?ssl=false&connectTimeoutMS=10000&socketTimeoutMS=10000", sf);
conn.disconnect(); conn.disconnect();
try try
{ {
conn.connect("mongodb://127.0.0.1/admin?connectTimeoutMS=foo", sf); conn.connect("mongodb://" + host + "/admin?connectTimeoutMS=foo", sf);
fail("invalid parameter - must throw"); fail("invalid parameter - must throw");
} }
catch (Poco::Exception&) catch (Poco::Exception&)
@ -442,19 +454,22 @@ void MongoDBTest::testConnectURI()
CppUnit::Test* MongoDBTest::suite() CppUnit::Test* MongoDBTest::suite()
{ {
#ifdef POCO_ANDROID
std::string host = "10.0.2.2";
#else
std::string host = "127.0.0.1";
#endif
try try
{ {
_mongo = new Poco::MongoDB::Connection("127.0.0.1", 27017); _mongo = new Poco::MongoDB::Connection(host, 27017);
std::cout << "Connected to [127.0.0.1:27017]" << std::endl; std::cout << "Connected to [" << host << ":27017]" << std::endl;
} }
catch (Poco::Net::ConnectionRefusedException& e) catch (Poco::Net::ConnectionRefusedException& e)
{ {
std::cout << "Couldn't connect to " << e.message() << ". " << std::endl; std::cout << "Couldn't connect to " << e.message() << ". " << std::endl;
return 0; return 0;
} }
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("MongoDBTest"); CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("MongoDBTest");
CppUnit_addTest(pSuite, MongoDBTest, testBuildInfo); CppUnit_addTest(pSuite, MongoDBTest, testBuildInfo);
CppUnit_addTest(pSuite, MongoDBTest, testInsertRequest); CppUnit_addTest(pSuite, MongoDBTest, testInsertRequest);
CppUnit_addTest(pSuite, MongoDBTest, testQueryRequest); CppUnit_addTest(pSuite, MongoDBTest, testQueryRequest);
@ -469,6 +484,5 @@ CppUnit::Test* MongoDBTest::suite()
CppUnit_addTest(pSuite, MongoDBTest, testCommand); CppUnit_addTest(pSuite, MongoDBTest, testCommand);
CppUnit_addTest(pSuite, MongoDBTest, testUUID); CppUnit_addTest(pSuite, MongoDBTest, testUUID);
CppUnit_addTest(pSuite, MongoDBTest, testConnectURI); CppUnit_addTest(pSuite, MongoDBTest, testConnectURI);
return pSuite; return pSuite;
} }

View File

@ -17,5 +17,10 @@ POCO_SOURCES_AUTO_PLAT( TEST_SRCS WINCE
) )
add_executable( ${TESTUNIT} ${TEST_SRCS} ) add_executable( ${TESTUNIT} ${TEST_SRCS} )
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all) if(ANDROID)
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
COMMAND ${CMAKE_COMMAND} -DANDROID_NDK=${ANDROID_NDK} -DLIBRARY_DIR=${CMAKE_BINARY_DIR}/lib -DUNITTEST=${CMAKE_BINARY_DIR}/bin/${TESTUNIT} -DTEST_PARAMETER=-all -P ${CMAKE_SOURCE_DIR}/cmake/ExecuteOnAndroid.cmake)
else()
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all)
endif()
target_link_libraries( ${TESTUNIT} PocoNet PocoUtil PocoXML PocoFoundation CppUnit) target_link_libraries( ${TESTUNIT} PocoNet PocoUtil PocoXML PocoFoundation CppUnit)

View File

@ -52,12 +52,17 @@ void ICMPClientTest::testPing()
registerDelegates(icmpClient); registerDelegates(icmpClient);
assert(icmpClient.ping("127.0.0.1") > 0); assert(icmpClient.ping("127.0.0.1") > 0);
#ifdef POCO_ANDROID
assert(icmpClient.ping("10.0.2.15", 4) > 0);
assert(icmpClient.ping("10.0.2.2", 4) > 0);
#else
assert(icmpClient.ping("www.appinf.com", 4) > 0); assert(icmpClient.ping("www.appinf.com", 4) > 0);
// warning: may fail depending on the existence of the addresses at test site // warning: may fail depending on the existence of the addresses at test site
// if so, adjust accordingly (i.e. specify non-existent or unreachable IP addresses) // if so, adjust accordingly (i.e. specify non-existent or unreachable IP addresses)
assert(0 == icmpClient.ping("192.168.243.1")); assert(0 == icmpClient.ping("192.168.243.1"));
assert(0 == icmpClient.ping("10.11.12.13")); assert(0 == icmpClient.ping("10.11.12.13"));
#endif
unregisterDelegates(icmpClient); unregisterDelegates(icmpClient);
} }
@ -72,12 +77,17 @@ void ICMPClientTest::testBigPing()
registerDelegates(icmpClient); registerDelegates(icmpClient);
assert(icmpClient.ping("127.0.0.1", 1) > 0); assert(icmpClient.ping("127.0.0.1", 1) > 0);
#ifdef POCO_ANDROID
assert(icmpClient.ping("10.0.2.15", 4) > 0);
assert(icmpClient.ping("10.0.2.2", 4) > 0);
#else
assert(icmpClient.ping("www.appinf.com", 4) > 0); assert(icmpClient.ping("www.appinf.com", 4) > 0);
// warning: may fail depending on the existence of the addresses at test site // warning: may fail depending on the existence of the addresses at test site
// if so, adjust accordingly (i.e. specify non-existent or unreachable IP addresses) // if so, adjust accordingly (i.e. specify non-existent or unreachable IP addresses)
assert(0 == icmpClient.ping("192.168.243.1")); assert(0 == icmpClient.ping("192.168.243.1"));
assert(0 == icmpClient.ping("10.11.12.13")); assert(0 == icmpClient.ping("10.11.12.13"));
#endif
unregisterDelegates(icmpClient); unregisterDelegates(icmpClient);
} }

View File

@ -47,15 +47,23 @@ MulticastSocketTest::~MulticastSocketTest()
void MulticastSocketTest::testMulticast() void MulticastSocketTest::testMulticast()
{ {
MulticastEchoServer echoServer; try {
MulticastSocket ms(SocketAddress::IPv4); MulticastEchoServer echoServer;
int n = ms.sendTo("hello", 5, echoServer.group()); MulticastSocket ms(SocketAddress::IPv4);
assert (n == 5); int n = ms.sendTo("hello", 5, echoServer.group());
char buffer[256]; assert (n == 5);
n = ms.receiveBytes(buffer, sizeof(buffer)); char buffer[256];
assert (n == 5); n = ms.receiveBytes(buffer, sizeof(buffer));
assert (std::string(buffer, n) == "hello"); assert (n == 5);
ms.close(); assert (std::string(buffer, n) == "hello");
ms.close();
}
catch(Poco::NotImplementedException e)
{
#ifndef POCO_ANDROID
throw e;
#endif
}
} }

View File

@ -48,11 +48,14 @@ NTPClientTest::~NTPClientTest()
void NTPClientTest::testTimeSync() void NTPClientTest::testTimeSync()
{ {
#ifndef POCO_ANDROID
if (ICMPClient::pingIPv4("pool.ntp.org") <= 0) if (ICMPClient::pingIPv4("pool.ntp.org") <= 0)
{ {
std::cerr << "pool.ntp.org not accessibe, test skipped" << std::endl; std::cerr << "pool.ntp.org not accessibe, test skipped" << std::endl;
return; return;
} }
#endif
assert(_ntpClient.request("pool.ntp.org") > 0); assert(_ntpClient.request("pool.ntp.org") > 0);
} }

View File

@ -39,199 +39,271 @@ NetworkInterfaceTest::~NetworkInterfaceTest()
void NetworkInterfaceTest::testMap() void NetworkInterfaceTest::testMap()
{ {
NetworkInterface::Map m = NetworkInterface::map(false, false); try
assert (!m.empty());
for (NetworkInterface::Map::const_iterator it = m.begin(); it != m.end(); ++it)
{ {
std::cout << std::endl << "=============" << std::endl; NetworkInterface::Map m = NetworkInterface::map(false, false);
assert (!m.empty());
std::cout << "Index: " << it->second.index() << std::endl; for (NetworkInterface::Map::const_iterator it = m.begin(); it != m.end(); ++it)
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 << 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 << "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() void NetworkInterfaceTest::testList()
{ {
NetworkInterface::List list = NetworkInterface::list(false, false); try
assert (!list.empty());
for (NetworkInterface::List::const_iterator it = list.begin(); it != list.end(); ++it)
{ {
std::cout << std::endl << "==============" << std::endl; NetworkInterface::List list = NetworkInterface::list(false, false);
assert (!list.empty());
std::cout << "Index: " << it->index() << std::endl; for (NetworkInterface::List::const_iterator it = list.begin(); it != list.end(); ++it)
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; std::cout << std::endl << "==============" << 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 << "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() void NetworkInterfaceTest::testForName()
{ {
NetworkInterface::Map map = NetworkInterface::map(); try
for (NetworkInterface::Map::const_iterator it = map.begin(); it != map.end(); ++it)
{ {
NetworkInterface ifc = NetworkInterface::forName(it->second.name()); NetworkInterface::Map map = NetworkInterface::map();
assert (ifc.name() == it->second.name()); 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() void NetworkInterfaceTest::testForAddress()
{ {
NetworkInterface::Map map = NetworkInterface::map(); try
for (NetworkInterface::Map::const_iterator it = map.begin(); it != map.end(); ++it)
{ {
// not all interfaces have IP configured NetworkInterface::Map map = NetworkInterface::map();
if (it->second.addressList().empty()) continue; for (NetworkInterface::Map::const_iterator it = map.begin(); it != map.end(); ++it)
if (it->second.supportsIPv4())
{ {
NetworkInterface ifc = NetworkInterface::forAddress(it->second.firstAddress(IPAddress::IPv4)); // not all interfaces have IP configured
assert (ifc.firstAddress(IPAddress::IPv4) == it->second.firstAddress(IPAddress::IPv4)); if (it->second.addressList().empty()) continue;
IPAddress addr(IPAddress::IPv4); if (it->second.supportsIPv4())
assert (addr.isWildcard());
it->second.firstAddress(addr, IPAddress::IPv4);
assert (!addr.isWildcard());
}
else
{
try
{ {
it->second.firstAddress(IPAddress::IPv4); NetworkInterface ifc = NetworkInterface::forAddress(it->second.firstAddress(IPAddress::IPv4));
fail ("must throw"); assert (ifc.firstAddress(IPAddress::IPv4) == it->second.firstAddress(IPAddress::IPv4));
}
catch (NotFoundException&) { }
IPAddress addr(IPAddress::IPv4); IPAddress addr(IPAddress::IPv4);
assert (addr.isWildcard()); assert (addr.isWildcard());
it->second.firstAddress(addr, IPAddress::IPv4); it->second.firstAddress(addr, IPAddress::IPv4);
assert (addr.isWildcard()); 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() void NetworkInterfaceTest::testForIndex()
{ {
NetworkInterface::Map map = NetworkInterface::map(); try
for (NetworkInterface::Map::const_iterator it = map.begin(); it != map.end(); ++it)
{ {
NetworkInterface ifc = NetworkInterface::forIndex(it->second.index()); NetworkInterface::Map map = NetworkInterface::map();
assert (ifc.index() == it->second.index()); 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() void NetworkInterfaceTest::testMapIpOnly()
{ {
NetworkInterface::Map m = NetworkInterface::map(true, false); try
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()); NetworkInterface::Map m = NetworkInterface::map(true, false);
std::cout << "Interface: (" << it->second.index() << ")" << std::endl; assert (!m.empty());
std::cout << "Address: " << it->second.address() << std::endl;
NetworkInterface::MACAddress mac(it->second.macAddress()); std::cout << std::endl;
if (!mac.empty() && (it->second.type() != NetworkInterface::NI_TYPE_SOFTWARE_LOOPBACK)) for (NetworkInterface::Map::const_iterator it = m.begin(); it != m.end(); ++it)
std::cout << "MAC Address:" << mac << std::endl; {
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() void NetworkInterfaceTest::testMapUpOnly()
{ {
NetworkInterface::Map m = NetworkInterface::map(false, true); try
assert (!m.empty());
for (NetworkInterface::Map::const_iterator it = m.begin(); it != m.end(); ++it)
{ {
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() void NetworkInterfaceTest::testListMapConformance()
{ {
NetworkInterface::Map m = NetworkInterface::map(false, false); try
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)
{ {
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; int counter = 0;
const List& ipList = mapIt->second.addressList(); NetworkInterface::Map::const_iterator mapIt = m.begin();
if (ipList.size() > 0) NetworkInterface::List::const_iterator listIt = l.begin();
for (; mapIt != m.end(); ++mapIt)
{ {
List::const_iterator ipIt = ipList.begin(); NetworkInterface::MACAddress mac(mapIt->second.macAddress());
List::const_iterator ipEnd = ipList.end();
for(; ipIt != ipEnd; ++ipIt, ++counter, ++listIt) typedef NetworkInterface::AddressList List;
const List& ipList = mapIt->second.addressList();
if (ipList.size() > 0)
{ {
if(listIt == l.end()) fail("wrong number of list items"); List::const_iterator ipIt = ipList.begin();
NetworkInterface::MACAddress lmac = listIt->macAddress(); List::const_iterator ipEnd = ipList.end();
assert (lmac == mac); 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
}
} }

View File

@ -503,7 +503,11 @@ void SocketTest::testSelect3()
void SocketTest::testEchoUnixLocal() void SocketTest::testEchoUnixLocal()
{ {
#if defined(POCO_OS_FAMILY_UNIX) #if defined(POCO_OS_FAMILY_UNIX)
#if defined(POCO_ANDROID)
Poco::File socketFile("/data/local/tmp/SocketTest.sock");
#else
Poco::File socketFile("/tmp/SocketTest.sock"); Poco::File socketFile("/tmp/SocketTest.sock");
#endif
if (socketFile.exists()) socketFile.remove(); if (socketFile.exists()) socketFile.remove();
SocketAddress localAddr(SocketAddress::UNIX_LOCAL, socketFile.path()); SocketAddress localAddr(SocketAddress::UNIX_LOCAL, socketFile.path());
EchoServer echoServer(localAddr); EchoServer echoServer(localAddr);

View File

@ -17,12 +17,21 @@ POCO_SOURCES_AUTO_PLAT( TEST_SRCS WINCE
) )
add_executable( ${TESTUNIT} ${TEST_SRCS} ) add_executable( ${TESTUNIT} ${TEST_SRCS} )
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND ${TESTUNIT} -all) if(ANDROID)
target_link_libraries( ${TESTUNIT} PocoNetSSL PocoCrypto PocoNet PocoUtil PocoXML PocoFoundation CppUnit) add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
COMMAND ${CMAKE_COMMAND} -DANDROID_NDK=${ANDROID_NDK} "-DTEST_FILES=${CMAKE_CURRENT_SOURCE_DIR}/any.pem;${CMAKE_CURRENT_SOURCE_DIR}/rootcert.pem;${CMAKE_CURRENT_SOURCE_DIR}/testrunner.xml" -DLIBRARY_DIR=${CMAKE_BINARY_DIR}/lib -DUNITTEST=${CMAKE_BINARY_DIR}/bin/${TESTUNIT} -DTEST_PARAMETER=-all -P ${CMAKE_SOURCE_DIR}/cmake/ExecuteOnAndroid.cmake)
# The test is run in the build directory. So the test data is copied there too add_custom_command(TARGET ${TESTUNIT} POST_BUILD
add_custom_command(TARGET ${TESTUNIT} POST_BUILD COMMAND ${CMAKE_COMMAND} -DANDROID_NDK=${ANDROID_NDK} -DFILES="${CMAKE_CURRENT_SOURCE_DIR}/any.pem" -P ${CMAKE_SOURCE_DIR}/cmake/PushOnAndroid.cmake
COMMAND ${CMAKE_COMMAND} -DANDROID_NDK=${ANDROID_NDK} -DFILES="${CMAKE_CURRENT_SOURCE_DIR}/rootcert.pem" -P ${CMAKE_SOURCE_DIR}/cmake/PushOnAndroid.cmake
COMMAND ${CMAKE_COMMAND} -DANDROID_NDK=${ANDROID_NDK} -DFILES="${CMAKE_CURRENT_SOURCE_DIR}/testrunner.xml" -P ${CMAKE_SOURCE_DIR}/cmake/PushOnAndroid.cmake)
else()
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND ${TESTUNIT} -all)
# The test is run in the build directory. So the test data is copied there too
add_custom_command(TARGET ${TESTUNIT} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/any.pem ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/any.pem ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/rootcert.pem ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/rootcert.pem ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/testrunner.xml ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TESTUNIT}.xml COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/testrunner.xml ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TESTUNIT}.xml
) )
endif()
target_link_libraries( ${TESTUNIT} PocoNetSSL PocoCrypto PocoNet PocoUtil PocoXML PocoFoundation CppUnit)

View File

@ -13,5 +13,10 @@ POCO_SOURCES_AUTO_PLAT( TEST_SRCS OFF
) )
add_executable( ${TESTUNIT} ${TEST_SRCS} ) add_executable( ${TESTUNIT} ${TEST_SRCS} )
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all) if(ANDROID)
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
COMMAND ${CMAKE_COMMAND} -DANDROID_NDK=${ANDROID_NDK} -DLIBRARY_DIR=${CMAKE_BINARY_DIR}/lib -DUNITTEST=${CMAKE_BINARY_DIR}/bin/${TESTUNIT} -DTEST_PARAMETER=-all -P ${CMAKE_SOURCE_DIR}/cmake/ExecuteOnAndroid.cmake)
else()
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all)
endif()
target_link_libraries( ${TESTUNIT} PocoPDF PocoFoundation CppUnit ) target_link_libraries( ${TESTUNIT} PocoPDF PocoFoundation CppUnit )

View File

@ -19,7 +19,15 @@ POCO_SOURCES_AUTO_PLAT( TEST_SRCS WINCE
set(TESTUNIT "${LIBNAME}-testrunner") set(TESTUNIT "${LIBNAME}-testrunner")
add_executable( ${TESTUNIT} ${TEST_SRCS} ) add_executable( ${TESTUNIT} ${TEST_SRCS} )
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all) if(ANDROID)
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
COMMAND ${CMAKE_COMMAND} -DANDROID_NDK=${ANDROID_NDK} -DLIBRARY_DIR=${CMAKE_BINARY_DIR}/lib -DUNITTEST=${CMAKE_BINARY_DIR}/bin/${TESTUNIT} -DTEST_PARAMETER=-all -P ${CMAKE_SOURCE_DIR}/cmake/ExecuteOnAndroid.cmake)
else()
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all)
endif()
target_link_libraries( ${TESTUNIT} ${CMAKE_THREAD_LIBS_INIT} PocoRedis PocoFoundation CppUnit ) target_link_libraries( ${TESTUNIT} ${CMAKE_THREAD_LIBS_INIT} PocoRedis PocoFoundation CppUnit )
if(OLD_REDIS_VERSION)
target_compile_definitions( ${TESTUNIT} PRIVATE OLD_REDIS_VERSION)
endif(OLD_REDIS_VERSION)

View File

@ -32,6 +32,9 @@ RedisTest::RedisTest(const std::string& name):
_host("localhost"), _host("localhost"),
_port(6379) _port(6379)
{ {
#ifdef POCO_ANDROID
_host = "10.0.2.2";
#endif
if (!_connected) if (!_connected)
{ {
try try
@ -954,6 +957,7 @@ void RedisTest::testPING()
fail(e.message()); fail(e.message());
} }
#ifndef OLD_REDIS_VERSION
// A PING with a custom string responds with a bulk string // A PING with a custom string responds with a bulk string
command.add("Hello"); command.add("Hello");
try try
@ -966,7 +970,7 @@ void RedisTest::testPING()
{ {
fail(e.message()); fail(e.message());
} }
#endif
} }
@ -3002,6 +3006,5 @@ CppUnit::Test* RedisTest::suite()
CppUnit_addTest(pSuite, RedisTest, testRPOPLPUSH); CppUnit_addTest(pSuite, RedisTest, testRPOPLPUSH);
CppUnit_addTest(pSuite, RedisTest, testRPUSH); CppUnit_addTest(pSuite, RedisTest, testRPUSH);
CppUnit_addTest(pSuite, RedisTest, testPool); CppUnit_addTest(pSuite, RedisTest, testPool);
return pSuite; return pSuite;
} }

View File

@ -23,5 +23,10 @@ POCO_SOURCES_AUTO_PLAT( TEST_SRCS WINCE
) )
add_executable( ${TESTUNIT} ${TEST_SRCS} ) add_executable( ${TESTUNIT} ${TEST_SRCS} )
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all) if(ANDROID)
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
COMMAND ${CMAKE_COMMAND} -DANDROID_NDK=${ANDROID_NDK} -DLIBRARY_DIR=${CMAKE_BINARY_DIR}/lib -DUNITTEST=${CMAKE_BINARY_DIR}/bin/${TESTUNIT} -DTEST_PARAMETER=-all -P ${CMAKE_SOURCE_DIR}/cmake/ExecuteOnAndroid.cmake)
else()
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all)
endif()
target_link_libraries( ${TESTUNIT} PocoUtil PocoJSON PocoXML PocoFoundation CppUnit) target_link_libraries( ${TESTUNIT} PocoUtil PocoJSON PocoXML PocoFoundation CppUnit)

View File

@ -17,5 +17,10 @@ POCO_SOURCES_AUTO_PLAT( TEST_SRCS WINCE
) )
add_executable( ${TESTUNIT} ${TEST_SRCS} ) add_executable( ${TESTUNIT} ${TEST_SRCS} )
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all) if(ANDROID)
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
COMMAND ${CMAKE_COMMAND} -DANDROID_NDK=${ANDROID_NDK} -DLIBRARY_DIR=${CMAKE_BINARY_DIR}/lib -DUNITTEST=${CMAKE_BINARY_DIR}/bin/${TESTUNIT} -DTEST_PARAMETER=-all -P ${CMAKE_SOURCE_DIR}/cmake/ExecuteOnAndroid.cmake)
else()
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all)
endif()
target_link_libraries( ${TESTUNIT} PocoXML PocoFoundation CppUnit) target_link_libraries( ${TESTUNIT} PocoXML PocoFoundation CppUnit)

View File

@ -17,10 +17,15 @@ POCO_SOURCES_AUTO_PLAT( TEST_SRCS WINCE
) )
add_executable( ${TESTUNIT} ${TEST_SRCS} ) add_executable( ${TESTUNIT} ${TEST_SRCS} )
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all) if(ANDROID)
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
COMMAND ${CMAKE_COMMAND} -DANDROID_NDK=${ANDROID_NDK} "-DTEST_FILES=${CMAKE_CURRENT_SOURCE_DIR}/data;" -DLIBRARY_DIR=${CMAKE_BINARY_DIR}/lib -DUNITTEST=${CMAKE_BINARY_DIR}/bin/${TESTUNIT} -DTEST_PARAMETER=-all -P ${CMAKE_SOURCE_DIR}/cmake/ExecuteOnAndroid.cmake)
else()
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all)
# The test is run in the build directory. So the test data is copied there too
add_custom_command(TARGET ${TESTUNIT} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/data ${CMAKE_CURRENT_BINARY_DIR}/data )
endif()
#set_target_properties( ${TESTUNIT} PROPERTIES COMPILE_FLAGS ${RELEASE_CXX_FLAGS} ) #set_target_properties( ${TESTUNIT} PROPERTIES COMPILE_FLAGS ${RELEASE_CXX_FLAGS} )
target_link_libraries( ${TESTUNIT} PocoZip PocoNet PocoFoundation CppUnit ) target_link_libraries( ${TESTUNIT} PocoZip PocoNet PocoFoundation CppUnit )
# The test is run in the build directory. So the test data is copied there too
add_custom_command(TARGET ${TESTUNIT} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/data ${CMAKE_CURRENT_BINARY_DIR}/data )

View File

@ -0,0 +1,29 @@
get_filename_component(UNITTEST_FILENAME ${UNITTEST} NAME)
message(STATUS "Cleanup /data/local/tmp ...")
execute_process(COMMAND ${ANDROID_NDK}/../platform-tools/adb shell "rm -r /data/local/tmp/*" OUTPUT_QUIET)
foreach(_TEST_DATA IN ITEMS ${TEST_FILES})
message(STATUS "Push ${_TEST_DATA} to android ...")
execute_process(COMMAND ${ANDROID_NDK}/../platform-tools/adb push ${_TEST_DATA} /data/local/tmp/ OUTPUT_QUIET)
endforeach()
message(STATUS "Push ${LIBRARY_DIR} to android ...")
execute_process(COMMAND ${ANDROID_NDK}/../platform-tools/adb push ${LIBRARY_DIR} /data/local/tmp/ OUTPUT_QUIET)
message(STATUS "Push ${UNITTEST} to android ...")
execute_process(COMMAND ${ANDROID_NDK}/../platform-tools/adb push ${UNITTEST} /data/local/tmp/ OUTPUT_QUIET)
message(STATUS "Execute ${UNITTEST_FILENAME} ${TEST_PARAMETER} on android ...")
execute_process(
COMMAND ${ANDROID_NDK}/../platform-tools/adb shell "cd /data/local/tmp;su root sh -c 'LD_LIBRARY_PATH=/data/local/tmp/lib TMPDIR=/data/local/tmp HOME=/data/local/tmp ./${UNITTEST_FILENAME} ${TEST_PARAMETER};echo exit code $?'"
RESULT_VARIABLE _RESULT
OUTPUT_VARIABLE _OUT
ERROR_VARIABLE _ERR
)
if(_RESULT)
message(FATAL_ERROR "Execution of ${UNITTEST_FILENAME} failed")
else()
string(REGEX MATCH "exit code ([0-9]+)" _EXIT_CODE ${_OUT})
if(NOT "${CMAKE_MATCH_1}" EQUAL 0)
string(REGEX REPLACE "exit code [0-9]+" "" _PRINT_OUT ${_OUT})
message(FATAL_ERROR "${UNITTEST_FILENAME} execution error: ${_PRINT_OUT} ${_ERR}")
endif()
endif()

View File

@ -5,6 +5,7 @@ export CPPUNIT_IGNORE="\
N7CppUnit10TestCallerI13RawSocketTestEE.testEchoIPv4 \ N7CppUnit10TestCallerI13RawSocketTestEE.testEchoIPv4 \
N7CppUnit10TestCallerI13RawSocketTestEE.testSendToReceiveFromIPv4 \ N7CppUnit10TestCallerI13RawSocketTestEE.testSendToReceiveFromIPv4 \
N7CppUnit10TestCallerI14ICMPClientTestEE.testPing \ N7CppUnit10TestCallerI14ICMPClientTestEE.testPing \
N7CppUnit10TestCallerI14ICMPClientTestEE.testBigPing \
N7CppUnit10TestCallerI22HTTPSClientSessionTestEE.testProxy \ N7CppUnit10TestCallerI22HTTPSClientSessionTestEE.testProxy \
N7CppUnit10TestCallerI22HTTPSStreamFactoryTestEE.testProxy \ N7CppUnit10TestCallerI22HTTPSStreamFactoryTestEE.testProxy \
N7CppUnit10TestCallerI19MulticastSocketTestEE.testMulticast \ N7CppUnit10TestCallerI19MulticastSocketTestEE.testMulticast \