Skip to content

Commit cc0fa13

Browse files
added GTEST_ENABLE flag for bulkdata
1 parent 4f58a73 commit cc0fa13

File tree

12 files changed

+293
-53
lines changed

12 files changed

+293
-53
lines changed

source/bulkdata/profile.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@
4545

4646
#define MAX_LEN 256
4747

48+
#ifdef GTEST_ENABLE
49+
#define sendReportOverHTTP __wrap_sendReportOverHTTP
50+
#define sendCachedReportsOverHTTP __wrap_sendCachedReportsOverHTTP
51+
#endif
52+
4853
static bool initialized = false;
4954
static Vector *profileList;
5055
static pthread_mutex_t plMutex;

source/bulkdata/profilexconf.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -986,4 +986,9 @@ T2ERROR ProfileXConf_storeMarkerEvent(T2Event *eventInfo)
986986
T2Debug("%s --out\n", __FUNCTION__);
987987
return T2ERROR_SUCCESS;
988988
}
989-
989+
#ifdef GTEST_ENABLE
990+
void test_set_reportThreadExits(bool value)
991+
{
992+
reportThreadExits = value;
993+
}
994+
#endif

source/bulkdata/reportprofiles.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,3 +1514,21 @@ bool isMtlsEnabled(void)
15141514
#endif
15151515
#endif
15161516
}
1517+
1518+
#ifdef GTEST_ENABLE
1519+
typedef void* (*reportOnDemandFunc)(void*);
1520+
reportOnDemandFunc reportOnDemandFuncCallback(void)
1521+
{
1522+
return reportOnDemand;
1523+
}
1524+
typedef void (*freeProfilesHashMapFunc)(void *);
1525+
freeProfilesHashMapFunc freeProfilesHashMapFuncCallback(void)
1526+
{
1527+
return freeProfilesHashMap;
1528+
}
1529+
typedef void (*freeReportProfileHashMapFunc)(void *);
1530+
freeReportProfileHashMapFunc freeReportProfileHashMapFuncCallback(void)
1531+
{
1532+
return freeReportProfileHashMap;
1533+
}
1534+
#endif

source/ccspinterface/rbusInterface.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,9 +1954,11 @@ bool rbusCheckMethodExists(const char* rbusMethodName)
19541954
return true ;
19551955
}
19561956
#ifdef GTEST_ENABLE
1957+
#ifdef DCMAGENT
19571958
typedef void (*rbusReloadConfFunc)(rbusHandle_t, rbusEvent_t const *, rbusEventSubscription_t *);
19581959
rbusReloadConfFunc rbusReloadConfFuncCallback(void)
19591960
{
19601961
return rbusReloadConf;
19611962
}
19621963
#endif
1964+
#endif

source/test/bulkdata/Makefile.am

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
# limitations under the License.
1919
##########################################################################
2020

21-
AM_CXXFLAGS = -fno-permissive -std=c++11 -DPERSIST_LOG_MON_REF -fPIC -DPRIVACYMODES_CONTROL -DBULKDATA
21+
AM_CXXFLAGS = -fno-permissive -std=c++11 -DGTEST_ENABLE -DPERSIST_LOG_MON_REF -fPIC -DPRIVACYMODES_CONTROL -DBULKDATA
2222
#-DFEATURE_SUPPORT_WEBCONFIG -DDROP_ROOT_PRIV
2323

24-
AM_CFLAGS = -DPERSIST_LOG_MON_REF -fPIC
24+
AM_CFLAGS = -DPERSIST_LOG_MON_REF -DGTEST_ENABLE -fPIC
2525

2626
AUTOMAKE_OPTIONS = subdir-objects
2727

@@ -51,21 +51,25 @@ profilexconf_gtest_bin_LDFLAGS = -L/usr/src/googletest/googletest/lib/.libs -l
5151

5252
profilexconf_gtest_bin_LDFLAGS += -Wl,--wrap=sendReportOverHTTP -Wl,--wrap=sendCachedReportsOverHTTP
5353

