RDK Documentation (Open Sourced RDK Components)
rdk_dynamic_logger_test.c
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2016 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 #include<stdio.h>
21 #include "libIBus.h"
22 #include "rdk_log_reg.h"
23 
24 
25 /*
26 To build the test app, add test folder to the below lines
27 SUBDIRS = src include test
28 DIST_SUBDIRS = cfg src include test
29 To the file rdk_logger/generic/Makefile.am
30 
31 How to test :
32 
33 1. Run the test App dynamicLoggerTest in the box.
34 The binary can be copied to the box after compiling the test code by doing a bitbake for rdk-logger
35 with the above changes.
36 2. The test application has registered for dynamic logging updates with
37 Application Name :
38  Application1
39 Module Name ------ SubModule Name ------ Registered Callback
40 ClosedCaptions1 NULL CC_LOG_ControlCB1
41 ClosedCaptions2 NULL CC_LOG_ControlCB2
42 ServiceManager devicesettings CC_LOG_ControlCB3
43 ServiceManager hdmicec CC_LOG_ControlCB4
44 
45 Or
46 
47 Application Name :
48  Application2
49 Module Name ------ SubModule Name ------ Registered Callback
50 ClosedCaptions1 NULL CC_LOG_CallBack1
51 ClosedCaptions2 NULL CC_LOG_CallBack2
52 ServiceManager devicesettings CC_LOG_CallBack3
53 ServiceManager hdmicec CC_LOG_CallBack4
54 
55 3. Execute the rdklogctrl tool with proper input parameters and check whether the
56 test application is showing correct print.
57 
58 eg. If we execute the tool with following parameters
59 ./rdklogctrl Application1 ClosedCaptions1 NULL DEBUG ON
60 
61 The test application will print
62 TEST : CC_LOG_ControlCB1 called for ClosedCaptions1
63 TEST : ##############Data obtained ################
64 TEST : moduleName : ClosedCaptions1 subComponentName : NULL loggingLevel : DEBUG log_status : 1
65 
66 Similarly different combinations of input parameters can be tested.
67 
68 */
69 
70 void CC_LOG_ControlCB1(const char *moduleName, const char *subComponentName, const char *loggingLevel, int log_status)
71 {
72  printf("TEST : CC_LOG_ControlCB1 called for ClosedCaptions1\n");
73  printf("TEST : ##############Data obtained ################\n");
74  printf("TEST : moduleName : %s subComponentName : %s loggingLevel : %s log_status : %d\n",moduleName,subComponentName,loggingLevel,log_status);
75 }
76 void CC_LOG_ControlCB2(const char *moduleName, const char *subComponentName, const char *loggingLevel, int log_status)
77 {
78  printf("TEST : CC_LOG_ControlCB2 called for ClosedCaptions2\n");
79  printf("TEST : ##############Data obtained ################\n");
80  printf("TEST : moduleName : %s subComponentName : %s loggingLevel : %s log_status : %d\n",moduleName,subComponentName,loggingLevel,log_status);
81 }
82 void CC_LOG_ControlCB3(const char *moduleName, const char *subComponentName, const char *loggingLevel, int log_status)
83 {
84  printf("TEST : CC_LOG_ControlCB3 called for ServiceManager devicesettings\n");
85  printf("TEST : ##############Data obtained ################\n");
86  printf("TEST : moduleName : %s subComponentName : %s loggingLevel : %s log_status : %d\n",moduleName,subComponentName,loggingLevel,log_status);
87 }
88 void CC_LOG_ControlCB4(const char *moduleName, const char *subComponentName, const char *loggingLevel, int log_status)
89 {
90  printf("TEST : CC_LOG_ControlCB4 called for ServiceManager hdmicec\n");
91  printf("TEST : ##############Data obtained ################\n");
92  printf("TEST : moduleName : %s subComponentName : %s loggingLevel : %s log_status : %d\n",moduleName,subComponentName,loggingLevel,log_status);
93 }
94 void CC_LOG_CallBack1(const char *moduleName, const char *subComponentName, const char *loggingLevel, int log_status)
95 {
96  printf("TEST : CC_LOG_CallBack1 called for ClosedCaptions1\n");
97  printf("TEST : ##############Data obtained ################\n");
98  printf("TEST : moduleName : %s subComponentName : %s loggingLevel : %s log_status : %d\n",moduleName,subComponentName,loggingLevel,log_status);
99 }
100 void CC_LOG_CallBack2(const char *moduleName, const char *subComponentName, const char *loggingLevel, int log_status)
101 {
102  printf("TEST : CC_LOG_CallBack2 called for ClosedCaptions2\n");
103  printf("TEST : ##############Data obtained ################\n");
104  printf("TEST : moduleName : %s subComponentName : %s loggingLevel : %s log_status : %d\n",moduleName,subComponentName,loggingLevel,log_status);
105 }
106 void CC_LOG_CallBack3(const char *moduleName, const char *subComponentName, const char *loggingLevel, int log_status)
107 {
108  printf("TEST : CC_LOG_CallBack3 called for ServiceManager devicesettings\n");
109  printf("TEST : ##############Data obtained ################\n");
110  printf("TEST : moduleName : %s subComponentName : %s loggingLevel : %s log_status : %d\n",moduleName,subComponentName,loggingLevel,log_status);
111 }
112 void CC_LOG_CallBack4(const char *moduleName, const char *subComponentName, const char *loggingLevel, int log_status)
113 {
114  printf("TEST : CC_LOG_CallBack4 called for ServiceManager hdmicec\n");
115  printf("TEST : ##############Data obtained ################\n");
116  printf("TEST : moduleName : %s subComponentName : %s loggingLevel : %s log_status : %d\n",moduleName,subComponentName,loggingLevel,log_status);
117 }
118 
119 #define IARM_BUS_DYNAMIC_LOGGER_TESTAPP "LOG_TESTER"
120 
121 void main()
122 {
123  IARM_Bus_Init(IARM_BUS_DYNAMIC_LOGGER_TESTAPP);
125  rdk_logger_initialize();
126  int i;
127 
128  printf("Thanks for using Dynamic Logger TestApp \n");
129  printf("Please select the App name\n 1 - Application1 2 - Application2 \n");
130  scanf("%d", &i);
131 
132  switch(i)
133  {
134  case 1:
135 
136  printf("Registering app Application1 \n");
137  rdk_logger_setAppName("Application1");
138  rdk_logger_registerLogCtrlComp("ClosedCaption1", NULL, CC_LOG_ControlCB1);
139  rdk_logger_registerLogCtrlComp("ClosedCaption2", NULL, CC_LOG_ControlCB2);
140  rdk_logger_registerLogCtrlComp("ServiceManager", "devicesettings", CC_LOG_ControlCB3);
141  rdk_logger_registerLogCtrlComp("ServiceManager", "hdmicec", CC_LOG_ControlCB4);
142 
143  break;
144 
145  case 2 :
146 
147  printf("Registering app Application2 \n");
148  rdk_logger_setAppName("Application2");
149  rdk_logger_registerLogCtrlComp("ClosedCaption1", NULL, CC_LOG_CallBack1);
150  rdk_logger_registerLogCtrlComp("ClosedCaption2", NULL, CC_LOG_CallBack2);
151  rdk_logger_registerLogCtrlComp("ServiceManager", "devicesettings", CC_LOG_CallBack3);
152  rdk_logger_registerLogCtrlComp("ServiceManager", "hdmicec", CC_LOG_CallBack4);
153 
154  break;
155 
156  default:
157  break;
158  }
159  while(1)
160  {
161  sleep(10);
162  }
163 
164  rdk_logger_unRegisterLogCtrlComp("ServiceManager", "hdmicec");
165  rdk_logger_unRegisterLogCtrlComp("ClosedCaption2", NULL);
166  rdk_logger_unRegisterLogCtrlComp("ClosedCaption1", NULL);
167  rdk_logger_unRegisterLogCtrlComp("ServiceManager", "devicesettings");
168 
169  rdk_logger_unInitialize();
171  IARM_Bus_Term();
172  return;
173 }
IARM_Bus_Term
IARM_Result_t IARM_Bus_Term(void)
This API is used to terminate the IARM-Bus library.
IARM_Bus_Disconnect
IARM_Result_t IARM_Bus_Disconnect(void)
This API disconnect Application from IARM Bus so the application will not receive any IARM event or R...
libIBus.h
RDK IARM-Bus API Declarations.
IARM_Bus_Connect
IARM_Result_t IARM_Bus_Connect(void)
This API is used to connect application to the IARM bus daemon. After connected, the application can ...
Definition: iarmMgrMocks.cpp:33
IARM_Bus_Init
IARM_Result_t IARM_Bus_Init(const char *name)
This API is used to initialize the IARM-Bus library.
Definition: iarmMgrMocks.cpp:38