Skip to content
Open
33 changes: 32 additions & 1 deletion .github/workflows/L2-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ name: L2 Integration Tests

on:
pull_request:
branches: [ develop ]
branches: [ feature/l2docs ]
push:
branches: [ feature/l2docs ]

permissions:
contents: write
Comment on lines +9 to +10

env:
AUTOMATICS_UNAME: ${{ secrets.AUTOMATICS_UNAME }}
Expand All @@ -18,6 +23,7 @@ jobs:
uses: actions/checkout@v4
with:
path: remote_debugger
token: ${{ secrets.GITHUB_TOKEN }}

- name: Check out dependent repostiories
uses: actions/checkout@v4
Expand Down Expand Up @@ -88,3 +94,28 @@ jobs:
run: |
docker cp /tmp/L2_TEST_RESULTS ci-container:/tmp/L2_TEST_RESULTS
docker exec -i ci-container bash -c "echo 'Contents in workspace directory' && ls -l && echo '===============================' && echo 'Contents in /tmp/L2_TEST_RESULTS' && ls -l /tmp/L2_TEST_RESULTS && echo '===============================' && git config --global --add safe.directory /mnt/L2_CONTAINER_SHARED_VOLUME/remote_debugger && gtest-json-result-push.py /tmp/L2_TEST_RESULTS https://rdkeorchestrationservice.apps.cloud.comcast.net/rdke_orchestration_api/push_unit_test_results /mnt/L2_CONTAINER_SHARED_VOLUME/remote_debugger"

- name: Copy lcov tracefile from container
id: copy_tracefile
if: github.event_name == 'push'
continue-on-error: true
run: docker cp native-platform:/tmp/l2_coverage/coverage.info /tmp/coverage.info

- name: Generate L2_Coverage.md
if: github.event_name == 'push' && steps.copy_tracefile.outcome == 'success'
run: |
python3 remote_debugger/test/functional-tests/generate_l2_coverage_report.py \
--tracefile /tmp/coverage.info \
--features-dir remote_debugger/test/functional-tests/features \
--tests-dir remote_debugger/test/functional-tests/tests \
--output remote_debugger/test/functional-tests/L2_Coverage.md

- name: Commit L2_Coverage.md
if: github.event_name == 'push' && steps.copy_tracefile.outcome == 'success'
run: |
cd remote_debugger
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add test/functional-tests/L2_Coverage.md
git diff --cached --quiet || git commit -m "ci: regenerate L2_Coverage.md [skip ci]"
git push
2 changes: 1 addition & 1 deletion cov_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,5 @@ cd $WORKDIR
autoreconf -i
autoupdate
./configure --prefix=${INSTALL_DIR} --enable-iarmbusSupport=yes
make remotedebugger_CFLAGS="-I/usr/include/cjson -I/usr/local/include/wdmp-c -I/usr/local/include/rbus -I/usr/local/include -I./unittest/mocks -I/usr/local/include/trower-base64 -DIARMBUS_SUPPORT -DUSECOV -DUSE_L2_SUPPORT" remotedebugger_LDFLAGS="-L/usr/local/lib -lrdkloggers -lcjson -lrfcapi -lrbus -lmsgpackc -lsecure_wrapper -lwebconfig_framework -lIARMBus -ltr181api -L/usr/local/lib/x86_64-linux-gnu -ltrower-base64 -L/usr/lib/x86_64-linux-gnu"
make remotedebugger_CFLAGS="-I/usr/include/cjson -I/usr/local/include/wdmp-c -I/usr/local/include/rbus -I/usr/local/include -I./unittest/mocks -I/usr/local/include/trower-base64 -DIARMBUS_SUPPORT -DUSECOV -DUSE_L2_SUPPORT --coverage" remotedebugger_LDFLAGS="-L/usr/local/lib -lrdkloggers -lcjson -lrfcapi -lrbus -lmsgpackc -lsecure_wrapper -lwebconfig_framework -lIARMBus -ltr181api -L/usr/local/lib/x86_64-linux-gnu -ltrower-base64 -L/usr/lib/x86_64-linux-gnu --coverage"
make install
28 changes: 25 additions & 3 deletions run_l2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,23 @@ RESULT_DIR="/tmp/l2_test_report"
STATIC_PROFILE_DIR="/etc/rrd"
OUTPUT_DIR="/tmp/rrd"
LIB_DIR="/lib/rdk"
COV_DIR="/tmp/l2_coverage"

