Native Tests

As mentioned earlier, native tests are typically used for exercising HAL or interacting directly with lower level system services, and to leverage continuous testing service, native tests should be built with gtest framework.

Here are some general instructions:

  1. See sample native test module setup at: libs/hwui/unit_tests

  2. Test module makefile should use BUILD_NATIVE_TEST build rule so that gtest dependencies are included automatically

  3. Write a test config

  4. Build the test module with mmm or mma (depends on if it's an incremental or full build), e.g.:

    make hwui_unit_tests -j
    
  5. Automatic installation and run with the TradeFederation test harness:

    make tradefed-all -j
    tradefed.sh run template/local_min --template:map test=hwui_unit_tests
    
  6. Manually Install and Run:

    1. Push the generated test binary onto device:

      adb push ${OUT}/data/nativetest/hwui_unit_tests/hwui_unit_tests \
        /data/nativetest/hwui_unit_tests/hwui_unit_tests
      
    2. Execute the test by invoking test binary on device:

      adb shell /data/nativetest/hwui_unit_tests/hwui_unit_tests
      

    This launches the native test. You can also add `--help` parameter to your test binary to find out more about the different ways to customize test execution. You can also check out the gtest advanced guide for more parameters usage: * https://github.com/google/googletest/blob/master/googletest/docs/AdvancedGuide.md