-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Hexagon] Add support for on-device unit testing using gtest #11145
[Hexagon] Add support for on-device unit testing using gtest #11145
Conversation
Is there a reason that you put test files under |
edb2fc9
to
39c2275
Compare
|
||
// initialize gtest with arguments and run | ||
::testing::InitGoogleTest(&argc, argv.data()); | ||
*rv = RUN_ALL_TESTS(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat! looks like gtest supports capturing the stdout to a string that we can return in the ret value across the FFI,
testing::internal::CaptureStdout();
// Run tests
// ...
std::string output = testing::internal::GetCapturedStdout();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, it looks like stdout redirection is one of the disabled features in the Hexagon SDK gtest version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How so? in that case can we target a generic gtest and then modify to support for Hexagon as we have discussed potentially doing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding is that one must set GTEST_HAS_STREAM_REDIRECTION=0
when compiling gtest for Hexagon which disables the CaptureStdout
function. I believe this would be true even if we used a "stock" gtest version as opposed to the gtest version in the Hexagon SDK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Darn. @kparzysz-quic any idea why this is disabled for Hexagon? Is there an alternative for us to capture stdout on Hexagon?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know. What happens if we set GTEST_HAS_STREAM_REDIRECTION=1
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GTest stream redirection relies on dup2(), which does not exist under QuRT.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Short answer: We need a separate directory from which to include runtime tests. Long answer ... All files in The Other Hexagon classes e.g. for thread management coming soon to TVM will not be so easily implemented on x86 which is part of the motivation for this PR. |
I think @areusch may argue this is a reasonable example of why we should have test files co-located with source implementations. That said, for now we could consider changing the cpptest globbing to exclude the runtime subdirectory with the assumption that runtime specific tests will need to be globbed by a tvm_runtime compatible gtest impl. |
@kparzysz-quic please review |
I don't mind the current |
@adstraw until such a future time as we colocate all the tests with the source files, i think it'd be great to keep them underneath |
Given that |
if(BUILD_FOR_HEXAGON OR USE_HEXAGON_RPC) | ||
# Common sources for TVM runtime with Hexagon support | ||
file_glob_append(RUNTIME_HEXAGON_SRCS | ||
"${TVMRT_SOURCE_DIR}/hexagon/*.cc" | ||
) | ||
else() | ||
file_glob_append(RUNTIME_HEXAGON_SRCS | ||
"${TVMRT_SOURCE_DIR}/hexagon/hexagon_module.cc" | ||
) | ||
endif() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part disables Hexagon runtime when building for x86. Please revert this.
Nevermind. It was an error on my side. Sorry for the noise.
…11145) * link gtest to tvm runtime * first test running! * HexagonBuffer tests running in sim * move to new tests directory * use USE_HEXAGON_SDK * add python frontend for Hexagon unit tests * clean up after rebase * isolate cmake changes to Hexagon * add gtest init with arguments * add hexagon sources only if building for Hexagon; remove workaround * format & lint * fix Hexagon build error * remove x86 implementation and win32 code * check if hexagon gtest path exists before linking * make USE_HEXAGON_GTEST an optional cmake param * turn on Hexagon gtest in Hexagon CI * Hexagon unit tests should fail if run without proper gtest linkage * add tvm option; move Hexagon tests to test/cpp-runtime/hexagon * add libinfo * trigger ci
…11145) * link gtest to tvm runtime * first test running! * HexagonBuffer tests running in sim * move to new tests directory * use USE_HEXAGON_SDK * add python frontend for Hexagon unit tests * clean up after rebase * isolate cmake changes to Hexagon * add gtest init with arguments * add hexagon sources only if building for Hexagon; remove workaround * format & lint * fix Hexagon build error * remove x86 implementation and win32 code * check if hexagon gtest path exists before linking * make USE_HEXAGON_GTEST an optional cmake param * turn on Hexagon gtest in Hexagon CI * Hexagon unit tests should fail if run without proper gtest linkage * add tvm option; move Hexagon tests to test/cpp-runtime/hexagon * add libinfo * trigger ci
…11145) * link gtest to tvm runtime * first test running! * HexagonBuffer tests running in sim * move to new tests directory * use USE_HEXAGON_SDK * add python frontend for Hexagon unit tests * clean up after rebase * isolate cmake changes to Hexagon * add gtest init with arguments * add hexagon sources only if building for Hexagon; remove workaround * format & lint * fix Hexagon build error * remove x86 implementation and win32 code * check if hexagon gtest path exists before linking * make USE_HEXAGON_GTEST an optional cmake param * turn on Hexagon gtest in Hexagon CI * Hexagon unit tests should fail if run without proper gtest linkage * add tvm option; move Hexagon tests to test/cpp-runtime/hexagon * add libinfo * trigger ci
Adds Hexagon on-device unit testing support by linking the tvm runtime with gtest. Also moves
HexagonBuffer
unit tests from their original home as part of thecpptest
executable to their new home as a Hexagon on-device unit test. This is a Hexagon specific and proof-of-concept implementation for this discussion topic.cc @mehrdadh