[cmake] enable running simulation unit tests using cmake (#4842)

In this commit, we would be able to run all the simulation unit tests
easier with cmake:

./script/test clean build unit_tests
This commit is contained in:
Li Cao
2020-04-20 20:52:38 -07:00
committed by GitHub
parent 8de4ab4740
commit e839100be1
4 changed files with 614 additions and 0 deletions
+15
View File
@@ -168,6 +168,17 @@ do_clean() {
rm -rfv "${OT_BUILDDIR}"
}
do_unit() {
local builddir="${OT_BUILDDIR}/cmake/openthread-simulation-${THREAD_VERSION}"
if [[ ! -d "${builddir}" ]]; then
echo "Cannot find build directory!"
exit -1
fi
cd "${builddir}"
ninja test
}
do_cert() {
export top_builddir="${OT_BUILDDIR}/cmake/openthread-simulation-${THREAD_VERSION}"
@@ -269,6 +280,7 @@ COMMANDS:
build Build project for running tests. This can be used to rebuild the project for changes.
cert Run a single thread-cert test. ENVIRONMENTS should be the same as those given to build or update.
cert_suite Run a batch of thread-cert tests and summarize the test results. Only echo logs for failing tests.
unit Run all the unit tests. This should be called after simulation is built.
expect Run expect tests.
help Print this help.
@@ -381,6 +393,9 @@ main()
shift
do_cert_suite "$@"
;;
unit)
do_unit
;;
help)
print_usage
;;