Search code examples
googletesthexagon-dsp

Is it possible to run GoogleTest - based unit-tests with Hexagon SDK?


I'm very new to the topic of DSP development. I have asked this question in the Qualcomm forum 2 months ago, but haven't received any answer.

Currently I'm involved in the porting of parts of our code to the Hexagon DSP, made by Qualcomm.

Our code base compiles to a shared library and a unit-test suite based on GoogleTest.

I have successfully compiled the library with hexagon-clang, that is a part of Hexagon SDK 3.5.2. However, hexagon-clang doesn't compile gtest, because of limited standard library support.

What options do I have to run unit-tests?

Update.

  1. Our code is configured with CMake. It uses Hexagon_toolchain.cmake, coming with SDK. Related CMake command line switches are: -DV=hexagon_Debug_toolv83_v66 -DCMAKE_TOOLCHAIN_FILE=%HEXAGON_SDK_ROOT%\build\cmake\Hexagon_Toolchain.cmake -DQURT_OS=1 -DHEXAGON_CMAKE_ROOT=%HEXAGON_SDK_ROOT%\build\cmake
  2. During compilation of GTest hexagon-clang cannot find header file regex.h. Indeed, this file can be found only in Android NDK, that is installed by Hexagon SDK. I've tried setting include paths for hexagon-clang, but have got other errors with other header files. I've stopped this exercise because I doubt that "cherry-picking" fragments of Android NDK is a correct way to build an application that should run on DSP.

Solution

  • Solved.

    1. Turned off two GTest options (GTEST_HAS_POSIX_RE and GTEST_HAS_STREAM_REDIRECTION):
        ...
        if(HEXAGON)
            add_compile_definitions(GTEST_HAS_POSIX_RE=0 GTEST_HAS_STREAM_REDIRECTION=0)
        endif()
    
        add_subdirectory(gtest)
        ....
    
    1. Added some code to GoogleTest to support QURT. Unfortunately, I cannot publish these changes, however, they are straightforward. GoogleTest library contains an OS abstraction layer, which was missing QURT support. I've just followed error messages from the compiler and added missing functions. During that exercise I've found following 3 issues:
    • getcwd function in QURT POSIX support library always returned empty string.
    • there was no write function in QURT, so I've simulated it using fwrite (funny that read was present).
    • argv in main was always NULL, and I've had to call overloaded InitGoogleTest().