54-
profilexconf_gtest_bin_SOURCES = = gtest_main.cpp profilexconfTest.cpp profilexconfMock.cpp SchedulerMock.cpp ../mocks/SystemMock.cpp ../mocks/FileioMock.cpp ../mocks/rdklogMock.cpp ../mocks/rbusMock.cpp ../../bulkdata/profilexconf.c ../../utils/vector.c ../../utils/t2log_wrapper.c ../../utils/t2common.c ../../utils/t2collection.c ../../utils/persistence.c ../../bulkdata/t2markers.c ../../reportgen/reportgen.c ../../dcautil/legacyutils.c
54+
profilexconf_gtest_bin_SOURCES = gtest_main.cpp profilexconfTest.cpp profilexconfMock.cpp SchedulerMock.cpp ../mocks/SystemMock.cpp ../mocks/FileioMock.cpp ../mocks/rdklogMock.cpp ../mocks/rbusMock.cpp ../../bulkdata/profilexconf.c ../../utils/vector.c ../../utils/t2log_wrapper.c ../../utils/t2common.c ../../utils/t2collection.c ../../utils/persistence.c ../../bulkdata/t2markers.c ../../reportgen/reportgen.c ../../dcautil/legacyutils.c
55+
56+
profile_gtest_bin_CFLAGS = -DGTEST_ENABLE
5557

5658
profile_gtest_bin_CPPFLAGS = -I$(PKG_CONFIG_SYSROOT_DIR)/usr/include/gtest -I$(PKG_CONFIG_SYSROOT_DIR)/usr/include/glib-2.0 -I$(PKG_CONFIG_SYSROOT_DIR)/usr/lib/x86_64-linux-gnu/glib-2.0/include -I$(PKG_CONFIG_SYSROOT_DIR)/usr/local/lib -I$(PKG_CONFIG_SYSROOT_DIR)$(includedir)/gtest -I${top_srcdir}/gtest/include -I${top_srcdir}/source/include -I${top_srcdir}/source -I${top_srcdir}/source/test/mocks -I${top_srcdir}/source/test/rbus -I${top_srcdir}/source/test/rdk_logger -I${top_srcdir}/include -I${top_srcdir}/source/utils -I${top_srcdir}/source/privacycontrol -I${PKG_CONFIG_SYSROOT_DIR}$(includedir)/rbus -I${top_srcdir}/source/dcautil -I${top_srcdir}/source/ccspinterface -I${top_srcdir}/source/reportgen -I${top_srcdir}/source/xconf-client -I${top_srcdir}/source/protocol/http -I${top_srcdir}/source/protocol/rbusMethod -I${top_srcdir}/source/t2parser -I${top_srcdir}/source/bulkdata -I${top_srcdir}/source/scheduler -I${top_srcdir}/source/ccspinterface -I${PKG_CONFIG_SYSROOT_DIR}$(includedir) -I${PKG_CONFIG_SYSROOT_DIR}/usr/src/googletest/googlemock/include -I${RDK_PROJECT_ROOT_PATH}/$(GLIB_CFLAGS) -I${PKG_CONFIG_SYSROOT_DIR}$(includedir)/glib-2.0 -I${PKG_CONFIG_SYSROOT_DIR}$(libdir)/glib-2.0/include
5759

