fsbarata / ndktest-plugin

Run Googltest based C++ tests in Android devices

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NDK Test Gradle Plugin

Description

Build NDK Googletest based C++ tests with gradle and run them on an Android device. Can be used in Android studio.

Requirements

It is important to have a compiling NDK configuration in place.

How to use

Simply apply the plugin and you're ready to go.

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'com.github.fsbarata:ndktest-gradle-plugin:1.0.0
    }
}

apply plugin: 'com.github.fsbarata.ndktest'

This will add multiple tasks to your project:

  1. compileVariantNdkTest
  2. connectedVariantNdkTest

Simply running the connectedVariantNdkTest will compile it and run on the device.

Configure

After configuring your NDK, you may configure NDK test plugin by the following:

android {
	...
	sourceSets {
		test {
			jni.srcDirs = ['src/test/jni']
		}
	}
}

ndktest {
	cFlags = "-std=c++11"
	ldLibs = ["log"]
	abiFilters = ['x86','armeabi-v7a']
}

Known issues

  1. Currently not compatible with gradle experimental plugin
  2. Does not run as a testing task
  3. Cannot debug on device using Android studio (some code is in place but I was unable to fix the gdb server)
  4. Does not support multiple devices

Suggestions

  1. Use abi filters to avoid compiling every architecture every time. Use the architecture of the device under test.
  2. Create a gradle task Android studio run configuration
  3. Disable jniDebuggable for faster builds and runs

About

Run Googltest based C++ tests in Android devices


Languages

Language:Groovy 100.0%