From 27685efafa1108ccbcba99ec63e78427ee920f3c Mon Sep 17 00:00:00 2001 From: Alex Rousskov Date: Sat, 2 Jul 2022 14:09:16 +0000 Subject: [PATCH] Bug 5160: Test suite fails with -flto=auto (#897) 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 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/tests/testStoreHashIndex.cc b/src/tests/testStoreHashIndex.cc index 37c5f44185..5eaf2e468f 100644 --- a/src/tests/testStoreHashIndex.cc +++ b/src/tests/testStoreHashIndex.cc @@ -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 */ -- 2.39.5