[VOL-1787] :
This commit sets up a unit-test framework for openolt
agent based on gtest, gmock and c-mock utilities.
A sample unit-test case to test EnableOlt success case is also
added. More test cases will be added in future commit.
Change-Id: If020be489a04d97df5fcbc15e9207deeee2fcfac
diff --git a/agent/src/core.cc b/agent/src/core.cc
index a2da56d..9f30bde 100644
--- a/agent/src/core.cc
+++ b/agent/src/core.cc
@@ -39,18 +39,22 @@
#include <bcmolt_api.h>
#include <bcmolt_host_api.h>
#include <bcmolt_api_model_supporting_enums.h>
+
#include <bal_version.h>
#include <bcmolt_api_conn_mgr.h>
//CLI header files
#include <bcmcli_session.h>
#include <bcmcli.h>
#include <bcm_api_cli.h>
+
#include <bcmos_common.h>
#include <bcm_config.h>
// FIXME : dependency problem
// #include <bcm_common_gpon.h>
// #include <bcm_dev_log_task.h>
}
+
+
dev_log_id openolt_log_id = bcm_dev_log_id_register("OPENOLT", DEV_LOG_LEVEL_INFO, DEV_LOG_ID_TYPE_BOTH);
dev_log_id omci_log_id = bcm_dev_log_id_register("OMCI", DEV_LOG_LEVEL_INFO, DEV_LOG_ID_TYPE_BOTH);
@@ -737,7 +741,6 @@
bcmos_errno err;
bcmolt_host_init_parms init_parms = {};
init_parms.transport.type = BCM_HOST_API_CONN_LOCAL;
- bcmcli_session_parm mon_session_parm;
if (!state.is_activated()) {
@@ -749,6 +752,7 @@
return bcm_to_grpc_err(err, "Failed to init OLT");
}
+ bcmcli_session_parm mon_session_parm;
/* Create CLI session */
memset(&mon_session_parm, 0, sizeof(mon_session_parm));
mon_session_parm.get_prompt = openolt_cli_get_prompt_cb;
@@ -803,8 +807,9 @@
BCMOLT_MSG_FIELD_SET (&oper, system_mode, BCMOLT_SYSTEM_MODE_GPON__16_X);
}
err = bcmolt_oper_submit(dev_id, &oper.hdr);
- if (err)
- OPENOLT_LOG(ERROR, openolt_log_id, "Enable PON deivce %d failed\n", dev);
+ if (err) {
+ OPENOLT_LOG(ERROR, openolt_log_id, "Enable PON device %d failed, err %d\n", dev, err);
+ }
bcmos_usleep(200000);
}
else {
diff --git a/agent/src/stats_collection.cc b/agent/src/stats_collection.cc
index 693c782..2d535cf 100644
--- a/agent/src/stats_collection.cc
+++ b/agent/src/stats_collection.cc
@@ -77,13 +77,14 @@
openolt::PortStatistics* collectPortStatistics(bcmolt_intf_ref intf_ref) {
+ openolt::PortStatistics* port_stats = get_default_port_statistics();
+#ifndef TEST_MODE
bcmos_errno err;
bcmolt_stat_flags clear_on_read = BCMOLT_STAT_FLAGS_NONE;
bcmolt_nni_interface_stats nni_stats;
bcmolt_onu_itu_pon_stats pon_stats;
bcmolt_pon_interface_itu_pon_stats itu_pon_stats;
- openolt::PortStatistics* port_stats = get_default_port_statistics();
switch (intf_ref.intf_type) {
case BCMOLT_INTERFACE_TYPE_NNI:
@@ -177,7 +178,7 @@
time_t now;
time(&now);
port_stats->set_timestamp((int)now);
-
+#endif
return port_stats;
}
diff --git a/agent/src/translation.cc b/agent/src/translation.cc
index 4a84385..2c82f58 100644
--- a/agent/src/translation.cc
+++ b/agent/src/translation.cc
@@ -15,6 +15,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <string.h>
#include "translation.h"
int interface_key_to_port_no(bcmolt_interface_id intf_id,
diff --git a/agent/src/utils.cc b/agent/src/utils.cc
index d748ce3..9fde90e 100644
--- a/agent/src/utils.cc
+++ b/agent/src/utils.cc
@@ -15,6 +15,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <string.h>
#include "utils.h"
std::string serial_number_to_str(bcmolt_serial_number* serial_number) {