From 0c4b0dac6040f36507026ac12891bc09921e5b09 Mon Sep 17 00:00:00 2001 From: NĂ©lio Laranjeiro Date: Tue, 15 Mar 2011 16:25:18 +0100 Subject: cesar/bsu: save sta_avln when positioned after the removed avln, closes #2399 bsu_avln_remove corrupts the sta_avln pointer when it removes the AVLN in positions before in the table. --- cesar/bsu/test/utest/src/bsut.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'cesar/bsu/test') diff --git a/cesar/bsu/test/utest/src/bsut.c b/cesar/bsu/test/utest/src/bsut.c index eb437fb717..7e22d519cc 100644 --- a/cesar/bsu/test/utest/src/bsut.c +++ b/cesar/bsu/test/utest/src/bsut.c @@ -849,6 +849,41 @@ test_case_bsu_add_avln_array_full (test_t t) bsu_test_uninit (&ctx); } +void +test_case_bsu_avln_remove (test_t t) +{ + test_case_begin (t, "AVLN remove"); + test_begin ( + t, "add and remove avlns with sta_avln setted before and after") + { + bsu_test_t ctx; + bsu_test_init (&ctx); + bool added; + uint i; + for (i = 0; i < BSU_FOREIGN_AVLNS_NB; i++) + { + bsu_avln_add (ctx.bsu, i, i, i, &added); + test_fail_unless (added); + } + /* sta_avln is the one removed. */ + ctx.bsu->sta_avln = &ctx.bsu->avlns[1]; + /* Reinitialise the sync information wrote by bsu_test_init. */ + bsu_ntb_init (&ctx.bsu->poweron.sync); + bsu_avln_remove (1, 1, 1); + test_fail_unless (ctx.bsu->sta_avln == &ctx.bsu->poweron); + /* sta_avln is the first one. */ + ctx.bsu->sta_avln = &ctx.bsu->avlns[0]; + bsu_avln_remove (2, 2, 2); + test_fail_unless (ctx.bsu->sta_avln == &ctx.bsu->avlns[0]); + /* sta_avln is the 4th one. */ + ctx.bsu->sta_avln = &ctx.bsu->avlns[4]; + bsu_avln_remove (3, 3, 3); + test_fail_unless (ctx.bsu->sta_avln == &ctx.bsu->avlns[3]); + bsu_test_uninit (&ctx); + } + test_end; +} + void test_suite_bsu (test_t t) { @@ -863,4 +898,5 @@ test_suite_bsu (test_t t) test_case_bsu_nek_index (t); test_case_bsu_discover_update (t); test_case_bsu_add_avln_array_full (t); + test_case_bsu_avln_remove (t); } -- cgit v1.2.3