diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/lib/test_typelist.c | 8 | ||||
| -rw-r--r-- | tests/lib/test_typelist.h | 64 | ||||
| -rw-r--r-- | tests/topotests/lib/topotest.py | 2 |
3 files changed, 70 insertions, 4 deletions
diff --git a/tests/lib/test_typelist.c b/tests/lib/test_typelist.c index 607e29e56b..6e69658490 100644 --- a/tests/lib/test_typelist.c +++ b/tests/lib/test_typelist.c @@ -58,9 +58,10 @@ #define T_HASH (1 << 2) #define T_HEAP (1 << 3) #define T_ATOMIC (1 << 4) +#define T_REVERSE (1 << 5) #define _T_LIST (0) -#define _T_DLIST (0) +#define _T_DLIST (0 | T_REVERSE) #define _T_ATOMLIST (0 | T_ATOMIC) #define _T_HEAP (T_SORTED | T_HEAP) #define _T_SORTLIST_UNIQ (T_SORTED | T_UNIQ) @@ -68,8 +69,8 @@ #define _T_HASH (T_SORTED | T_UNIQ | T_HASH) #define _T_SKIPLIST_UNIQ (T_SORTED | T_UNIQ) #define _T_SKIPLIST_NONUNIQ (T_SORTED) -#define _T_RBTREE_UNIQ (T_SORTED | T_UNIQ) -#define _T_RBTREE_NONUNIQ (T_SORTED) +#define _T_RBTREE_UNIQ (T_SORTED | T_UNIQ | T_REVERSE) +#define _T_RBTREE_NONUNIQ (T_SORTED | T_REVERSE) #define _T_ATOMSORT_UNIQ (T_SORTED | T_UNIQ | T_ATOMIC) #define _T_ATOMSORT_NONUNIQ (T_SORTED | T_ATOMIC) @@ -79,6 +80,7 @@ #define IS_HASH(type) (_T_TYPE(type) & T_HASH) #define IS_HEAP(type) (_T_TYPE(type) & T_HEAP) #define IS_ATOMIC(type) (_T_TYPE(type) & T_ATOMIC) +#define IS_REVERSE(type) (_T_TYPE(type) & T_REVERSE) static struct timeval ref, ref0; diff --git a/tests/lib/test_typelist.h b/tests/lib/test_typelist.h index 8261616ed2..e3579c67a2 100644 --- a/tests/lib/test_typelist.h +++ b/tests/lib/test_typelist.h @@ -31,6 +31,11 @@ #define list_const_next concat(TYPE, _const_next) #define list_next concat(TYPE, _next) #define list_next_safe concat(TYPE, _next_safe) +#define list_const_last concat(TYPE, _const_last) +#define list_last concat(TYPE, _last) +#define list_const_prev concat(TYPE, _const_prev) +#define list_prev concat(TYPE, _prev) +#define list_prev_safe concat(TYPE, _prev_safe) #define list_count concat(TYPE, _count) #define list_add concat(TYPE, _add) #define list_add_head concat(TYPE, _add_head) @@ -171,6 +176,9 @@ static void concat(test_, TYPE)(void) list_init(&head); assert(list_first(&head) == NULL); +#if IS_REVERSE(REALTYPE) + assert(list_last(&head) == NULL); +#endif ts_hash("init", "df3f619804a92fdb4057192dc43dd748ea778adc52bc498ce80524c014b81119"); @@ -203,6 +211,10 @@ static void concat(test_, TYPE)(void) assert(!list_first(&head)); assert(list_count(&other) == k); assert(list_first(&other) != NULL); +#if IS_REVERSE(REALTYPE) + assert(!list_last(&head)); + assert(list_last(&other) != NULL); +#endif ts_hash_headx( &other, "swap1", "a538546a6e6ab0484e925940aa8dd02fd934408bbaed8cb66a0721841584d838"); @@ -269,13 +281,36 @@ static void concat(test_, TYPE)(void) (void)cprev; #else assert(!cprev || cprev->val < citem->val); +#if IS_REVERSE(REALTYPE) + assert(list_const_prev(chead, citem) == cprev); +#endif #endif cprev = citem; k++; } assert(list_count(chead) == k); +#if IS_REVERSE(REALTYPE) + assert(cprev == list_const_last(chead)); +#endif ts_ref("walk"); +#if IS_REVERSE(REALTYPE) && !IS_HASH(REALTYPE) && !IS_HEAP(REALTYPE) + cprev = NULL; + k = 0; + + frr_rev_each(list_const, chead, citem) { + assert(!cprev || cprev->val > citem->val); + assert(list_const_next(chead, citem) == cprev); + + cprev = citem; + k++; + } + assert(list_count(chead) == k); + assert(cprev == list_const_first(chead)); + + ts_ref("reverse-walk"); +#endif + #if IS_UNIQ(REALTYPE) prng_free(prng); prng = prng_new(0); @@ -439,6 +474,9 @@ static void concat(test_, TYPE)(void) } assert(list_count(&head) == k); assert(list_first(&head) != NULL); +#if IS_REVERSE(REALTYPE) + assert(list_last(&head) != NULL); +#endif ts_hash("fill / add_tail", "eabfcf1413936daaf20965abced95762f45110a6619b84aac7d38481bce4ea19"); #if !IS_ATOMIC(REALTYPE) @@ -451,6 +489,10 @@ static void concat(test_, TYPE)(void) assert(!list_first(&head)); assert(list_count(&other) == k); assert(list_first(&other) != NULL); +#if IS_REVERSE(REALTYPE) + assert(!list_last(&head)); + assert(list_last(&other) != NULL); +#endif ts_hash_head( &other, "swap1", "eabfcf1413936daaf20965abced95762f45110a6619b84aac7d38481bce4ea19"); @@ -534,6 +576,21 @@ static void concat(test_, TYPE)(void) } ts_hash("member", "42b8950c880535b2d2e0c980f9845f7841ecf675c0fb9801aec4170d2036349d"); #endif +#if IS_REVERSE(REALTYPE) + i = 0; + prev = NULL; + + frr_rev_each (list, &head, item) { + assert(item->scratchpad != 0); + assert(list_next(&head, item) == prev); + + i++; + prev = item; + } + assert(list_first(&head) == prev); + assert(list_count(&head) == i); + ts_hash("reverse-walk", "42b8950c880535b2d2e0c980f9845f7841ecf675c0fb9801aec4170d2036349d"); +#endif while ((item = list_pop(&head))) { assert(item->scratchpad != 0); @@ -746,6 +803,13 @@ static void concat(test_, TYPE)(void) #undef list_first #undef list_next #undef list_next_safe +#undef list_const_first +#undef list_const_next +#undef list_last +#undef list_prev +#undef list_prev_safe +#undef list_const_last +#undef list_const_prev #undef list_count #undef list_add #undef list_add_head diff --git a/tests/topotests/lib/topotest.py b/tests/topotests/lib/topotest.py index 4e5fe4c90b..62b6a8a70e 100644 --- a/tests/topotests/lib/topotest.py +++ b/tests/topotests/lib/topotest.py @@ -1749,7 +1749,7 @@ class Router(Node): daemon, self.logdir, self.name ) - cmdopt = "{} --log file:{}.log --log-level debug".format( + cmdopt = "{} --command-log-always --log file:{}.log --log-level debug".format( daemon_opts, daemon ) if extra_opts: |
