@@ -27,41 +27,39 @@ log() {
2727 echo " "
2828}
2929
30- # Initialize branch variable with an if-else statement
31- branch=${BRANCH:- stable2}
32- log " INFO" " Using branch: $branch "
33-
34- # Check if RdkbGMock directory already exists
30+ # Clone or enter RdkbGMock
3531if [ -d " RdkbGMock" ]; then
3632 log " INFO" " RdkbGMock directory already exists. Skipping clone."
3733 cd RdkbGMock
3834else
39- log " INFO" " RdkbGMock directory does not exist. Cloning repository ..."
40- if git clone ssh://gerrit.teamccp.com:29418/rdk/rdkb/components/opensource/ccsp/RdkbGMock/generic RdkbGMock -b " $branch " ; then
41- log " INFO " " Entering into RdkbGMock directory... "
35+ log " INFO" " Cloning RdkbGMock repository from GitHub ..."
36+ # Use token for authentication if provided
37+ if git clone -b " develop " " https://github.com/rdkcentral/gmock-broadband.git " RdkbGMock ; then
4238 cd RdkbGMock
4339 else
44- log " ERROR" " Failed to clone RdkbGMock repository. "
40+ log " ERROR" " Failed to clone repository with branch: develop "
4541 exit 1
4642 fi
4743fi
4844
49- # Check if change number/revision is provided
45+ # Check if a pull request ID is provided in argument 1
5046if [ -n " $1 " ]; then
51- change_revision=$1
52- change_number=$( echo $change_revision | cut -d' /' -f1)
53- revision=$( echo $change_revision | cut -d' /' -f2)
54- last_two_digits=${change_number: -2}
55-
56- log " INFO" " Fetching and cherry-picking changes..."
57- if git fetch ssh://gerrit.teamccp.com:29418/rdk/rdkb/components/opensource/ccsp/RdkbGMock/generic refs/changes/" $last_two_digits " /" $change_number " /" $revision " && git cherry-pick FETCH_HEAD; then
58- log " INFO" " Changes fetched and cherry-picked successfully."
47+ pr_id=" $1 "
48+ log " INFO" " Fetching PR ID: $pr_id and checking out FETCH_HEAD"
49+ if git fetch " https://github.com/rdkcentral/gmock-broadband.git" pull/" $pr_id " /head && git checkout FETCH_HEAD; then
50+ log " INFO" " Successfully checked out PR #$pr_id "
5951 else
60- log " ERROR" " Failed to fetch and cherry-pick changes. "
52+ log " ERROR" " Failed to fetch or checkout PR # $pr_id "
6153 exit 1
6254 fi
6355else
64- log " INFO" " No change number/revision provided, skipping git fetch and cherry-pick."
56+ log " INFO" " No PR ID provided. Fetching latest from branch: develop"
57+ if git fetch " https://github.com/rdkcentral/gmock-broadband.git" develop && git checkout develop; then
58+ log " INFO" " Checked out latest branch: develop"
59+ else
60+ log " ERROR" " Failed to fetch or checkout branch: develop"
61+ exit 1
62+ fi
6563fi
6664
6765log " INFO" " Start Running RdkbGMock Dependency Component Script..."
8785fi
8886
8987# Run configure with specific options
90- log " INFO" " Running configure with options --enable-gtestapp and --enable- unitTestDockerSupport..."
88+ log " INFO" " Running configure with options --enable-unitTestDockerSupport..."
9189if ./configure --enable-unitTestDockerSupport; then
9290 log " INFO" " Configuration successful."
9391else
@@ -100,32 +98,61 @@ if [ ! -f "${PWD}/RdkbGMock/docker_scripts/export_var.sh" ]; then
10098 log " ERROR" " RdkbGMock/docker_scripts/export_var.sh does not exist in the directory $PWD ."
10199 exit 1
102100else
103- # Source the export_var.sh script from the current working directory
104101 source " RdkbGMock/docker_scripts/export_var.sh"
105-
106- # Log the paths set by the sourced script
107102 log " INFO" " C_INCLUDE_PATH is set to: $C_INCLUDE_PATH "
108103 log " INFO" " CPLUS_INCLUDE_PATH is set to: $CPLUS_INCLUDE_PATH "
109104fi
110105
111- # Run make for specific target
112- log " INFO" " Running make for CcspDmcliTest_gtest.bin..."
113- if make -C source/test/CcspDmcliTest; then
114- log " INFO" " Make operation completed successfully."
115- else
116- log " ERROR" " Make operation failed."
117- exit 1
118- fi
119- log " INFO" " Completed running UT script."
120-
121106log " INFO" " Preparing to run the Gtest Binary"
122- if [ -f " ./source/test/CcspDmcliTest/CcspDmcliTest_gtest.bin" ]; then
123- log " INFO" " Running CcspDmcliTest_gtest.bin"
124- ./source/test/CcspDmcliTest/CcspDmcliTest_gtest.bin
125- log " INFO" " Completed Test Execution"
126- else
127- log " ERROR" " CcspDmcliTest_gtest.bin does not exist, cannot run tests"
128- exit 1
107+ # Generic function to build and run all gtest binaries under source/test and its subfolders
108+ run_all_gtests () {
109+ local test_dirs
110+ local make_dir
111+ local bin_files
112+ local bin_file
113+
114+ # Only include directories that contain a Makefile and do not contain makefile or GNUmakefile
115+ test_dirs=( $( find source/test -type f -name ' Makefile' -exec dirname {} \; | sort -u) )
116+
117+ for make_dir in " ${test_dirs[@]} " ; do
118+ log " INFO" " Running make in $make_dir ..."
119+ if make -C " $make_dir " ; then
120+ log " INFO" " Make operation completed successfully in $make_dir ."
121+ else
122+ log " ERROR" " Make operation failed in $make_dir ."
123+ exit 1
124+ fi
125+ done
126+
127+ log " INFO" " Completed running all make operations."
128+
129+ # Find all .bin files under source/test and its subfolders
130+ bin_files=( $( find source/test -type f -name " *.bin" ) )
131+
132+ if [[ ${# bin_files[@]} -eq 0 ]]; then
133+ log " ERROR" " No .bin files found under source/test, cannot run tests"
134+ exit 1
135+ fi
136+
137+ for bin_file in " ${bin_files[@]} " ; do
138+ if [[ -x " $bin_file " ]]; then
139+ log " INFO" " Running $( basename " $bin_file " ) "
140+ " $bin_file "
141+ log " INFO" " Completed Test Execution for $( basename " $bin_file " ) "
142+ else
143+ log " ERROR" " $( basename " $bin_file " ) is not executable, skipping"
144+ fi
145+ done
146+ }
147+
148+ # Call the generic function to build and run all gtest binaries
149+ run_all_gtests
150+
151+ # Check if coverage.info exists before filtering
152+ if [ -f coverage.info ] || [ -d out ]; then
153+ log " INFO" " Removing existing coverage.info and/or out directory"
154+ [ -f coverage.info ] && rm -f coverage.info
155+ [ -d out ] && rm -rf out
129156fi
130157
131158log " INFO" " Starting Gcov for code coverage analysis"
0 commit comments