mirror of
https://github.com/pocoproject/poco.git
synced 2025-01-31 06:35:03 +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:
parent
d162110e67
commit
9feabc7723
93
.travis.yml
93
.travis.yml
@ -33,6 +33,99 @@ before_script:
|
||||
|
||||
matrix:
|
||||
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)"
|
||||
compiler: gcc
|
||||
script:
|
||||
|
@ -141,6 +141,7 @@ else(POCO_STATIC)
|
||||
endif(POCO_STATIC)
|
||||
|
||||
if(ENABLE_TESTS)
|
||||
option(ENABLE_LONG_RUNNING_TESTS "Enable long running test" ON)
|
||||
include(CTest)
|
||||
enable_testing()
|
||||
message(STATUS "Building with unittests & samples")
|
||||
|
@ -13,5 +13,10 @@ POCO_SOURCES_AUTO_PLAT( TEST_SRCS OFF
|
||||
)
|
||||
|
||||
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 )
|
||||
|
@ -17,8 +17,13 @@ POCO_SOURCES_AUTO_PLAT( TEST_SRCS WINCE
|
||||
)
|
||||
|
||||
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 )
|
||||
if(UNIX)
|
||||
if(UNIX AND NOT ANDROID)
|
||||
target_link_libraries( ${TESTUNIT} pthread)
|
||||
endif(UNIX)
|
||||
endif(UNIX AND NOT ANDROID)
|
||||
|
@ -13,5 +13,10 @@ POCO_SOURCES_AUTO_PLAT( TEST_SRCS OFF
|
||||
)
|
||||
|
||||
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 )
|
||||
|
@ -13,5 +13,10 @@ POCO_SOURCES_AUTO_PLAT( TEST_SRCS OFF
|
||||
)
|
||||
|
||||
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 )
|
||||
|
@ -17,5 +17,10 @@ POCO_SOURCES_AUTO_PLAT( TEST_SRCS WINCE
|
||||
)
|
||||
|
||||
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 )
|
||||
|
@ -22,5 +22,10 @@ POCO_SOURCES_AUTO_PLAT( TEST_SRCS OFF
|
||||
)
|
||||
|
||||
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)
|
||||
|
@ -17,10 +17,15 @@ POCO_SOURCES_AUTO_PLAT( TEST_SRCS WINCE
|
||||
)
|
||||
|
||||
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} )
|
||||
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 )
|
||||
|
@ -25,17 +25,25 @@ POCO_SOURCES_AUTO_PLAT( TEST_SRCS WINCE
|
||||
)
|
||||
|
||||
add_executable( ${TESTUNIT} ${TEST_SRCS} )
|
||||
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
|
||||
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;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 )
|
||||
if(UNIX)
|
||||
if(UNIX AND NOT ANDROID)
|
||||
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
|
||||
add_custom_command(TARGET ${TESTUNIT} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/data ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/data )
|
||||
if(ENABLE_LONG_RUNNING_TESTS)
|
||||
target_compile_definitions( ${TESTUNIT} PRIVATE ENABLE_LONG_RUNNING_TESTS)
|
||||
endif(ENABLE_LONG_RUNNING_TESTS)
|
||||
|
||||
# TestApp
|
||||
if(WINCE)
|
||||
|
@ -203,10 +203,10 @@ void ClassLoaderTest::tearDown()
|
||||
CppUnit::Test* ClassLoaderTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ClassLoaderTest");
|
||||
|
||||
#ifndef POCO_NO_SHAREDMEMORY
|
||||
CppUnit_addTest(pSuite, ClassLoaderTest, testClassLoader1);
|
||||
CppUnit_addTest(pSuite, ClassLoaderTest, testClassLoader2);
|
||||
CppUnit_addTest(pSuite, ClassLoaderTest, testClassLoader3);
|
||||
|
||||
#endif
|
||||
return pSuite;
|
||||
}
|
||||
|
@ -459,9 +459,9 @@ void GlobTest::testGlob()
|
||||
#if !defined(_WIN32_WCE)
|
||||
// won't work if current directory is root dir
|
||||
files.clear();
|
||||
Glob::glob("../*/globtest/*/", files);
|
||||
Glob::glob("globtest/../*/testsuite/*/", files);
|
||||
translatePaths(files);
|
||||
assert (files.size() == 3);
|
||||
assert (files.size() == 1);
|
||||
#endif
|
||||
|
||||
File dir("globtest");
|
||||
|
@ -66,17 +66,36 @@ void NamedEventTest::testNamedEvent()
|
||||
thr1.start(te);
|
||||
Timestamp now;
|
||||
Thread::sleep(2000);
|
||||
testEvent.set();
|
||||
try {
|
||||
testEvent.set();
|
||||
}
|
||||
catch(Poco::NotImplementedException e)
|
||||
{
|
||||
#ifndef POCO_ANDROID
|
||||
throw e;
|
||||
#endif
|
||||
}
|
||||
thr1.join();
|
||||
#ifndef POCO_ANDROID
|
||||
assert (te.timestamp() > now);
|
||||
|
||||
#endif
|
||||
Thread thr2;
|
||||
thr2.start(te);
|
||||
now.update();
|
||||
Thread::sleep(2000);
|
||||
testEvent.set();
|
||||
try {
|
||||
testEvent.set();
|
||||
}
|
||||
catch(Poco::NotImplementedException e)
|
||||
{
|
||||
#ifndef POCO_ANDROID
|
||||
throw e;
|
||||
#endif
|
||||
}
|
||||
thr2.join();
|
||||
#ifndef POCO_ANDROID
|
||||
assert (te.timestamp() > now);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -87,15 +87,23 @@ NamedMutexTest::~NamedMutexTest()
|
||||
|
||||
void NamedMutexTest::testLock()
|
||||
{
|
||||
testMutex.lock();
|
||||
Thread thr;
|
||||
TestLock tl;
|
||||
thr.start(tl);
|
||||
Timestamp now;
|
||||
Thread::sleep(2000);
|
||||
testMutex.unlock();
|
||||
thr.join();
|
||||
assert (tl.timestamp() > now);
|
||||
try {
|
||||
testMutex.lock();
|
||||
Thread thr;
|
||||
TestLock tl;
|
||||
thr.start(tl);
|
||||
Timestamp now;
|
||||
Thread::sleep(2000);
|
||||
testMutex.unlock();
|
||||
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;
|
||||
thr1.start(ttl1);
|
||||
thr1.join();
|
||||
#ifndef POCO_ANDROID
|
||||
assert (ttl1.locked());
|
||||
|
||||
testMutex.lock();
|
||||
Thread thr2;
|
||||
TestTryLock ttl2;
|
||||
thr2.start(ttl2);
|
||||
thr2.join();
|
||||
testMutex.unlock();
|
||||
assert (!ttl2.locked());
|
||||
#endif
|
||||
try {
|
||||
testMutex.lock();
|
||||
Thread thr2;
|
||||
TestTryLock ttl2;
|
||||
thr2.start(ttl2);
|
||||
thr2.join();
|
||||
testMutex.unlock();
|
||||
assert (!ttl2.locked());
|
||||
}
|
||||
catch(Poco::NotImplementedException e)
|
||||
{
|
||||
#ifndef POCO_ANDROID
|
||||
throw e;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -74,13 +74,14 @@ void PBKDF2EngineTest::testPBKDF2c()
|
||||
void PBKDF2EngineTest::testPBKDF2d()
|
||||
{
|
||||
// test vector 4 from RFC 6070
|
||||
|
||||
#if defined(ENABLE_LONG_RUNNING_TESTS)
|
||||
std::string p("password");
|
||||
std::string s("salt");
|
||||
PBKDF2Engine<HMACEngine<SHA1Engine> > pbkdf2(s, 16777216, 20);
|
||||
pbkdf2.update(p);
|
||||
std::string dk = DigestEngine::digestToHex(pbkdf2.digest());
|
||||
assert (dk == "eefe3d61cd4da4e4e9945b3d6ba2158c2634e984");
|
||||
#endif // defined(ENABLE_LONG_RUNNING_TESTS)
|
||||
}
|
||||
|
||||
|
||||
|
@ -37,7 +37,7 @@ void ProcessTest::testLaunch()
|
||||
{
|
||||
std::string name("TestApp");
|
||||
std::string cmd;
|
||||
#if defined(_DEBUG)
|
||||
#if defined(_DEBUG) && !(defined(POCO_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)
|
||||
#if defined(_DEBUG) && !(defined(POCO_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)
|
||||
#if defined(_DEBUG) && !(defined(POCO_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)
|
||||
#if defined(_DEBUG) && !(defined(POCO_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)
|
||||
#if defined(_DEBUG) && !(defined(POCO_ANDROID))
|
||||
name += "d";
|
||||
#endif
|
||||
|
||||
|
@ -131,6 +131,7 @@ RWLockTest::~RWLockTest()
|
||||
|
||||
void RWLockTest::testLock()
|
||||
{
|
||||
#if defined(ENABLE_LONG_RUNNING_TESTS)
|
||||
RWLock lock;
|
||||
int counter = 0;
|
||||
RWLockRunnable r1(lock, counter);
|
||||
@ -159,11 +160,13 @@ void RWLockTest::testLock()
|
||||
assert (r3.ok());
|
||||
assert (r4.ok());
|
||||
assert (r5.ok());
|
||||
#endif // defined(ENABLE_LONG_RUNNING_TESTS)
|
||||
}
|
||||
|
||||
|
||||
void RWLockTest::testTryLock()
|
||||
{
|
||||
#if defined(ENABLE_LONG_RUNNING_TESTS)
|
||||
RWLock lock;
|
||||
int counter = 0;
|
||||
RWTryLockRunnable r1(lock, counter);
|
||||
@ -192,6 +195,7 @@ void RWLockTest::testTryLock()
|
||||
assert (r3.ok());
|
||||
assert (r4.ok());
|
||||
assert (r5.ok());
|
||||
#endif // defined(ENABLE_LONG_RUNNING_TESTS)
|
||||
}
|
||||
|
||||
|
||||
|
@ -140,10 +140,10 @@ void SharedLibraryTest::tearDown()
|
||||
CppUnit::Test* SharedLibraryTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("SharedLibraryTest");
|
||||
|
||||
#ifndef POCO_NO_SHAREDMEMORY
|
||||
CppUnit_addTest(pSuite, SharedLibraryTest, testSharedLibrary1);
|
||||
CppUnit_addTest(pSuite, SharedLibraryTest, testSharedLibrary2);
|
||||
CppUnit_addTest(pSuite, SharedLibraryTest, testSharedLibrary3);
|
||||
|
||||
#endif
|
||||
return pSuite;
|
||||
}
|
||||
|
@ -17,9 +17,14 @@ POCO_SOURCES_AUTO_PLAT( TEST_SRCS WINCE
|
||||
)
|
||||
|
||||
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 )
|
||||
|
||||
# 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 )
|
||||
|
@ -19,5 +19,10 @@ POCO_SOURCES_AUTO_PLAT( TEST_SRCS WINCE
|
||||
set(TESTUNIT "${LIBNAME}-testrunner")
|
||||
|
||||
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 )
|
||||
|
@ -291,7 +291,13 @@ void MongoDBTest::testBuildInfo()
|
||||
|
||||
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::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::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();
|
||||
|
||||
try
|
||||
{
|
||||
conn.connect("http://127.0.0.1", sf);
|
||||
conn.connect("http://" + host, sf);
|
||||
fail("invalid URI scheme - must throw");
|
||||
}
|
||||
catch (Poco::UnknownURISchemeException&)
|
||||
@ -414,19 +426,19 @@ void MongoDBTest::testConnectURI()
|
||||
|
||||
try
|
||||
{
|
||||
conn.connect("mongodb://127.0.0.1?ssl=true", sf);
|
||||
conn.connect("mongodb://" + host + "?ssl=true", sf);
|
||||
fail("SSL not supported, must throw");
|
||||
}
|
||||
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();
|
||||
|
||||
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");
|
||||
}
|
||||
catch (Poco::Exception&)
|
||||
@ -442,19 +454,22 @@ void MongoDBTest::testConnectURI()
|
||||
|
||||
CppUnit::Test* MongoDBTest::suite()
|
||||
{
|
||||
#ifdef POCO_ANDROID
|
||||
std::string host = "10.0.2.2";
|
||||
#else
|
||||
std::string host = "127.0.0.1";
|
||||
#endif
|
||||
try
|
||||
{
|
||||
_mongo = new Poco::MongoDB::Connection("127.0.0.1", 27017);
|
||||
std::cout << "Connected to [127.0.0.1:27017]" << std::endl;
|
||||
_mongo = new Poco::MongoDB::Connection(host, 27017);
|
||||
std::cout << "Connected to [" << host << ":27017]" << std::endl;
|
||||
}
|
||||
catch (Poco::Net::ConnectionRefusedException& e)
|
||||
{
|
||||
std::cout << "Couldn't connect to " << e.message() << ". " << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("MongoDBTest");
|
||||
|
||||
CppUnit_addTest(pSuite, MongoDBTest, testBuildInfo);
|
||||
CppUnit_addTest(pSuite, MongoDBTest, testInsertRequest);
|
||||
CppUnit_addTest(pSuite, MongoDBTest, testQueryRequest);
|
||||
@ -469,6 +484,5 @@ CppUnit::Test* MongoDBTest::suite()
|
||||
CppUnit_addTest(pSuite, MongoDBTest, testCommand);
|
||||
CppUnit_addTest(pSuite, MongoDBTest, testUUID);
|
||||
CppUnit_addTest(pSuite, MongoDBTest, testConnectURI);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
@ -17,5 +17,10 @@ POCO_SOURCES_AUTO_PLAT( TEST_SRCS WINCE
|
||||
)
|
||||
|
||||
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)
|
||||
|
@ -52,12 +52,17 @@ void ICMPClientTest::testPing()
|
||||
registerDelegates(icmpClient);
|
||||
|
||||
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);
|
||||
|
||||
// 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)
|
||||
assert(0 == icmpClient.ping("192.168.243.1"));
|
||||
assert(0 == icmpClient.ping("10.11.12.13"));
|
||||
#endif
|
||||
|
||||
unregisterDelegates(icmpClient);
|
||||
}
|
||||
@ -72,12 +77,17 @@ void ICMPClientTest::testBigPing()
|
||||
registerDelegates(icmpClient);
|
||||
|
||||
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);
|
||||
|
||||
// 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)
|
||||
assert(0 == icmpClient.ping("192.168.243.1"));
|
||||
assert(0 == icmpClient.ping("10.11.12.13"));
|
||||
#endif
|
||||
|
||||
unregisterDelegates(icmpClient);
|
||||
}
|
||||
|
@ -47,15 +47,23 @@ MulticastSocketTest::~MulticastSocketTest()
|
||||
|
||||
void MulticastSocketTest::testMulticast()
|
||||
{
|
||||
MulticastEchoServer echoServer;
|
||||
MulticastSocket ms(SocketAddress::IPv4);
|
||||
int n = ms.sendTo("hello", 5, echoServer.group());
|
||||
assert (n == 5);
|
||||
char buffer[256];
|
||||
n = ms.receiveBytes(buffer, sizeof(buffer));
|
||||
assert (n == 5);
|
||||
assert (std::string(buffer, n) == "hello");
|
||||
ms.close();
|
||||
try {
|
||||
MulticastEchoServer echoServer;
|
||||
MulticastSocket ms(SocketAddress::IPv4);
|
||||
int n = ms.sendTo("hello", 5, echoServer.group());
|
||||
assert (n == 5);
|
||||
char buffer[256];
|
||||
n = ms.receiveBytes(buffer, sizeof(buffer));
|
||||
assert (n == 5);
|
||||
assert (std::string(buffer, n) == "hello");
|
||||
ms.close();
|
||||
}
|
||||
catch(Poco::NotImplementedException e)
|
||||
{
|
||||
#ifndef POCO_ANDROID
|
||||
throw e;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -48,11 +48,14 @@ NTPClientTest::~NTPClientTest()
|
||||
|
||||
void NTPClientTest::testTimeSync()
|
||||
{
|
||||
#ifndef POCO_ANDROID
|
||||
if (ICMPClient::pingIPv4("pool.ntp.org") <= 0)
|
||||
{
|
||||
std::cerr << "pool.ntp.org not accessibe, test skipped" << std::endl;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
assert(_ntpClient.request("pool.ntp.org") > 0);
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -503,7 +503,11 @@ void SocketTest::testSelect3()
|
||||
void SocketTest::testEchoUnixLocal()
|
||||
{
|
||||
#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");
|
||||
#endif
|
||||
if (socketFile.exists()) socketFile.remove();
|
||||
SocketAddress localAddr(SocketAddress::UNIX_LOCAL, socketFile.path());
|
||||
EchoServer echoServer(localAddr);
|
||||
|
@ -17,12 +17,21 @@ POCO_SOURCES_AUTO_PLAT( TEST_SRCS WINCE
|
||||
)
|
||||
|
||||
add_executable( ${TESTUNIT} ${TEST_SRCS} )
|
||||
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND ${TESTUNIT} -all)
|
||||
target_link_libraries( ${TESTUNIT} PocoNetSSL PocoCrypto PocoNet PocoUtil PocoXML 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
|
||||
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}/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)
|
||||
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}/rootcert.pem ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
|
||||
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)
|
||||
|
||||
|
@ -13,5 +13,10 @@ POCO_SOURCES_AUTO_PLAT( TEST_SRCS OFF
|
||||
)
|
||||
|
||||
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 )
|
||||
|
@ -19,7 +19,15 @@ POCO_SOURCES_AUTO_PLAT( TEST_SRCS WINCE
|
||||
set(TESTUNIT "${LIBNAME}-testrunner")
|
||||
|
||||
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 )
|
||||
|
||||
if(OLD_REDIS_VERSION)
|
||||
target_compile_definitions( ${TESTUNIT} PRIVATE OLD_REDIS_VERSION)
|
||||
endif(OLD_REDIS_VERSION)
|
||||
|
@ -32,6 +32,9 @@ RedisTest::RedisTest(const std::string& name):
|
||||
_host("localhost"),
|
||||
_port(6379)
|
||||
{
|
||||
#ifdef POCO_ANDROID
|
||||
_host = "10.0.2.2";
|
||||
#endif
|
||||
if (!_connected)
|
||||
{
|
||||
try
|
||||
@ -954,6 +957,7 @@ void RedisTest::testPING()
|
||||
fail(e.message());
|
||||
}
|
||||
|
||||
#ifndef OLD_REDIS_VERSION
|
||||
// A PING with a custom string responds with a bulk string
|
||||
command.add("Hello");
|
||||
try
|
||||
@ -966,7 +970,7 @@ void RedisTest::testPING()
|
||||
{
|
||||
fail(e.message());
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -3002,6 +3006,5 @@ CppUnit::Test* RedisTest::suite()
|
||||
CppUnit_addTest(pSuite, RedisTest, testRPOPLPUSH);
|
||||
CppUnit_addTest(pSuite, RedisTest, testRPUSH);
|
||||
CppUnit_addTest(pSuite, RedisTest, testPool);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
@ -23,5 +23,10 @@ POCO_SOURCES_AUTO_PLAT( TEST_SRCS WINCE
|
||||
)
|
||||
|
||||
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)
|
||||
|
@ -17,5 +17,10 @@ POCO_SOURCES_AUTO_PLAT( TEST_SRCS WINCE
|
||||
)
|
||||
|
||||
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)
|
||||
|
@ -17,10 +17,15 @@ POCO_SOURCES_AUTO_PLAT( TEST_SRCS WINCE
|
||||
)
|
||||
|
||||
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} )
|
||||
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 )
|
||||
|
29
cmake/ExecuteOnAndroid.cmake
Normal file
29
cmake/ExecuteOnAndroid.cmake
Normal 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()
|
@ -5,6 +5,7 @@ export CPPUNIT_IGNORE="\
|
||||
N7CppUnit10TestCallerI13RawSocketTestEE.testEchoIPv4 \
|
||||
N7CppUnit10TestCallerI13RawSocketTestEE.testSendToReceiveFromIPv4 \
|
||||
N7CppUnit10TestCallerI14ICMPClientTestEE.testPing \
|
||||
N7CppUnit10TestCallerI14ICMPClientTestEE.testBigPing \
|
||||
N7CppUnit10TestCallerI22HTTPSClientSessionTestEE.testProxy \
|
||||
N7CppUnit10TestCallerI22HTTPSStreamFactoryTestEE.testProxy \
|
||||
N7CppUnit10TestCallerI19MulticastSocketTestEE.testMulticast \
|
||||
|
Loading…
x
Reference in New Issue
Block a user