On Wed, Nov 22, 2023 at 11:49:55AM +0100, Michal Privoznik wrote: > The way that nwfilterxml2firewalltest works is: it loads a > NWFilter XML from a file, parses it and then calls > ebiptablesApplyNewRules() recording all commands that would be > executed when instantiating the rule. This is then compared to > expected output. > > But the very first thing that ebiptablesApplyNewRules() does, it > calls qsort() to sort the rules. But with new glibc, qsort() is > not stable anymore and thus the order in which two rules with > equal priorities are applied is not guaranteed. > > Use qsort() from virqsortmock which produces stable results. Aside from the test suite, I'm not too happy with the idea that our ordering of applying rules is non-deterministic :-( There is a well defined ordering for rules - the order in which the user/app listed them in the virNWFilterDef XML document. We have to override this for sorting by priority, but when priority matches, IMHO we should honour the XML rules ordering. I have no idea how hard that is to achieve though, as the place where we do the qsort() seems quite remote from the place where we know the XML doc ordering. > > Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> > --- > tests/nwfilterxml2firewalltest.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/tests/nwfilterxml2firewalltest.c b/tests/nwfilterxml2firewalltest.c > index b78b1b7947..8dadc50054 100644 > --- a/tests/nwfilterxml2firewalltest.c > +++ b/tests/nwfilterxml2firewalltest.c > @@ -461,7 +461,9 @@ mymain(void) > return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; > } > > -VIR_TEST_MAIN_PRELOAD(mymain, VIR_TEST_MOCK("virfirewall")) > +VIR_TEST_MAIN_PRELOAD(mymain, > + VIR_TEST_MOCK("virqsort"), > + VIR_TEST_MOCK("virfirewall")) > > #else /* ! defined (__linux__) */ > > -- > 2.41.0 > _______________________________________________ > Devel mailing list -- devel@xxxxxxxxxxxxxxxxx > To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :| _______________________________________________ Devel mailing list -- devel@xxxxxxxxxxxxxxxxx To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx