Skip to content

Commit db0a394

Browse files
authored
Fix switchlink_link_test (#166)
The switchlink_link unit test fails when run with the command bazel test --define target=dpdk --//flags:ovs=true //switchlink:all - Addressed the issue by conditionalizing out the two VxLAN test cases when OVSP4RT support is enabled. - Introduced an internal VXLAN_OPTION conditional to indicate whether VxLAN support is enabled. Signed-off-by: Derek Foster <[email protected]>
1 parent 673c45f commit db0a394

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

krnlmon_options.h

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,33 @@
1313
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
16+
*
17+
* ---------------------------------------------------------------------
18+
* This header file maps compile-time symbol definitions (such as
19+
* ES2K_TARGET) to internal symbol definitions that specify which
20+
* features the compile-time symbols enable (such as LAG_OPTION).
21+
*
22+
* This is infinitely better than leaving the reader scratching
23+
* their head, trying to figure out why some random piece of code
24+
* is wrapped in an "#if !defined(OVSP4RT_SUPPORT)" conditional
25+
* (which the original author didn't bother to comment).
26+
* ---------------------------------------------------------------------
1627
*/
1728

1829
#ifndef KRNLMON_OPTIONS_H_
1930
#define KRNLMON_OPTIONS_H_
2031

2132
#if defined(DPDK_TARGET)
2233
// DPDK options
23-
2434
#elif defined(ES2K_TARGET)
2535
// ES2K options
2636
#define LAG_OPTION 1
27-
2837
#else
2938
#error "ASSERT: Unknown TARGET type!"
3039
#endif
3140

41+
#if !defined(OVSP4RT_SUPPORT)
42+
#define VXLAN_OPTION 1
43+
#endif
44+
3245
#endif // KRNLMON_OPTIONS_H_

switchlink/switchlink_link.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ void switchlink_process_link_msg(const struct nlmsghdr* nlmsg, int msgtype) {
331331
case SWITCHLINK_LINK_TYPE_ETH:
332332
break;
333333

334-
#if !defined(OVSP4RT_SUPPORT)
334+
#ifdef VXLAN_OPTION
335335
case SWITCHLINK_LINK_TYPE_VXLAN: {
336336
switchlink_db_tunnel_interface_info_t tnl_intf_info = {0};
337337
snprintf(tnl_intf_info.ifname, sizeof(tnl_intf_info.ifname), "%s",
@@ -405,7 +405,7 @@ void switchlink_process_link_msg(const struct nlmsghdr* nlmsg, int msgtype) {
405405
} else {
406406
krnlmon_assert(msgtype == RTM_DELLINK);
407407

408-
#if !defined(OVSP4RT_SUPPORT)
408+
#ifdef VXLAN_OPTION
409409
if (link_type == SWITCHLINK_LINK_TYPE_VXLAN) {
410410
switchlink_delete_tunnel_interface(ifmsg->ifi_index);
411411
return;

switchlink/switchlink_link_test.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ TEST_F(SwitchlinkTest, can_create_generic_link) {
221221
0);
222222
}
223223

224+
#ifdef VXLAN_OPTION
225+
224226
/**
225227
* Creates a vxlan link.
226228
*
@@ -300,6 +302,8 @@ TEST_F(SwitchlinkTest, can_create_vxlan_link) {
300302
EXPECT_EQ(results[0].tunnel_info.ttl, vxlan_ttl);
301303
}
302304

305+
#endif // VXLAN_OPTION
306+
303307
/**
304308
* Attempts to create a bridge link.
305309
*
@@ -362,6 +366,8 @@ TEST_F(SwitchlinkTest, does_not_create_bridge_link) {
362366
ASSERT_EQ(results.size(), 0);
363367
}
364368

369+
#ifdef VXLAN_OPTION
370+
365371
/**
366372
* Deletes a vxlan link.
367373
*
@@ -411,6 +417,8 @@ TEST_F(SwitchlinkTest, can_delete_vxlan_link) {
411417
EXPECT_EQ(results[0].ifindex, hdr.ifi_index);
412418
}
413419

420+
#endif // VXLAN_OPTION
421+
414422
/**
415423
* Deletes a tunnel ("tun") link.
416424
*

0 commit comments

Comments
 (0)