Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build_inside_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ autoreconf --install
# FLags to print compiler warnings
DEBUG_CFLAGS="-Wall -Werror -Wextra"

export CFLAGS=" ${DEBUG_CFLAGS} -I${INSTALL_DIR}/include/rtmessage -I${INSTALL_DIR}/include/msgpack -I${INSTALL_DIR}/include/rbus -I${INSTALL_DIR}/include -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/local/include -DFEATURE_SUPPORT_WEBCONFIG -DRDK_LOGGER -DPERSIST_LOG_MON_REF"
export CFLAGS=" ${DEBUG_CFLAGS} -I${INSTALL_DIR}/include/rtmessage -I${INSTALL_DIR}/include/msgpack -I${INSTALL_DIR}/include/rbus -I${INSTALL_DIR}/include -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/local/include -DFEATURE_SUPPORT_WEBCONFIG -DRDK_LOGGER -DPERSIST_LOG_MON_REF -DDCMAGENT"

export LDFLAGS="-L/usr/lib/x86_64-linux-gnu -lglib-2.0"

Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ AC_ARG_ENABLE([gtestapp],
case "${enableval}" in
yes) GTEST_SUPPORT_ENABLED=true
GTEST_ENABLE_FLAG=" -DGTEST_ENABLE"
m4_if(m4_sysval,[0],[AC_CONFIG_FILES([source/test/Makefile source/test/dcautils/Makefile source/test/t2parser/Makefile source/test/scheduler/Makefile source/test/reportgen/Makefile])]);;
m4_if(m4_sysval,[0],[AC_CONFIG_FILES([source/test/Makefile source/test/dcautils/Makefile source/test/t2parser/Makefile source/test/scheduler/Makefile source/test/reportgen/Makefile source/test/bulkdata/Makefile source/test/ccspinterface/Makefile])]);;
no) GTEST_SUPPORT_ENABLED=false AC_MSG_ERROR([Gtest support is disabled]);;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-gtestapp ]);;
esac
Expand Down
8 changes: 8 additions & 0 deletions include/telemetry_busmessage_sender.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ T2ERROR t2_event_d(const char* marker, int value);
*/
void t2_uninit(void);


/*
* NAME : filtered_event_send
* DESCRIPTION :
*
*/
int filtered_event_send(const char* data, const char *markerName);

#ifdef __cplusplus
}
#endif
Expand Down
5 changes: 5 additions & 0 deletions source/bulkdata/profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,9 @@ unsigned int getMinThresholdDuration(char *profileName);
void reportGenerationCompleteReceiver(char* profileName);

void NotifySchedulerstart(char* profileName, bool isschedulerstarted);

T2ERROR appendTriggerCondition (Profile *tempProfile, const char *referenceName, const char *referenceValue);

T2ERROR ReportProfiles_addReportProfile(Profile *profile);
T2ERROR RemovePreRPfromDisk(const char* path, hash_map_t *map);
#endif /* _PROFILE_H_ */
4 changes: 4 additions & 0 deletions source/bulkdata/profilexconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,9 @@ T2ERROR ProfileXConf_storeMarkerEvent(T2Event *eventInfo);
char* ProfileXconf_getName();
T2ERROR ProfileXConf_terminateReport();

T2ERROR ReportProfiles_setProfileXConf(ProfileXConf *profile);

T2ERROR ReportProfiles_deleteProfileXConf(ProfileXConf *profile);


#endif /* _PROFILE_H_ */
7 changes: 7 additions & 0 deletions source/bulkdata/reportprofiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <stdbool.h>
#include <cjson/cJSON.h>
#include "telemetry2_0.h"
#include "t2eventreceiver.h"

