diff options
| author | Zeming LIU <zeming.liu@windriver.com> | 2026-06-08 10:41:04 +0800 |
|---|---|---|
| committer | Khem Raj <khem.raj@oss.qualcomm.com> | 2026-06-08 16:44:39 -0700 |
| commit | ee3134d2e897998562c480aca29ba2b8792ae8b2 (patch) | |
| tree | 16d6bb7b664bbd6c9a2eea409a1f8bdd3791b450 | |
| parent | f79aaeb8285f1b38b9193998f43baf74c43084ae (diff) | |
| download | meta-openembedded-ee3134d2e897998562c480aca29ba2b8792ae8b2.tar.gz | |
Add ptest support for googletest
Test result:
root@qemux86-64:~# ptest-runner googletest
START: ptest-runner
2026-06-08T02:33
BEGIN: /usr/lib/googletest/ptest
PASS: gmock-actions_test
PASS: gmock-cardinalities_test
PASS: gmock_ex_test
PASS: gmock-function-mocker_test
PASS: gmock-internal-utils_test
PASS: gmock-matchers-arithmetic_test
PASS: gmock-matchers-comparisons_test
PASS: gmock-matchers-containers_test
PASS: gmock-matchers-misc_test
PASS: gmock-more-actions_test
PASS: gmock-nice-strict_test
PASS: gmock-port_test
PASS: gmock-spec-builders_test
PASS: gmock_link_test
PASS: gmock_test
PASS: gmock_stress_test
PASS: gmock-more-actions_no_exception_test
PASS: gmock_no_rtti_test
PASS: googletest-death-test-test
PASS: gtest_environment_test
PASS: googletest-filepath-test
PASS: googletest-listener-test
PASS: gtest_main_unittest
PASS: googletest-message-test
PASS: gtest_no_test_unittest
PASS: googletest-options-test
PASS: googletest-param-test-test
PASS: googletest-port-test
PASS: gtest_pred_impl_unittest
PASS: gtest_premature_exit_test
PASS: googletest-printers-test
PASS: gtest_prod_test
PASS: gtest_repeat_test
PASS: gtest_sole_header_test
PASS: gtest_stress_test
PASS: googletest-test-part-test
PASS: gtest_throw_on_failure_ex_test
PASS: gtest-typed-test_test
PASS: gtest_unittest
PASS: gtest-unittest-api_test
PASS: gtest_skip_in_environment_setup_test
PASS: gtest_skip_test
PASS: gtest-death-test_ex_nocatch_test
PASS: gtest-death-test_ex_catch_test
PASS: gtest_no_rtti_unittest
PASS: googletest-break-on-failure-unittest
PASS: gtest_skip_check_output_test
PASS: gtest_skip_environment_check_output_test
PASS: googletest-catch-exceptions-test
PASS: googletest-color-test
PASS: googletest-env-var-test
PASS: googletest-filter-unittest
PASS: gtest_help_test
PASS: googletest-list-tests-unittest
PASS: googletest-output-test
PASS: googletest-shuffle-test
PASS: googletest-throw-on-failure-test
PASS: googletest-uninitialized-test
PASS: gtest_list_output_unittest
PASS: gtest_xml_outfiles_test
PASS: googletest-json-outfiles-test
PASS: gtest_xml_output_unittest
PASS: googletest-json-output-unittest
DURATION: 16
END: /usr/lib/googletest/ptest
2026-06-08T02:34
STOP: ptest-runner
TOTAL: 1 FAIL: 0
Signed-off-by: Zeming LIU <zeming.liu@windriver.com>
Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
| -rw-r--r-- | meta-oe/conf/include/ptest-packagelists-meta-oe.inc | 1 | ||||
| -rw-r--r-- | meta-oe/recipes-test/googletest/files/run-ptest | 3 | ||||
| -rw-r--r-- | meta-oe/recipes-test/googletest/googletest_1.17.0.bb | 44 |
3 files changed, 47 insertions, 1 deletions
diff --git a/meta-oe/conf/include/ptest-packagelists-meta-oe.inc b/meta-oe/conf/include/ptest-packagelists-meta-oe.inc index f43bdf3c70..0467d1f424 100644 --- a/meta-oe/conf/include/ptest-packagelists-meta-oe.inc +++ b/meta-oe/conf/include/ptest-packagelists-meta-oe.inc | |||
| @@ -23,6 +23,7 @@ PTESTS_FAST_META_OE = "\ | |||
| 23 | function2 \ | 23 | function2 \ |
| 24 | fwupd \ | 24 | fwupd \ |
| 25 | gcab \ | 25 | gcab \ |
| 26 | googletest \ | ||
| 26 | hunspell \ | 27 | hunspell \ |
| 27 | imagemagick \ | 28 | imagemagick \ |
| 28 | jemalloc \ | 29 | jemalloc \ |
diff --git a/meta-oe/recipes-test/googletest/files/run-ptest b/meta-oe/recipes-test/googletest/files/run-ptest new file mode 100644 index 0000000000..da46c68550 --- /dev/null +++ b/meta-oe/recipes-test/googletest/files/run-ptest | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | ctest | sed -u 's/\*\*\*/ /g' | awk '/Test +#/{gsub(/Passed/,"PASS"); gsub(/Failed/,"FAIL"); gsub(/Skipped/,"SKIP"); print $6": "$4; fflush();}' | ||
diff --git a/meta-oe/recipes-test/googletest/googletest_1.17.0.bb b/meta-oe/recipes-test/googletest/googletest_1.17.0.bb index c8ed80053d..4d5340b994 100644 --- a/meta-oe/recipes-test/googletest/googletest_1.17.0.bb +++ b/meta-oe/recipes-test/googletest/googletest_1.17.0.bb | |||
| @@ -7,15 +7,20 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=cbbd27594afd089daa160d3a16dd515a" | |||
| 7 | PROVIDES += "gmock gtest" | 7 | PROVIDES += "gmock gtest" |
| 8 | 8 | ||
| 9 | SRC_URI = "git://github.com/google/googletest.git;branch=v1.17.x;protocol=https \ | 9 | SRC_URI = "git://github.com/google/googletest.git;branch=v1.17.x;protocol=https \ |
| 10 | file://run-ptest \ | ||
| 10 | " | 11 | " |
| 11 | SRCREV = "52eb8108c5bdec04579160ae17225d66034bd723" | 12 | SRCREV = "52eb8108c5bdec04579160ae17225d66034bd723" |
| 12 | 13 | ||
| 13 | inherit cmake pkgconfig | 14 | inherit cmake pkgconfig ptest |
| 14 | 15 | ||
| 15 | # allow for shared libraries, but do not default to them | 16 | # allow for shared libraries, but do not default to them |
| 16 | # | 17 | # |
| 17 | PACKAGECONFIG[shared] = "-DBUILD_SHARED_LIBS=ON,-DBUILD_SHARED_LIBS=OFF,," | 18 | PACKAGECONFIG[shared] = "-DBUILD_SHARED_LIBS=ON,-DBUILD_SHARED_LIBS=OFF,," |
| 18 | 19 | ||
| 20 | EXTRA_OECMAKE += "${@bb.utils.contains('PTEST_ENABLED', '1', '-Dgtest_build_tests=ON -Dgmock_build_tests=ON', '', d)}" | ||
| 21 | |||
| 22 | DEPENDS += "${@bb.utils.contains('PTEST_ENABLED', '1', 'rsync-native', '', d)}" | ||
| 23 | |||
| 19 | CXXFLAGS:append = " -fPIC" | 24 | CXXFLAGS:append = " -fPIC" |
| 20 | 25 | ||
| 21 | ALLOW_EMPTY:${PN} = "1" | 26 | ALLOW_EMPTY:${PN} = "1" |
| @@ -35,3 +40,40 @@ do_configure:prepend() { | |||
| 35 | # there isn't python in HOSTTOOLS so "env python" fails | 40 | # there isn't python in HOSTTOOLS so "env python" fails |
| 36 | sed -i 's@^#!/usr/bin/env python$@#!/usr/bin/env python3@g' ${S}/googlemock/test/*py ${S}/googletest/test/*py | 41 | sed -i 's@^#!/usr/bin/env python$@#!/usr/bin/env python3@g' ${S}/googlemock/test/*py ${S}/googletest/test/*py |
| 37 | } | 42 | } |
| 43 | |||
| 44 | do_install_ptest() { | ||
| 45 | install -d ${D}${PTEST_PATH}/lib | ||
| 46 | |||
| 47 | ptest_libs="libshared_gmock_main.so \ | ||
| 48 | libgtest_dll.so \ | ||
| 49 | libgmock_main_no_exception.so \ | ||
| 50 | libgtest_main_no_exception.so \ | ||
| 51 | libgtest_no_exception.so \ | ||
| 52 | libgtest_main_no_rtti.so \ | ||
| 53 | " | ||
| 54 | for i in ${ptest_libs}; do | ||
| 55 | [ -f ${B}/lib/${i} ] && install -m 0755 ${B}/lib/${i} ${D}${PTEST_PATH}/lib | ||
| 56 | done | ||
| 57 | |||
| 58 | rsync -a ${B}/googletest ${D}${PTEST_PATH} \ | ||
| 59 | --exclude CMakeFiles \ | ||
| 60 | --exclude cmake_install.cmake \ | ||
| 61 | --exclude Makefile \ | ||
| 62 | --exclude generated | ||
| 63 | install -d ${D}${PTEST_PATH}/googletest/test | ||
| 64 | cp ${S}/googletest/test/*.py ${D}${PTEST_PATH}/googletest/test | ||
| 65 | cp ${S}/googletest/test/*.txt ${D}${PTEST_PATH}/googletest/test | ||
| 66 | rsync -a ${B}/googlemock ${D}${PTEST_PATH} \ | ||
| 67 | --exclude CMakeFiles \ | ||
| 68 | --exclude cmake_install.cmake \ | ||
| 69 | --exclude Makefile \ | ||
| 70 | --exclude generated | ||
| 71 | cp ${B}/CTestTestfile.cmake ${D}${PTEST_PATH} | ||
| 72 | sed -i -e 's#${B}#${PTEST_PATH}#g' `find ${D}${PTEST_PATH} -name CTestTestfile.cmake` | ||
| 73 | sed -i -e 's#${S}#${PTEST_PATH}#g' `find ${D}${PTEST_PATH} -name CTestTestfile.cmake` | ||
| 74 | sed -i -e 's#${RECIPE_SYSROOT_NATIVE}##g' `find ${D}${PTEST_PATH} -name CTestTestfile.cmake` | ||
| 75 | sed -i -e 's#${PYTHON}#/usr/bin/python3#g' `find ${D}${PTEST_PATH} -name CTestTestfile.cmake` | ||
| 76 | sed -i -e 's#${WORKDIR}##g' `find ${D}${PTEST_PATH} -name CTestTestfile.cmake` | ||
| 77 | } | ||
| 78 | |||
| 79 | RDEPENDS:${PN}-ptest += "cmake sed python3-datetime python3-difflib python3-json python3-xml python3-misc python3-unittest" | ||
