Skip to content

Bundle C++ app as a Yocto-ready ptest package#3

Draft
onkelpit with Copilot wants to merge 2 commits into
masterfrom
copilot/bundle-cpp-application-test-package
Draft

Bundle C++ app as a Yocto-ready ptest package#3
onkelpit with Copilot wants to merge 2 commits into
masterfrom
copilot/bundle-cpp-application-test-package

Conversation

Copilot AI commented Apr 8, 2026

Copy link
Copy Markdown

Summary

Reviews and bundles the Area51 C++ project into a well-structured test package that can be used in Yocto Project builds via the ptest bbclass.


Changes

CMakeLists.txt

  • Raised minimum CMake version to 3.10 and added C++11 standard requirement
  • Replaced old variable-style Boost link (${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) with the modern imported target Boost::unit_test_framework
  • Added GNUInstallDirs for standard, relocatable install paths
  • Wrapped all test targets behind a BUILD_TESTING option (defaults ON)
  • Added a proper ptest install target: all test binaries + run-ptest land in ${CMAKE_INSTALL_LIBDIR}/Area51/ptest/ (Yocto ${PTEST_PATH})
  • Fixed broken install(FILES … TYPE BIN) syntax (was mixing FILES keyword with TYPE BIN)
  • Named CTest tests descriptively (CatchTests, BoostTest_Factorial, …)

test2.cpp / test3.cpp

  • Fixed duplicate BOOST_TEST_MODULE macro (test_module1 in all three Boost files). Now test_module1, test_module2, test_module3 respectively — required for correct Boost.Test linking.

run-ptest (new)

  • Shell script consumed by Yocto's ptest-runner. Runs each test binary in sequence and emits PASS: / FAIL: lines in the format expected by the runner.

README.md

  • Added project layout, dependency table, build/test/install instructions, and Yocto usage section.

meta-area51/recipes-test/area51/area51_git.bb (new)

BitBake recipe — see below.


Validation

All 4 CTest tests pass locally:

1/4 Test #1: CatchTests .......................   Passed    0.00 sec
2/4 Test #2: BoostTest_Factorial ..............   Passed    0.00 sec
3/4 Test #3: BoostTest_HumanFactorial .........   Passed    0.00 sec
4/4 Test #4: BoostTest_HumanName ..............   Passed    0.00 sec

100% tests passed, 0 tests failed out of 4

BitBake recipe

# meta-area51/recipes-test/area51/area51_git.bb

SUMMARY = "Area51 – C++ demo application with ptest package"
DESCRIPTION = "A small C++ application and its bundled Boost.Test/Catch2 \
test suite, packaged for Yocto ptest integration."
HOMEPAGE = "https://github.com/onkelpit/Area51"

# Add a LICENSE file to the repository, then replace the placeholder below
# with: md5sum LICENSE
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=<replace-with-actual-md5-of-LICENSE-file>"

# ── Source ───────────────────────────────────────────────────────────────────
SRC_URI = "git://github.com/onkelpit/Area51.git;protocol=https;branch=main"
SRCREV = "${AUTOREV}"

PV = "1.0+git${SRCPV}"
S = "${WORKDIR}/git"

# ── Build ────────────────────────────────────────────────────────────────────
inherit cmake ptest

DEPENDS = "boost"

# Enable BUILD_TESTING only when ptest is in DISTRO_FEATURES
EXTRA_OECMAKE = "-DBUILD_TESTING=${@bb.utils.contains('DISTRO_FEATURES', 'ptest', 'ON', 'OFF', d)}"

# ── Packages ──────────────────────────────────────────────────────────────────
PACKAGES =+ "${PN}-ptest"

FILES:${PN}-ptest = "${libdir}/${PN}/ptest/"

RDEPENDS:${PN}-ptest = "\
    ${PN} \
    boost-test \
    ptest-runner \
"

# ── ptest install ─────────────────────────────────────────────────────────────
# cmake --install (run by the cmake bbclass) already places binaries and
# run-ptest under ${libdir}/${PN}/ptest/ via the CMakeLists.txt PTEST_INSTALL_DIR.
do_install_ptest() {
    :
}

How to use in a Yocto build

  1. Copy meta-area51/ into your bblayers.conf layer list (or add it as a separate layer).
  2. Ensure ptest is in DISTRO_FEATURES (or EXTRA_IMAGE_FEATURES += "ptest-pkgs").
  3. Add area51-ptest to your image recipe.
  4. On the target, run:
    ptest-runner area51

Note: Before submitting to a production layer, add a LICENSE file to the repository and update LIC_FILES_CHKSUM with the real MD5 (md5sum LICENSE). Also pin SRCREV to a fixed commit SHA instead of ${AUTOREV} for reproducible builds.

Copilot AI and others added 2 commits April 8, 2026 13:00
- Modernise CMakeLists.txt to CMake 3.10+, C++11, GNUInstallDirs,
  modern Boost targets, BUILD_TESTING option, and ptest-compatible
  install layout (lib/Area51/ptest/)
- Fix duplicate BOOST_TEST_MODULE names in test2.cpp (→ test_module2)
  and test3.cpp (→ test_module3)
- Add run-ptest shell script for Yocto ptest-runner integration
- Update README.md with build/test/install/Yocto usage instructions
- Add meta-area51/recipes-test/area51/area51_git.bb BitBake recipe

Agent-Logs-Url: https://github.com/onkelpit/Area51/sessions/08b13553-00dd-4fce-bce3-b01971b7ff19

Co-authored-by: onkelpit <7003446+onkelpit@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants