google test on android

574 views
Skip to first unread message

Ken Turkowski

unread,
Jul 22, 2011, 2:08:47 PM7/22/11
to andro...@googlegroups.com
I am getting ready to start porting unit tests to android. I an using the NDK, Eclipse and cross development tools on the Macintosh. I'm not sure how to get started.

- How do I compile the google test library?
Can I use configure, cmake, or something else, or is it necessary to construct a make file manually?
If manually, do you have makefile that I can just run?
- How about the sample tests?
How do I compile them?
- Is it possible to write a shell script that will run the successfully compiled tests (e.g. $ABIN/*Test)
on the device and report the results, in the same way that unit tests work on the Mac or Linux?
- Can I run the tests in the emulator as well as on the device?
- Can I debug the tests in Eclipse?
How do I set it up?

-Ken

Kirill Kornyakov

unread,
Jul 26, 2011, 5:22:57 PM7/26/11
to andro...@googlegroups.com
Unfortunately I don't have a simple example showing how to do this, but I want to say that almost everything is possible. OpenCV library has unit tests, which are built on top of gtest. And our buildbot (continuos integration system written in python) runs this tests every night on an Android device. But I will not recommend you to look into OpenCV internals, because this is large library and probably better to start from scratch...

Answers for some of you questions are below:


- Is it possible to write a shell script that will run the successfully compiled tests (e.g. $ABIN/*Test)
   on the device and report the results, in the same way that unit tests work on the Mac or Linux?

Yes, it is possible. For communication with device through command line you can use adb tool. But first of all you need rooted device, otherwise you will not have access even to chmod command. If you don't know where to get rooted device, use emulator.
Then you have to build your gtests as Android console applications. They actually similar to usual console apps on linux. Having console test application you can create a shell script (or batch, python, etc) which will push the console to the device, and return you text output. adb push, adb shell chmod ..., adb shell <run>, ...

- Can I run the tests in the emulator as well as on the device?
Yes, but be careful with compilation options, because emulator has older ARM architecture (v6?). Modern devices have ARM v7 arch.

- Can I debug the tests in Eclipse?
   How do I set it up?
There is a way to debug native applications on Android. NVidia has some tools http://developer.nvidia.com/content/announcing-initial-release-tegra-android-development-pack, and they said that they are not specific for Tegra. Google also gives some links on "ndk debugging".

Best regards,
Kirill Kornyakov
Reply all
Reply to author
Forward
0 new messages