AndroidTestUtilities — CMake 4.1.4 Documentation

# AndroidTestUtilities

Added in version 3.7.

This module provides a command to create a test that pushes data needed for testing an Android device behavior onto a connected Android device.

Load this module in a CMake project with:

    include(AndroidTestUtilities)

## Commands

This module provides the following command:

android_add_test_data

  Creates a test that automatically loads specified data onto an Android device:

      android_add_test_data(
        <test-name>
        [FILES <files>...]
        [FILES_DEST <device-dir>]
        [LIBS <libs>...]
        [LIBS_DEST <device-dir>]
        DEVICE_OBJECT_STORE <device-dir>
        DEVICE_TEST_DIR <device-dir>
        [NO_LINK_REGEX <regexes>...]
      )

  This command accepts files and libraries needed to run project-specific tests as well as separate destinations for each. It will create a test that loads the files into a device object store and link to them from the specified destination. The files are only uploaded if they are not already in the object store.

  On the host operating system, files and libraries are copied at build time. For on-device testing, the files are loaded onto the device by the manufactured test at run time.

  This command accepts the following named parameters:

  `FILES <files>...`

    Zero or more files needed for testing.

  `FILES_DEST <device-dir>`

    Absolute path where the data files are expected to be.

  `LIBS <libs>...`

    Zero or more libraries needed for testing.

  `LIBS_DEST <device-dir>`

    Absolute path where the libraries are expected to be.

  `DEVICE_OBJECT_STORE <device-dir>`

    Absolute path to the on-device location where the data files are initially stored.

  `DEVICE_TEST_DIR <device-dir>`

    Absolute path to the root directory of the on-device test location.

  `NO_LINK_REGEX <regexes>...`

    A list of regular expression patterns matching file names to be copied from the object store to the test directory, instead of being symlinked.

## Examples

The following example shows how to use this module to create a test named `example_setup_test` that prepares data during the build phase. This test can then be run using `ctest(1)` to load the data onto the Android device.

`CMakeLists.txt`

    include(AndroidTestUtilities)

    android_add_test_data(
      example_setup_test
      FILES data/protobuffer.p data/file.txt
      LIBS libs/library_1 libs/library_2
      DEVICE_OBJECT_STORE "/sdcard/.ExternalData/SHA"
      DEVICE_TEST_DIR "/data/local/tests/example"
    )