Skip to content

fix(agw): Added uint test case on start and stop of open flow controller #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions lte/gateway/c/core/oai/test/sgw_s8_task/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ include_directories("${PROJECT_SOURCE_DIR}/tasks/sgw_s8")
set(SGW_S8_TEST_CONFIG_SRC
sgw_s8_test.cpp
sgw_csr.cpp
sgw_open_flow_controller.cpp
)

add_executable(sgw_s8_test ${SGW_S8_TEST_CONFIG_SRC})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/**
* Copyright 2020 The Magma Authors.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*
* 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 <gtest/gtest.h>
extern "C" {
#include "log.h"
#include "sgw_s8_s11_handlers.h"
#include "sgw_handlers.h"
#include "spgw_types.h"
#include "s11_messages_types.h"
#include "common_types.h"
#include "sgw_config.h"
#include "dynamic_memory_check.h"
#include "sgw_context_manager.h"
#include "gtpv1u.h"
}

using ::testing::Test;
spgw_config_t spgw_config;

const struct gtp_tunnel_ops* gtp_tunnel_ops;
void initialize_gtpv1u(void) {
int rv = 0;
struct in_addr netaddr;
uint32_t netmask = 0;
int fd0 = 2;
int fd1 = 5;
int mtu = 1024;
gtp_tunnel_ops = gtp_tunnel_ops_init_openflow();
if (gtp_tunnel_ops == NULL) {
OAILOG_CRITICAL(LOG_GTPV1U, "ERROR in initializing gtp_tunnel_ops\n");
return;
}
// Reset GTP tunnel states
rv = gtp_tunnel_ops->reset();
if (rv != 0) {
OAILOG_CRITICAL(LOG_GTPV1U, "ERROR clean existing gtp states.\n");
return;
}
netaddr.s_addr = INADDR_ANY;
netmask = 0;
// Init GTP device, using the same MTU as SGi.
gtp_tunnel_ops->init(&netaddr, netmask, mtu, &fd0, &fd1, false);

// END-GTP quick integration only for evaluation purpose

OAILOG_DEBUG(LOG_GTPV1U, "Initializing GTPV1U interface: DONE\n");
return;
}

void uninitialize_gtpv1u(void) {
gtp_tunnel_ops->uninit();
OAILOG_DEBUG(LOG_GTPV1U, "Uninitializing GTPV1U interface: DONE\n");
return;
}

TEST(SGW_S8_OVSTest, openflowControllerStartAndStop) {
spgw_config.pgw_config.enable_nat = false;
spgw_config.sgw_config.ovs_config.uplink_port_num = 2;

spgw_config.sgw_config.ovs_config.uplink_mac =
bfromcstr_with_str_len("ff:ff:ff:ff:ff:ff", strlen("ff:ff:ff:ff:ff:ff"));
spgw_config.sgw_config.ovs_config.gtp_port_num = 32768;
spgw_config.sgw_config.ovs_config.mtr_port_num = 15577;
spgw_config.sgw_config.ovs_config.internal_sampling_port_num = 15578;
spgw_config.sgw_config.ovs_config.internal_sampling_fwd_tbl_num = 201;
initialize_gtpv1u();
bdestroy_wrapper(&spgw_config.sgw_config.ovs_config.uplink_mac);
uninitialize_gtpv1u();
}