From bb87c1ef601295110c798c01d422ba46f31ab6c3 Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Sat, 14 Nov 2026 15:16:15 -0500 Subject: [PATCH 1/3] COMP: Set the strict store-copy format with a configured header * Add the cache option SIMPLNX_STORE_COPY_STRICT_FORMAT (default OFF). When ON, a store copy to a storage format that has no registered I/O manager fails instead of falling back to in-memory storage. * Generate simplnx/Common/StoreCopyConfig.hpp from the option. Only StoreCopyUtilities.cpp and the tests that check the behavior include it, so changing the option recompiles only those files. Before, an out-of-core build passed the macro as a PUBLIC compile definition to every file that uses simplnx. * Print the option in the configuration summary. * Move PlaceholderPlanManager into UnitTestCommon and register it for the HDF5-OOC format in the strict-mode tests, so the simplnx tests no longer include the out-of-core storage plugin and a simplnx-only build with the option ON compiles and runs them. Signed-off-by: Michael Jackson --- CMakeLists.txt | 7 ++ cmake/StoreCopyConfig.hpp.in | 5 ++ cmake/Summary.cmake | 1 + src/simplnx/Utilities/StoreCopyUtilities.cpp | 5 +- test/DataArrayTest.cpp | 3 +- test/MemorySafetyTest.cpp | 25 ++++--- test/StorageFormatPlanTest.cpp | 69 ++++++++++--------- .../UnitTest/PlaceholderPlanManager.hpp | 49 +++++++++++++ 8 files changed, 117 insertions(+), 47 deletions(-) create mode 100644 cmake/StoreCopyConfig.hpp.in create mode 100644 test/UnitTestCommon/include/simplnx/UnitTest/PlaceholderPlanManager.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index f91d7dba00..d21b514547 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,6 +31,8 @@ enable_vcpkg_manifest_feature(TEST_VAR SIMPLNX_BUILD_PYTHON FEATURE "python") option(SIMPLNX_BUILD_TESTS "Enable buildingtests" ON) enable_vcpkg_manifest_feature(TEST_VAR SIMPLNX_BUILD_TESTS FEATURE "tests") +option(SIMPLNX_STORE_COPY_STRICT_FORMAT "Fail a store copy to a storage format with no registered I/O manager instead of falling back to in-memory storage" OFF) + # ------------------------------------------------------------------------------ # are multithreading algorithms enabled # ------------------------------------------------------------------------------ @@ -318,6 +320,10 @@ configure_file( ${simplnx_SOURCE_DIR}/cmake/SimplnxConfig.hpp.in ${SIMPLNX_GENERATED_DIR}/simplnx/Common/SimplnxConfig.hpp @ONLY) +configure_file( + ${simplnx_SOURCE_DIR}/cmake/StoreCopyConfig.hpp.in + ${SIMPLNX_GENERATED_DIR}/simplnx/Common/StoreCopyConfig.hpp + @ONLY) set(SIMPLNX_GENERATED_HEADER_DIR ${simplnx_BINARY_DIR}/generated/simplnx) set(SIMPLNX_EXPORT_HEADER ${SIMPLNX_GENERATED_HEADER_DIR}/simplnx_export.hpp) @@ -668,6 +674,7 @@ set(SIMPLNX_HDRS ) set(SIMPLNX_GENERATED_HEADERS + ${SIMPLNX_GENERATED_DIR}/simplnx/Common/StoreCopyConfig.hpp ${SIMPLNX_EXPORT_HEADER} ) diff --git a/cmake/StoreCopyConfig.hpp.in b/cmake/StoreCopyConfig.hpp.in new file mode 100644 index 0000000000..70281ec563 --- /dev/null +++ b/cmake/StoreCopyConfig.hpp.in @@ -0,0 +1,5 @@ +#pragma once + +// Generated by configure_file(). When enabled, store copies fail for storage +// formats with no registered I/O manager instead of using in-memory storage. +#cmakedefine01 SIMPLNX_STORE_COPY_STRICT_FORMAT diff --git a/cmake/Summary.cmake b/cmake/Summary.cmake index c06a749497..57a60ff142 100644 --- a/cmake/Summary.cmake +++ b/cmake/Summary.cmake @@ -65,6 +65,7 @@ else() endif() message(STATUS "* -------------- Simplnx Configuration Options -------------------------------------") +message(STATUS "* SIMPLNX_STORE_COPY_STRICT_FORMAT: ${SIMPLNX_STORE_COPY_STRICT_FORMAT}") message(STATUS "* SIMPLNX_BUILD_TESTS: ${SIMPLNX_BUILD_TESTS}") message(STATUS "* SIMPLNX_ENABLE_MULTICORE: ${SIMPLNX_ENABLE_MULTICORE}") message(STATUS "* SIMPLNX_ENABLE_COMPRESSORS: ${SIMPLNX_ENABLE_COMPRESSORS}") diff --git a/src/simplnx/Utilities/StoreCopyUtilities.cpp b/src/simplnx/Utilities/StoreCopyUtilities.cpp index 4100d95829..37c3acdaa5 100644 --- a/src/simplnx/Utilities/StoreCopyUtilities.cpp +++ b/src/simplnx/Utilities/StoreCopyUtilities.cpp @@ -1,5 +1,6 @@ #include "StoreCopyUtilities.hpp" +#include "simplnx/Common/StoreCopyConfig.hpp" #include "simplnx/Core/Application.hpp" #include "simplnx/Core/Preferences.hpp" #include "simplnx/DataStructure/DataPath.hpp" @@ -18,10 +19,6 @@ #include #include -#ifndef SIMPLNX_STORE_COPY_STRICT_FORMAT -#define SIMPLNX_STORE_COPY_STRICT_FORMAT 0 -#endif - namespace nx::core { namespace diff --git a/test/DataArrayTest.cpp b/test/DataArrayTest.cpp index 903400c094..81e9b90846 100644 --- a/test/DataArrayTest.cpp +++ b/test/DataArrayTest.cpp @@ -1,6 +1,7 @@ #include "simplnx/DataStructure/DataArray.hpp" #include "simplnx/Common/Array.hpp" #include "simplnx/Common/ScopeGuard.hpp" +#include "simplnx/Common/StoreCopyConfig.hpp" #include "simplnx/Common/Types.hpp" #include "simplnx/Common/TypesUtility.hpp" #include "simplnx/Core/Application.hpp" @@ -1839,7 +1840,7 @@ TEST_CASE("Unknown store-copy formats obey the compiled build policy", "[simplnx ListStore lists(ShapeType{3}); lists.setList(0, std::vector{4, 5}); StringStore strings({"first", "second"}, {2}); -#if defined(SIMPLNX_STORE_COPY_STRICT_FORMAT) && SIMPLNX_STORE_COPY_STRICT_FORMAT +#if SIMPLNX_STORE_COPY_STRICT_FORMAT REQUIRE_THROWS_WITH(numeric.deepCopy(unknown), Catch::Contains(unknown)); REQUIRE_THROWS_WITH(placeholderResult.value()->deepCopy(unknown), Catch::Contains(unknown)); REQUIRE_THROWS_WITH(lists.deepCopy(unknown), Catch::Contains(unknown)); diff --git a/test/MemorySafetyTest.cpp b/test/MemorySafetyTest.cpp index fab5a735df..be2ce10288 100644 --- a/test/MemorySafetyTest.cpp +++ b/test/MemorySafetyTest.cpp @@ -1,5 +1,6 @@ #include +#include "simplnx/Common/StoreCopyConfig.hpp" #include "simplnx/Core/Application.hpp" #include "simplnx/DataStructure/DataGroup.hpp" #include "simplnx/DataStructure/DataStructure.hpp" @@ -9,8 +10,9 @@ #include "simplnx/Filter/Parameters.hpp" #include "simplnx/Utilities/ArrayCreationUtilities.hpp" -#if defined(SIMPLNX_STORE_COPY_STRICT_FORMAT) && SIMPLNX_STORE_COPY_STRICT_FORMAT -#include "SimplnxOoc/OocDataIOManager.hpp" +#if SIMPLNX_STORE_COPY_STRICT_FORMAT +#include "simplnx/UnitTest/PlaceholderPlanManager.hpp" +#include "simplnx/UnitTest/UnitTestCommon.hpp" #endif #include @@ -21,10 +23,11 @@ using namespace nx::core; namespace { -void RegisterOocManagerForStrictBuild() +void RegisterPlaceholderManagerForStrictBuild() { -#if defined(SIMPLNX_STORE_COPY_STRICT_FORMAT) && SIMPLNX_STORE_COPY_STRICT_FORMAT - SimplnxOoc::registerIOManager(Application::GetOrCreateInstance()->getIOCollection()); +#if SIMPLNX_STORE_COPY_STRICT_FORMAT + auto registration = UnitTest::RegisterPlaceholderPlanManager(Application::GetOrCreateInstance()->getIOCollection(), "HDF5-OOC"); + SIMPLNX_RESULT_REQUIRE_VALID(registration); #endif } } // namespace @@ -59,7 +62,7 @@ TEST_CASE("MemorySafety: WouldExceedAvailableMemory pure overload", "[MemorySafe TEST_CASE("MemorySafety: EmptyDataStore::memoryUsage in-core vs OOC", "[MemorySafety]") { - RegisterOocManagerForStrictBuild(); + RegisterPlaceholderManagerForStrictBuild(); using StoreT = EmptyDataStore; const ShapeType tupleShape{100}; // 100 tuples const ShapeType compShape{4}; // x4 components @@ -70,7 +73,7 @@ TEST_CASE("MemorySafety: EmptyDataStore::memoryUsage in-core vs OOC", "[MemorySa REQUIRE(inCore.valid()); REQUIRE(inCore.value()->memoryUsage() == logicalBytes); -#if defined(SIMPLNX_STORE_COPY_STRICT_FORMAT) && SIMPLNX_STORE_COPY_STRICT_FORMAT +#if SIMPLNX_STORE_COPY_STRICT_FORMAT // Non-empty format (OOC placeholder) -> 0 (data lives on disk). auto ooc = StoreT::Create(tupleShape, compShape, "HDF5-OOC"); REQUIRE(ooc.valid()); @@ -85,7 +88,7 @@ TEST_CASE("MemorySafety: EmptyDataStore::memoryUsage in-core vs OOC", "[MemorySa TEST_CASE("MemorySafety: CreateArray preflight emits -271 only for over-available in-core arrays", "[MemorySafety]") { - RegisterOocManagerForStrictBuild(); + RegisterPlaceholderManagerForStrictBuild(); // A tuple count whose float32 size (~4 PB) exceeds available RAM on any machine, // but is far below uint64 overflow. Preflight never allocates, so this is safe. const std::vector hugeTupleShape{uint64{1} * 1000 * 1000 * 1000 * 1000}; // 1e12 tuples @@ -113,7 +116,7 @@ TEST_CASE("MemorySafety: CreateArray preflight emits -271 only for over-availabl Result<> r = ArrayCreationUtilities::CreateArray(ds, hugeTupleShape, compShape, path, IDataAction::Mode::Preflight, "HDF5-OOC"); REQUIRE_FALSE(r.invalid()); const auto count = std::count_if(r.warnings().cbegin(), r.warnings().cend(), [](const Warning& w) { return w.code == -271; }); -#if defined(SIMPLNX_STORE_COPY_STRICT_FORMAT) && SIMPLNX_STORE_COPY_STRICT_FORMAT +#if SIMPLNX_STORE_COPY_STRICT_FORMAT REQUIRE(count == 0); #else REQUIRE(count == 1); @@ -134,7 +137,7 @@ TEST_CASE("MemorySafety: CreateArray preflight emits -271 only for over-availabl TEST_CASE("MemorySafety: DataStructure::memoryUsage counts OOC preflight arrays as 0", "[MemorySafety]") { - RegisterOocManagerForStrictBuild(); + RegisterPlaceholderManagerForStrictBuild(); DataStructure ds; DataGroup::Create(ds, "Group"); const std::vector tupleShape{1000}; @@ -145,7 +148,7 @@ TEST_CASE("MemorySafety: DataStructure::memoryUsage counts OOC preflight arrays REQUIRE_FALSE(ArrayCreationUtilities::CreateArray(ds, tupleShape, compShape, DataPath({"Group", "Ooc"}), IDataAction::Mode::Preflight, "HDF5-OOC").invalid()); // In-core builds normalize an unavailable OOC request to memory. Strict OOC builds preserve the OOC plan. -#if defined(SIMPLNX_STORE_COPY_STRICT_FORMAT) && SIMPLNX_STORE_COPY_STRICT_FORMAT +#if SIMPLNX_STORE_COPY_STRICT_FORMAT REQUIRE(ds.memoryUsage() == inCoreBytes); #else REQUIRE(ds.memoryUsage() == 2 * inCoreBytes); diff --git a/test/StorageFormatPlanTest.cpp b/test/StorageFormatPlanTest.cpp index f5451503cd..bcec90e484 100644 --- a/test/StorageFormatPlanTest.cpp +++ b/test/StorageFormatPlanTest.cpp @@ -1,5 +1,6 @@ #include "simplnx/Common/Result.hpp" #include "simplnx/Common/ScopeGuard.hpp" +#include "simplnx/Common/StoreCopyConfig.hpp" #include "simplnx/Core/Application.hpp" #include "simplnx/Core/Preferences.hpp" #include "simplnx/DataStructure/BaseGroup.hpp" @@ -30,9 +31,7 @@ #include "simplnx/Utilities/StoreCopyUtilities.hpp" #include -#if defined(SIMPLNX_STORE_COPY_STRICT_FORMAT) && SIMPLNX_STORE_COPY_STRICT_FORMAT -#include "SimplnxOoc/OocDataIOManager.hpp" -#endif +#include "simplnx/UnitTest/PlaceholderPlanManager.hpp" #include "simplnx/unit_test/simplnx_test_dirs.hpp" @@ -137,22 +136,6 @@ class ThrowingFormatResolver : public IDataStoreFormatResolver bool m_ThrowBadAllocation = false; }; -class PlaceholderPlanManager : public IDataIOManager -{ -public: - PlaceholderPlanManager() - { - addDataStoreCreationFnc(k_SelectedFormat.str(), [](DataType, const ShapeType&, const ShapeType&, const std::optional&, DataStoreInitializationMode) -> std::unique_ptr { - throw std::runtime_error("The metadata-only import must not invoke the value-store factory"); - }); - } - - std::string formatName() const override - { - return k_SelectedFormat.str(); - } -}; - struct ScopedTempFile { explicit ScopedTempFile(fs::path filePath) @@ -213,9 +196,32 @@ void CreateLargeMetadataFile(const fs::path& filePath) } } // namespace +TEST_CASE("StorageFormatPlan: placeholder registration preserves an existing manager", "[simplnx][StorageFormatPlan]") +{ + DataIOCollection collection; + const std::string format = "HDF5-OOC"; + auto registration = UnitTest::RegisterPlaceholderPlanManager(collection, format); + SIMPLNX_RESULT_REQUIRE_VALID(registration); + auto firstManager = collection.getManager(format); + REQUIRE(firstManager != nullptr); + REQUIRE(firstManager->hasDataStoreCreationFnc(format)); + + auto repeatedRegistration = UnitTest::RegisterPlaceholderPlanManager(collection, format); + SIMPLNX_RESULT_REQUIRE_VALID(repeatedRegistration); + REQUIRE(collection.getManager(format) == firstManager); + + // Model an application-provided manager replacing the placeholder. + auto applicationManager = std::make_shared(format); + auto applicationRegistration = collection.addIOManager(applicationManager); + SIMPLNX_RESULT_REQUIRE_VALID(applicationRegistration); + auto preservedRegistration = UnitTest::RegisterPlaceholderPlanManager(collection, format); + SIMPLNX_RESULT_REQUIRE_VALID(preservedRegistration); + REQUIRE(collection.getManager(format) == applicationManager); +} + TEST_CASE("StorageFormatPlan: numeric selection validates capability without allocating", "[StorageFormatPlan][T04][T08][T09]") { - auto manager = std::make_shared(); + auto manager = std::make_shared(k_SelectedFormat.str()); auto managerRegistrationResult = Application::GetOrCreateInstance()->getIOCollection().addIOManager(manager); SIMPLNX_RESULT_REQUIRE_VALID(managerRegistrationResult); @@ -264,7 +270,7 @@ TEST_CASE("StorageFormatPlan: numeric selection reports unsupported formats and { const std::string unavailableFormat = "storage-format-plan-unavailable"; auto unavailable = ValidateNumericStorageFormat(unavailableFormat); -#if defined(SIMPLNX_STORE_COPY_STRICT_FORMAT) && SIMPLNX_STORE_COPY_STRICT_FORMAT +#if SIMPLNX_STORE_COPY_STRICT_FORMAT REQUIRE(unavailable.invalid()); REQUIRE(unavailable.errors().size() == 1); REQUIRE(unavailable.errors()[0].code == -10600); @@ -312,7 +318,7 @@ TEST_CASE("StorageFormatPlan: factory creates validated memory and registered OO REQUIRE(namedMemoryResult.value()->getDataFormat().empty()); REQUIRE(namedMemoryResult.value()->memoryUsage() == 48); - auto manager = std::make_shared(); + auto manager = std::make_shared(k_SelectedFormat.str()); auto managerRegistrationResult = Application::GetOrCreateInstance()->getIOCollection().addIOManager(manager); SIMPLNX_RESULT_REQUIRE_VALID(managerRegistrationResult); auto registeredResult = EmptyDataStore::Create(ShapeType{6}, ShapeType{1}, k_SelectedFormat.str()); @@ -322,8 +328,9 @@ TEST_CASE("StorageFormatPlan: factory creates validated memory and registered OO REQUIRE(registeredResult.value()->getDataFormat() == k_SelectedFormat.str()); REQUIRE(registeredResult.value()->memoryUsage() == 0); -#if defined(SIMPLNX_STORE_COPY_STRICT_FORMAT) && SIMPLNX_STORE_COPY_STRICT_FORMAT - SimplnxOoc::registerIOManager(Application::GetOrCreateInstance()->getIOCollection()); +#if SIMPLNX_STORE_COPY_STRICT_FORMAT + auto placeholderRegistration = UnitTest::RegisterPlaceholderPlanManager(Application::GetOrCreateInstance()->getIOCollection(), "HDF5-OOC"); + SIMPLNX_RESULT_REQUIRE_VALID(placeholderRegistration); auto oocResult = EmptyDataStore::Create(ShapeType{2, 3}, ShapeType{2}, "HDF5-OOC"); SIMPLNX_RESULT_REQUIRE_VALID(oocResult); REQUIRE(oocResult.value()->getStoreType() == IDataStore::StoreType::Empty); @@ -443,7 +450,7 @@ TEST_CASE("StorageFormatPlan: obsolete store getters are unavailable", "[Storage TEST_CASE("StorageFormatPlan: common getter preserves the recorded source plan", "[StorageFormatPlan]") { - auto manager = std::make_shared(); + auto manager = std::make_shared(k_SelectedFormat.str()); REQUIRE(Application::GetOrCreateInstance()->getIOCollection().addIOManager(manager).valid()); auto sourceResult = EmptyDataStore::Create(ShapeType{4}, ShapeType{1}, k_SelectedFormat.str()); SIMPLNX_RESULT_REQUIRE_VALID(sourceResult); @@ -454,7 +461,7 @@ TEST_CASE("StorageFormatPlan: common getter preserves the recorded source plan", TEST_CASE("StorageFormatPlan: Empty conversion selects metadata without allocating values", "[StorageFormatPlan][T20]") { - auto manager = std::make_shared(); + auto manager = std::make_shared(k_SelectedFormat.str()); REQUIRE(Application::GetOrCreateInstance()->getIOCollection().addIOManager(manager).valid()); auto sourceResult = EmptyDataStore::Create(ShapeType{3}, ShapeType{1}, ""); SIMPLNX_RESULT_REQUIRE_VALID(sourceResult); @@ -493,7 +500,7 @@ TEST_CASE("StorageFormatPlan: import resolver receives 100 GB logical bytes from DataStructure::setDefaultFormatResolver(inMemoryResolver); }); - auto manager = std::make_shared(); + auto manager = std::make_shared(k_SelectedFormat.str()); auto managerRegistrationResult = Application::GetOrCreateInstance()->getIOCollection().addIOManager(manager); SIMPLNX_RESULT_REQUIRE_VALID(managerRegistrationResult); DataStructure::setDefaultFormatResolver(std::make_shared(k_SelectedFormat.str())); @@ -741,7 +748,7 @@ void CheckSelectedImportDefaultResolver(const std::shared_ptrgetIOCollection().addIOManager(std::make_shared()); + const auto registration = Application::GetOrCreateInstance()->getIOCollection().addIOManager(std::make_shared(k_SelectedFormat.str())); SIMPLNX_RESULT_REQUIRE_VALID(registration); const auto incomingResolver = std::make_shared(k_SelectedFormat.str()); const auto restoreIncoming = UnitTest::SetDefaultFormatResolverForScope(incomingResolver); @@ -821,7 +828,7 @@ TEST_CASE("StorageFormatPlan: selected import does not consult process policy", TEST_CASE("StorageFormatPlan: destination policy sees all selected metadata before values", "[StorageFormatPlan][SelectedImportPolicy]") { UnitTest::LoadPlugins(); - const auto registration = Application::GetOrCreateInstance()->getIOCollection().addIOManager(std::make_shared()); + const auto registration = Application::GetOrCreateInstance()->getIOCollection().addIOManager(std::make_shared(k_SelectedFormat.str())); SIMPLNX_RESULT_REQUIRE_VALID(registration); const auto incomingResolver = std::make_shared(k_SelectedFormat.str()); const auto restoreIncoming = UnitTest::SetDefaultFormatResolverForScope(incomingResolver); @@ -928,7 +935,7 @@ class LaterImportPlanFailure : public CompleteImportContextResolver TEST_CASE("Selected import test context restores nested resolver ownership", "[StorageFormatPlan][SelectedImportPolicy][FormatResolver]") { UnitTest::LoadPlugins(); - const auto registration = Application::GetOrCreateInstance()->getIOCollection().addIOManager(std::make_shared()); + const auto registration = Application::GetOrCreateInstance()->getIOCollection().addIOManager(std::make_shared(k_SelectedFormat.str())); SIMPLNX_RESULT_REQUIRE_VALID(registration); const bool throwFromNestedScope = GENERATE(false, true); CAPTURE(throwFromNestedScope); @@ -1255,7 +1262,7 @@ TEST_CASE("C8 rollback preserves an existing destination parent and its other ch } #endif -#if !defined(SIMPLNX_STORE_COPY_STRICT_FORMAT) || !SIMPLNX_STORE_COPY_STRICT_FORMAT +#if !SIMPLNX_STORE_COPY_STRICT_FORMAT namespace { const DataPath k_C8FinalizerLists({"SelectedGroup", "Lists"}); diff --git a/test/UnitTestCommon/include/simplnx/UnitTest/PlaceholderPlanManager.hpp b/test/UnitTestCommon/include/simplnx/UnitTest/PlaceholderPlanManager.hpp new file mode 100644 index 0000000000..41997dd277 --- /dev/null +++ b/test/UnitTestCommon/include/simplnx/UnitTest/PlaceholderPlanManager.hpp @@ -0,0 +1,49 @@ +#pragma once + +#include "simplnx/DataStructure/IO/Generic/DataIOCollection.hpp" +#include "simplnx/DataStructure/IO/Generic/IDataIOManager.hpp" + +#include +#include +#include +#include + +namespace nx::core::UnitTest +{ +// Advertises numeric-store capability for metadata planning without allocating storage. +class PlaceholderPlanManager : public IDataIOManager +{ +public: + explicit PlaceholderPlanManager(std::string format) + : m_Format(std::move(format)) + { + addDataStoreCreationFnc(m_Format, [](DataType, const ShapeType&, const ShapeType&, const std::optional&, DataStoreInitializationMode) -> std::unique_ptr { + throw std::runtime_error("The metadata-only import must not invoke the value-store factory"); + }); + } + + ~PlaceholderPlanManager() noexcept override = default; + PlaceholderPlanManager(const PlaceholderPlanManager&) = delete; + PlaceholderPlanManager(PlaceholderPlanManager&&) = delete; + PlaceholderPlanManager& operator=(const PlaceholderPlanManager&) = delete; + PlaceholderPlanManager& operator=(PlaceholderPlanManager&&) = delete; + + std::string formatName() const override + { + return m_Format; + } + +private: + std::string m_Format; +}; + +// Registration replaces matching names, so retain any manager already provided by the application. +[[nodiscard]] inline Result<> RegisterPlaceholderPlanManager(DataIOCollection& collection, const std::string& format) +{ + if(collection.getManager(format) != nullptr) + { + return {}; + } + return collection.addIOManager(std::make_shared(format)); +} +} // namespace nx::core::UnitTest From 93ae42066c8411bed672ce16f16b9f45b080bd5a Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Sat, 14 Nov 2026 15:16:15 -0500 Subject: [PATCH 2/3] COMP: Register BUILD_TESTING tests on the first configure * Run include(CTest) before add_subdirectory(src/apps). BUILD_TESTING is defined by include(CTest), so the nxrunner tests and the nxrunner_pipeline_flush tests were registered only after a second configure of a new build directory. * Remove the enable_testing() call in src/apps, which the earlier include(CTest) makes redundant. Signed-off-by: Michael Jackson --- CMakeLists.txt | 6 +++++- src/apps/CMakeLists.txt | 3 --- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d21b514547..79d7dab1bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -989,6 +989,11 @@ endif() # ------------------------------------------------------------------------------ # CLI Executables (nxrunner, nxinfo) # ------------------------------------------------------------------------------ +# Define BUILD_TESTING before configuring directories and tests that use it. +if(SIMPLNX_BUILD_TESTS) + include(CTest) +endif() + add_subdirectory(${simplnx_SOURCE_DIR}/src/apps) #------------------------------------------------------------------------------ @@ -1170,7 +1175,6 @@ if(SIMPLNX_ENABLE_PACKAGING) endif() if(SIMPLNX_BUILD_TESTS) - include(CTest) target_compile_definitions(simplnx PUBLIC "SIMPLNX_BUILD_TESTS=1") add_subdirectory(test) endif() diff --git a/src/apps/CMakeLists.txt b/src/apps/CMakeLists.txt index 1747596d73..75e792bb6e 100644 --- a/src/apps/CMakeLists.txt +++ b/src/apps/CMakeLists.txt @@ -146,9 +146,6 @@ simplnx_enable_warnings(TARGET nxinfo) # tests depend on it through a ctest fixture. # ----------------------------------------------------------------------- if(SIMPLNX_BUILD_TESTS) - # This directory is configured before the top-level include(CTest) call. - enable_testing() - set(NXINFO_TEST_INPUT "${SIMPLNX_TEST_OUTPUT_DIR}/nxinfo_ctest_input.dream3d") set(NXINFO_TEST_INVALID_INPUT "${SIMPLNX_TEST_OUTPUT_DIR}/nxinfo_ctest_invalid.dream3d") set(NXINFO_TEST_OUTPUT "${SIMPLNX_TEST_OUTPUT_DIR}/nxinfo_dump.json") From a502e600e405551442d74e6b35f5051d945a9c60 Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Thu, 19 Nov 2026 10:02:59 -0500 Subject: [PATCH 3/3] REV: Run the finalizer tests in strict builds and describe the strict option The three C8 finalizer tests now compile in strict builds. They return early only when an import finalizer is already registered. The option help and the generated-header comment now say that strict mode rejects a requested storage format when no registered factory supports the requested store type, for numeric array creation, import planning and store copies. Co-Authored-By: Claude Opus 5.5 --- CMakeLists.txt | 2 +- cmake/StoreCopyConfig.hpp.in | 5 +++-- test/StorageFormatPlanTest.cpp | 29 ++++++++++++++++++----------- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 79d7dab1bc..ab3dbf3cbd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,7 +31,7 @@ enable_vcpkg_manifest_feature(TEST_VAR SIMPLNX_BUILD_PYTHON FEATURE "python") option(SIMPLNX_BUILD_TESTS "Enable buildingtests" ON) enable_vcpkg_manifest_feature(TEST_VAR SIMPLNX_BUILD_TESTS FEATURE "tests") -option(SIMPLNX_STORE_COPY_STRICT_FORMAT "Fail a store copy to a storage format with no registered I/O manager instead of falling back to in-memory storage" OFF) +option(SIMPLNX_STORE_COPY_STRICT_FORMAT "Reject a requested storage format when no registered factory supports the requested store type. Applies to numeric array creation, import planning, and store copies." OFF) # ------------------------------------------------------------------------------ # are multithreading algorithms enabled diff --git a/cmake/StoreCopyConfig.hpp.in b/cmake/StoreCopyConfig.hpp.in index 70281ec563..67ea4dc09e 100644 --- a/cmake/StoreCopyConfig.hpp.in +++ b/cmake/StoreCopyConfig.hpp.in @@ -1,5 +1,6 @@ #pragma once -// Generated by configure_file(). When enabled, store copies fail for storage -// formats with no registered I/O manager instead of using in-memory storage. +// When enabled, reject a requested storage format when no registered factory +// supports the requested store type. This applies to numeric array creation, +// import planning, and store copies. #cmakedefine01 SIMPLNX_STORE_COPY_STRICT_FORMAT diff --git a/test/StorageFormatPlanTest.cpp b/test/StorageFormatPlanTest.cpp index bcec90e484..b4a83c26f4 100644 --- a/test/StorageFormatPlanTest.cpp +++ b/test/StorageFormatPlanTest.cpp @@ -1262,7 +1262,6 @@ TEST_CASE("C8 rollback preserves an existing destination parent and its other ch } #endif -#if !SIMPLNX_STORE_COPY_STRICT_FORMAT namespace { const DataPath k_C8FinalizerLists({"SelectedGroup", "Lists"}); @@ -1529,11 +1528,14 @@ class C8WarningPlanResolver : public RecordingFormatResolver TEST_CASE("C8 single active finalizer observes complete plans and exact leaves once", "[C8][SelectedImportFinalizer]") { - const auto application = Application::GetOrCreateInstance(); + auto& collection = Application::GetOrCreateInstance()->getIOCollection(); + if(collection.anyManagerFinalizesImport()) + { + WARN("Skipping because an import finalizer is already active."); + return; + } SelectedImportTestContext context("c8_single_finalizer.dream3d"); WriteC8FinalizerFile(context.file.path); - auto& collection = application->getIOCollection(); - REQUIRE_FALSE(collection.anyManagerFinalizesImport()); const auto manager = std::make_shared(); const auto disable = MakeScopeGuard([manager]() noexcept { manager->active = false; }); auto registration = collection.addIOManager(manager); @@ -1589,6 +1591,12 @@ TEST_CASE("C8 single active finalizer observes complete plans and exact leaves o TEST_CASE("C8 publication handoff preserves warning order and exact destination state", "[C8][SelectedImportPublication][SelectedImportFinalizer]") { UnitTest::LoadPlugins(); + auto& collection = Application::GetOrCreateInstance()->getIOCollection(); + if(collection.anyManagerFinalizesImport()) + { + WARN("Skipping because an import finalizer is already active."); + return; + } static_assert(noexcept(std::declval().swap(std::declval()))); static_assert(std::is_nothrow_move_constructible_v); enum class Outcome : uint8 @@ -1600,11 +1608,8 @@ TEST_CASE("C8 publication handoff preserves warning order and exact destination }; const auto outcome = GENERATE(Outcome::OrdinarySuccess, Outcome::InstrumentedSuccess, Outcome::PublicationFailure, Outcome::AllocationFailure); CAPTURE(static_cast(outcome)); - const auto application = Application::GetOrCreateInstance(); const SelectedImportTestContext context("c8_publication_warning_handoff.dream3d"); WriteC8LegacyPlanWarningFile(context.file.path); - auto& collection = application->getIOCollection(); - REQUIRE_FALSE(collection.anyManagerFinalizesImport()); const auto manager = std::make_shared(); const auto disable = MakeScopeGuard([manager]() noexcept { manager->active = false; }); auto registration = collection.addIOManager(manager); @@ -1718,14 +1723,17 @@ TEST_CASE("C8 publication handoff preserves warning order and exact destination TEST_CASE("C8 planning and second leaf failures retain earlier warnings without publication", "[C8][SelectedImportFinalizer]") { + auto& collection = Application::GetOrCreateInstance()->getIOCollection(); + if(collection.anyManagerFinalizesImport()) + { + WARN("Skipping because an import finalizer is already active."); + return; + } const bool planningFailure = GENERATE(false, true); const bool warm = GENERATE(false, true); CAPTURE(planningFailure, warm); - const auto application = Application::GetOrCreateInstance(); SelectedImportTestContext context("c8_failure_warning_order.dream3d"); WriteC8LegacyPlanWarningFile(context.file.path); - auto& collection = application->getIOCollection(); - REQUIRE_FALSE(collection.anyManagerFinalizesImport()); const auto manager = std::make_shared(); const auto disable = MakeScopeGuard([manager]() noexcept { manager->active = false; }); auto registration = collection.addIOManager(manager); @@ -1792,4 +1800,3 @@ TEST_CASE("C8 planning and second leaf failures retain earlier warnings without CHECK(&destination.formatResolver() == resolver.get()); CheckImportPolicyMarker(destination, marker, markerStore); } -#endif