Build test executable against shared libs, rather than from Oboe source
diff --git a/CMakeLists.txt b/CMakeLists.txt index 211e6b7..19e962c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt
@@ -82,6 +82,7 @@ -Wshadow -Wshadow-field -Ofast + -fno-rtti "$<$<CONFIG:DEBUG>:-Werror>") # Enable logging of D,V for debug builds @@ -95,4 +96,4 @@ ARCHIVE DESTINATION lib/${ANDROID_ABI}) # Also install the headers -install(DIRECTORY include/oboe DESTINATION include) \ No newline at end of file +install(DIRECTORY include/oboe DESTINATION include)
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1e8b459..ca1120e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt
@@ -7,7 +7,7 @@ # This may work on Linux. # set(ANDROID_NDK $ENV{HOME}/Android/sdk/ndk-bundle) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -std=c++14") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -std=c++14 -fno-rtti") # Include GoogleTest library set(GOOGLETEST_ROOT ${ANDROID_NDK}/sources/third_party/googletest) @@ -15,13 +15,10 @@ target_include_directories(gtest PRIVATE ${GOOGLETEST_ROOT}) target_include_directories(gtest PUBLIC ${GOOGLETEST_ROOT}/include) -# Include Oboe sources -set (OBOE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..) -add_subdirectory(${OBOE_DIR} ./oboe-bin) -include_directories( - ${OBOE_DIR}/include - ${OBOE_DIR}/src - ) +# Add the Oboe shared lib and headers +add_library(oboe SHARED IMPORTED) +set_property(TARGET oboe PROPERTY IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/../build/${ANDROID_ABI}/liboboe.so") +include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../include" "${CMAKE_CURRENT_SOURCE_DIR}/../src") # Build the test binary add_executable(
diff --git a/tests/run_tests.sh b/tests/run_tests.sh index c012035..557376a 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh
@@ -112,22 +112,10 @@ popd -# Copy the binary into the unit test runner app -mkdir ${TEST_RUNNER_ASSET_DIR}/${ABI} -DESTINATION_DIR=${TEST_RUNNER_ASSET_DIR}/${ABI}/${TEST_BINARY_FILENAME} -echo "Copying binary to ${DESTINATION_DIR}" -cp ${BUILD_DIR}/${TEST_BINARY_FILENAME} ${DESTINATION_DIR} +# Copy the test executable and shared lib onto the device or emulator +DESTINATION_DIR=/data/local +adb push ${BUILD_DIR}/${TEST_BINARY_FILENAME} ${DESTINATION_DIR} +adb push ../build/${ABI}/liboboe.so ${DESTINATION_DIR} -# Build and install the unit test runner app -pushd ${TEST_RUNNER_DIR} - echo "Building test runner app" - ./gradlew assembleDebug - echo "Installing to device" - ./gradlew installDebug -popd - -echo "Starting app - Check your device for test results" -adb shell am start ${TEST_RUNNER_PACKAGE_NAME}/.MainActivity - -sleep 1 -adb logcat ${TEST_RUNNER_PACKAGE_NAME} +# Execute the test binary +adb shell "export LD_LIBRARY_PATH=${DESTINATION_DIR} && exec ${DESTINATION_DIR}/${TEST_BINARY_FILENAME}"