]> git.puffer.fish Git - mirror/frr.git/commitdiff
tests/lib: fix seqlock test
authorDavid Lamparter <equinox@opensourcerouting.org>
Wed, 19 Jun 2024 19:36:17 +0000 (21:36 +0200)
committerDavid Lamparter <equinox@opensourcerouting.org>
Thu, 20 Jun 2024 09:02:19 +0000 (11:02 +0200)
seqlock_bump() used to return the value before bumping, but that's
unhelpful if you were to actually need it.  I had changed it to return
the value after, but the update to the test got lost at some point.

The return value is not in fact used anywhere in FRR, so while it is
a bug, it has zero impact.

NB: yes, test_seqlock is not run, which sounds wrong.  The problem here
is that (a) the test itself uses sleeps and is timing sensitive, which
would raise false positives.  And (b), the test is meaningless if
executed once.  It needs to be run millions of times under various
conditions (e.g. load) to catch rare races, and it needs to be run on
machines with "odd" memory models (in this case I used BE ppc32 and
ppc64 systems as test platforms.)

Fixes: 6046b690b53 ("lib/seqlock: avoid syscalls in no-waiter cases")
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
tests/lib/test_seqlock.c

index 288d4a8c255459c640e6bf081ab253802fd6da27..35501cbd4a6aa82c5c71b4446381f7bd1f686a41 100644 (file)
@@ -82,11 +82,11 @@ int main(int argc, char **argv)
        assert(seqlock_held(&sqlo));
 
        assert(seqlock_cur(&sqlo) == 1);
-       assert(seqlock_bump(&sqlo) == 1);
-       assert(seqlock_cur(&sqlo) == 5);
        assert(seqlock_bump(&sqlo) == 5);
+       assert(seqlock_cur(&sqlo) == 5);
        assert(seqlock_bump(&sqlo) == 9);
        assert(seqlock_bump(&sqlo) == 13);
+       assert(seqlock_bump(&sqlo) == 17);
        assert(seqlock_cur(&sqlo) == 17);
 
        assert(seqlock_held(&sqlo));