From fee4f17bff7e35f73e63c945384feadad8a8b1a3 Mon Sep 17 00:00:00 2001 From: DrDoof <8052722+DrDoof@users.noreply.github.com> Date: Sun, 4 Oct 2026 18:09:58 +0200 Subject: [PATCH] test/stp: print each scenario heading once Scenarios 4 and 7 start from the state scenario 3 leaves behind, and 38 from the one 37 leaves, and they called those scenarios for it, so the headings of 3 and 37 showed up again in the middle of the run. The setup of 3 and 37 now lives in functions of its own that the scenarios call. --- test/stp/stp_sim.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/test/stp/stp_sim.c b/test/stp/stp_sim.c index 5a0faf15..8689655b 100644 --- a/test/stp/stp_sim.c +++ b/test/stp/stp_sim.c @@ -337,9 +337,8 @@ static void scen_root_port(void) check_state(8, 3, "root port forwards after the listen period"); } -static void scen_ring(void) +static void ring(void) { - printf("3. a neighbour with a cheaper path to the root must block us\n"); reset_all(); links_set((1 << 0) | (1 << 8)); secs(1); @@ -364,10 +363,16 @@ static void scen_ring(void) check_state(0, 1, "port 1 is discarding (alternate)"); } +static void scen_ring(void) +{ + printf("3. a neighbour with a cheaper path to the root must block us\n"); + ring(); +} + static void scen_ring_clears(void) { printf("4. when the better neighbour goes quiet the port comes back\n"); - scen_ring(); + ring(); struct sim_bpdu from_root = { .port = 8, .root_prio = 0x40, .root_cost = 0, .br_prio = 0x40, .port_id = 2 }; memcpy(from_root.root_mac, ROOT_MAC, 6); @@ -436,7 +441,7 @@ static void scen_we_are_better(void) static void scen_alt_survives_link_bounce(void) { printf("7. a blocked port stays blocked when the carrier returns\n"); - scen_ring(); + ring(); struct sim_bpdu from_root = { .port = 8, .root_prio = 0x40, .root_cost = 0, .br_prio = 0x40, .port_id = 2 }; memcpy(from_root.root_mac, ROOT_MAC, 6); @@ -1129,9 +1134,8 @@ static void scen_backup_role(void) check(((stp_backup >> 3) & 1) == 0, "losing the link clears the backup role"); } -static void scen_migrate_to_stp(void) +static void migrate_to_stp(void) { - printf("37. a port that hears an 802.1D neighbour sends Config BPDUs\n"); reset_all(); stp_pflags[1] &= ~STP_PF_AUTOEDGE; links_set((1 << 1) | (1 << 8)); @@ -1150,10 +1154,16 @@ static void scen_migrate_to_stp(void) check(((stp_legacy >> 1) & 1) == 1 && ((stp_legacy >> 8) & 1) == 0, "only port 2 is switched, not the root port"); } +static void scen_migrate_to_stp(void) +{ + printf("37. a port that hears an 802.1D neighbour sends Config BPDUs\n"); + migrate_to_stp(); +} + static void scen_migrate_back(void) { printf("38. mcheck and an RST neighbour bring the port back to RSTP\n"); - scen_migrate_to_stp(); + migrate_to_stp(); struct sim_bpdu r = root_on(8); secs(4); stp_port_mcheck(1);