1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
# test script for running an android test and collecting the output
# this script is probably brittle as well peanut brittle. ots of
# hardcoded paths etc. Feel free to make it more generic as more devices
# platforms are tested.
# adb and sleep must be in the path
# the valid image must be on the device
#load the app
execute_process(
COMMAND adb install -r NativeVTK-debug.apk
WORKING_DIRECTORY ${WORKINGDIR}
OUTPUT_VARIABLE CMD_OUTPUT
ERROR_VARIABLE CMD_ERROR
RESULT_VARIABLE CMD_RESULT
)
if(CMD_RESULT)
message(FATAL_ERROR "Error running adb install with output ${CMD_OUTPUT} and errors ${CMD_ERROR}")
else()
message("Success running adb install")
endif()
# run the app
execute_process(
COMMAND adb shell am start -n com.kitware.NativeVTK/android.app.NativeActivity --es VTKTesting Testing
WORKING_DIRECTORY ${WORKINGDIR}
OUTPUT_VARIABLE CMD_OUTPUT
ERROR_VARIABLE CMD_ERROR
RESULT_VARIABLE CMD_RESULT
)
if(CMD_RESULT)
message(FATAL_ERROR "Error running adb shell am start with output ${CMD_OUTPUT} and errors ${CMD_ERROR}")
else()
message("Success running adb shell am start")
endif()
#sleep for a few sec
execute_process(COMMAND sleep 10)
# get the valid image
execute_process(
COMMAND adb pull /storage/emulated/legacy/Android/data/com.kitware.NativeVTK/files/NativeVTKResult.png
WORKING_DIRECTORY ${WORKINGDIR}
OUTPUT_VARIABLE CMD_OUTPUT
ERROR_VARIABLE CMD_ERROR
RESULT_VARIABLE CMD_RESULT
)
if(CMD_RESULT)
message(FATAL_ERROR "Error pulling result file back with output ${CMD_OUTPUT} and errors ${CMD_ERROR}")
else()
message("Success running adb pull ...")
endif()
# get the output text
execute_process(
COMMAND adb pull /storage/emulated/legacy/Android/data/com.kitware.NativeVTK/files/NativeVTKResult.txt
WORKING_DIRECTORY ${WORKINGDIR}
OUTPUT_VARIABLE CMD_OUTPUT
ERROR_VARIABLE CMD_ERROR
RESULT_VARIABLE CMD_RESULT
)
if(CMD_RESULT)
message(FATAL_ERROR "Error pulling result file text with output ${CMD_OUTPUT} and errors ${CMD_ERROR}")
else()
file(READ NativeVTKResult.txt TextResult)
message("${TextResult}")
endif()
|