Skip to content
This repository has been archived by the owner on Apr 28, 2022. It is now read-only.

Commit

Permalink
Set LD_LIBRARY_PATH before running test
Browse files Browse the repository at this point in the history
  • Loading branch information
ruslo committed Dec 28, 2016
1 parent bcf8e23 commit 56b1f60
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions AndroidApk.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@ function(android_add_test)
# * ADB_COMMAND
# * APP_ARGUMENTS
# * APP_DESTINATION
# * DEVICE_BIN_DIR
configure_file(
"${_ANDROID_APK_THIS_DIRECTORY}/templates/AndroidTest.cmake.in"
"${script_loc}"
Expand Down
13 changes: 12 additions & 1 deletion templates/AndroidTest.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ if(is_empty)
message(FATAL_ERROR "Expected APP_DESTINATION")
endif()

string(COMPARE EQUAL "@DEVICE_BIN_DIR@" "" is_empty)
if(is_empty)
message(FATAL_ERROR "Expected DEVICE_BIN_DIR")
endif()

get_filename_component(lib_dir "@DEVICE_BIN_DIR@/../lib" ABSOLUTE)

message("Push application to device: ${APP_SOURCE} -> @APP_DESTINATION@")
set(cmd "@ADB_COMMAND@" push "${APP_SOURCE}" "@APP_DESTINATION@")
execute_process(COMMAND ${cmd} RESULT_VARIABLE result)
Expand All @@ -36,11 +43,15 @@ foreach(arg ${app_arguments})
set(arguments "${arguments} \"${arg}\"")
endforeach()

message("Set LD_LIBRARY_PATH to '${lib_dir}'")
message("Working directory '@DEVICE_BIN_DIR@'")
message("Run application: \"@APP_DESTINATION@\" ${arguments}")

execute_process(
COMMAND
"@ADB_COMMAND@" shell "\"@APP_DESTINATION@\" ${arguments}; echo $?"
"@ADB_COMMAND@"
shell
"cd \"@DEVICE_BIN_DIR@\"; export \"LD_LIBRARY_PATH=${lib_dir}\"; \"@APP_DESTINATION@\" ${arguments}; echo $?"
RESULT_VARIABLE result
OUTPUT_VARIABLE output
ERROR_VARIABLE output
Expand Down

0 comments on commit 56b1f60

Please sign in to comment.