TSG-20717 Service Chaining增加全局链路号以支持无历史状态发包
This commit is contained in:
84
common/test/gtest_vxlan.cpp
Normal file
84
common/test/gtest_vxlan.cpp
Normal file
@@ -0,0 +1,84 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "vxlan.h"
|
||||
|
||||
static inline void hexdump(const char *data, int len)
|
||||
{
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
printf("%02x ", data[i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
TEST(VXLAN, TEST1)
|
||||
{
|
||||
char buff[8] = {0};
|
||||
struct vxlan_hdr *hdr = (struct vxlan_hdr *)buff;
|
||||
|
||||
vxlan_set_flags(hdr, VXLAN_DEFAULT_FLAGS);
|
||||
vxlan_set_dir(hdr, 0);
|
||||
vxlan_set_traffic(hdr, 0);
|
||||
vxlan_set_sf_index(hdr, 0);
|
||||
vxlan_set_link_id(hdr, 0);
|
||||
vxlan_set_stateless(hdr, 0);
|
||||
|
||||
EXPECT_TRUE(vxlan_get_flags(hdr) == VXLAN_DEFAULT_FLAGS);
|
||||
EXPECT_TRUE(vxlan_get_dir(hdr) == 0);
|
||||
EXPECT_TRUE(vxlan_get_traffic(hdr) == 0);
|
||||
EXPECT_TRUE(vxlan_get_sf_index(hdr) == 0);
|
||||
EXPECT_TRUE(vxlan_get_link_id(hdr) == 0);
|
||||
EXPECT_TRUE(vxlan_get_stateless(hdr) == 0);
|
||||
|
||||
hexdump(buff, 8);
|
||||
}
|
||||
|
||||
TEST(VXLAN, TEST2)
|
||||
{
|
||||
char buff[8] = {0};
|
||||
struct vxlan_hdr *hdr = (struct vxlan_hdr *)buff;
|
||||
|
||||
vxlan_set_flags(hdr, VXLAN_DEFAULT_FLAGS);
|
||||
vxlan_set_dir(hdr, 1);
|
||||
vxlan_set_traffic(hdr, 1);
|
||||
vxlan_set_sf_index(hdr, 1);
|
||||
vxlan_set_link_id(hdr, 1);
|
||||
vxlan_set_stateless(hdr, 1);
|
||||
|
||||
EXPECT_TRUE(vxlan_get_flags(hdr) == VXLAN_DEFAULT_FLAGS);
|
||||
EXPECT_TRUE(vxlan_get_dir(hdr) == 1);
|
||||
EXPECT_TRUE(vxlan_get_traffic(hdr) == 1);
|
||||
EXPECT_TRUE(vxlan_get_sf_index(hdr) == 1);
|
||||
EXPECT_TRUE(vxlan_get_link_id(hdr) == 1);
|
||||
EXPECT_TRUE(vxlan_get_stateless(hdr) == 1);
|
||||
|
||||
hexdump(buff, 8);
|
||||
}
|
||||
|
||||
TEST(VXLAN, TEST3)
|
||||
{
|
||||
char buff[8] = {0};
|
||||
struct vxlan_hdr *hdr = (struct vxlan_hdr *)buff;
|
||||
|
||||
vxlan_set_flags(hdr, VXLAN_DEFAULT_FLAGS);
|
||||
vxlan_set_dir(hdr, 1);
|
||||
vxlan_set_traffic(hdr, 1);
|
||||
vxlan_set_sf_index(hdr, 31);
|
||||
vxlan_set_link_id(hdr, 65535);
|
||||
vxlan_set_stateless(hdr, 1);
|
||||
|
||||
EXPECT_TRUE(vxlan_get_flags(hdr) == VXLAN_DEFAULT_FLAGS);
|
||||
EXPECT_TRUE(vxlan_get_dir(hdr) == 1);
|
||||
EXPECT_TRUE(vxlan_get_traffic(hdr) == 1);
|
||||
EXPECT_TRUE(vxlan_get_sf_index(hdr) == 31);
|
||||
EXPECT_TRUE(vxlan_get_link_id(hdr) == 65535);
|
||||
EXPECT_TRUE(vxlan_get_stateless(hdr) == 1);
|
||||
|
||||
hexdump(buff, 8);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
Reference in New Issue
Block a user