From c505e2f6bbce9dcd1d8321c58197be4ab37c9e29 Mon Sep 17 00:00:00 2001 From: scott snyder <scott.snyder@cern.ch> Date: Fri, 17 Nov 2017 15:36:24 +0100 Subject: [PATCH] IOVSvc+DataModelRunTests: Make CondInputLoader output ordering portable. CondInputLoader prints the objects it contains by iterating over a unordered_set. This means that the ordering of the dump is unspecified, and can (and does) vary between different versions of the compiler. Change to printing these in sorted order, so that the output is well-defined. --- Control/IOVSvc/src/CondInputLoader.cxx | 27 ++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/Control/IOVSvc/src/CondInputLoader.cxx b/Control/IOVSvc/src/CondInputLoader.cxx index dc20a9fdb0f..23b5f5f93cc 100644 --- a/Control/IOVSvc/src/CondInputLoader.cxx +++ b/Control/IOVSvc/src/CondInputLoader.cxx @@ -27,6 +27,25 @@ #include "TClass.h" + +namespace +{ + struct DataObjIDSorter { + bool operator()( const DataObjID* a, const DataObjID* b ) { return a->fullKey() < b->fullKey(); } + }; + + // Sort a DataObjIDColl in a well-defined, reproducible manner. + // Used for making debugging dumps. + std::vector<const DataObjID*> sortedDataObjIDColl( const DataObjIDColl& coll ) + { + std::vector<const DataObjID*> v; + v.reserve( coll.size() ); + for ( const DataObjID& id : coll ) v.push_back( &id ); + std::sort( v.begin(), v.end(), DataObjIDSorter() ); + return v; + } +} + /////////////////////////////////////////////////////////////////// // Public methods: /////////////////////////////////////////////////////////////////// @@ -184,13 +203,13 @@ CondInputLoader::initialize() StatusCode sc(StatusCode::SUCCESS); std::ostringstream str; str << "Will create WriteCondHandle dependencies for the following DataObjects:"; - for (auto &e : m_load) { - str << "\n + " << e; - if (e.key() == "") { + for (auto &e : sortedDataObjIDColl(m_load)) { + str << "\n + " << *e; + if (e->key() == "") { sc = StatusCode::FAILURE; str << " ERROR: empty key is not allowed!"; } else { - SG::VarHandleKey vhk(e.clid(),e.key(),Gaudi::DataHandle::Writer, + SG::VarHandleKey vhk(e->clid(),e->key(),Gaudi::DataHandle::Writer, StoreID::storeName(StoreID::CONDITION_STORE)); if (m_condSvc->regHandle(this, vhk).isFailure()) { ATH_MSG_ERROR("Unable to register WriteCondHandle " << vhk.fullKey()); -- GitLab