export RRD_COVERAGE_MODE=1
Comment on lines +25 to +27

mkdir -p "$RESULT_DIR"
mkdir -p "$OUTPUT_DIR"
mkdir -p "$STATIC_PROFILE_DIR"
mkdir -p "$LIB_DIR"
mkdir -p "$COV_DIR"
mkdir -p /media/apps/RDK-RRD-Test/etc/rrd

touch /media/apps/RDK-RRD-Test/etc/rrd/remote_debugger.json
echo "AA:BB:CC:DD:EE:FF" >> /tmp/.estb_mac


apt-get remove systemd
apt-get update && apt-get install -y tcpdump
apt-get remove -y systemd || true
apt-get update && apt-get install -y tcpdump lcov

echo "LOG_PATH=/opt/logs" >> /etc/include.properties
cp remote_debugger.json /etc/rrd/remote_debugger.json
Expand All @@ -60,6 +64,11 @@ ln -s /usr/local/bin/journalctl /usr/bin/journalctl
rm -rf /tmp/rrd/*
rm -rf /opt/logs/remotedebugger.log*

# lcov baseline — capture zero counters before any test runs
lcov --zerocounters --directory "$(pwd)/src"
lcov --capture --initial --directory "$(pwd)/src" \
--output-file "$COV_DIR/coverage_base.info" --rc lcov_branch_coverage=1

# Run L2 Test cases
pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rrd_dynamic_profile_missing_report.json test/functional-tests/tests/test_rrd_dynamic_profile_missing_report.py
pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/test_category.json test/functional-tests/tests/test_rrd_dynamic_subcategory_report.py
Expand Down Expand Up @@ -90,5 +99,18 @@ pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rrd_pr
pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rrd_dynamic_profile_rdm_node_length_exceeded.json test/functional-tests/tests/test_rrd_dynamic_profile_rdm_node_length_exceeded.py



# Capture, filter, and report coverage
lcov --capture --directory "$(pwd)/src" \
--output-file "$COV_DIR/coverage_test.info" --rc lcov_branch_coverage=1
lcov --add-tracefile "$COV_DIR/coverage_base.info" \
--add-tracefile "$COV_DIR/coverage_test.info" \
--output-file "$COV_DIR/coverage_merged.info" --rc lcov_branch_coverage=1
lcov --remove "$COV_DIR/coverage_merged.info" '/usr/*' \
--output-file "$COV_DIR/coverage.info" --rc lcov_branch_coverage=1
genhtml "$COV_DIR/coverage.info" \
--output-directory "$COV_DIR/html" \
--title "Remote Debugger L2 Coverage" \
--branch-coverage --legend
echo "Coverage report : $COV_DIR/html/index.html"
echo "lcov tracefile : $COV_DIR/coverage.info"

16 changes: 15 additions & 1 deletion src/rrdMain.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,18 @@
#include "rrdDynamic.h"
#include "rrdEventProcess.h"
#include "rrdInterface.h"

#ifdef USECOV
#include <signal.h>
#include <stdlib.h>
Comment on lines +26 to +28
extern void __gcov_dump(void);
/* Flush gcov counters on SIGTERM so lcov captures L2 exercise data. */
static void rrd_gcov_sigterm_handler(int sig)
{
(void)sig;
__gcov_dump();
_exit(0);
}
Comment on lines +31 to +36
#endif

devicePropertiesData devPropData;

Expand Down Expand Up @@ -139,6 +150,9 @@ int main(int argc, char *argv[])
pthread_t RRDTR69ThreadID;

rdk_logger_init(DEBUG_INI_FILE);
#ifdef USECOV
signal(SIGTERM, rrd_gcov_sigterm_handler);
#endif
#if !defined(GTEST_ENABLE)
/* Store Device Info.*/
RRDStoreDeviceInfo(&devPropData);
Expand Down
Loading