summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorNeale Ranns <neale@graphiant.com>2022-02-09 13:30:37 +0000
committerDamjan Marion <dmarion@me.com>2022-02-10 17:27:04 +0000
commitf5756175e6296939c3d580c2120306ba28bab91b (patch)
tree726b313d3818d463dd2b3b35c18e960a9098e44a /src/plugins
parent791144cbc5587d64253f3d89b5d2f0ae3f6dfb0d (diff)
tests: Fix the FIB UT
Type: test The FIB UT fails in debug mode because there is no string associated woth its fib_node_type_t. Change the tests to register their own type, which will give it a name. Signed-off-by: Neale Ranns <neale@graphiant.com> Change-Id: I36e546718faa7241c088494cbae10939aca51d5a
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/unittest/fib_test.c51
1 files changed, 26 insertions, 25 deletions
diff --git a/src/plugins/unittest/fib_test.c b/src/plugins/unittest/fib_test.c
index 2261a9d28d0..cc9a572b5ce 100644
--- a/src/plugins/unittest/fib_test.c
+++ b/src/plugins/unittest/fib_test.c
@@ -7579,6 +7579,7 @@ fib_test_child_get_node (fib_node_index_t index)
}
static int fib_test_walk_spawns_walks;
+static fib_node_type_t test_node_type;
static fib_node_back_walk_rc_t
fib_test_child_back_walk_notify (fib_node_t *node,
@@ -7589,9 +7590,9 @@ fib_test_child_back_walk_notify (fib_node_t *node,
vec_add1(tc->ctxs, *ctx);
if (1 == fib_test_walk_spawns_walks)
- fib_walk_sync(FIB_NODE_TYPE_TEST, tc->index, ctx);
+ fib_walk_sync(test_node_type, tc->index, ctx);
if (2 == fib_test_walk_spawns_walks)
- fib_walk_async(FIB_NODE_TYPE_TEST, tc->index,
+ fib_walk_async(test_node_type, tc->index,
FIB_WALK_PRIORITY_HIGH, ctx);
return (FIB_NODE_BACK_WALK_CONTINUE);
@@ -7632,23 +7633,23 @@ fib_test_walk (void)
res = 0;
vm = vlib_get_main();
- fib_node_register_type(FIB_NODE_TYPE_TEST, &fib_test_child_vft);
+ test_node_type = fib_node_register_new_type("fib-test", &fib_test_child_vft);
/*
* init a fake node on which we will add children
*/
fib_node_init(&fib_test_nodes[PARENT_INDEX].node,
- FIB_NODE_TYPE_TEST);
+ test_node_type);
FOR_EACH_TEST_CHILD(tc)
{
- fib_node_init(&tc->node, FIB_NODE_TYPE_TEST);
+ fib_node_init(&tc->node, test_node_type);
fib_node_lock(&tc->node);
tc->ctxs = NULL;
tc->index = ii;
- tc->sibling = fib_node_child_add(FIB_NODE_TYPE_TEST,
+ tc->sibling = fib_node_child_add(test_node_type,
PARENT_INDEX,
- FIB_NODE_TYPE_TEST, ii);
+ test_node_type, ii);
}
/*
@@ -7656,7 +7657,7 @@ fib_test_walk (void)
*/
high_ctx.fnbw_reason = FIB_NODE_BW_REASON_FLAG_RESOLVE;
- fib_walk_async(FIB_NODE_TYPE_TEST, PARENT_INDEX,
+ fib_walk_async(test_node_type, PARENT_INDEX,
FIB_WALK_PRIORITY_HIGH, &high_ctx);
FIB_TEST(N_TEST_CHILDREN+1 == fib_node_list_get_size(PARENT()->fn_children),
"Parent has %d children pre-walk",
@@ -7702,9 +7703,9 @@ fib_test_walk (void)
high_ctx.fnbw_reason = FIB_NODE_BW_REASON_FLAG_RESOLVE;
low_ctx.fnbw_reason = FIB_NODE_BW_REASON_FLAG_ADJ_UPDATE;
- fib_walk_async(FIB_NODE_TYPE_TEST, PARENT_INDEX,
+ fib_walk_async(test_node_type, PARENT_INDEX,
FIB_WALK_PRIORITY_HIGH, &high_ctx);
- fib_walk_async(FIB_NODE_TYPE_TEST, PARENT_INDEX,
+ fib_walk_async(test_node_type, PARENT_INDEX,
FIB_WALK_PRIORITY_LOW, &low_ctx);
fib_walk_process_queues(vm, 1);
@@ -7730,9 +7731,9 @@ fib_test_walk (void)
high_ctx.fnbw_reason = FIB_NODE_BW_REASON_FLAG_RESOLVE;
low_ctx.fnbw_reason = FIB_NODE_BW_REASON_FLAG_RESOLVE;
- fib_walk_async(FIB_NODE_TYPE_TEST, PARENT_INDEX,
+ fib_walk_async(test_node_type, PARENT_INDEX,
FIB_WALK_PRIORITY_HIGH, &high_ctx);
- fib_walk_async(FIB_NODE_TYPE_TEST, PARENT_INDEX,
+ fib_walk_async(test_node_type, PARENT_INDEX,
FIB_WALK_PRIORITY_HIGH, &low_ctx);
fib_walk_process_queues(vm, 1);
@@ -7758,9 +7759,9 @@ fib_test_walk (void)
high_ctx.fnbw_reason = FIB_NODE_BW_REASON_FLAG_RESOLVE;
low_ctx.fnbw_reason = FIB_NODE_BW_REASON_FLAG_ADJ_UPDATE;
- fib_walk_async(FIB_NODE_TYPE_TEST, PARENT_INDEX,
+ fib_walk_async(test_node_type, PARENT_INDEX,
FIB_WALK_PRIORITY_HIGH, &high_ctx);
- fib_walk_async(FIB_NODE_TYPE_TEST, PARENT_INDEX,
+ fib_walk_async(test_node_type, PARENT_INDEX,
FIB_WALK_PRIORITY_HIGH, &low_ctx);
fib_walk_process_queues(vm, 1);
@@ -7786,7 +7787,7 @@ fib_test_walk (void)
*/
high_ctx.fnbw_reason = FIB_NODE_BW_REASON_FLAG_RESOLVE;
- fib_walk_async(FIB_NODE_TYPE_TEST, PARENT_INDEX,
+ fib_walk_async(test_node_type, PARENT_INDEX,
FIB_WALK_PRIORITY_HIGH, &high_ctx);
fib_walk_process_queues(vm, 0);
@@ -7840,7 +7841,7 @@ fib_test_walk (void)
/*
* schedule another walk that will catch-up and merge.
*/
- fib_walk_async(FIB_NODE_TYPE_TEST, PARENT_INDEX,
+ fib_walk_async(test_node_type, PARENT_INDEX,
FIB_WALK_PRIORITY_HIGH, &high_ctx);
fib_walk_process_queues(vm, 1);
@@ -7873,13 +7874,13 @@ fib_test_walk (void)
*/
high_ctx.fnbw_reason = FIB_NODE_BW_REASON_FLAG_RESOLVE;
- fib_walk_async(FIB_NODE_TYPE_TEST, PARENT_INDEX,
+ fib_walk_async(test_node_type, PARENT_INDEX,
FIB_WALK_PRIORITY_HIGH, &high_ctx);
fib_walk_process_queues(vm, 0);
fib_walk_process_queues(vm, 0);
- fib_walk_sync(FIB_NODE_TYPE_TEST, PARENT_INDEX, &high_ctx);
+ fib_walk_sync(test_node_type, PARENT_INDEX, &high_ctx);
FOR_EACH_TEST_CHILD(tc)
{
@@ -7908,9 +7909,9 @@ fib_test_walk (void)
* make the parent a child of one of its children, thus inducing a routing loop.
*/
fib_test_nodes[PARENT_INDEX].sibling =
- fib_node_child_add(FIB_NODE_TYPE_TEST,
+ fib_node_child_add(test_node_type,
1, // the first child
- FIB_NODE_TYPE_TEST,
+ test_node_type,
PARENT_INDEX);
/*
@@ -7919,7 +7920,7 @@ fib_test_walk (void)
*/
fib_test_walk_spawns_walks = 1;
- fib_walk_sync(FIB_NODE_TYPE_TEST, PARENT_INDEX, &high_ctx);
+ fib_walk_sync(test_node_type, PARENT_INDEX, &high_ctx);
FOR_EACH_TEST_CHILD(tc)
{
@@ -7960,7 +7961,7 @@ fib_test_walk (void)
* execute an async walk of the graph loop, with each child spawns sync walks
*/
high_ctx.fnbw_depth = 0;
- fib_walk_async(FIB_NODE_TYPE_TEST, PARENT_INDEX,
+ fib_walk_async(test_node_type, PARENT_INDEX,
FIB_WALK_PRIORITY_HIGH, &high_ctx);
fib_walk_process_queues(vm, 1);
@@ -7982,7 +7983,7 @@ fib_test_walk (void)
*/
fib_test_walk_spawns_walks = 2;
high_ctx.fnbw_depth = 0;
- fib_walk_async(FIB_NODE_TYPE_TEST, PARENT_INDEX,
+ fib_walk_async(test_node_type, PARENT_INDEX,
FIB_WALK_PRIORITY_HIGH, &high_ctx);
fib_walk_process_queues(vm, 1);
@@ -8000,7 +8001,7 @@ fib_test_walk (void)
}
- fib_node_child_remove(FIB_NODE_TYPE_TEST,
+ fib_node_child_remove(test_node_type,
1, // the first child
fib_test_nodes[PARENT_INDEX].sibling);
@@ -8009,7 +8010,7 @@ fib_test_walk (void)
*/
FOR_EACH_TEST_CHILD(tc)
{
- fib_node_child_remove(FIB_NODE_TYPE_TEST, PARENT_INDEX,
+ fib_node_child_remove(test_node_type, PARENT_INDEX,
tc->sibling);
fib_node_deinit(&tc->node);
fib_node_unlock(&tc->node);
se. */ #ifndef included_vcom_h #define included_vcom_h /* VCOM DEBUG flag. Setting this to 1 or 0 turns off ASSERT & other debugging code. */ #ifndef VCOM_DEBUG #define VCOM_DEBUG 0 #endif #include <vcl/vcom_glibc_socket.h> #define MAX_VCOM_APP_NAME 256 /* Returns 0 on success or -1 on error. */ extern int vcom_set_app_name (char *__app_name); /* * * File descriptor based APIs * */ /* * vpp implementation of glibc APIs from <unistd.h> */ extern int vcom_close (int __fd); extern ssize_t __wur vcom_read (int __fd, void *__buf, size_t __nbytes); extern ssize_t __wur vcom_write (int __fd, const void *__buf, size_t __n); extern ssize_t __wur vcom_readv (int __fd, const struct iovec *__iov, int __iovcnt); extern ssize_t __wur vcom_writev (int __fd, const struct iovec *__iov, int __iovcnt); /* * vpp implementation of glibc APIs from <fcntl.h> */ extern int vcom_fcntl (int __fd, int __cmd, ...); /* * VPP implementation of glibc APIs ioctl */ extern int vcom_ioctl (int __fd, unsigned long int __cmd, ...); /* * vpp implementation of glibc APIs from <sys/select.h> */ extern int vcom_select (int __nfds, fd_set * __restrict __readfds, fd_set * __restrict __writefds, fd_set * __restrict __exceptfds, struct timeval *__restrict __timeout); #ifdef __USE_XOPEN2K extern int vcom_pselect (int __nfds, fd_set * __restrict __readfds, fd_set * __restrict __writefds, fd_set * __restrict __exceptfds, const struct timespec *__restrict __timeout, const __sigset_t * __restrict __sigmask); #endif /* * vpp implementation of glibc APIs from <sys/socket.h> */ extern int __THROW vcom_socket (int __domain, int __type, int __protocol); /* On Linux, the only supported domain for this call is AF_UNIX * (or synonymously, AF_LOCAL). Most implementations have the * same restriction. * vpp does not implement AF_UNIX domain in this release. * */ extern int __THROW vcom_socketpair (int __domain, int __type, int __protocol, int __fds[2]); extern int __THROW vcom_bind (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len); extern int __THROW vcom_getsockname (int __fd, __SOCKADDR_ARG __addr, socklen_t * __restrict __len); extern int vcom_connect (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len); extern int __THROW vcom_getpeername (int __fd, __SOCKADDR_ARG __addr, socklen_t * __restrict __len); extern ssize_t vcom_send (int __fd, const void *__buf, size_t __n, int __flags); extern ssize_t vcom_recv (int __fd, void *__buf, size_t __n, int __flags); extern ssize_t vcom_sendto (int __fd, const void *__buf, size_t __n, int __flags, __CONST_SOCKADDR_ARG __addr, socklen_t __addr_len); extern ssize_t vcom_recvfrom (int __fd, void *__restrict __buf, size_t __n, int __flags, __SOCKADDR_ARG __addr, socklen_t * __restrict __addr_len); extern ssize_t vcom_sendmsg (int __fd, const struct msghdr *__message, int __flags); #ifdef __USE_GNU extern int sendmmsg (int __fd, struct mmsghdr *__vmessages, unsigned int __vlen, int __flags); #endif extern ssize_t vcom_recvmsg (int __fd, struct msghdr *__message, int __flags); #ifdef __USE_GNU extern int vcom_recvmmsg (int __fd, struct mmsghdr *__vmessages, unsigned int __vlen, int __flags, struct timespec *__tmo); #endif extern int __THROW vcom_getsockopt (int __fd, int __level, int __optname, void *__restrict __optval, socklen_t * __restrict __optlen); extern int __THROW vcom_setsockopt (int __fd, int __level, int __optname, const void *__optval, socklen_t __optlen); extern int __THROW vcom_listen (int __fd, int __n); extern int vcom_accept (int __fd, __SOCKADDR_ARG __addr, socklen_t * __restrict __addr_len); #ifdef __USE_GNU /* * Similar to 'accept' but takes an additional parameter to specify * flags. * */ /* TBD: implemented later */ extern int vcom_accept4 (int __fd, __SOCKADDR_ARG __addr, socklen_t * __restrict __addr_len, int __flags); #endif extern int __THROW vcom_shutdown (int __fd, int __how); extern int __THROW vcom_epoll_create (int __size); extern int __THROW vcom_epoll_create1 (int __flags); extern int __THROW vcom_epoll_ctl (int __epfd, int __op, int __fd, struct epoll_event *__event); extern int vcom_epoll_wait (int __epfd, struct epoll_event *__events, int __maxevents, int __timeout); extern int vcom_epoll_pwait (int __epfd, struct epoll_event *__events, int __maxevents, int __timeout, const __sigset_t * __ss); /* * NOTE: observed __nfds is less than 128 from kubecon strace files * for the POC, it's fair to assume that nfds is less than 1024. * TBD: make it thread safe and design to scale. * */ #define MAX_POLL_NFDS_DEFAULT 1024 extern int vcom_poll (struct pollfd *__fds, nfds_t __nfds, int __timeout); #ifdef __USE_GNU extern int vcom_ppoll (struct pollfd *__fds, nfds_t __nfds, const struct timespec *__timeout, const __sigset_t * __ss); #endif #endif /* included_vcom_h */ /* * fd.io coding-style-patch-verification: ON * * Local Variables: * eval: (c-set-style "gnu") * End: */