Dillon
Dillon

Reputation: 364

Setting up / Running tests for modules built on AOSP

I am new to AOSP.

We are developing an AOSP C++ middleware module. Currently we have the LOCAL_MODULE setup as the name Foo, with some LOCAL_SHARED_LIBRARIES like Audio, SqliteDatabase, Curl, http client, etc...

I would like to see if it is possible to use googletest to run some unit tests against my code.

I am having issues setup and running the tests. Could anyone give me some guidelines or some examples? (Even a fooDummyTest assert(true) is fine).

  1. How do I structure my code?
  2. What do I do to run the tests? (make Foo vs make FooTest?)

Any resources or links are welcome, thanks in advance!!!

Upvotes: 2

Views: 1819

Answers (2)

Dillon
Dillon

Reputation: 364

I actually ended up creating a separate module in Android.mk, and have a host libraries compiled on linux. For other libs, I mock the classes.

include $(BUILD_HOST_NATIVE_TEST)

Upvotes: 0

Hugo y
Hugo y

Reputation: 1507

You can take a look at a module with BUILD_NATIVE_TEST variable, for example:

frameworks/av/camera/tests/Android.mk

Also take a look at the files listed in LOCAL_SRC_FILES you will find examples of Google tests there.

To build the test, go to the directory containing the Android.mk and run mm (after the correct lunch command).

Watch the build output and find the test executable path and push it to the target with adb push or use adb sync to sync everything. Then connect to the target and run the test by calling the test executable.

Upvotes: 0

Related Questions