diff --git a/DataFormats/TestObjects/interface/SchemaEvolutionTestObjects.h b/DataFormats/TestObjects/interface/SchemaEvolutionTestObjects.h index 3eb527df94ac3..1c1374cd7f047 100644 --- a/DataFormats/TestObjects/interface/SchemaEvolutionTestObjects.h +++ b/DataFormats/TestObjects/interface/SchemaEvolutionTestObjects.h @@ -1,6 +1,7 @@ #ifndef DataFormats_TestObjects_SchemaEvolutionTestObjects_h #define DataFormats_TestObjects_SchemaEvolutionTestObjects_h +#include #include // Don't delete the following comment line. @@ -23,7 +24,6 @@ #include #include -#include #include #endif @@ -208,6 +208,37 @@ namespace edmtest { #endif }; + class SchemaEvolutionAutoPtrToUniquePtr { + public: + SchemaEvolutionAutoPtrToUniquePtr(SchemaEvolutionAutoPtrToUniquePtr&&) = delete; + SchemaEvolutionAutoPtrToUniquePtr& operator=(SchemaEvolutionAutoPtrToUniquePtr const&) = delete; + SchemaEvolutionAutoPtrToUniquePtr& operator=(SchemaEvolutionAutoPtrToUniquePtr&&) = delete; + + SchemaEvolutionAutoPtrToUniquePtr() : a_(0), b_(0) {} + ~SchemaEvolutionAutoPtrToUniquePtr() {} +#if defined DataFormats_TestObjects_USE_OLD + SchemaEvolutionAutoPtrToUniquePtr(SchemaEvolutionAutoPtrToUniquePtr const& other) + : a_(other.a_), b_(other.b_), contained_(new SchemaEvolutionContained(other.contained_->c_)) {} + + SchemaEvolutionAutoPtrToUniquePtr(int a, int b, int c) + : a_(a), b_(b), contained_(new SchemaEvolutionContained(c)) {} + int a_; + int b_; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + std::auto_ptr contained_; +#pragma GCC diagnostic pop +#else + SchemaEvolutionAutoPtrToUniquePtr(int a, int b, int c) + : a_(a), b_(b), contained_(std::make_unique(c)) {} + SchemaEvolutionAutoPtrToUniquePtr(SchemaEvolutionAutoPtrToUniquePtr const& other) + : a_(other.a_), b_(other.b_), contained_(std::make_unique(other.contained_->c_)) {} + int a_; + int b_; + std::unique_ptr contained_; +#endif + }; + class SchemaEvolutionCArrayToStdArray { public: #if defined DataFormats_TestObjects_USE_OLD @@ -285,6 +316,7 @@ namespace edmtest { SchemaEvolutionAddBase const&, SchemaEvolutionPointerToMember const&, SchemaEvolutionPointerToUniquePtr const&, + SchemaEvolutionAutoPtrToUniquePtr const&, SchemaEvolutionCArrayToStdArray const&, // SchemaEvolutionCArrayToStdVector const&, SchemaEvolutionVectorToList const&, @@ -305,6 +337,7 @@ namespace edmtest { SchemaEvolutionAddBase addBase_; SchemaEvolutionPointerToMember pointerToMember_; SchemaEvolutionPointerToUniquePtr pointerToUniquePtr_; + SchemaEvolutionAutoPtrToUniquePtr autoPtrToUniquePtr_; SchemaEvolutionCArrayToStdArray cArrayToStdArray_; // This one is commented out because it fails reading an old format // input file with an executable built with the modified format. diff --git a/DataFormats/TestObjects/src/SchemaEvolutionTestObjects.cc b/DataFormats/TestObjects/src/SchemaEvolutionTestObjects.cc index d79d7b663ab71..3274054e6bd81 100644 --- a/DataFormats/TestObjects/src/SchemaEvolutionTestObjects.cc +++ b/DataFormats/TestObjects/src/SchemaEvolutionTestObjects.cc @@ -13,6 +13,7 @@ namespace edmtest { SchemaEvolutionAddBase const& addBase, SchemaEvolutionPointerToMember const& pointerToMember, SchemaEvolutionPointerToUniquePtr const& pointerToUniquePtr, + SchemaEvolutionAutoPtrToUniquePtr const& autoPtrToUniquePtr, SchemaEvolutionCArrayToStdArray const& cArrayToStdArray, // SchemaEvolutionCArrayToStdVector const& cArrayToStdVector, SchemaEvolutionVectorToList const& vectorToList, @@ -27,6 +28,7 @@ namespace edmtest { addBase_(addBase), pointerToMember_(pointerToMember), pointerToUniquePtr_(pointerToUniquePtr), + autoPtrToUniquePtr_(autoPtrToUniquePtr), cArrayToStdArray_(cArrayToStdArray), // cArrayToStdVector_(cArrayToStdVector), vectorToList_(vectorToList), diff --git a/DataFormats/TestObjects/src/classes.h b/DataFormats/TestObjects/src/classes.h index 3d3a4ffc2ec32..c69c8b724bfaf 100644 --- a/DataFormats/TestObjects/src/classes.h +++ b/DataFormats/TestObjects/src/classes.h @@ -44,3 +44,23 @@ #include #include + +// related to SchemaEvolutionTestObjects.h +#ifndef DataFormats_TestObjects_USE_OLD + +// The following is from an example by Jakob Blomer from the ROOT team +namespace edmtest::compat { + template + struct deprecated_auto_ptr { + // We use compat_auto_ptr only to assign the wrapped raw pointer + // to a unique pointer in an I/O customization rule. + // Therefore, we don't delete on destruction (because ownership + // gets transferred to the unique pointer). + + // ~deprecated_auto_ptr() { delete _M_ptr; } + + T *_M_ptr = nullptr; + }; +} // namespace edmtest::compat + +#endif diff --git a/DataFormats/TestObjects/src/classes_def.xml b/DataFormats/TestObjects/src/classes_def.xml index 6362e93f9970c..33425f903e957 100644 --- a/DataFormats/TestObjects/src/classes_def.xml +++ b/DataFormats/TestObjects/src/classes_def.xml @@ -295,6 +295,20 @@ exception when running testMissingDictionaryChecking_cfg.py. + + - + - + - + - + - + - + - + - + - + + + + + + + + + + - + - + - + - + - + + + - - + diff --git a/FWCore/Services/plugins/InitRootHandlers.cc b/FWCore/Services/plugins/InitRootHandlers.cc index 78c222742a3df..2a2de3e1db606 100644 --- a/FWCore/Services/plugins/InitRootHandlers.cc +++ b/FWCore/Services/plugins/InitRootHandlers.cc @@ -164,7 +164,7 @@ namespace { } //Contents of a message which should be reported as an INFO not a ERROR - constexpr std::array in_message{ + constexpr std::array in_message{ {"no dictionary for class", "already in TClassTable", "matrix not positive definite", @@ -175,7 +175,8 @@ namespace { "nbinsy is <=0 - set to nbinsy = 1", "oneapi::tbb::global_control is limiting", "ufirst < fXmin, fXmin is used", - "ulast > fXmax, fXmax is used"}}; + "ulast > fXmax, fXmax is used", + "Inspection for auto_ptr"}}; //Location generating messages which should be reported as an INFO not a ERROR constexpr std::array in_location{{"Fit", diff --git a/IOPool/Input/test/SchemaEvolutionTestRead.cc b/IOPool/Input/test/SchemaEvolutionTestRead.cc index ae418c532f99a..f9b9de4fffc66 100644 --- a/IOPool/Input/test/SchemaEvolutionTestRead.cc +++ b/IOPool/Input/test/SchemaEvolutionTestRead.cc @@ -48,12 +48,14 @@ namespace edmtest { const std::vector expectedVectorVectorIntegralValues_; const edm::EDGetTokenT vectorVectorToken_; const edm::EDGetTokenT vectorVectorNonSplitToken_; + const bool testAutoPtrToUniquePtr_; }; SchemaEvolutionTestRead::SchemaEvolutionTestRead(edm::ParameterSet const& iPSet) : expectedVectorVectorIntegralValues_(iPSet.getParameter>("expectedVectorVectorIntegralValues")), vectorVectorToken_(consumes(iPSet.getParameter("vectorVectorTag"))), - vectorVectorNonSplitToken_(consumes(iPSet.getParameter("vectorVectorTag"))) { + vectorVectorNonSplitToken_(consumes(iPSet.getParameter("vectorVectorTag"))), + testAutoPtrToUniquePtr_(iPSet.getParameter("testAutoPtrToUniquePtr")) { if (expectedVectorVectorIntegralValues_.size() != 15) { throwWithMessageFromConstructor("test configuration error, expectedVectorVectorIntegralValues must have size 15"); } @@ -68,6 +70,7 @@ namespace edmtest { edm::ParameterSetDescription desc; desc.add>("expectedVectorVectorIntegralValues"); desc.add("vectorVectorTag"); + desc.add("testAutoPtrToUniquePtr", false); descriptions.addDefault(desc); } @@ -170,6 +173,19 @@ namespace edmtest { throwWithMessage("analyzeVectorVector, pointerToUniquePtr c_ does not contain expected value"); } + if (testAutoPtrToUniquePtr_) { + SchemaEvolutionAutoPtrToUniquePtr const& autoPtrToUniquePtr = element.autoPtrToUniquePtr_; + if (autoPtrToUniquePtr.a_ != expectedVectorVectorIntegralValues_[8] + iOffset + j * 23) { + throwWithMessage("analyzeVectorVector, autoPtrToUniquePtr a_ does not contain expected value"); + } + if (autoPtrToUniquePtr.b_ != expectedVectorVectorIntegralValues_[8] + iOffset + j * 123) { + throwWithMessage("analyzeVectorVector, autoPtrToUniquePtr b_ does not contain expected value"); + } + if (autoPtrToUniquePtr.contained_->c_ != expectedVectorVectorIntegralValues_[8] + iOffset + j * 1023) { + throwWithMessage("analyzeVectorVector, autoPtrToUniquePtr c_ does not contain expected value"); + } + } + SchemaEvolutionCArrayToStdArray const& cArrayToStdArray = element.cArrayToStdArray_; if (cArrayToStdArray.a_[0] != expectedVectorVectorIntegralValues_[9] + iOffset + j * 19) { throwWithMessage("analyzeVectorVector, cArrayToStdArray a_[0] does not contain expected value"); diff --git a/IOPool/Input/test/SchemaEvolutionTestWrite.cc b/IOPool/Input/test/SchemaEvolutionTestWrite.cc index a951bb1870b00..dd481c617e782 100644 --- a/IOPool/Input/test/SchemaEvolutionTestWrite.cc +++ b/IOPool/Input/test/SchemaEvolutionTestWrite.cc @@ -103,6 +103,9 @@ namespace edmtest { SchemaEvolutionPointerToUniquePtr pointerToUniquePtr(testIntegralValues_[8] + iOffset + j * 18, testIntegralValues_[8] + iOffset + j * 108, testIntegralValues_[8] + iOffset + j * 1008); + SchemaEvolutionAutoPtrToUniquePtr autoPtrToUniquePtr(testIntegralValues_[8] + iOffset + j * 23, + testIntegralValues_[8] + iOffset + j * 123, + testIntegralValues_[8] + iOffset + j * 1023); SchemaEvolutionCArrayToStdArray cArrayToStdArray(testIntegralValues_[9] + iOffset + j * 19, testIntegralValues_[9] + iOffset + j * 109, testIntegralValues_[9] + iOffset + j * 1009); @@ -128,6 +131,7 @@ namespace edmtest { addBase, pointerToMember, pointerToUniquePtr, + autoPtrToUniquePtr, cArrayToStdArray, // cArrayToStdVector, vectorToList, diff --git a/IOPool/Input/test/SchemaEvolution_test_read_cfg.py b/IOPool/Input/test/SchemaEvolution_test_read_cfg.py index f4ae9aa123de2..49054ec13e904 100644 --- a/IOPool/Input/test/SchemaEvolution_test_read_cfg.py +++ b/IOPool/Input/test/SchemaEvolution_test_read_cfg.py @@ -9,6 +9,7 @@ parser.add_argument("--inputFile", type=str, help="Input file name (default: SchemaEvolutionTest.root)", default="SchemaEvolutionTest.root") parser.add_argument("--outputFileName", type=str, help="Output file name (default: SchemaEvolutionTest2.root)", default="SchemaEvolutionTest2.root") parser.add_argument("--enableStreamerInfosFix", action="store_true", help="Enable service that fixes missing streamer infos") +parser.add_argument("--testAutoPtrToUniquePtr", action="store_true", help="Test AutoPtrToUniquePtr evolution") args = parser.parse_args() process = cms.Process("READ") @@ -82,7 +83,8 @@ expectedVectorVectorIntegralValues = cms.vint32( 11, 21, 31, 41, 51, 61, 71, 81, 91, 101, 111, 121, 131, 141, 151 ), - vectorVectorTag = cms.InputTag("writeSchemaEvolutionTest", "", "PROD") + vectorVectorTag = cms.InputTag("writeSchemaEvolutionTest", "", "PROD"), + testAutoPtrToUniquePtr = cms.bool(args.testAutoPtrToUniquePtr) ) process.out = cms.OutputModule("PoolOutputModule", diff --git a/IOPool/Input/test/testSchemaEvolution.sh b/IOPool/Input/test/testSchemaEvolution.sh index 7c799f9294e59..a3cf48e069983 100755 --- a/IOPool/Input/test/testSchemaEvolution.sh +++ b/IOPool/Input/test/testSchemaEvolution.sh @@ -15,10 +15,10 @@ LOCAL_TEST_DIR=${SCRAM_TEST_PATH} # in the later cmsRun processes, they are more likely to be # caused by a failure in ROOT schema evolution. cmsRun ${LOCAL_TEST_DIR}/SchemaEvolution_create_test_file_cfg.py --splitLevel 0 || die 'Failure using SchemaEvolution_create_test_file_cfg.py splitLevel 0' $? -cmsRun ${LOCAL_TEST_DIR}/SchemaEvolution_test_read_cfg.py --inputFile SchemaEvolutionTest_splitLevel0.root || die 'Failure using SchemaEvolution_create_test_file_cfg.py splitLevel 0' $? +cmsRun ${LOCAL_TEST_DIR}/SchemaEvolution_test_read_cfg.py --inputFile SchemaEvolutionTest_splitLevel0.root --testAutoPtrToUniquePtr || die 'Failure using SchemaEvolution_create_test_file_cfg.py splitLevel 0' $? cmsRun ${LOCAL_TEST_DIR}/SchemaEvolution_create_test_file_cfg.py --splitLevel 99 || die 'Failure using SchemaEvolution_create_test_file_cfg.py splitLevel 99' $? -cmsRun ${LOCAL_TEST_DIR}/SchemaEvolution_test_read_cfg.py --inputFile SchemaEvolutionTest_splitLevel99.root || die 'Failure using SchemaEvolution_create_test_file_cfg.py splitLevel 99' $? +cmsRun ${LOCAL_TEST_DIR}/SchemaEvolution_test_read_cfg.py --inputFile SchemaEvolutionTest_splitLevel99.root --testAutoPtrToUniquePtr || die 'Failure using SchemaEvolution_create_test_file_cfg.py splitLevel 99' $? # For each StreamerInfo in the input file, test for existence of StreamerInfo for @@ -94,11 +94,11 @@ done file=SchemaEvolutionTestOLD15_1_0_pre5_splitLevel0.root inputfile=$(edmFileInPath IOPool/Input/data/$file) || die "Failure edmFileInPath IOPool/Input/data/$file" $? -cmsRun ${LOCAL_TEST_DIR}/SchemaEvolution_test_read_cfg.py --inputFile "$inputfile" || die "Failed to read old file $file" $? +cmsRun ${LOCAL_TEST_DIR}/SchemaEvolution_test_read_cfg.py --inputFile "$inputfile" --testAutoPtrToUniquePtr || die "Failed to read old file $file" $? file=SchemaEvolutionTestOLD15_1_0_pre5_splitLevel99.root inputfile=$(edmFileInPath IOPool/Input/data/$file) || die "Failure edmFileInPath IOPool/Input/data/$file" $? -cmsRun ${LOCAL_TEST_DIR}/SchemaEvolution_test_read_cfg.py --inputFile "$inputfile" || die "Failed to read old file $file" $? +cmsRun ${LOCAL_TEST_DIR}/SchemaEvolution_test_read_cfg.py --inputFile "$inputfile" --testAutoPtrToUniquePtr || die "Failed to read old file $file" $? file=SchemaEvolutionTestOLD13_0_0.root inputfile=$(edmFileInPath IOPool/Input/data/$file) || die "Failure edmFileInPath IOPool/Input/data/$file" $?