Commit c7d9890795 for frr
commit c7d989079592cb9a1ec94086c4e1bb488c7976dc
Author: Jing Kan <kanjing.kj@alibaba-inc.com>
Date: Tue Nov 3 11:19:23 2026 +0800
tests: avoid invalid AF indexes in capability tests
The MP8 fixture uses an unsupported AFI/SAFI pair. When mapping fails,
the returned AFI_MAX or SAFI_MAX sentinel is not a valid peer AF-array
index, but the diagnostic output still reads afc_recv and afc_nego.
Only print and check the peer AF arrays after successful mapping. Keep
the unsupported-family diagnostic and the existing failure expectation
when a supposedly valid family cannot be mapped.
Signed-off-by: Jing Kan <kanjing.kj@alibaba-inc.com>
diff --git a/tests/bgpd/test_capability.c b/tests/bgpd/test_capability.c
index 261b7c9da7..24d7656b4b 100644
--- a/tests/bgpd/test_capability.c
+++ b/tests/bgpd/test_capability.c
@@ -860,19 +860,19 @@ static void parse_test(struct peer *peer, struct test_segment *t, int type)
/* Convert AFI, SAFI to internal values, check. */
if (bgp_map_afi_safi_iana2int(t->afi, t->safi, &afi, &safi)) {
+ printf("MP: %u/%u: unsupported AFI/SAFI\n", t->afi, t->safi);
if (t->afi_valid == VALID_AFI)
failed++;
- }
- printf("MP: %u(%u)/%u(%u): recv %u, nego %u\n", t->afi, afi,
- t->safi, safi, peer->afc_recv[afi][safi],
- peer->afc_nego[afi][safi]);
-
- if (t->afi_valid == VALID_AFI) {
-
- if (!peer->afc_recv[afi][safi])
- failed++;
- if (!peer->afc_nego[afi][safi])
- failed++;
+ } else {
+ printf("MP: %u(%u)/%u(%u): recv %u, nego %u\n", t->afi, afi, t->safi, safi,
+ peer->afc_recv[afi][safi], peer->afc_nego[afi][safi]);
+
+ if (t->afi_valid == VALID_AFI) {
+ if (!peer->afc_recv[afi][safi])
+ failed++;
+ if (!peer->afc_nego[afi][safi])
+ failed++;
+ }
}
}