58-
profile_gtest_bin_SOURCES = gtest_main.cpp ../mocks/SystemMock.cpp ../mocks/FileioMock.cpp ../mocks/rdklogMock.cpp ../mocks/rbusMock.cpp ../mocks/rdkconfigMock.cpp ../mocks/VectorMock.cpp SchedulerMock.cpp ../../bulkdata/profile.c profileTest.cpp ../../utils/persistence.c ../../utils/t2common.c ../../utils/t2collection.c ../../utils/t2MtlsUtils.c ../../utils/t2log_wrapper.c ../../dcautil/dcautil.c ../../dcautil/dca.c ../../dcautil/legacyutils.c ../../dcautil/dcaproc.c ../../xconf-client/xconfclient.c ../../protocol/rbusMethod/rbusmethodinterface.c ../../privacycontrol/rdkservices_privacyutils.c ../../reportgen/reportgen.c ../../bulkdata/t2eventreceiver.c ../../bulkdata/t2markers.c ../../t2parser/t2parser.c ../../bulkdata/datamodel.c ../../t2parser/t2parserxconf.c ../../bulkdata/reportprofiles.c ../../bulkdata/profilexconf.c ../../ccspinterface/rbusInterface.c ../../ccspinterface/busInterface.c ../../protocol/http/curlinterface.c ../../protocol/http/multicurlinterface.c
60+
profile_gtest_bin_SOURCES = gtest_main.cpp ../mocks/SystemMock.cpp ../mocks/FileioMock.cpp ../mocks/rdklogMock.cpp ../mocks/rbusMock.cpp ../mocks/rdkconfigMock.cpp ../mocks/VectorMock.cpp SchedulerMock.cpp profileMock.cpp ../../bulkdata/profile.c profileTest.cpp ../../utils/persistence.c ../../utils/t2common.c ../../utils/t2collection.c ../../utils/t2MtlsUtils.c ../../utils/t2log_wrapper.c ../../dcautil/dcautil.c ../../dcautil/dca.c ../../dcautil/legacyutils.c ../../dcautil/dcaproc.c ../../xconf-client/xconfclient.c ../../protocol/rbusMethod/rbusmethodinterface.c ../../privacycontrol/rdkservices_privacyutils.c ../../reportgen/reportgen.c ../../bulkdata/t2eventreceiver.c ../../bulkdata/t2markers.c ../../t2parser/t2parser.c ../../bulkdata/datamodel.c ../../t2parser/t2parserxconf.c ../../bulkdata/reportprofiles.c ../../bulkdata/profilexconf.c ../../ccspinterface/rbusInterface.c ../../ccspinterface/busInterface.c ../../protocol/http/curlinterface.c ../../protocol/http/multicurlinterface.c
5961

6062
profile_gtest_bin_LDFLAGS = -L/usr/src/googletest/googletest/lib/.libs -lgcov -L/src/googletest/googlemock/lib -L/usr/src/googletest/googlemock/lib/.libs -L/usr/include/glib-2.0 -lgmock -lcjson -lcurl -lmsgpackc -lgtest -lgtest_main -lglib-2.0
6163

62-
# Test binary for reportprofiles.c
64+
profile_gtest_bin_LDFLAGS += -Wl,--wrap=sendReportOverHTTP -Wl,--wrap=sendCachedReportsOverHTTP
65+
66+
reportprofiles_gtest_bin_CFLAGS = -DGTEST_ENABLE
6367

6468
reportprofiles_gtest_bin_CPPFLAGS = -I$(PKG_CONFIG_SYSROOT_DIR)/usr/include/gtest -I$(PKG_CONFIG_SYSROOT_DIR)/usr/include/glib-2.0 -I$(PKG_CONFIG_SYSROOT_DIR)/usr/lib/x86_64-linux-gnu/glib-2.0/include -I$(PKG_CONFIG_SYSROOT_DIR)/usr/local/lib -I$(PKG_CONFIG_SYSROOT_DIR)$(includedir)/gtest -I${top_srcdir}/gtest/include -I${top_srcdir}/source/include -I${top_srcdir}/source -I${top_srcdir}/source/test/mocks -I${top_srcdir}/source/test/rbus -I${top_srcdir}/source/test/rdk_logger -I${top_srcdir}/include -I${top_srcdir}/source/utils -I${top_srcdir}/source/privacycontrol -I${PKG_CONFIG_SYSROOT_DIR}$(includedir)/rbus -I${top_srcdir}/source/dcautil -I${top_srcdir}/source/ccspinterface -I${top_srcdir}/source/reportgen -I${top_srcdir}/source/xconf-client -I${top_srcdir}/source/protocol/http -I${top_srcdir}/source/protocol/rbusMethod -I${top_srcdir}/source/t2parser -I${top_srcdir}/source/bulkdata -I${top_srcdir}/source/scheduler -I${top_srcdir}/source/ccspinterface -I${PKG_CONFIG_SYSROOT_DIR}$(includedir) -I${PKG_CONFIG_SYSROOT_DIR}/usr/src/googletest/googlemock/include -I${RDK_PROJECT_ROOT_PATH}/$(GLIB_CFLAGS) -I${PKG_CONFIG_SYSROOT_DIR}$(includedir)/glib-2.0 -I${PKG_CONFIG_SYSROOT_DIR}$(libdir)/glib-2.0/include
6569

