]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 5160: Test suite fails with -flto=auto (#897)
authorAlex Rousskov <rousskov@measurement-factory.com>
Sat, 2 Jul 2022 14:09:16 +0000 (14:09 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Sat, 2 Jul 2022 14:09:25 +0000 (14:09 +0000)
    FAIL: tests/testStore
    Test name: testStoreHashIndex::testSearch
        - check failed: setHow_ != optUnspecified
        exception location: ../src/base/YesNoNone.h(48) operator bool

Segmentation fault in tests/testStore is another symptom.

testStoreHashIndex calls Store::Root().init() which eventually gets to
MemStore::Requested() which correctly requires Config.memShared to be
configured. Hack the missing configuration replacement, following the
inconsistent pattern in three other test suites.

Similarly, Store::Disks::init() needs Config.store_dir_select_algorithm.

TODO: Reduce configuration code duplication and such bugs by providing
initialization method(s) for all Store::Root()-using tests to (re)use.

What does LTO have to do with any of it? CPPUnit [allegedly] randomizes
execution of test suites using raw C++ pointers, and a test suite in the
testStore collection probably contains the right initialization code.
Unfortunately, Config initialization is evidently shared across test
suites (XXX). LTO evidently changes those raw pointer values enough to
change the order in an unfortunate way.

[allegedly]: https://sourceforge.net/p/cppunit/bugs/182/

src/tests/testStoreHashIndex.cc

index 37c5f44185bc3ccdfa8f4d27cffee09f473c2b79..5eaf2e468f406406e0feb41a46c24452fb615d7d 100644 (file)
@@ -100,6 +100,8 @@ static void commonInit()
     if (inited)
         return;
 
+    inited = true;
+
     Mem::Init();
 
     Config.Store.avgObjectSize = 1024;
@@ -107,6 +109,10 @@ static void commonInit()
     Config.Store.objectsPerBucket = 20;
 
     Config.Store.maxObjectSize = 2048;
+
+    Config.memShared.defaultTo(false);
+
+    Config.store_dir_select_algorithm = xstrdup("round-robin");
 }
 
 /* TODO make this a cbdata class */