//Including Webconfig Framework For Telemetry 2.0 As part of RDKB-28897
#if defined(FEATURE_SUPPORT_WEBCONFIG)
Expand Down Expand Up @@ -104,6 +105,12 @@ int __ReportProfiles_ProcessReportProfilesMsgPackBlob(void *msgpack, bool checkP

void ReportProfiles_ProcessReportProfilesMsgPackBlob(char *msgpack_blob, int msgpack_blob_size);

T2ERROR ReportProfiles_storeMarkerEvent(char *profileName, T2Event *eventInfo);

T2ERROR privacymode_do_not_share ();

T2ERROR ReportProfiles_deleteProfile(const char* profileName);

bool isMtlsEnabled(void);

void profilemem_usage(unsigned int *value);
Expand Down
8 changes: 8 additions & 0 deletions source/bulkdata/t2eventreceiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,12 @@ T2ERROR T2ER_StartDispatchThread();

T2ERROR T2ER_StopDispatchThread();

void freeT2Event(void *data);

void* T2ER_EventDispatchThread(void *arg);

void T2ER_PushDataWithDelim(char* eventInfo, char* user_data);

void T2ER_Push(char* eventName, char* eventValue);

#endif /* SOURCE_BULKDATA_T2EVENTRECEIVER_H_ */
2 changes: 2 additions & 0 deletions source/bulkdata/t2markers.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ T2ERROR destroyT2MarkerComponentMap();

T2ERROR clearT2MarkerComponentMap();

T2ERROR updateEventMap(const char* markerName, T2Marker* t2Marker);

T2ERROR addT2EventMarker(const char* markerName, const char* compName, const char *profileName, unsigned int skipFreq);

void getComponentMarkerList(const char* compName, void **markerList);
Expand Down
10 changes: 10 additions & 0 deletions source/ccspinterface/rbusInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@
#include "busInterface.h"
#include "telemetry2_0.h"

bool isRbusInitialized( );

void logHandler(rbusLogLevel level, const char* file, int line, int threadId, char* message);

rbusError_t eventSubHandler(rbusHandle_t handle, rbusEventSubAction_t action, const char* eventName, rbusFilter_t* filter, int interval, bool* autoPublish);

void publishReportUploadStatus(char* status);

void setT2EventReceiveState(int T2_STATE);

typedef void (*rbusMethodCallBackPtr) (rbusHandle_t handle, char const* methodName, rbusError_t retStatus, rbusObject_t params);

T2ERROR getRbusParameterVal(const char* paramName, char **paramValue);
Expand Down
2 changes: 1 addition & 1 deletion source/test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
AUTOMAKE_OPTIONS = subdir-objects


SUBDIRS = t2parser reportgen scheduler dcautils
SUBDIRS = bulkdata t2parser reportgen scheduler dcautils ccspinterface
35 changes: 35 additions & 0 deletions source/test/bulkdata/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
##########################################################################
# If not stated otherwise in this file or this component's LICENSE
# file the following copyright and licenses apply:
#
# Copyright 2018 RDK Management
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##########################################################################

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

AM_CFLAGS = -DGTEST_ENABLE -DPERSIST_LOG_MON_REF -fPIC

AUTOMAKE_OPTIONS = subdir-objects

ACLOCAL_AMFLAGS = -I m4

bin_PROGRAMS = profile_gtest.bin

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

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

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
132 changes: 132 additions & 0 deletions source/test/bulkdata/SchedulerMock.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/*
* Copyright 2020 Comcast Cable Communications Management, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include "test/bulkdata/SchedulerMock.h"

SchedulerMock* g_schedulerMock = nullptr;

extern "C" {

// Mock implementations of scheduler functions
T2ERROR initScheduler(TimeoutNotificationCB notificationCb, ActivationTimeoutCB activationCB, NotifySchedulerstartCB notifyschedulerCB)
{
if (g_schedulerMock)
{
return g_schedulerMock->initScheduler(notificationCb, activationCB, notifyschedulerCB);
}

// Fallback implementation for when mock is not set
return T2ERROR_SUCCESS;
}

void uninitScheduler()
{
if (g_schedulerMock)
{
g_schedulerMock->uninitScheduler();
return;
}

// Fallback implementation - do nothing
}

T2ERROR registerProfileWithScheduler(const char* profileName, unsigned int timeInterval, unsigned int activationTimeout, bool deleteonTimout, bool repeat, bool reportOnUpdate, unsigned int firstReportingInterval, char *timeRef)
{
if (g_schedulerMock)
{
return g_schedulerMock->registerProfileWithScheduler(profileName, timeInterval, activationTimeout, deleteonTimout, repeat, reportOnUpdate, firstReportingInterval, timeRef);
}

// Fallback implementation for when mock is not set
if (!profileName) return T2ERROR_INVALID_ARGS;
return T2ERROR_SUCCESS;
}

T2ERROR unregisterProfileFromScheduler(const char* profileName)
{
if (g_schedulerMock)
{
return g_schedulerMock->unregisterProfileFromScheduler(profileName);
}

// Fallback implementation for when mock is not set
if (!profileName) return T2ERROR_INVALID_ARGS;
return T2ERROR_SUCCESS;
}

T2ERROR SendInterruptToTimeoutThread(char* profileName)
{
if (g_schedulerMock)
{
return g_schedulerMock->SendInterruptToTimeoutThread(profileName);
}

// Fallback implementation for when mock is not set
if (!profileName) return T2ERROR_INVALID_ARGS;
return T2ERROR_SUCCESS;
}

bool get_logdemand()
{
if (g_schedulerMock)
{
return g_schedulerMock->get_logdemand();
}

// Fallback implementation for when mock is not set
return false;
}

void set_logdemand(bool value)
{
if (g_schedulerMock)
{
g_schedulerMock->set_logdemand(value);
return;
}

// Fallback implementation - do nothing
}

int getLapsedTime(struct timespec *result, struct timespec *x, struct timespec *y)
{
if (g_schedulerMock)
{
return g_schedulerMock->getLapsedTime(result, x, y);
}

// Fallback implementation for when mock is not set
if (!result || !x || !y) return -1;

// Simple fallback implementation
result->tv_sec = y->tv_sec - x->tv_sec;
result->tv_nsec = y->tv_nsec - x->tv_nsec;

if (result->tv_nsec < 0) {
result->tv_sec--;
result->tv_nsec += 1000000000;
}

return 0;
}

} // extern "C"
45 changes: 45 additions & 0 deletions source/test/bulkdata/SchedulerMock.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright 2020 Comcast Cable Communications Management, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef SOURCE_TEST_BULKDATA_SCHEDULERMOCK_H_
#define SOURCE_TEST_BULKDATA_SCHEDULERMOCK_H_

#include <gtest/gtest.h>
#include <gmock/gmock.h>

extern "C" {
#include "scheduler.h"
#include "telemetry2_0.h"
}

class SchedulerMock
{
public:
MOCK_METHOD(T2ERROR, initScheduler, (TimeoutNotificationCB notificationCb, ActivationTimeoutCB activationCB, NotifySchedulerstartCB notifyschedulerCB), ());
MOCK_METHOD(void, uninitScheduler, (), ());
MOCK_METHOD(T2ERROR, registerProfileWithScheduler, (const char* profileName, unsigned int timeInterval, unsigned int activationTimeout, bool deleteonTimout, bool repeat, bool reportOnUpdate, unsigned int firstReportingInterval, char *timeRef), ());
MOCK_METHOD(T2ERROR, unregisterProfileFromScheduler, (const char* profileName), ());
MOCK_METHOD(T2ERROR, SendInterruptToTimeoutThread, (char* profileName), ());
MOCK_METHOD(bool, get_logdemand, (), ());
MOCK_METHOD(void, set_logdemand, (bool value), ());
MOCK_METHOD(int, getLapsedTime, (struct timespec *result, struct timespec *x, struct timespec *y), ());
};

extern SchedulerMock* g_schedulerMock;

#endif // SOURCE_TEST_BULKDATA_SCHEDULERMOCK_H_
44 changes: 44 additions & 0 deletions source/test/bulkdata/gtest_main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2018 RDK Management
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <string.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <gtest/gtest.h>
#include <gmock/gmock.h>

#define GTEST_DEFAULT_RESULT_FILEPATH "/tmp/Gtest_Report/"
#define GTEST_DEFAULT_RESULT_FILENAME "bulkdata_gtest_report.json"
#define GTEST_REPORT_FILEPATH_SIZE 128

GTEST_API_ int main(int argc, char *argv[])
{
char testresults_fullfilepath[GTEST_REPORT_FILEPATH_SIZE];
char buffer[GTEST_REPORT_FILEPATH_SIZE];

memset( testresults_fullfilepath, 0, GTEST_REPORT_FILEPATH_SIZE );
memset( buffer, 0, GTEST_REPORT_FILEPATH_SIZE );

snprintf( testresults_fullfilepath, GTEST_REPORT_FILEPATH_SIZE, "json:%s%s" , GTEST_DEFAULT_RESULT_FILEPATH , GTEST_DEFAULT_RESULT_FILENAME);
::testing::InitGoogleTest(&argc, argv);
::testing::GTEST_FLAG(output) = testresults_fullfilepath;
::testing::InitGoogleMock(&argc, argv);
return RUN_ALL_TESTS();
}
Loading