aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Sardara <msardara@cisco.com>2022-09-14 16:17:22 +0200
committerMauro Sardara <msardara@cisco.com>2022-09-14 16:26:27 +0200
commit34e32b751d8060f93646d3fa542ddea73de901c4 (patch)
tree7ebb988de951fcddc7312c3a5b337c874350219b
parent6c9f120f028bcca93fd087afa648f653b208eb35 (diff)
ci: correctly generate tests reports
Do not use make test to run the tests after the build, as it overwrites the report file for each single unit tests. Signed-off-by: Mauro Sardara <msardara@cisco.com> Change-Id: Icdc55b31c1e36b213f977b76f8518ac16c393afc
-rw-r--r--scripts/build-packages.sh29
-rw-r--r--scripts/functions.sh8
-rwxr-xr-xscripts/run-sonar.sh11
3 files changed, 29 insertions, 19 deletions
diff --git a/scripts/build-packages.sh b/scripts/build-packages.sh
index 598b3f626..dddc98deb 100644
--- a/scripts/build-packages.sh
+++ b/scripts/build-packages.sh
@@ -17,6 +17,20 @@ set -euxo pipefail
SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE}")" ; pwd -P )
source ${SCRIPT_PATH}/functions.sh
+BUILD_PATH="${SCRIPT_PATH}/../packages"
+TEST_REPORT_DIR="${BUILD_PATH}/reports"
+BUILD_ROOT_DIR="${BUILD_PATH}/build-root/bin"
+MAKE_FOLDER="${SCRIPT_PATH}/.."
+
+function execute_tests() {
+ mkdir -p "${TEST_REPORT_DIR}"
+ pushd "${BUILD_ROOT_DIR}"
+ for component in "${TEST_COMPONENTS[@]}"; do
+ GTEST_OUTPUT="xml:${TEST_REPORT_DIR}/${component}-report.xml" "./${component}_tests"
+ done
+ popd
+}
+
# Parameters:
# $1 = Package name
#
@@ -28,18 +42,11 @@ function build_package() {
echo "*******************************************************************"
# Run unit tests and make the package
- export GTEST_OUTPUT="xml:report.xml"
- make -C "${SCRIPT_PATH}/.." BUILD_PATH="${SCRIPT_PATH}/../packages" INSTALL_PREFIX=/usr test package-release
-
- pushd ${SCRIPT_PATH}/../packages
- # Find and collect reports
- mkdir -p reports
- REPORTS=($(find . -iname 'report.xml'))
- echo "${REPORTS[@]}"
- for report in "${REPORTS[@]}"; do
- mv "${report}" "reports/$(echo ${report} | awk -F/ '{print $(2)"-"$(NF)}')"
- done
+ make -C "${MAKE_FOLDER}" BUILD_PATH="${BUILD_PATH}" INSTALL_PREFIX=/usr package-release
+
+ execute_tests
+ pushd "${BUILD_PATH}"
find . -not -name '*.deb' \
-not -name '*.rpm' \
-not -name 'reports' \
diff --git a/scripts/functions.sh b/scripts/functions.sh
index d6d8bf84e..544c283fc 100644
--- a/scripts/functions.sh
+++ b/scripts/functions.sh
@@ -31,6 +31,14 @@ fi
COLLECTD_SOURCE="https://github.com/collectd/collectd/releases/download/collectd-5.12.0/collectd-5.12.0.tar.bz2"
+declare -a TEST_COMPONENTS=(
+ "libtransport"
+ "lib"
+ "hicn_light"
+ "hicnplugin"
+ "libhicnctrl"
+)
+
function install_collectd_headers() {
curl -OL ${COLLECTD_SOURCE}
tar -xf collectd-5.12.0.tar.bz2
diff --git a/scripts/run-sonar.sh b/scripts/run-sonar.sh
index 3d386bbfc..87a94b592 100755
--- a/scripts/run-sonar.sh
+++ b/scripts/run-sonar.sh
@@ -6,6 +6,9 @@ set -euxo pipefail
# PROJECT_KEY=fdio-hicn
# PROJECT_ORGANIZATION=fdio
+SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE}")" ; pwd -P )
+source "${SCRIPT_PATH}/functions.sh"
+
export SONAR_TOKEN=$API_TOKEN
export SONAR_SCANNER_VERSION=4.7.0.2747
export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
@@ -30,14 +33,6 @@ make SONAR_BUILD_WRAPPER=${HOME}/.sonar/build-wrapper-linux-x86/build-wrapper-li
# Run tests to compute test coverage
pushd ${BUILD_PATH}
-declare -a TEST_COMPONENTS=(
- "libtransport"
- "lib"
- "hicn_light"
- "hicnplugin"
- "libhicnctrl"
-)
-
# Save first test executable
FIRST_COMPONENT="${TEST_COMPONENTS[0]}"
FIRST_TEST="${TEST_PATH}/${FIRST_COMPONENT}_tests"