6670
reportprofiles_gtest_bin_SOURCES = gtest_main.cpp ../mocks/SystemMock.cpp ../mocks/FileioMock.cpp ../mocks/rdklogMock.cpp ../mocks/rbusMock.cpp ../mocks/rdkconfigMock.cpp ../mocks/VectorMock.cpp SchedulerMock.cpp reportprofileMock.cpp ../../bulkdata/reportprofiles.c reportprofilesTest.cpp ../../utils/persistence.c ../../utils/t2common.c ../../utils/t2collection.c ../../utils/t2MtlsUtils.c ../../utils/t2log_wrapper.c ../../dcautil/dcautil.c ../../dcautil/dca.c ../../dcautil/legacyutils.c ../../dcautil/dcaproc.c ../../xconf-client/xconfclient.c ../../protocol/rbusMethod/rbusmethodinterface.c ../../privacycontrol/rdkservices_privacyutils.c ../../reportgen/reportgen.c ../../bulkdata/t2eventreceiver.c ../../bulkdata/t2markers.c ../../t2parser/t2parser.c ../../bulkdata/datamodel.c ../../t2parser/t2parserxconf.c ../../bulkdata/profile.c ../../bulkdata/profilexconf.c ../../ccspinterface/rbusInterface.c ../../ccspinterface/busInterface.c ../../protocol/http/curlinterface.c ../../protocol/http/multicurlinterface.c
6771

6872
reportprofiles_gtest_bin_LDFLAGS = -L/usr/src/googletest/googletest/lib/.libs -L/usr/src/googletest/googlemock/lib/.libs -lgmock -lgtest -lpthread -lcjson -lmsgpackc -lglib-2.0 -lrt -lcurl
6973

70-
reportprofiles_gtest_bin_LDFLAGS += -Wl,--wrap=isRbusEnabled
74+
reportprofiles_gtest_bin_LDFLAGS += -Wl,--wrap=isRbusEnabled -Wl,--wrap=sendReportOverHTTP -Wl,--wrap=sendCachedReportsOverHTTP
7175

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright 2020 Comcast Cable Communications Management, LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* SPDX-License-Identifier: Apache-2.0
17+
*/
18+
#include <stdbool.h>
19+
#include <cjson/cJSON.h>
20+
#include "vector.h"
21+
#include "msgpack.h"
22+
#include "test/bulkdata/profileMock.h"
23+
24+
25+
//protocol mock functions
26+
extern "C" T2ERROR __wrap_sendReportOverHTTP(char *httpUrl, char *payload)
27+
{
28+
if(!g_profileMock)
29+
{
30+
return T2ERROR_FAILURE;
31+
}
32+
// No mock function needed, just a stub
33+
return g_profileMock->sendReportOverHTTP(httpUrl, payload);
34+
}
35+
36+
extern "C" T2ERROR __wrap_sendCachedReportsOverHTTP(char *httpUrl, Vector *reportList)
37+
{
38+
if(!g_profileMock)
39+
{
40+
return T2ERROR_FAILURE;
41+
}
42+
// No mock function needed, just a stub
43+
return g_profileMock->sendCachedReportsOverHTTP(httpUrl, reportList);
44+
}
45+

source/test/bulkdata/profileMock.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright 2020 Comcast Cable Communications Management, LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* SPDX-License-Identifier: Apache-2.0
17+
*/
18+
//#ifndef SOURCE_TEST_MOCKS_SYSTEMMOCK_H_
19+
//#define SOURCE_TEST_MOCKS_SYSTEMMOCK_H_
20+
21+
#include <gtest/gtest.h>
22+
#include <gmock/gmock.h>
23+
#include "telemetry2_0.h"
24+
25+
26+
class profileMock
27+
{
28+
public:
29+
30+
MOCK_METHOD(T2ERROR, sendReportOverHTTP, (char *httpUrl, char *payload), ());
31+
MOCK_METHOD(T2ERROR, sendCachedReportsOverHTTP, (char *httpUrl, Vector *reportList), ());
32+
};
33+
34+
extern profileMock *g_profileMock;
35+

source/test/bulkdata/profileTest.cpp

Lines changed: 100 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "test/mocks/rdkconfigMock.h"
1818
#include "test/mocks/VectorMock.h"
1919
#include "test/bulkdata/SchedulerMock.h"
20+
#include "test/bulkdata/profileMock.h"
2021

2122
using namespace std;
2223

