Wire --run-coverage end to end and remove the DTC pure-virtual forwarders
- new_docker_build.sh: --run-coverage now instruments the RelWithDebInfo build with -O0 -g --coverage (CMAKE_*_FLAGS_RELWITHDEBINFO), runs ctest and collects an lcov report (capture/extract/genhtml/summary) under <pipeline-root>/coverage/<project>/<os>; the lcov steps share an ignore-errors list for the -O0 data quirks (inconsistent, count, ...). - Lts/DDS/DTC/generic_dtc.h: remove the one-line forwarders that called the pure virtuals of GenericDtcSC (latent infinite recursion, and an undefined symbol at link time at -O0, e.g. coverage builds); the concrete classes in generic_dtc_impl.h implement every method final, and the 'using' declarations keep the base methods accessible. - README.md: document the coverage flow (Step 6), update the option rows and add a troubleshooting entry for the -O0 pure-virtual link failure.
This commit is contained in:
1 parent
aa519a56d2
commit
72c87230fd
3 files changed
+131
-38
No files matched your search
@@ -59,13 +59,12 @@ class GenericDtc
|
|||||||
using BaseClass::takeAlive;
|
using BaseClass::takeAlive;
|
||||||
using BaseClass::takeDisposed;
|
using BaseClass::takeDisposed;
|
||||||
using BaseClass::SubscriberCallback;
|
using BaseClass::SubscriberCallback;
|
||||||
bool setSubscriberCallback(const typename BaseClass::SubscriberCallback& callback) override { return BaseClass::setSubscriberCallback(callback); }
|
// NOTE: the methods of GenericDtcSC are deliberately NOT overridden here.
|
||||||
bool readAlive(TopicType& data) { return BaseClass::readAlive(data); }
|
// They stay pure and are implemented by the concrete classes in
|
||||||
bool takeAlive(TopicType& data) { return BaseClass::takeAlive(data); }
|
// generic_dtc_impl.h; calls through this class dispatch virtually.
|
||||||
bool takeDisposed(TopicType& data) { return BaseClass::takeDisposed(data); }
|
// One-line forwarders like `return BaseClass::readAlive(data);` must not be
|
||||||
bool hasSamples() const { return BaseClass::hasSamples(); }
|
// re-introduced: they are a latent infinite recursion at runtime and an
|
||||||
DRO_OBJECT* dataReader() const override { return BaseClass::dataReader(); }
|
// undefined pure-virtual symbol at link time at -O0 (e.g. coverage builds).
|
||||||
bool waitForHistoricalData(int timeoutMSec) { return BaseClass::waitForHistoricalData(timeoutMSec); }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename DRO_OBJECT>
|
template <typename DRO_OBJECT>
|
||||||
@@ -82,13 +81,12 @@ class GenericDtcSampleInfo
|
|||||||
using BaseClass::takeAlive;
|
using BaseClass::takeAlive;
|
||||||
using BaseClass::takeDisposed;
|
using BaseClass::takeDisposed;
|
||||||
using BaseClass::SubscriberCallback;
|
using BaseClass::SubscriberCallback;
|
||||||
bool setSubscriberCallback(const typename BaseClass::SubscriberCallback& callback) override { return BaseClass::setSubscriberCallback(callback); }
|
// NOTE: the methods of GenericDtcSC are deliberately NOT overridden here.
|
||||||
bool readAlive(TopicType& data) { return BaseClass::readAlive(data); }
|
// They stay pure and are implemented by the concrete classes in
|
||||||
bool takeAlive(TopicType& data) { return BaseClass::takeAlive(data); }
|
// generic_dtc_impl.h; calls through this class dispatch virtually.
|
||||||
bool takeDisposed(TopicType& data) { return BaseClass::takeDisposed(data); }
|
// One-line forwarders like `return BaseClass::readAlive(data);` must not be
|
||||||
bool hasSamples() const { return BaseClass::hasSamples(); }
|
// re-introduced: they are a latent infinite recursion at runtime and an
|
||||||
DRO_OBJECT* dataReader() const override { return BaseClass::dataReader(); }
|
// undefined pure-virtual symbol at link time at -O0 (e.g. coverage builds).
|
||||||
bool waitForHistoricalData(int timeoutMSec) { return BaseClass::waitForHistoricalData(timeoutMSec); }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename DRO_OBJECT>
|
template <typename DRO_OBJECT>
|
||||||
@@ -105,13 +103,12 @@ class Ddtc
|
|||||||
using BaseClass::takeAlive;
|
using BaseClass::takeAlive;
|
||||||
using BaseClass::takeDisposed;
|
using BaseClass::takeDisposed;
|
||||||
using BaseClass::SubscriberCallback;
|
using BaseClass::SubscriberCallback;
|
||||||
bool setSubscriberCallback(const typename BaseClass::SubscriberCallback& callback) override { return BaseClass::setSubscriberCallback(callback); }
|
// NOTE: the methods of GenericDtcSC are deliberately NOT overridden here.
|
||||||
bool readAlive(TopicType& data) { return BaseClass::readAlive(data); }
|
// They stay pure and are implemented by the concrete classes in
|
||||||
bool takeAlive(TopicType& data) { return BaseClass::takeAlive(data); }
|
// generic_dtc_impl.h; calls through this class dispatch virtually.
|
||||||
bool takeDisposed(TopicType& data) { return BaseClass::takeDisposed(data); }
|
// One-line forwarders like `return BaseClass::readAlive(data);` must not be
|
||||||
bool hasSamples() const { return BaseClass::hasSamples(); }
|
// re-introduced: they are a latent infinite recursion at runtime and an
|
||||||
DRO_OBJECT* dataReader() const override { return BaseClass::dataReader(); }
|
// undefined pure-virtual symbol at link time at -O0 (e.g. coverage builds).
|
||||||
bool waitForHistoricalData(int timeoutMSec) { return BaseClass::waitForHistoricalData(timeoutMSec); }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename DRO_OBJECT>
|
template <typename DRO_OBJECT>
|
||||||
@@ -128,12 +125,11 @@ class DdtcSampleInfo
|
|||||||
using BaseClass::takeAlive;
|
using BaseClass::takeAlive;
|
||||||
using BaseClass::takeDisposed;
|
using BaseClass::takeDisposed;
|
||||||
using BaseClass::SubscriberCallback;
|
using BaseClass::SubscriberCallback;
|
||||||
bool setSubscriberCallback(const typename BaseClass::SubscriberCallback& callback) override { return BaseClass::setSubscriberCallback(callback); }
|
// NOTE: the methods of GenericDtcSC are deliberately NOT overridden here.
|
||||||
bool readAlive(TopicType& data) { return BaseClass::readAlive(data); }
|
// They stay pure and are implemented by the concrete classes in
|
||||||
bool takeAlive(TopicType& data) { return BaseClass::takeAlive(data); }
|
// generic_dtc_impl.h; calls through this class dispatch virtually.
|
||||||
bool takeDisposed(TopicType& data) { return BaseClass::takeDisposed(data); }
|
// One-line forwarders like `return BaseClass::readAlive(data);` must not be
|
||||||
bool hasSamples() const { return BaseClass::hasSamples(); }
|
// re-introduced: they are a latent infinite recursion at runtime and an
|
||||||
DRO_OBJECT* dataReader() const override { return BaseClass::dataReader(); }
|
// undefined pure-virtual symbol at link time at -O0 (e.g. coverage builds).
|
||||||
bool waitForHistoricalData(int timeoutMSec) { return BaseClass::waitForHistoricalData(timeoutMSec); }
|
|
||||||
};
|
};
|
||||||
} // namespace DTC
|
} // namespace DTC
|
||||||
@@ -252,12 +252,28 @@ in-tree flow calls `new_docker_build.sh` (the Release 2 driver). See
|
|||||||
|
|
||||||
## Step 6 — Code coverage (lcov)
|
## Step 6 — Code coverage (lcov)
|
||||||
|
|
||||||
`--run-coverage` is available and is mutually exclusive with
|
`--run-coverage` builds the whole Release 2 scope instrumented
|
||||||
`--run-jenkins-builder`. In the current tree it only passes
|
(`-O0 -g --coverage`, overriding the RelWithDebInfo flags), runs the
|
||||||
`-DRUN_COVERAGE=ON` / `-DCOVERAGE_OUTPUT_DIR` to the configure — those
|
ctest suite and collects an lcov report inside the container
|
||||||
variables are not consumed by any `CMakeLists.txt` yet, so no lcov
|
(lcov + genhtml ship in the `legatus-qt6:1.0` image):
|
||||||
data is collected. The option is kept for the (still to be wired)
|
|
||||||
coverage step.
|
```bash
|
||||||
|
./new_docker_build.sh --run-coverage
|
||||||
|
```
|
||||||
|
|
||||||
|
The report is written to
|
||||||
|
`<pipeline-root>/coverage/<PROJECT>/<OS_VERSION>/` (default:
|
||||||
|
`coverage/guez/26.04/`), next to `qt-migration-legatus/` and outside
|
||||||
|
the tree:
|
||||||
|
|
||||||
|
- `html/index.html` — browser report (line + branch coverage)
|
||||||
|
- `coverage.info` — lcov tracefile, filtered to `qt-migration-legatus/*`
|
||||||
|
- `coverage_summary.txt` — totals (line / branch hit rate)
|
||||||
|
|
||||||
|
`--coverage-output-dir DIR` moves the report; `DIR` must be an absolute
|
||||||
|
path under the pipeline root (relative values are ignored and the
|
||||||
|
default above is used). The option is mutually exclusive with
|
||||||
|
`--run-jenkins-builder`.
|
||||||
|
|
||||||
## Options reference
|
## Options reference
|
||||||
|
|
||||||
@@ -279,8 +295,8 @@ The main ones:
|
|||||||
| `--run-jenkins-builder` | off | produce the DEB packages (Step 4) |
|
| `--run-jenkins-builder` | off | produce the DEB packages (Step 4) |
|
||||||
| `--package-output-dir DIR` | `./packages-out` | pass-through (see Step 4 note) |
|
| `--package-output-dir DIR` | `./packages-out` | pass-through (see Step 4 note) |
|
||||||
| `--lts-version / --project / --build-number / --build-tag` | `1.0` / `guez` / `1` / `manual-build` | package metadata |
|
| `--lts-version / --project / --build-number / --build-tag` | `1.0` / `guez` / `1` / `manual-build` | package metadata |
|
||||||
| `--run-coverage` | off | coverage flag pass-through (Step 6) |
|
| `--run-coverage` | off | instrument with `-O0 --coverage`, run ctest, collect the lcov report (Step 6); mutually exclusive with `--run-jenkins-builder` |
|
||||||
| `--coverage-output-dir DIR` | `./coverage-out` | pass-through (see Step 6) |
|
| `--coverage-output-dir DIR` | `<pipeline-root>/coverage/<project>/<os>` | report dir — only absolute paths under the pipeline root are honored (Step 6) |
|
||||||
|
|
||||||
Environment overrides: `BUILD_GROUP1/3/5/6`, `RUN_CTEST`, `TESTS_ONLY`,
|
Environment overrides: `BUILD_GROUP1/3/5/6`, `RUN_CTEST`, `TESTS_ONLY`,
|
||||||
`USE_PREBUILT_IMAGE`, `DOCKER_IMAGE`, `CMAKE_BUILD_FLAGS`,
|
`USE_PREBUILT_IMAGE`, `DOCKER_IMAGE`, `CMAKE_BUILD_FLAGS`,
|
||||||
@@ -302,6 +318,14 @@ Environment overrides: `BUILD_GROUP1/3/5/6`, `RUN_CTEST`, `TESTS_ONLY`,
|
|||||||
`QT_PLUGIN_PATH` from Step 3).
|
`QT_PLUGIN_PATH` from Step 3).
|
||||||
- **`GrantleeParserSmoke`: `ktexttemplate_defaulttags` not found** →
|
- **`GrantleeParserSmoke`: `ktexttemplate_defaulttags` not found** →
|
||||||
run ctest/tests with the system plugin dir prepended (Step 3).
|
run ctest/tests with the system plugin dir prepended (Step 3).
|
||||||
|
- **Coverage build fails to link with `undefined reference` to
|
||||||
|
`DTC::GenericDtcSC<...>::readAlive(...)` etc.** — a call to a pure
|
||||||
|
virtual function only links at `-O1` and above (GCC rewrites it to
|
||||||
|
`__cxa_pure_virtual`); at `-O0` the raw symbol stays undefined. This
|
||||||
|
was triggered by the one-line forwarders in
|
||||||
|
`Lts/DDS/DTC/generic_dtc.h`, which have been removed: the concrete
|
||||||
|
classes in `generic_dtc_impl.h` implement every method `final`, so
|
||||||
|
the forwarders were dead code (and a latent infinite recursion).
|
||||||
- **Stale build tree** → the driver always recreates `../build/`; for
|
- **Stale build tree** → the driver always recreates `../build/`; for
|
||||||
manual builds delete `../build/` and rerun Step 2 if CMake behaves
|
manual builds delete `../build/` and rerun Step 2 if CMake behaves
|
||||||
oddly.
|
oddly.
|
||||||
|
|||||||
@@ -48,8 +48,11 @@ Packages (DEB, via in-tree rpmbuild/make_rpm_ubuntu26_release2.py):
|
|||||||
--build-tag TAG Build tag for the package (default: manual-build)
|
--build-tag TAG Build tag for the package (default: manual-build)
|
||||||
|
|
||||||
Coverage (lcov):
|
Coverage (lcov):
|
||||||
--run-coverage Coverage build + lcov report (README.md Step 6)
|
--run-coverage Build with -O0 --coverage, run ctest and collect
|
||||||
--coverage-output-dir DIR Directory for coverage output (default: ./coverage-out)
|
the lcov report (README.md Step 6)
|
||||||
|
--coverage-output-dir DIR Report dir (default: <pipeline-root>/coverage/
|
||||||
|
<project>/<os>/; honored when it is an absolute
|
||||||
|
path under the pipeline root)
|
||||||
|
|
||||||
Environment overrides: BUILD_GROUP1/3/5/6, RUN_CTEST, TESTS_ONLY,
|
Environment overrides: BUILD_GROUP1/3/5/6, RUN_CTEST, TESTS_ONLY,
|
||||||
USE_PREBUILT_IMAGE, DOCKER_IMAGE, CMAKE_BUILD_FLAGS, DOCKER_MOUNT_ROOT,
|
USE_PREBUILT_IMAGE, DOCKER_IMAGE, CMAKE_BUILD_FLAGS, DOCKER_MOUNT_ROOT,
|
||||||
@@ -261,6 +264,26 @@ BUILD_DIR="../build"
|
|||||||
log_info "Using build directory: ${BUILD_DIR}"
|
log_info "Using build directory: ${BUILD_DIR}"
|
||||||
rm -rf "${BUILD_DIR}"
|
rm -rf "${BUILD_DIR}"
|
||||||
mkdir -p "${BUILD_DIR}"
|
mkdir -p "${BUILD_DIR}"
|
||||||
|
# Make it absolute: later steps (ctest/coverage) cd elsewhere and must
|
||||||
|
# still find the build tree.
|
||||||
|
BUILD_DIR="$(cd "${BUILD_DIR}" && pwd)"
|
||||||
|
|
||||||
|
# Coverage instrumentation (lcov): override the release flags with
|
||||||
|
# -O0 --coverage when RUN_COVERAGE=ON.
|
||||||
|
COV_CMAKE_ARGS=()
|
||||||
|
if [[ "${RUN_COVERAGE}" == "ON" ]]; then
|
||||||
|
log_info "Coverage mode: instrumenting with -O0 --coverage"
|
||||||
|
# The build type is RelWithDebInfo, so the config-specific flag variables
|
||||||
|
# are CMAKE_{C,CXX}_FLAGS_RELWITHDEBINFO (NOT *_RELEASE - those apply to
|
||||||
|
# the Release build type only).
|
||||||
|
COV_CMAKE_ARGS=(
|
||||||
|
"-DCMAKE_C_FLAGS_RELWITHDEBINFO=-O0 -g --coverage -DNDEBUG -fPIC"
|
||||||
|
"-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=-O0 -g --coverage -DNDEBUG -fPIC"
|
||||||
|
"-DCMAKE_EXE_LINKER_FLAGS=--coverage"
|
||||||
|
"-DCMAKE_SHARED_LINKER_FLAGS=--coverage"
|
||||||
|
)
|
||||||
|
fi
|
||||||
|
|
||||||
cmake -B "${BUILD_DIR}" \
|
cmake -B "${BUILD_DIR}" \
|
||||||
-G Ninja \
|
-G Ninja \
|
||||||
-DBUILD_TESTING=ON \
|
-DBUILD_TESTING=ON \
|
||||||
@@ -281,6 +304,7 @@ cmake -B "${BUILD_DIR}" \
|
|||||||
-DBUILD_TAG="${BUILD_TAG}" \
|
-DBUILD_TAG="${BUILD_TAG}" \
|
||||||
-DRUN_COVERAGE="${RUN_COVERAGE}" \
|
-DRUN_COVERAGE="${RUN_COVERAGE}" \
|
||||||
-DCOVERAGE_OUTPUT_DIR="${COVERAGE_OUTPUT_DIR}" \
|
-DCOVERAGE_OUTPUT_DIR="${COVERAGE_OUTPUT_DIR}" \
|
||||||
|
"${COV_CMAKE_ARGS[@]}" \
|
||||||
'"${CMAKE_BUILD_FLAGS}"' \
|
'"${CMAKE_BUILD_FLAGS}"' \
|
||||||
.
|
.
|
||||||
|
|
||||||
@@ -327,6 +351,55 @@ if [[ "${RUN_CTEST}" == "ON" ]] && [[ "${TESTS_ONLY}" != "ON" ]]; then
|
|||||||
cd ..
|
cd ..
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Code coverage (lcov): collect the tracefile, filter it down to the
|
||||||
|
# migrated tree, generate the browsable report and the scope summary.
|
||||||
|
if [[ "${RUN_COVERAGE}" == "ON" ]]; then
|
||||||
|
log_info "Collecting code coverage (lcov)..."
|
||||||
|
OS_VERSION=$(eval $(grep "^VERSION_ID=" /etc/os-release) && echo "$VERSION_ID")
|
||||||
|
COV_DIR="${DOCKER_MOUNT_ROOT}/coverage/${PROJECT}/${OS_VERSION}"
|
||||||
|
# Honor --coverage-output-dir when it is an absolute path under the
|
||||||
|
# pipeline root (the only place the host can see it inside the container).
|
||||||
|
case "${COVERAGE_OUTPUT_DIR}" in
|
||||||
|
/*)
|
||||||
|
if [[ "${COVERAGE_OUTPUT_DIR}" == "${MIGRATE_PIPELINE_ROOT}"/* ]]; then
|
||||||
|
COV_DIR="${DOCKER_MOUNT_ROOT}${COVERAGE_OUTPUT_DIR#"${MIGRATE_PIPELINE_ROOT}"}"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
rm -rf "${COV_DIR}"
|
||||||
|
mkdir -p "${COV_DIR}"
|
||||||
|
cd "${BUILD_DIR}"
|
||||||
|
# gcov data quirks under -O0 (exception-tag mismatches, inlined-lambda
|
||||||
|
# consistency checks, ...): suppressed so the steps below don't abort.
|
||||||
|
LCOV_IGNORE_ERRORS="mismatch,unused,source,category,version,gcov,corrupt,unsupported,inconsistent,count"
|
||||||
|
# 1) capture all instrumented objects under the build tree
|
||||||
|
lcov --capture --directory . \
|
||||||
|
--output-file "${COV_DIR}/coverage_raw.info" \
|
||||||
|
--rc branch_coverage=1 \
|
||||||
|
--ignore-errors="${LCOV_IGNORE_ERRORS}" \
|
||||||
|
|| die "lcov capture failed"
|
||||||
|
# 2) keep only the migrated-tree sources (drops Qt, RTI, system paths)
|
||||||
|
lcov --extract "${COV_DIR}/coverage_raw.info" "${DOCKER_MOUNT_ROOT}/qt-migration-legatus/*" \
|
||||||
|
--output-file "${COV_DIR}/coverage.info" \
|
||||||
|
--rc branch_coverage=1 \
|
||||||
|
--ignore-errors="${LCOV_IGNORE_ERRORS}" \
|
||||||
|
|| die "lcov extract failed"
|
||||||
|
rm -f "${COV_DIR}/coverage_raw.info"
|
||||||
|
# 3) browsable report (line + branch coverage per file)
|
||||||
|
genhtml "${COV_DIR}/coverage.info" \
|
||||||
|
--output-directory "${COV_DIR}/html" \
|
||||||
|
--branch-coverage \
|
||||||
|
--title "Legatus Qt6 Release 2 - code coverage" \
|
||||||
|
--ignore-errors="${LCOV_IGNORE_ERRORS}" \
|
||||||
|
|| die "genhtml failed"
|
||||||
|
# 4) whole-scope totals
|
||||||
|
lcov --summary "${COV_DIR}/coverage.info" --rc branch_coverage=1 \
|
||||||
|
--ignore-errors="${LCOV_IGNORE_ERRORS}" \
|
||||||
|
> "${COV_DIR}/coverage_summary.txt"
|
||||||
|
log_info "Coverage report: ${COV_DIR} (html/index.html, coverage.info, coverage_summary.txt)"
|
||||||
|
cat "${COV_DIR}/coverage_summary.txt"
|
||||||
|
fi
|
||||||
|
|
||||||
# DEB Package Production (in-tree rpmbuild)
|
# DEB Package Production (in-tree rpmbuild)
|
||||||
if [[ "${RUN_JENKINS_BUILDER}" == "ON" ]]; then
|
if [[ "${RUN_JENKINS_BUILDER}" == "ON" ]]; then
|
||||||
log_info "=== DEB Package Production (in-tree rpmbuild) ==="
|
log_info "=== DEB Package Production (in-tree rpmbuild) ==="
|
||||||
|
|||||||
Reference in new issue
Block a user