VOL-2014: Rebase bal30-dev branch with master and re-verify sanity with SEBA2.0 and VOLTHA2.x before merge to master
Squashed all commits from bal30-dev branch to master branch as a single commit.
Bumped version to 2.0.0-dev .
Update README.md with the required ONL version for BAL3.1 .
VOL-2130: Wrong queue id assigned for downstream queue on tm_sched
for the subscriber when using single gem port.
Use queue_id as 0 when using single gem port.
Issues need to be taken care:
VOL-1580: Support reporting ONU Registration ID as part of ONU Activation Indication
- commented the code developed for VOL-1580 to fetch ONU registration ID as it uses BAL2.6 specific API's.
- Need to check how the same can be achieved using BAL3.x API's to fetch ONU registration ID
Set .gitreview defaultbranch to bal30-dev
Rebase change - Removed .gitreview defaultbranch so that by default it will point to master
Change-Id: Ib57e52e98cf09f4fa3dbaa9156a4375b7dc6ee43
Rebase: [VOL-1635] [BAL3.0 Bridade] OLT Activation [VOL-1636] [BAL3.0 Bridade] ONU Discovery,
This OpenOLT agent supports the BAL V3.0.3.3 SDK. OLT/ONU activation from voltha-1.7 is successful
Change-Id: I860b31317172139cd4c4244a93e79e0c3ce4fdf8
Rebase: [VOL-1685][BAL3.0 Bridade] generate OpenOLT debian package file
Change-Id: Ib0332d948602bf7892b6aae91a4147356237f7e2
Rebase: [VOL-1685][BAL3.0 Brigade] generate OpenOLT debian package file
missing copy shell files (dev_mgmt_daemon and openolt).
Change-Id: Id29dc24be4d1d5fc12a26884e5b5a69de91fbd69
Rebase: [VOL-1685][BAL3.0 Brigade] generate OpenOLT debian package file
Change-Id: Ic5453616c0dbdbc1fb1eb241feba1cbfca5e8e85
Rebase: [VOL-1852][BAL3.0 Brigade] Support Edge-core OLT ASFvOLT16 (XGS-PON) and
ASGvOLT64 (GPON) devices
Change-Id: I316d35bc76c38b5381e8896148b4ee5cebbd1099
VOL-1850: Fix packet duplication with TM Queue Mapping profile
Fix for US and DS scheduler ID allocation irrespective of device type(asfvolt16/asfvolt64)
README.md file update with BAL3.1.1.1 specifications
Change-Id: I255bf7a4ff35771e9c628bb822ba2190a1fcd5ed
Rebase: [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
Rebase: [VOL-2040]: Patch the macro required by core.cc into bcmos_system.h file
Change-Id: Ic841785b2ce451b1acaf007074b8c458687bc753
Rebase: [VOL-2043] : OLT Enable Test Case
- Added more test cases for OLT Enable. Now covers all scenarios.
- Fixed typos in unit test README.md
Change-Id: Ib931d89cedee78fe40ca67761a028365a047ebc3
Rebase: VOL-1941: Use protobufs from the voltha-protos repo, not a copy
- Use protobufs from the voltha-protos repo, not a copy
- Provided option to specify the openolt proto version via make option
- Removed duplicate README.md
Change-Id: Id67714c8119521f8358aaa9245268c47b7e843cf
diff --git a/agent/test/src/bal_mocker.cc b/agent/test/src/bal_mocker.cc
new file mode 100644
index 0000000..b38906f
--- /dev/null
+++ b/agent/test/src/bal_mocker.cc
@@ -0,0 +1,25 @@
+/*
+ Copyright (C) 2018 Open Networking Foundation
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+
+
+#include "bal_mocker.h"
+extern "C" {
+CMOCK_MOCK_FUNCTION1(BalMocker, bcmolt_host_init, bcmos_errno(bcmolt_host_init_parms*));
+CMOCK_MOCK_FUNCTION2(BalMocker, bcmolt_cfg_get, bcmos_errno(bcmolt_oltid, bcmolt_cfg*));
+CMOCK_MOCK_FUNCTION2(BalMocker, bcmolt_oper_submit, bcmos_errno(bcmolt_oltid, bcmolt_oper*));
+}
diff --git a/agent/test/src/bal_stub.cc b/agent/test/src/bal_stub.cc
new file mode 100644
index 0000000..5ab1b79
--- /dev/null
+++ b/agent/test/src/bal_stub.cc
@@ -0,0 +1,318 @@
+/*
+ Copyright (C) 2018 Open Networking Foundation
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+
+// This file stub definitions for some BAL APIs that are unavailable
+// in TEST_MODE
+//
+extern "C" {
+#include <test_stub.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
+
+#include <bcmos_system.h>
+#include <bcmolt_msg.h>
+#include <bcmolt_host_api.h>
+
+char log_string[500];
+dev_log_id def_log_id=0;
+
+void bcmos_usleep(uint32_t us) {
+ // let always sleep for 1s irrespective of the value passed.
+ sleep (1);
+}
+
+void bcmos_fastlock_init(bcmos_fastlock *lock, uint32_t flags) {
+ pthread_mutex_init(&(lock->lock), NULL);
+}
+
+long bcmos_fastlock_lock(bcmos_fastlock *lock) {
+ pthread_mutex_lock(&(lock->lock));
+}
+
+void bcmos_fastlock_unlock(bcmos_fastlock *lock, long flags) {
+ pthread_mutex_unlock(&(lock->lock));
+}
+
+/* Initialize API layer */
+bcmos_errno bcmolt_api_init(void)
+{
+ printf("-- entering :stubbed %s\n", __FUNCTION__);
+ return BCM_ERR_OK;
+}
+
+/* Set configuration */
+bcmos_errno bcmolt_cfg_set(bcmolt_oltid olt, bcmolt_cfg *cfg)
+{
+ printf("-- entering :stubbed %s\n", __FUNCTION__);
+ return BCM_ERR_OK;
+}
+
+/* Get configuration */
+/*
+bcmos_errno bcmolt_cfg_get(bcmolt_oltid olt, bcmolt_cfg *cfg)
+{
+ printf("-- entering :stubbed %s\n", __FUNCTION__);
+ return BCM_ERR_OK;
+}
+*/
+
+/* Clear configuration */
+bcmos_errno bcmolt_cfg_clear(bcmolt_oltid olt, bcmolt_cfg *cfg)
+{
+ printf("-- entering :stubbed %s\n", __FUNCTION__);
+ return BCM_ERR_OK;
+}
+
+/* Get statistics */
+bcmos_errno bcmolt_stat_get(bcmolt_oltid olt, bcmolt_stat *stat, bcmolt_stat_flags flags)
+{
+ printf("-- entering :stubbed %s\n", __FUNCTION__);
+ return BCM_ERR_OK;
+}
+
+/* Get statistics configuration */
+bcmos_errno bcmolt_stat_cfg_get(bcmolt_oltid olt, bcmolt_stat_cfg *cfg)
+{
+ printf("-- entering :stubbed %s\n", __FUNCTION__);
+ return BCM_ERR_OK;
+}
+
+/* Set statistics configuration */
+bcmos_errno bcmolt_stat_cfg_set(bcmolt_oltid olt, bcmolt_stat_cfg *cfg)
+{
+ printf("-- entering :stubbed %s\n", __FUNCTION__);
+ return BCM_ERR_OK;
+}
+
+/* Register Autonomous Indication Message Handler */
+bcmos_errno bcmolt_ind_subscribe(bcmolt_oltid olt, bcmolt_rx_cfg *rx_cfg)
+{
+ printf("-- entering :stubbed %s\n", __FUNCTION__);
+ return BCM_ERR_OK;
+}
+
+/* Un-register Autonomous Indication Message Handler registered by bcmolt_ind_subscribe() */
+bcmos_errno bcmolt_ind_unsubscribe(bcmolt_oltid olt, bcmolt_rx_cfg *rx_cfg)
+{
+ printf("-- entering :stubbed %s\n", __FUNCTION__);
+ return BCM_ERR_OK;
+}
+
+/* Submit Operation */
+/*
+bcmos_errno bcmolt_oper_submit(bcmolt_oltid olt, bcmolt_oper *oper)
+{
+ printf("-- entering :stubbed %s\n", __FUNCTION__);
+ return BCM_ERR_OK;
+}
+*/
+
+/* Get configuration of multiple objects */
+bcmos_errno bcmolt_multi_cfg_get(
+ bcmolt_oltid olt,
+ bcmolt_multi_cfg *cfg,
+ bcmolt_filter_flags filter_flags)
+{
+ printf("-- entering :stubbed %s\n", __FUNCTION__);
+ return BCM_ERR_OK;
+}
+
+/* Get statistics of multiple objects */
+bcmos_errno bcmolt_multi_stat_get(
+ bcmolt_oltid olt,
+ bcmolt_multi_stat *stat,
+ bcmolt_stat_flags stat_flags,
+ bcmolt_filter_flags filter_flags)
+{
+ printf("-- entering :stubbed %s\n", __FUNCTION__);
+ return BCM_ERR_OK;
+}
+
+/* Map error code to error string */
+const char *bcmos_strerror(bcmos_errno err)
+{
+ static const char *errstr[] = {
+ [-BCM_ERR_OK] = "OK",
+ [-BCM_ERR_IN_PROGRESS] = "In progress",
+ [-BCM_ERR_PARM] = "Error in parameters",
+ [-BCM_ERR_NOMEM] = "No memory",
+ [-BCM_ERR_NORES] = "No resources",
+ [-BCM_ERR_INTERNAL] = "Internal error",
+ [-BCM_ERR_NOENT] = "Entry doesn't exist",
+ [-BCM_ERR_NODEV] = "Device doesn't exist",
+ [-BCM_ERR_ALREADY] = "Entry already exists/already in requested state",
+ [-BCM_ERR_RANGE] = "Out of range",
+ [-BCM_ERR_PERM] = "No permission to perform an operation",
+ [-BCM_ERR_NOT_SUPPORTED] = "Operation is not supported",
+ [-BCM_ERR_PARSE] = "Parsing error",
+ [-BCM_ERR_INVALID_OP] = "Invalid operation",
+ [-BCM_ERR_IO] = "I/O error",
+ [-BCM_ERR_STATE] = "Object is in bad state",
+ [-BCM_ERR_DELETED] = "Object is deleted",
+ [-BCM_ERR_TOO_MANY] = "Too many objects",
+ [-BCM_ERR_NO_MORE] = "No more entries",
+ [-BCM_ERR_OVERFLOW] = "Buffer overflow",
+ [-BCM_ERR_COMM_FAIL] = "Communication failure",
+ [-BCM_ERR_NOT_CONNECTED] = "No connection with the target system",
+ [-BCM_ERR_SYSCALL_ERR] = "System call returned error",
+ [-BCM_ERR_MSG_ERROR] = "Received message is insane",
+ [-BCM_ERR_TOO_MANY_REQS] = "Too many outstanding requests",
+ [-BCM_ERR_TIMEOUT] = "Operation timed out",
+ [-BCM_ERR_TOO_MANY_FRAGS] = "Too many fragments",
+ [-BCM_ERR_NULL] = "Got NULL pointer",
+ [-BCM_ERR_READ_ONLY] = "Attempt to set read-only parameter",
+ [-BCM_ERR_ONU_ERR_RESP] = "ONU returned an error response",
+ [-BCM_ERR_MANDATORY_PARM_IS_MISSING] = "Mandatory parameter is missing",
+ [-BCM_ERR_KEY_RANGE] = "Key field out of range",
+ [-BCM_ERR_QUEUE_EMPTY] = "Rx of PCIe empty",
+ [-BCM_ERR_QUEUE_FULL] = "Tx of PCIe full",
+ [-BCM_ERR_TOO_LONG] = "Processing is taking too long, but will finish eventually",
+ [-BCM_ERR_INSUFFICIENT_LIST_MEM] = "Insufficient list memory provided",
+ [-BCM_ERR_OUT_OF_SYNC] = "Sequence number or operation step was out of sync",
+ [-BCM_ERR_CHECKSUM] = "Checksum error",
+ [-BCM_ERR_IMAGE_TYPE] = "Unsupported file/image type",
+ [-BCM_ERR_INCOMPLETE_TERMINATION] = "Incomplete premature termination",
+ [-BCM_ERR_MISMATCH] = "Parameters mismatch",
+ };
+ static const char *unknown = "*unknown*";
+
+ if ((unsigned)(-err) >= sizeof(errstr)/sizeof(errstr[0]) || !errstr[-err])
+ return unknown;
+ return errstr[-err];
+}
+
+void bcmolt_msg_free(bcmolt_msg *msg)
+{
+ return;
+}
+
+void bcmolt_api_set_prop_present(bcmolt_msg *msg, const void *prop_ptr)
+{
+ return;
+}
+
+const bcmolt_enum_val bcmolt_obj_id_string_table[] = {"dummy string, never used"};
+const bcmolt_enum_val bcmolt_interface_state_string_table[] = {"dummy string, never used"};
+
+dev_log_id bcm_dev_log_id_register(const char *xi_name,
+ bcm_dev_log_level xi_default_log_level,
+ bcm_dev_log_id_type xi_default_log_type) {
+ return 0;
+}
+bool bcmcli_is_stopped(bcmcli_session *sess) {
+ printf("-- stub bcmcli_is_stopped called --\n");
+ return true;
+}
+
+bool bcmcli_parse(bcmcli_session *sess, char *s) {
+ printf("-- stub bcmcli_parse called --\n");
+ return true;
+}
+
+bool bcmcli_driver(bcmcli_session *sess) {
+ printf("-- stub bcmcli_driver called --\n");
+ return true;
+}
+void bcmcli_token_destroy(void *ptr) {
+ printf("-- stub bcmcli_token_destroy called --\n");
+ return;
+}
+
+void bcmcli_session_close( bcmcli_session*ptr) {
+ printf("-- stub bcmcli_session_close called --\n");
+ return;
+}
+
+bcmos_errno bcm_api_cli_set_commands(bcmcli_session *sess) {
+ printf("-- stub bcm_api_cli_set_commands called --\n");
+ return BCM_ERR_OK;
+}
+
+void bcmcli_stop(bcmcli_session *sess) {
+ printf("-- stub bcmcli_stop called --\n");
+ return;
+}
+
+void bcmcli_session_print(bcmcli_session *sess, const char *s) {
+ printf("-- stub bcmcli_session_print called --\n");
+ return;
+}
+
+bcmos_errno bcmcli_session_open(bcmcli_session_parm *mon_sess, bcmcli_session **curr_sess) {
+ printf("-- stub bcmcli_session_open called --\n");
+ return BCM_ERR_OK;
+}
+
+void bcm_dev_log_log(dev_log_id xi_id,
+ bcm_dev_log_level xi_log_level,
+ uint32_t xi_flags,
+ const char *fmt,
+ ...) {
+ memset(log_string, '\0', sizeof(log_string));
+ va_list args;
+ va_start(args, fmt);
+ vsnprintf(log_string, 490, fmt, args);
+ switch (xi_log_level) {
+ case DEV_LOG_LEVEL_FATAL:
+ printf("FATAL: %s\n", log_string);
+ // exit (0);
+ break;
+ case DEV_LOG_LEVEL_ERROR:
+ printf("ERROR : %s\n", log_string);
+ break;
+ case DEV_LOG_LEVEL_WARNING:
+ printf("WARNING : %s\n", log_string);
+ break;
+ case DEV_LOG_LEVEL_INFO:
+ printf("INFO : %s\n", log_string);
+ break;
+ case DEV_LOG_LEVEL_DEBUG:
+ printf("DEBUG : %s\n", log_string);
+ break;
+ default:
+ printf("%s\n", log_string);
+ }
+ va_end(args);
+}
+
+bcmos_errno bcmos_task_query(const bcmos_task *task, bcmos_task_parm *parm) {
+ printf (" -- stub bcmos_task_query called --\n");
+ return BCM_ERR_OK;
+}
+
+bcmos_errno bcmos_task_create(bcmos_task *task, const bcmos_task_parm *parm) {
+ printf (" -- stub bcmos_task_create called --\n");
+ return BCM_ERR_OK;
+}
+
+int bcmos_printf(const char *fmt, ...) {
+ memset(log_string, '\0', sizeof(log_string));
+ va_list args;
+ va_start(args, fmt);
+ vsnprintf(log_string, 490, fmt, args);
+ printf("%s\n", log_string);
+ va_end(args);
+
+}
+
+bcmos_bool bcmolt_api_conn_mgr_is_connected(bcmolt_goid olt) {
+ printf ("-- stub bcmolt_api_conn_mgr_is_connected called --\n");
+ return true;
+}
+}
diff --git a/agent/test/src/main_test.cc b/agent/test/src/main_test.cc
new file mode 100644
index 0000000..7f04e9c
--- /dev/null
+++ b/agent/test/src/main_test.cc
@@ -0,0 +1,23 @@
+/*
+ Copyright (C) 2018 Open Networking Foundation
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "gtest/gtest.h"
+
+int main(int argc, char **argv) {
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
diff --git a/agent/test/src/test_enable_olt.cc b/agent/test/src/test_enable_olt.cc
new file mode 100644
index 0000000..0cdb965
--- /dev/null
+++ b/agent/test/src/test_enable_olt.cc
@@ -0,0 +1,162 @@
+/*
+ Copyright (C) 2018 Open Networking Foundation
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+#include "gtest/gtest.h"
+#include "bal_mocker.h"
+#include "core.h"
+
+class TestOltEnable : public ::testing::Test {
+ protected:
+ virtual void SetUp() {
+ }
+
+ virtual void TearDown() {
+ // Code here will be called immediately after each test
+ // (right before the destructor).
+ }
+};
+
+
+// Test Fixture for OltEnable
+
+// Test 1: OltEnableSuccess case
+TEST_F(TestOltEnable, OltEnableSuccess){
+ // NiceMock is used to suppress 'WillByDefault' return errors on using 'NiceMock'.
+ // This is described in https://github.com/arangodb-helper/gtest/blob/master/googlemock/docs/CookBook.md
+ ::testing::NiceMock<BalMocker> balMock;
+ bcmos_errno host_init_res = BCM_ERR_OK;
+ bcmos_errno bal_cfg_get_res = BCM_ERR_NOT_CONNECTED;
+ bcmos_errno olt_oper_res = BCM_ERR_OK;
+
+ Status olt_enable_res;
+
+ // The 'EXPECT_CALL' will do strict validation of input parameters. This may not be relevant for
+ // the current test case. Use 'ON_CALL' instead.
+ // The ON_CALL results in WARNINGs when running tests. Use NickMock instead of directly using BalMocker.
+ // https://github.com/google/googletest/blob/master/googlemock/docs/cook_book.md#the-nice-the-strict-and-the-naggy-nicestrictnaggy
+ // In below tests '::testing::_' does no validation on argument.
+ ON_CALL(balMock, bcmolt_host_init(::testing::_)).WillByDefault(::testing::Return(host_init_res));
+ ON_CALL(balMock, bcmolt_cfg_get(::testing::_,::testing::_)).WillByDefault(::testing::Return(bal_cfg_get_res));
+ ON_CALL(balMock, bcmolt_oper_submit(::testing::_, ::testing::_)).WillByDefault(::testing::Return(olt_oper_res));
+
+ olt_enable_res = Enable_(1, NULL);
+ ASSERT_TRUE( olt_enable_res.error_message() == Status::OK.error_message() );
+}
+
+// Test 2: OltEnableFail_host_init_fail
+TEST_F(TestOltEnable, OltEnableFail_host_init_fail) {
+ // NiceMock is used to suppress 'WillByDefault' return errors on using 'NiceMock'.
+ // This is described in https://github.com/arangodb-helper/gtest/blob/master/googlemock/docs/CookBook.md
+ ::testing::NiceMock<BalMocker> balMock;
+ bcmos_errno host_init_res = BCM_ERR_INTERNAL;
+ bcmos_errno bal_cfg_get_res = BCM_ERR_NOT_CONNECTED;
+ bcmos_errno olt_oper_res = BCM_ERR_OK;
+
+ Status olt_enable_res;
+
+ // The 'EXPECT_CALL' will do strict validation of input parameters. This may not be relevant for
+ // the current test case. Use 'ON_CALL' instead.
+ // The ON_CALL results in WARNINGs when running tests. Use NickMock instead of directly using BalMocker.
+ // https://github.com/google/googletest/blob/master/googlemock/docs/cook_book.md#the-nice-the-strict-and-the-naggy-nicestrictnaggy
+ // In below tests '::testing::_' does no validation on argument.
+ ON_CALL(balMock, bcmolt_host_init(::testing::_)).WillByDefault(::testing::Return(host_init_res));
+ ON_CALL(balMock, bcmolt_cfg_get(::testing::_,::testing::_)).WillByDefault(::testing::Return(bal_cfg_get_res));
+ ON_CALL(balMock, bcmolt_oper_submit(::testing::_, ::testing::_)).WillByDefault(::testing::Return(olt_oper_res));
+
+ olt_enable_res = Enable_(1, NULL);
+ ASSERT_TRUE( olt_enable_res.error_message() != Status::OK.error_message() );
+}
+
+// Test 3: OltEnableSuccess_PON_Device_Connected
+TEST_F(TestOltEnable, OltEnableSuccess_PON_Device_Connected) {
+ // NiceMock is used to suppress 'WillByDefault' return errors on using 'NiceMock'.
+ // This is described in https://github.com/arangodb-helper/gtest/blob/master/googlemock/docs/CookBook.md
+ ::testing::NiceMock<BalMocker> balMock;
+ bcmos_errno host_init_res = BCM_ERR_OK;
+ bcmos_errno bal_cfg_get_res = BCM_ERR_OK;
+
+ Status olt_enable_res;
+
+ // The 'EXPECT_CALL' will do strict validation of input parameters. This may not be relevant for
+ // the current test case. Use 'ON_CALL' instead.
+ // The ON_CALL results in WARNINGs when running tests. Use NickMock instead of directly using BalMocker.
+ // https://github.com/google/googletest/blob/master/googlemock/docs/cook_book.md#the-nice-the-strict-and-the-naggy-nicestrictnaggy
+ // In below tests '::testing::_' does no validation on argument.
+ ON_CALL(balMock, bcmolt_host_init(::testing::_)).WillByDefault(::testing::Return(host_init_res));
+ ON_CALL(balMock, bcmolt_cfg_get(::testing::_,::testing::_)).WillByDefault(::testing::Return(bal_cfg_get_res));
+
+ olt_enable_res = Enable_(1, NULL);
+ ASSERT_TRUE( olt_enable_res.error_message() == Status::OK.error_message() );
+}
+
+// Test 4: OltEnableFail_All_PON_Enable_Fail
+TEST_F(TestOltEnable, OltEnableFail_All_PON_Enable_Fail) {
+ // NiceMock is used to suppress 'WillByDefault' return errors on using 'NiceMock'.
+ // This is described in https://github.com/arangodb-helper/gtest/blob/master/googlemock/docs/CookBook.md
+ ::testing::NiceMock<BalMocker> balMock;
+ bcmos_errno host_init_res = BCM_ERR_OK;
+ bcmos_errno bal_cfg_get_res = BCM_ERR_NOT_CONNECTED;
+ bcmos_errno olt_oper_res = BCM_ERR_INTERNAL;
+
+ Status olt_enable_res;
+
+ // Ensure that the state of the OLT is in deactivated to start with..
+ state.deactivate();
+
+ // The 'EXPECT_CALL' will do strict validation of input parameters. This may not be relevant for
+ // the current test case. Use 'ON_CALL' instead.
+ // The ON_CALL results in WARNINGs when running tests. Use NickMock instead of directly using BalMocker.
+ // https://github.com/google/googletest/blob/master/googlemock/docs/cook_book.md#the-nice-the-strict-and-the-naggy-nicestrictnaggy
+ // In below tests '::testing::_' does no validation on argument.
+ ON_CALL(balMock, bcmolt_host_init(::testing::_)).WillByDefault(::testing::Return(host_init_res));
+ ON_CALL(balMock, bcmolt_cfg_get(::testing::_,::testing::_)).WillByDefault(::testing::Return(bal_cfg_get_res));
+ ON_CALL(balMock, bcmolt_oper_submit(::testing::_, ::testing::_)).WillByDefault(::testing::Return(olt_oper_res));
+
+ olt_enable_res = Enable_(1, NULL);
+ ASSERT_TRUE( olt_enable_res.error_message() != Status::OK.error_message() );
+}
+
+// Test 5 OltEnableSuccess_One_PON_Enable_Fail : One PON device enable fails, but all others succeed.
+TEST_F(TestOltEnable, OltEnableSuccess_One_PON_Enable_Fail) {
+ // NiceMock is used to suppress 'WillByDefault' return errors on using 'NiceMock'.
+ // This is described in https://github.com/arangodb-helper/gtest/blob/master/googlemock/docs/CookBook.md
+ ::testing::NiceMock<BalMocker> balMock;
+ bcmos_errno host_init_res = BCM_ERR_OK;
+ bcmos_errno bal_cfg_get_res = BCM_ERR_NOT_CONNECTED;
+ bcmos_errno olt_oper_res_fail = BCM_ERR_INTERNAL;
+ bcmos_errno olt_oper_res_success = BCM_ERR_OK;
+
+ Status olt_enable_res;
+
+ // Ensure that the state of the OLT is in deactivated to start with..
+ state.deactivate();
+
+ // The 'EXPECT_CALL' will do strict validation of input parameters. This may not be relevant for
+ // the current test case. Use 'ON_CALL' instead.
+ // The ON_CALL results in WARNINGs when running tests. Use NickMock instead of directly using BalMocker.
+ // https://github.com/google/googletest/blob/master/googlemock/docs/cook_book.md#the-nice-the-strict-and-the-naggy-nicestrictnaggy
+ // In below tests '::testing::_' does no validation on argument.
+ ON_CALL(balMock, bcmolt_host_init(::testing::_)).WillByDefault(::testing::Return(host_init_res));
+ ON_CALL(balMock, bcmolt_cfg_get(::testing::_,::testing::_)).WillByDefault(::testing::Return(bal_cfg_get_res));
+ // For the the first PON mac device, the activation result will fail, and will succeed for all other PON mac devices.
+ EXPECT_CALL(balMock, bcmolt_oper_submit(::testing::_, ::testing::_))
+ .WillOnce(::testing::Return(olt_oper_res_fail))
+ .WillRepeatedly(::testing::Return(olt_oper_res_success));
+
+ olt_enable_res = Enable_(1, NULL);
+ // The OLT activation should succeed if at least one PON mac device activation succeeds.
+ ASSERT_TRUE( olt_enable_res.error_message() == Status::OK.error_message() );
+}