@@ -34,6 +35,8 @@ extern "C" {
3435
#include "profilexconf.h"
3536
#include "t2eventreceiver.h"
3637
#include "msgpack.h"
38+
#include <glib.h>
39+
#include <glib/gi18n.h>
3740

3841
extern bool initialized;
3942

@@ -46,6 +49,7 @@ SystemMock * g_systemMock = NULL;
4649
rdklogMock *m_rdklogMock = NULL;
4750
rbusMock *g_rbusMock = NULL;
4851
rdkconfigMock *g_rdkconfigMock = nullptr;
52+
profileMock *g_profileMock = nullptr;
4953
extern VectorMock *g_vectorMock;
5054
extern SchedulerMock *g_schedulerMock;
5155

@@ -59,6 +63,7 @@ class ProfileTest : public ::testing::Test {
5963
g_rdkconfigMock = new rdkconfigMock();
6064
g_vectorMock = new VectorMock();
6165
g_schedulerMock = new SchedulerMock();
66+
g_profileMock = new profileMock();
6267
}
6368
void TearDown() override
6469
{
@@ -68,13 +73,15 @@ class ProfileTest : public ::testing::Test {
6873
delete g_rdkconfigMock;
6974
delete g_vectorMock;
7075
delete g_schedulerMock;
76+
delete g_profileMock;
7177

7278
g_fileIOMock = nullptr;
7379
g_systemMock = nullptr;
7480
g_rbusMock = nullptr;
7581
g_rdkconfigMock = nullptr;
7682
g_vectorMock = nullptr;
7783
g_schedulerMock = nullptr;
84+
g_profileMock = nullptr;
7885
}
7986
};
8087

@@ -859,12 +866,81 @@ TEST_F(ProfileTest, deleteAllReportProfiles) {
859866
EXPECT_EQ(deleteAllReportProfiles(), T2ERROR_SUCCESS);
860867
}
861868

869+
#ifdef GTEST_ENABLE
870+
extern "C" {
871+
typedef void* (*reportOnDemandFunc)(void*);
872+
reportOnDemandFunc reportOnDemandFuncCallback(void);
873+
typedef void (*freeProfilesHashMapFunc)(void *);
874+
freeProfilesHashMapFunc freeProfilesHashMapFuncCallback(void);
875+
typedef void (*freeReportProfileHashMapFunc)(void *);
876+
freeReportProfileHashMapFunc freeReportProfileHashMapFuncCallback(void);
877+
typedef void (*__msgpack_free_blobFunc)(void*);
878+
__msgpack_free_blobFunc __msgpack_free_blobFuncCallback(void);
879+
}
880+
881+
TEST(ReportProfilesCallbacks, FreeProfilesHashMap) {
882+
auto cb = freeProfilesHashMapFuncCallback();
883+
ASSERT_NE(cb, nullptr);
884+
885+
// Test with an actual element
886+
hash_element_t* item = (hash_element_t*) std::malloc(sizeof(hash_element_t));
887+
item->key = (char*) std::malloc(12);
888+
std::strcpy(item->key, "testkey");
889+
item->data = std::malloc(8);
890+
cb(item);
891+
892+
// Test with nullptr
893+
cb(nullptr);
894+
}
895+
TEST_F(ProfileTest, reportOnDemandTest)
896+
{
897+
reportOnDemandFunc func = reportOnDemandFuncCallback();
898+
ASSERT_NE(func,nullptr);
899+
func((void*)"ABORT");
900+
func((void*)"FOO");
901+
func(nullptr);
902+
}
903+
904+
TEST(ReportProfilesCallbacks, FreeReportProfileHashMap) {
905+
auto cb = freeReportProfileHashMapFuncCallback();
906+
ASSERT_NE(cb, nullptr);
907+
908+
// Make an item with ReportProfile-like .data
909+
hash_element_t* item = (hash_element_t*) std::malloc(sizeof(hash_element_t));
910+
item->key = (char*) std::malloc(12);
911+
std::strcpy(item->key, "profkey");
912+
struct ReportProfile {
913+
char* hash;
914+
char* config;
915+
void* hash_map_pad; // just to align with how your system might fill it, can be omitted
916+
};
917+
ReportProfile* rp = (ReportProfile*) std::malloc(sizeof(ReportProfile));
918+
rp->hash = (char*) std::malloc(6);
919+
std::strcpy(rp->hash, "hashV");
920+
rp->config = (char*) std::malloc(8);
921+
std::strcpy(rp->config, "cfgVal");
922+
item->data = rp;
923+
924+
cb(item);
925+
926+
// Safe to call with nullptr
927+
cb(nullptr);
928+
SUCCEED();
929+
}
930+
#endif
862931
#endif
863932

864933
#if 1
865934
//comment
866935
//=================================== profilexconf.c ================================
867936

937+
938+
#ifdef GTEST_ENABLE
939+
extern "C" {
940+
void test_set_reportThreadExits(bool value);
941+
}
942+
#endif
943+
868944
TEST_F(ProfileTest, InitAndUninit) {
869945
// Covers ProfileXConf_init and ProfileXConf_uninit
870946
#if 1
@@ -909,11 +985,21 @@ TEST_F(ProfileTest, SetAndIsSet) {
909985
profile->cachedReportList = nullptr;
910986
profile->protocol = strdup("HTTP");
911987
profile->encodingType = strdup("JSON");
912-
profile->t2HTTPDest = nullptr;
913-
profile->grepSeekProfile = nullptr;
988+
profile->jsonReportObj = nullptr; // types now match
989+
profile->checkPreviousSeek = true;
990+
991+
profile->t2HTTPDest = (T2HTTP *)malloc(sizeof(T2HTTP));
992+
profile->t2HTTPDest->URL = strdup("https://mock1xconf:50051/dataLakeMockXconf");
993+
profile->isUpdated = true;
994+
GrepSeekProfile *gsProfile = (GrepSeekProfile *)malloc(sizeof(GrepSeekProfile));
995+
if (gsProfile)
996+
{
997+
gsProfile->logFileSeekMap = hash_map_create();
998+
gsProfile->execCounter = 0;
999+
}
1000+
profile->grepSeekProfile = gsProfile;
1001+
//profile->grepSeekProfile = nullptr;
9141002
profile->reportInProgress = false;
915-
profile->isUpdated = false;
916-
9171003
EXPECT_CALL(*g_vectorMock, Vector_Size(_))
9181004
.Times(::testing::AtMost(3))
9191005
.WillRepeatedly(Return(0)); // Return 1 to indicate one profile in the list
@@ -926,26 +1012,29 @@ TEST_F(ProfileTest, SetAndIsSet) {
9261012
EXPECT_CALL(*g_vectorMock, Vector_PushBack(_, _))
9271013
.Times(::testing::AtMost(3))
9281014
.WillRepeatedly(Return(T2ERROR_SUCCESS));
929-
1015+
9301016
// Scheduler mock expectations - ProfileXConf_set calls registerProfileWithScheduler
9311017
EXPECT_CALL(*g_schedulerMock, registerProfileWithScheduler(_, _, _, _, _, _, _, _))
9321018
.Times(::testing::AtMost(1))
9331019
.WillRepeatedly(Return(T2ERROR_SUCCESS));
934-
1020+
9351021
EXPECT_EQ(ProfileXConf_set(profile), T2ERROR_SUCCESS);
9361022
EXPECT_TRUE(ProfileXConf_isSet());
9371023

1024+
9381025
// Get name
9391026
char* name = ProfileXconf_getName();
9401027
ASSERT_NE(name, nullptr);
9411028
EXPECT_STREQ(name, "TestProfile");
9421029
free(name);
9431030

944-
// Clean up - ProfileXConf_uninit calls unregisterProfileFromScheduler
945-
EXPECT_CALL(*g_schedulerMock, unregisterProfileFromScheduler(_))
946-
.Times(::testing::AtMost(1))
947-
.WillRepeatedly(Return(T2ERROR_SUCCESS));
948-
1031+
test_set_reportThreadExits(true);
1032+
generateDcaReport(false,true);
1033+
EXPECT_CALL(*g_schedulerMock, SendInterruptToTimeoutThread(_))
1034+
.Times(::testing::AtMost(1));
1035+
1036+
ReportProfiles_Interrupt();
1037+
9491038
EXPECT_EQ(ProfileXConf_uninit(), T2ERROR_SUCCESS);
9501039
}
9511040

0 commit comments

Comments
 (0)