diff --git a/bindings/C/adios2/adios2_c_adios.cpp b/bindings/C/adios2/adios2_c_adios.cpp index f9ab0062e1..bfe46cbf5e 100644 --- a/bindings/C/adios2/adios2_c_adios.cpp +++ b/bindings/C/adios2/adios2_c_adios.cpp @@ -11,10 +11,13 @@ #include "adios2_c_adios.h" #include "adios2/ADIOSMPI.h" #include "adios2/core/ADIOS.h" +#include "adios2/helper/adiosFunctions.h" adios2_adios *adios2_init_config(const char *config_file, MPI_Comm mpi_comm, const adios2_debug_mode debug_mode) { + adios2::CheckForNullptr(config_file, + "for config_file, in call to adios2_init_config"); const bool debugBool = (debug_mode == adios2_debug_mode_on) ? true : false; adios2_adios *adios = reinterpret_cast( new adios2::ADIOS(config_file, mpi_comm, debugBool, "C")); @@ -40,6 +43,8 @@ adios2_adios *adios2_init_nompi(const adios2_debug_mode debug_mode) adios2_io *adios2_declare_io(adios2_adios *adios, const char *ioName) { + adios2::CheckForNullptr(adios, + "for adios2_adios, in call to adios2_declare_io"); adios2_io *io = reinterpret_cast( &reinterpret_cast(adios)->DeclareIO(ioName)); return io; @@ -47,10 +52,14 @@ adios2_io *adios2_declare_io(adios2_adios *adios, const char *ioName) void adios2_flush_all(adios2_adios *adios) { + adios2::CheckForNullptr(adios, + "for adios2_adios, in call to adios2_flush_all"); reinterpret_cast(adios)->FlushAll(); } void adios2_finalize(adios2_adios *adios) { + adios2::CheckForNullptr(adios, + "for adios2_adios, in call to adios2_finalize"); delete reinterpret_cast(adios); } diff --git a/bindings/C/adios2/adios2_c_engine.cpp b/bindings/C/adios2/adios2_c_engine.cpp index e066706aa3..d9ef2b7696 100644 --- a/bindings/C/adios2/adios2_c_engine.cpp +++ b/bindings/C/adios2/adios2_c_engine.cpp @@ -17,6 +17,8 @@ adios2_step_status adios2_begin_step(adios2_engine *engine, const adios2_step_mode mode, const float timeout_seconds) { + adios2::CheckForNullptr(engine, + "for adios2_engine, in call to adios2_begin_step"); auto &engineCpp = *reinterpret_cast(engine); adios2::StepStatus statusCpp = adios2::StepStatus::OK; @@ -70,6 +72,12 @@ adios2_step_status adios2_begin_step(adios2_engine *engine, void adios2_put_sync(adios2_engine *engine, adios2_variable *variable, const void *values) { + adios2::CheckForNullptr(engine, + "for adios2_engine, in call to adios2_put_sync"); + + adios2::CheckForNullptr(variable, + "for adios2_variable, in call to adios2_put_sync"); + adios2::VariableBase *variableBase = reinterpret_cast(variable); const std::string type(variableBase->m_Type); @@ -92,6 +100,12 @@ void adios2_put_sync(adios2_engine *engine, adios2_variable *variable, void adios2_put_sync_self(adios2_engine *engine, adios2_variable *variable) { + adios2::CheckForNullptr( + engine, "for adios2_engine, in call to adios2_put_sync_self"); + + adios2::CheckForNullptr( + variable, "for adios2_variable, in call to adios2_put_sync_self"); + adios2::VariableBase *variableBase = reinterpret_cast(variable); const std::string type(variableBase->m_Type); @@ -114,6 +128,13 @@ void adios2_put_sync_self(adios2_engine *engine, adios2_variable *variable) void adios2_put_sync_by_name(adios2_engine *engine, const char *variable_name, const void *values) { + adios2::CheckForNullptr( + engine, "for adios2_engine, in call to adios2_put_sync_by_name"); + + adios2::CheckForNullptr( + variable_name, + "for const char* variable_name, in call to adios2_put_sync_by_name"); + auto &engineCpp = *reinterpret_cast(engine); const std::string type( engineCpp.GetIO().InquireVariableType(variable_name)); @@ -134,6 +155,12 @@ void adios2_put_sync_by_name(adios2_engine *engine, const char *variable_name, void adios2_put_deferred(adios2_engine *engine, adios2_variable *variable, const void *values) { + adios2::CheckForNullptr( + engine, "for adios2_engine, in call to adios2_put_deferred"); + + adios2::CheckForNullptr( + variable, "for adios2_variable, in call to adios2_put_deferred"); + adios2::VariableBase *variableBase = reinterpret_cast(variable); const std::string type(variableBase->m_Type); @@ -157,6 +184,12 @@ void adios2_put_deferred(adios2_engine *engine, adios2_variable *variable, void adios2_put_deferred_self(adios2_engine *engine, adios2_variable *variable) { + adios2::CheckForNullptr( + engine, "for adios2_engine, in call to adios2_put_deferred_self"); + + adios2::CheckForNullptr( + variable, "for adios2_variable, in call to adios2_put_deferred_self"); + adios2::VariableBase *variableBase = reinterpret_cast(variable); const std::string type(variableBase->m_Type); @@ -180,6 +213,13 @@ void adios2_put_deferred_self(adios2_engine *engine, adios2_variable *variable) void adios2_put_deferred_by_name(adios2_engine *engine, const char *variable_name, const void *values) { + adios2::CheckForNullptr( + engine, "for adios2_engine, in call to adios2_put_deferred_by_name"); + + adios2::CheckForNullptr(variable_name, + "for const char* variable_name, in call " + "to adios2_put_deferred_by_name"); + auto &engineCpp = *reinterpret_cast(engine); const std::string type( engineCpp.GetIO().InquireVariableType(variable_name)); @@ -200,6 +240,8 @@ void adios2_put_deferred_by_name(adios2_engine *engine, void adios2_perform_puts(adios2_engine *engine) { + adios2::CheckForNullptr( + engine, "for adios2_engine, in call to adios2_perform_puts"); auto &engineCpp = *reinterpret_cast(engine); engineCpp.PerformPuts(); } @@ -207,6 +249,11 @@ void adios2_perform_puts(adios2_engine *engine) void adios2_get_sync(adios2_engine *engine, adios2_variable *variable, void *values) { + adios2::CheckForNullptr(engine, + "for adios2_engine, in call to adios2_get_sync"); + adios2::CheckForNullptr(variable, "for adios2_variable, in call " + "to adios2_get_sync"); + adios2::VariableBase *variableBase = reinterpret_cast(variable); const std::string type(variableBase->m_Type); @@ -229,6 +276,11 @@ void adios2_get_sync(adios2_engine *engine, adios2_variable *variable, void adios2_get_sync_self(adios2_engine *engine, adios2_variable *variable) { + adios2::CheckForNullptr( + engine, "for adios2_engine, in call to adios2_get_sync_self"); + adios2::CheckForNullptr(variable, "for adios2_variable, in call " + "to adios2_get_sync_self"); + adios2::VariableBase *variableBase = reinterpret_cast(variable); const std::string type(variableBase->m_Type); @@ -251,6 +303,12 @@ void adios2_get_sync_self(adios2_engine *engine, adios2_variable *variable) void adios2_get_sync_by_name(adios2_engine *engine, const char *variable_name, void *values) { + adios2::CheckForNullptr( + engine, "for adios2_engine, in call to adios2_get_sync_by_name"); + adios2::CheckForNullptr(variable_name, + "for const char* variable_name, in call to " + "adios2_get_sync_by_name"); + auto &engineCpp = *reinterpret_cast(engine); const std::string type( engineCpp.GetIO().InquireVariableType(variable_name)); @@ -271,6 +329,11 @@ void adios2_get_sync_by_name(adios2_engine *engine, const char *variable_name, void adios2_get_deferred(adios2_engine *engine, adios2_variable *variable, void *values) { + adios2::CheckForNullptr( + engine, "for adios2_engine, in call to adios2_get_deferred"); + adios2::CheckForNullptr(variable, "for adios2_variable, in call " + "to adios2_get_deferred"); + adios2::VariableBase *variableBase = reinterpret_cast(variable); const std::string type(variableBase->m_Type); @@ -294,6 +357,11 @@ void adios2_get_deferred(adios2_engine *engine, adios2_variable *variable, void adios2_get_deferred_self(adios2_engine *engine, adios2_variable *variable) { + adios2::CheckForNullptr( + engine, "for adios2_engine, in call to adios2_get_deferred_self"); + adios2::CheckForNullptr(variable, "for adios2_variable, in call " + "to adios2_get_deferred_self"); + adios2::VariableBase *variableBase = reinterpret_cast(variable); const std::string type(variableBase->m_Type); @@ -317,6 +385,12 @@ void adios2_get_deferred_self(adios2_engine *engine, adios2_variable *variable) void adios2_get_deferred_by_name(adios2_engine *engine, const char *variable_name, void *values) { + adios2::CheckForNullptr( + engine, "for adios2_engine, in call to adios2_get_deferred_by_name"); + adios2::CheckForNullptr(variable_name, + "for const char* variable_name, in call " + "to adios2_get_deferred_by_name"); + auto &engineCpp = *reinterpret_cast(engine); const std::string type( engineCpp.GetIO().InquireVariableType(variable_name)); @@ -336,30 +410,40 @@ void adios2_get_deferred_by_name(adios2_engine *engine, void adios2_perform_gets(adios2_engine *engine) { + adios2::CheckForNullptr( + engine, "for adios2_engine, in call to adios2_perform_gets"); auto &engineCpp = *reinterpret_cast(engine); engineCpp.PerformGets(); } void adios2_end_step(adios2_engine *engine) { + adios2::CheckForNullptr(engine, + "for adios2_engine, in call to adios2_end_step"); auto &engineCpp = *reinterpret_cast(engine); engineCpp.EndStep(); } void adios2_write_step(adios2_engine *engine) { + adios2::CheckForNullptr(engine, + "for adios2_engine, in call to adios2_write_step"); auto &engineCpp = *reinterpret_cast(engine); engineCpp.WriteStep(); } void adios2_flush(adios2_engine *engine) { + adios2::CheckForNullptr(engine, + "for adios2_engine, in call to adios2_flush"); auto &engineCpp = *reinterpret_cast(engine); engineCpp.Flush(); } void adios2_close(adios2_engine *engine) { + adios2::CheckForNullptr(engine, + "for adios2_engine, in call to adios2_close"); auto &engineCpp = *reinterpret_cast(engine); engineCpp.Close(); } @@ -367,6 +451,8 @@ void adios2_close(adios2_engine *engine) void adios2_close_by_index(adios2_engine *engine, const unsigned int transport_index) { + adios2::CheckForNullptr( + engine, "for adios2_engine, in call to adios2_close_by_index"); auto &engineCpp = *reinterpret_cast(engine); engineCpp.Close(transport_index); } diff --git a/bindings/C/adios2/adios2_c_io.cpp b/bindings/C/adios2/adios2_c_io.cpp index b1a6dceacf..e5878aab09 100644 --- a/bindings/C/adios2/adios2_c_io.cpp +++ b/bindings/C/adios2/adios2_c_io.cpp @@ -22,6 +22,9 @@ adios2_define_variable(adios2_io *io, const char *name, const adios2_type type, const size_t *start, const size_t *count, const adios2_constant_dims constant_dims, void *data) { + adios2::CheckForNullptr(io, + "for adios2_io, in call to adios2_define_variable"); + const bool constantSizeBool = (constant_dims == adios2_constant_dims_true) ? true : false; @@ -227,6 +230,9 @@ adios2_define_variable(adios2_io *io, const char *name, const adios2_type type, adios2_variable *adios2_inquire_variable(adios2_io *io, const char *name) { + adios2::CheckForNullptr( + io, "for adios2_io, in call to adios2_inquire_variable"); + adios2::IO &ioCpp = *reinterpret_cast(io); const auto &dataMap = ioCpp.GetVariablesDataMap(); @@ -256,11 +262,17 @@ adios2_variable *adios2_inquire_variable(adios2_io *io, const char *name) int adios2_remove_variable(adios2_io *io, const char *name) { + adios2::CheckForNullptr(io, + "for adios2_io, in call to adios2_remove_variable"); + return (reinterpret_cast(io)->RemoveVariable(name)) ? 1 : 0; } void adios2_remove_all_variables(adios2_io *io) { + adios2::CheckForNullptr( + io, "for adios2_io, in call to adios2_remove_all_variables"); + reinterpret_cast(io)->RemoveAllVariables(); } @@ -269,6 +281,12 @@ adios2_attribute *adios2_define_attribute(adios2_io *io, const char *name, const void *data, const size_t elements) { + adios2::CheckForNullptr( + io, "for adios2_io, in call to adios2_define_attribute"); + + adios2::CheckForNullptr( + data, "for const void* data, in call to adios2_define_attribute"); + adios2::IO &ioCpp = *reinterpret_cast(io); adios2::AttributeBase *attribute = nullptr; @@ -439,26 +457,35 @@ adios2_attribute *adios2_define_attribute(adios2_io *io, const char *name, int adios2_remove_attribute(adios2_io *io, const char *name) { + adios2::CheckForNullptr( + io, "for adios2_io, in call to adios2_remove_attribute"); return (reinterpret_cast(io)->RemoveAttribute(name)) ? 1 : 0; } void adios2_remove_all_attributes(adios2_io *io) { + adios2::CheckForNullptr( + io, "for adios2_io, in call to adios2_remove_all_attributes"); reinterpret_cast(io)->RemoveAllAttributes(); } void adios2_set_engine(adios2_io *io, const char *engine_type) { + adios2::CheckForNullptr(io, "for adios2_io, in call to adios2_set_engine"); reinterpret_cast(io)->SetEngine(engine_type); } void adios2_set_parameter(adios2_io *io, const char *key, const char *value) { + adios2::CheckForNullptr(io, + "for adios2_io, in call to adios2_set_parameter"); reinterpret_cast(io)->SetParameter(key, value); } unsigned int adios2_add_transport(adios2_io *io, const char *transport_type) { + adios2::CheckForNullptr(io, + "for adios2_io, in call to adios2_add_transport"); return reinterpret_cast(io)->AddTransport(transport_type); } @@ -466,6 +493,8 @@ void adios2_set_transport_parameter(adios2_io *io, const unsigned int transport_index, const char *key, const char *value) { + adios2::CheckForNullptr( + io, "for adios2_io, in call to adios2_set_transport_parameter"); reinterpret_cast(io)->SetTransportParameter(transport_index, key, value); } @@ -473,6 +502,7 @@ void adios2_set_transport_parameter(adios2_io *io, adios2_engine *adios2_open(adios2_io *io, const char *name, const adios2_mode mode) { + adios2::CheckForNullptr(io, "for adios2_io, in call to adios2_open"); auto &ioCpp = *reinterpret_cast(io); return adios2_open_new_comm(io, name, mode, ioCpp.m_MPIComm); } @@ -480,6 +510,8 @@ adios2_engine *adios2_open(adios2_io *io, const char *name, adios2_engine *adios2_open_new_comm(adios2_io *io, const char *name, const adios2_mode mode, MPI_Comm mpi_comm) { + adios2::CheckForNullptr(io, + "for adios2_io, in call to adios2_open_new_comm"); auto &ioCpp = *reinterpret_cast(io); adios2::Engine *engine = nullptr; @@ -508,5 +540,7 @@ adios2_engine *adios2_open_new_comm(adios2_io *io, const char *name, void adios2_flush_all_engines(adios2_io *io) { + adios2::CheckForNullptr( + io, "for adios2_io, in call to adios2_flush_all_engines"); reinterpret_cast(io)->FlushAll(); } diff --git a/bindings/C/adios2/adios2_c_variable.cpp b/bindings/C/adios2/adios2_c_variable.cpp index db85a07f9f..636e631470 100644 --- a/bindings/C/adios2/adios2_c_variable.cpp +++ b/bindings/C/adios2/adios2_c_variable.cpp @@ -38,6 +38,9 @@ const std::map> adios2_types_map = { const char *adios2_variable_name(const adios2_variable *variable, size_t *length) { + adios2::CheckForNullptr( + variable, "for const adios2_variable, in call to adios2_variable_name"); + const adios2::VariableBase *variableBase = reinterpret_cast(variable); if (length != nullptr) @@ -49,6 +52,9 @@ const char *adios2_variable_name(const adios2_variable *variable, adios2_type adios2_variable_type(const adios2_variable *variable) { + adios2::CheckForNullptr( + variable, "for const adios2_variable, in call to adios2_variable_type"); + const adios2::VariableBase *variableBase = reinterpret_cast(variable); @@ -64,6 +70,8 @@ adios2_type adios2_variable_type(const adios2_variable *variable) int adios2_variable_is_constant_dims(const adios2_variable *variable) { + adios2::CheckForNullptr(variable, "for const adios2_variable, in call to " + "adios2_variable_is_constant_dims"); const adios2::VariableBase *variableBase = reinterpret_cast(variable); const int isConstantDims = (variableBase->m_ConstantDims) ? 1 : 0; @@ -72,6 +80,8 @@ int adios2_variable_is_constant_dims(const adios2_variable *variable) size_t adios2_variable_ndims(const adios2_variable *variable) { + adios2::CheckForNullptr(variable, "for const adios2_variable, in call to " + "adios2_variable_ndims"); const adios2::VariableBase *variableBase = reinterpret_cast(variable); return variableBase->m_Shape.size(); @@ -79,6 +89,8 @@ size_t adios2_variable_ndims(const adios2_variable *variable) const size_t *adios2_variable_shape(const adios2_variable *variable) { + adios2::CheckForNullptr(variable, "for const adios2_variable, in call to " + "adios2_variable_shape"); const adios2::VariableBase *variableBase = reinterpret_cast(variable); return variableBase->m_Shape.data(); @@ -86,6 +98,8 @@ const size_t *adios2_variable_shape(const adios2_variable *variable) const size_t *adios2_variable_start(const adios2_variable *variable) { + adios2::CheckForNullptr(variable, "for const adios2_variable, in call to " + "adios2_variable_start"); const adios2::VariableBase *variableBase = reinterpret_cast(variable); return variableBase->m_Start.data(); @@ -93,6 +107,8 @@ const size_t *adios2_variable_start(const adios2_variable *variable) const size_t *adios2_variable_count(const adios2_variable *variable) { + adios2::CheckForNullptr(variable, "for const adios2_variable, in call to " + "adios2_variable_count"); const adios2::VariableBase *variableBase = reinterpret_cast(variable); return variableBase->m_Count.data(); @@ -100,6 +116,8 @@ const size_t *adios2_variable_count(const adios2_variable *variable) size_t adios2_variable_available_steps_start(const adios2_variable *variable) { + adios2::CheckForNullptr(variable, "for const adios2_variable, in call to " + "adios2_variable_available_steps_start"); const adios2::VariableBase *variableBase = reinterpret_cast(variable); return variableBase->m_AvailableStepsStart; @@ -107,6 +125,8 @@ size_t adios2_variable_available_steps_start(const adios2_variable *variable) size_t adios2_variable_available_steps_count(const adios2_variable *variable) { + adios2::CheckForNullptr(variable, "for const adios2_variable, in call to " + "adios2_variable_available_steps_count"); const adios2::VariableBase *variableBase = reinterpret_cast(variable); return variableBase->m_AvailableStepsCount; @@ -126,6 +146,8 @@ void adios2_set_dimensions(adios2_variable *variable, const size_t ndims, } }; + adios2::CheckForNullptr(variable, "for adios2_variable, in call to " + "adios2_set_dimensions"); adios2::VariableBase *variableBase = reinterpret_cast(variable); @@ -138,6 +160,8 @@ void adios2_set_dimensions(adios2_variable *variable, const size_t ndims, void adios2_set_shape(adios2_variable *variable, const size_t ndims, const size_t *shape) { + adios2::CheckForNullptr(variable, "for adios2_variable, in call to " + "adios2_set_shape"); adios2::VariableBase *variableBase = reinterpret_cast(variable); const adios2::Dims shapeV(shape, shape + ndims); @@ -147,6 +171,8 @@ void adios2_set_shape(adios2_variable *variable, const size_t ndims, void adios2_set_selection(adios2_variable *variable, const size_t ndims, const size_t *start, const size_t *count) { + adios2::CheckForNullptr(variable, "for adios2_variable, in call to " + "adios2_set_selection"); adios2::VariableBase *variableBase = reinterpret_cast(variable); @@ -159,6 +185,8 @@ void adios2_set_selection(adios2_variable *variable, const size_t ndims, void adios2_set_step_selection(adios2_variable *variable, const size_t step_start, const size_t step_count) { + adios2::CheckForNullptr(variable, "for adios2_variable, in call to " + "adios2_set_step_selection"); adios2::VariableBase *variableBase = reinterpret_cast(variable); variableBase->SetStepSelection(adios2::Box{step_start, step_count}); @@ -166,6 +194,8 @@ void adios2_set_step_selection(adios2_variable *variable, void *adios2_get_data(const adios2_variable *variable) { + adios2::CheckForNullptr(variable, "for const adios2_variable, in call to " + "adios2_get_data"); const adios2::VariableBase *variableBase = reinterpret_cast(variable); const std::string type(variableBase->m_Type); @@ -190,6 +220,8 @@ void *adios2_get_data(const adios2_variable *variable) void adios2_set_data(adios2_variable *variable, const void *data) { + adios2::CheckForNullptr(variable, "for adios2_variable, in call to " + "adios2_set_data"); adios2::VariableBase *variableBase = reinterpret_cast(variable); diff --git a/bindings/python/EnginePy.cpp b/bindings/python/EnginePy.cpp index 10cd57bb66..4c18141cdd 100644 --- a/bindings/python/EnginePy.cpp +++ b/bindings/python/EnginePy.cpp @@ -30,6 +30,9 @@ StepStatus EnginePy::BeginStep(const StepMode mode, const float timeoutSeconds) void EnginePy::PutSync(VariableBase *variable, const pybind11::array &array) { + adios2::CheckForNullptr(variable, + "for variable, in call to PutSync a numpy array"); + if (variable->m_Type == "compound") { // not supported @@ -56,12 +59,18 @@ void EnginePy::PutSync(VariableBase *variable, const pybind11::array &array) void EnginePy::PutSync(VariableBase *variable, const std::string &string) { + adios2::CheckForNullptr(variable, + "for variable, in call to PutSync string"); + m_Engine.PutSync(*dynamic_cast *>(variable), string); } void EnginePy::PutDeferred(VariableBase *variable, const pybind11::array &array) { + adios2::CheckForNullptr( + variable, "for variable, in call to PutDeferred a numpy array"); + if (variable->m_Type == "compound") { // not supported @@ -88,6 +97,8 @@ void EnginePy::PutDeferred(VariableBase *variable, const pybind11::array &array) void EnginePy::PutDeferred(VariableBase *variable, const std::string &string) { + adios2::CheckForNullptr(variable, + "for variable, in call to PutDeferred a string"); m_Engine.PutDeferred( *dynamic_cast *>(variable), string); } @@ -96,6 +107,9 @@ void EnginePy::PerformPuts() { m_Engine.PerformPuts(); } void EnginePy::GetSync(VariableBase *variable, pybind11::array &array) { + adios2::CheckForNullptr(variable, + "for variable, in call to GetSync a numpy array"); + if (variable->m_Type == "compound") { // not supported @@ -125,6 +139,9 @@ void EnginePy::GetSync(VariableBase *variable, pybind11::array &array) void EnginePy::GetSync(VariableBase *variable, std::string &string) { + adios2::CheckForNullptr(variable, + "for variable, in call to GetSync a string"); + if (variable->m_Type == GetType()) { m_Engine.GetSync( @@ -143,6 +160,9 @@ void EnginePy::GetSync(VariableBase *variable, std::string &string) void EnginePy::GetDeferred(VariableBase *variable, pybind11::array &array) { + adios2::CheckForNullptr( + variable, "for variable, in call to GetDeferred a numpy array"); + if (variable->m_Type == "compound") { // not supported @@ -172,6 +192,9 @@ void EnginePy::GetDeferred(VariableBase *variable, pybind11::array &array) void EnginePy::GetDeferred(VariableBase *variable, std::string &string) { + adios2::CheckForNullptr(variable, + "for variable, in call to GetDeferred a string"); + if (variable->m_Type == GetType()) { m_Engine.GetDeferred( diff --git a/bindings/python/FilePy.cpp b/bindings/python/FilePy.cpp index 43b2f6ca1c..2e5c84f0bc 100644 --- a/bindings/python/FilePy.cpp +++ b/bindings/python/FilePy.cpp @@ -201,13 +201,6 @@ pybind11::array FilePy::Read(const std::string &name, const bool endl) return pybind11::array(); } -pybind11::array FilePy::Read(const std::string &name, const size_t step) -{ - throw std::invalid_argument("ERROR: adios2 file read variable " + name + - " signature not yet implemented\n"); - return pybind11::array(); -} - pybind11::array FilePy::Read(const std::string &name, const Dims &selectionStart, const Dims &selectionCount, const bool endl) @@ -228,13 +221,10 @@ pybind11::array FilePy::Read(const std::string &name, } ADIOS2_FOREACH_NUMPY_TYPE_1ARG(declare_type) #undef declare_type - else - { - throw std::invalid_argument( - "ERROR: adios2 file read variable " + name + - ", type can't be mapped to a numpy type, in call to read\n"); - } - return pybind11::array(); + + throw std::invalid_argument( + "ERROR: adios2 file read variable " + name + + ", type can't be mapped to a numpy type, in call to read\n"); } pybind11::array FilePy::Read(const std::string &name, diff --git a/bindings/python/FilePy.h b/bindings/python/FilePy.h index a997b139ca..5a0b3895ca 100644 --- a/bindings/python/FilePy.h +++ b/bindings/python/FilePy.h @@ -66,8 +66,6 @@ class FilePy pybind11::array Read(const std::string &name, const bool endl = false); - pybind11::array Read(const std::string &name, const size_t step); - pybind11::array Read(const std::string &name, const Dims &selectionStart, const Dims &selectionCount, const bool endl = false); diff --git a/source/adios2/helper/adiosType.h b/source/adios2/helper/adiosType.h index 75c53a23ce..b5e0618c3d 100644 --- a/source/adios2/helper/adiosType.h +++ b/source/adios2/helper/adiosType.h @@ -163,6 +163,14 @@ std::string VectorToCSV(const std::vector &input) noexcept; template std::string ValueToString(const T value) noexcept; +/** + * Checks if input pointer is nullptr ad throws an exception + * @param pointer input to be checked against nullptr + * @param hint additional exception information + */ +template +void CheckForNullptr(const T *pointer, const std::string hint); + } // end namespace adios2 #include "adiosType.inl" diff --git a/source/adios2/helper/adiosType.inl b/source/adios2/helper/adiosType.inl index 9fd5601b42..5c0b0bb18d 100644 --- a/source/adios2/helper/adiosType.inl +++ b/source/adios2/helper/adiosType.inl @@ -276,6 +276,15 @@ inline std::string VectorToCSV(const std::vector &input) noexcept return csv; } +template +void CheckForNullptr(const T *pointer, const std::string hint) +{ + if (pointer == nullptr) + { + std::invalid_argument("ERROR: found null pointer " + hint + "\n"); + } +} + } // end namespace adios2 #endif /* ADIOS2_HELPER_ADIOSTYPE_INL_ */ diff --git a/source/adios2/highlevelapi/fstream/ADIOS2fstream.cpp b/source/adios2/highlevelapi/fstream/ADIOS2fstream.cpp index ebe0d711a5..ca28730a2c 100644 --- a/source/adios2/highlevelapi/fstream/ADIOS2fstream.cpp +++ b/source/adios2/highlevelapi/fstream/ADIOS2fstream.cpp @@ -19,17 +19,45 @@ namespace adios2 fstream::fstream(const std::string &name, const openmode mode, MPI_Comm comm, const std::string engineType, const Params ¶meters, const vParams &transportParameters) -: m_Stream(std::make_shared(name, static_cast(mode), comm, - engineType, parameters, transportParameters, - "C++")) { + if (mode == openmode::out) + { + m_Stream = + std::make_shared(name, Mode::Write, comm, engineType, + parameters, transportParameters, "C++"); + } + else if (mode == openmode::app) + { + m_Stream = + std::make_shared(name, Mode::Append, comm, engineType, + parameters, transportParameters, "C++"); + } + else if (mode == openmode::in) + { + m_Stream = + std::make_shared(name, Mode::Read, comm, engineType, + parameters, transportParameters, "C++"); + } } fstream::fstream(const std::string &name, const openmode mode, MPI_Comm comm, const std::string configFile, const std::string ioInConfigFile) -: m_Stream(std::make_shared(name, static_cast(mode), comm, - configFile, ioInConfigFile, "C++")) { + if (mode == openmode::out) + { + m_Stream = std::make_shared(name, Mode::Write, comm, configFile, + ioInConfigFile, "C++"); + } + else if (mode == openmode::app) + { + m_Stream = std::make_shared(name, Mode::Append, comm, + configFile, ioInConfigFile, "C++"); + } + else if (mode == openmode::in) + { + m_Stream = std::make_shared(name, Mode::Read, comm, configFile, + ioInConfigFile, "C++"); + } } fstream::fstream(const std::string &name, const openmode mode, diff --git a/source/adios2/toolkit/format/bp3/BP3Base.h b/source/adios2/toolkit/format/bp3/BP3Base.h index 9b7e71b56d..d1ebc31e02 100644 --- a/source/adios2/toolkit/format/bp3/BP3Base.h +++ b/source/adios2/toolkit/format/bp3/BP3Base.h @@ -406,7 +406,7 @@ class BP3Base std::string GroupName; std::string Name; std::string Path; - uint8_t DataType; + uint8_t DataType = std::numeric_limits::max() - 1; }; /** diff --git a/source/adios2/toolkit/format/bp3/BP3Deserializer.tcc b/source/adios2/toolkit/format/bp3/BP3Deserializer.tcc index c7585bd236..31afa84e05 100644 --- a/source/adios2/toolkit/format/bp3/BP3Deserializer.tcc +++ b/source/adios2/toolkit/format/bp3/BP3Deserializer.tcc @@ -103,7 +103,9 @@ inline void BP3Deserializer::DefineVariableInIO( } else { - // TODO: throw exception? + throw std::runtime_error("ERROR: variable " + variableName + + " of type string can't be an array, when " + "parsing metadata in call to Open"); } // going back to get variable index position diff --git a/source/adios2/toolkit/format/bp3/BP3Serializer.cpp b/source/adios2/toolkit/format/bp3/BP3Serializer.cpp index ffb9e8cede..142cf5a238 100644 --- a/source/adios2/toolkit/format/bp3/BP3Serializer.cpp +++ b/source/adios2/toolkit/format/bp3/BP3Serializer.cpp @@ -1085,6 +1085,17 @@ void BP3Serializer::MergeSerializeIndices( headerSize = position; break; } + + if (m_DebugMode) + { + if (header.DataType == std::numeric_limits::max() - 1) + { + throw std::runtime_error( + "ERROR: invalid data type for variable " + header.Name + + "when writing collective metadata\n"); + } + } + // move all positions to headerSize for (size_t r = 0; r < indices.size(); ++r) { diff --git a/source/adios2/toolkit/profiling/iochrono/Timer.cpp b/source/adios2/toolkit/profiling/iochrono/Timer.cpp index 919bdc2d76..e180ebf43d 100644 --- a/source/adios2/toolkit/profiling/iochrono/Timer.cpp +++ b/source/adios2/toolkit/profiling/iochrono/Timer.cpp @@ -30,7 +30,7 @@ void Timer::Resume() noexcept m_InitialTimeSet = true; } -void Timer::Pause() noexcept +void Timer::Pause() { m_ElapsedTime = std::chrono::high_resolution_clock::now(); m_ProcessTime += GetElapsedTime(); diff --git a/source/adios2/toolkit/profiling/iochrono/Timer.h b/source/adios2/toolkit/profiling/iochrono/Timer.h index 351e141809..fb13a0cfdd 100644 --- a/source/adios2/toolkit/profiling/iochrono/Timer.h +++ b/source/adios2/toolkit/profiling/iochrono/Timer.h @@ -54,8 +54,10 @@ class Timer /** sets timer active to start counting */ void Resume() noexcept; - /** pauses timer (set to inactive) */ - void Pause() noexcept; + /** pauses timer (set to inactive) + * @exception std::invalid_argument if Resume not previously called + */ + void Pause(); /** Returns TimeUnit as a short std::string */ std::string GetShortUnits() const noexcept; diff --git a/source/adios2/toolkit/transport/file/FileStdio.cpp b/source/adios2/toolkit/transport/file/FileStdio.cpp index d3456419ec..6fc9123ea0 100644 --- a/source/adios2/toolkit/transport/file/FileStdio.cpp +++ b/source/adios2/toolkit/transport/file/FileStdio.cpp @@ -82,7 +82,8 @@ void FileStdio::Write(const char *buffer, size_t size, size_t start) auto lf_Write = [&](const char *buffer, size_t size) { ProfilerStart("write"); - auto writtenSize = std::fwrite(buffer, sizeof(char), size, m_File); + const auto writtenSize = + std::fwrite(buffer, sizeof(char), size, m_File); ProfilerStop("write"); CheckFile("couldn't write to file " + m_Name + @@ -99,7 +100,15 @@ void FileStdio::Write(const char *buffer, size_t size, size_t start) if (start != MaxSizeT) { - std::fseek(m_File, static_cast(start), SEEK_SET); + const auto status = + std::fseek(m_File, static_cast(start), SEEK_SET); + if (status != 0) + { + throw std::ios_base::failure( + "ERROR: couldn't move position of " + m_Name + + " file, in call to FileStdio Write fseek\n"); + } + CheckFile("couldn't move to start position " + std::to_string(start) + " in file " + m_Name + ", in call to stdio fseek at write "); } @@ -128,7 +137,7 @@ void FileStdio::Read(char *buffer, size_t size, size_t start) auto lf_Read = [&](char *buffer, size_t size) { ProfilerStart("read"); - auto readSize = std::fread(buffer, sizeof(char), size, m_File); + const auto readSize = std::fread(buffer, sizeof(char), size, m_File); ProfilerStop("read"); CheckFile("couldn't read to file " + m_Name + @@ -145,12 +154,12 @@ void FileStdio::Read(char *buffer, size_t size, size_t start) if (start != MaxSizeT) { - const auto result = + const auto status = std::fseek(m_File, static_cast(start), SEEK_SET); CheckFile("couldn't move to start position " + std::to_string(start) + " in file " + m_Name + ", in call to stdio fseek for read, result=" + - std::to_string(result)); + std::to_string(status)); } if (size > DefaultMaxFileBatchSize) @@ -175,12 +184,20 @@ void FileStdio::Read(char *buffer, size_t size, size_t start) size_t FileStdio::GetSize() { const auto currentPosition = ftell(m_File); + if (currentPosition == -1L) + { + throw std::ios_base::failure( + "ERROR: couldn't get current position of " + m_Name + + " file, in call to FileStdio GetSize ftell\n"); + } + fseek(m_File, 0, SEEK_END); const auto size = ftell(m_File); if (size == -1) { - throw std::ios_base::failure("ERROR: couldn't get size of " + m_Name + - " file\n"); + throw std::ios_base::failure( + "ERROR: couldn't get size of " + m_Name + + " file, in call to FileStdio GetSize ftell\n"); } fseek(m_File, currentPosition, SEEK_SET); return static_cast(size); diff --git a/testing/adios2/bindings/C/TestBPWriteTypes.cpp b/testing/adios2/bindings/C/TestBPWriteTypes.cpp index c8c32ba3cb..d0149819c2 100644 --- a/testing/adios2/bindings/C/TestBPWriteTypes.cpp +++ b/testing/adios2/bindings/C/TestBPWriteTypes.cpp @@ -120,8 +120,16 @@ int main(int argc, char **argv) MPI_Init(nullptr, nullptr); #endif - ::testing::InitGoogleTest(&argc, argv); - int result = RUN_ALL_TESTS(); + int result = -1; + try + { + ::testing::InitGoogleTest(&argc, argv); + result = RUN_ALL_TESTS(); + } + catch (std::exception &e) + { + result = 1; + } #ifdef ADIOS2_HAVE_MPI MPI_Finalize(); diff --git a/testing/adios2/bindings/C/TestBPWriteTypesHighLevel.cpp b/testing/adios2/bindings/C/TestBPWriteTypesHighLevel.cpp index e9d1537274..ee5d746894 100644 --- a/testing/adios2/bindings/C/TestBPWriteTypesHighLevel.cpp +++ b/testing/adios2/bindings/C/TestBPWriteTypesHighLevel.cpp @@ -167,8 +167,16 @@ int main(int argc, char **argv) MPI_Init(nullptr, nullptr); #endif - ::testing::InitGoogleTest(&argc, argv); - int result = RUN_ALL_TESTS(); + int result = -1; + try + { + ::testing::InitGoogleTest(&argc, argv); + result = RUN_ALL_TESTS(); + } + catch (std::exception &e) + { + result = 1; + } #ifdef ADIOS2_HAVE_MPI MPI_Finalize(); diff --git a/testing/adios2/engine/adios1/TestADIOS1WriteADIOS2Read.cpp b/testing/adios2/engine/adios1/TestADIOS1WriteADIOS2Read.cpp index 0b1d0e9cc6..ceaa2f4ccf 100644 --- a/testing/adios2/engine/adios1/TestADIOS1WriteADIOS2Read.cpp +++ b/testing/adios2/engine/adios1/TestADIOS1WriteADIOS2Read.cpp @@ -842,8 +842,16 @@ int main(int argc, char **argv) adios_init_noxml(MPI_COMM_WORLD); #endif - ::testing::InitGoogleTest(&argc, argv); - int result = RUN_ALL_TESTS(); + int result = -1; + try + { + ::testing::InitGoogleTest(&argc, argv); + result = RUN_ALL_TESTS(); + } + catch (std::exception &e) + { + result = 1; + } #ifdef ADIOS2_HAVE_MPI MPI_Finalize(); diff --git a/testing/adios2/engine/adios1/TestADIOS1WriteRead.cpp b/testing/adios2/engine/adios1/TestADIOS1WriteRead.cpp index aacfce9a19..43779960de 100644 --- a/testing/adios2/engine/adios1/TestADIOS1WriteRead.cpp +++ b/testing/adios2/engine/adios1/TestADIOS1WriteRead.cpp @@ -888,8 +888,16 @@ int main(int argc, char **argv) adios_init_noxml(MPI_COMM_WORLD); #endif - ::testing::InitGoogleTest(&argc, argv); - int result = RUN_ALL_TESTS(); + int result = -1; + try + { + ::testing::InitGoogleTest(&argc, argv); + result = RUN_ALL_TESTS(); + } + catch (std::exception &e) + { + result = 1; + } #ifdef ADIOS2_HAVE_MPI MPI_Finalize(); diff --git a/testing/adios2/engine/bp/TestBPWriteAggregateRead.cpp b/testing/adios2/engine/bp/TestBPWriteAggregateRead.cpp index 9fbdec8b4c..7d2a69a329 100644 --- a/testing/adios2/engine/bp/TestBPWriteAggregateRead.cpp +++ b/testing/adios2/engine/bp/TestBPWriteAggregateRead.cpp @@ -917,8 +917,16 @@ int main(int argc, char **argv) { MPI_Init(nullptr, nullptr); - ::testing::InitGoogleTest(&argc, argv); - int result = RUN_ALL_TESTS(); + int result = -1; + try + { + ::testing::InitGoogleTest(&argc, argv); + result = RUN_ALL_TESTS(); + } + catch (std::exception &e) + { + result = 1; + } MPI_Finalize(); diff --git a/testing/adios2/engine/bp/TestBPWriteFlushRead.cpp b/testing/adios2/engine/bp/TestBPWriteFlushRead.cpp index 26f399f3f8..861924191b 100644 --- a/testing/adios2/engine/bp/TestBPWriteFlushRead.cpp +++ b/testing/adios2/engine/bp/TestBPWriteFlushRead.cpp @@ -1376,8 +1376,16 @@ int main(int argc, char **argv) MPI_Init(nullptr, nullptr); #endif - ::testing::InitGoogleTest(&argc, argv); - int result = RUN_ALL_TESTS(); + int result = -1; + try + { + ::testing::InitGoogleTest(&argc, argv); + result = RUN_ALL_TESTS(); + } + catch (std::exception &e) + { + result = 1; + } #ifdef ADIOS2_HAVE_MPI MPI_Finalize(); diff --git a/testing/adios2/engine/bp/TestBPWriteProfilingJSON.cpp b/testing/adios2/engine/bp/TestBPWriteProfilingJSON.cpp index b77be999ea..c2385d0d04 100644 --- a/testing/adios2/engine/bp/TestBPWriteProfilingJSON.cpp +++ b/testing/adios2/engine/bp/TestBPWriteProfilingJSON.cpp @@ -307,8 +307,16 @@ int main(int argc, char **argv) MPI_Init(nullptr, nullptr); #endif - ::testing::InitGoogleTest(&argc, argv); - int result = RUN_ALL_TESTS(); + int result = -1; + try + { + ::testing::InitGoogleTest(&argc, argv); + result = RUN_ALL_TESTS(); + } + catch (std::exception &e) + { + result = 1; + } #ifdef ADIOS2_HAVE_MPI MPI_Finalize(); diff --git a/testing/adios2/engine/bp/TestBPWriteRead.cpp b/testing/adios2/engine/bp/TestBPWriteRead.cpp index 5dc915357b..5aa3f0b850 100644 --- a/testing/adios2/engine/bp/TestBPWriteRead.cpp +++ b/testing/adios2/engine/bp/TestBPWriteRead.cpp @@ -904,8 +904,16 @@ int main(int argc, char **argv) MPI_Init(nullptr, nullptr); #endif - ::testing::InitGoogleTest(&argc, argv); - int result = RUN_ALL_TESTS(); + int result = -1; + try + { + ::testing::InitGoogleTest(&argc, argv); + result = RUN_ALL_TESTS(); + } + catch (std::exception &e) + { + result = 1; + } #ifdef ADIOS2_HAVE_MPI MPI_Finalize(); diff --git a/testing/adios2/engine/bp/TestBPWriteReadADIOS2.cpp b/testing/adios2/engine/bp/TestBPWriteReadADIOS2.cpp index 6aae08c0ce..eefd67f829 100644 --- a/testing/adios2/engine/bp/TestBPWriteReadADIOS2.cpp +++ b/testing/adios2/engine/bp/TestBPWriteReadADIOS2.cpp @@ -921,8 +921,16 @@ int main(int argc, char **argv) MPI_Init(nullptr, nullptr); #endif - ::testing::InitGoogleTest(&argc, argv); - int result = RUN_ALL_TESTS(); + int result = -1; + try + { + ::testing::InitGoogleTest(&argc, argv); + result = RUN_ALL_TESTS(); + } + catch (std::exception &e) + { + result = 1; + } #ifdef ADIOS2_HAVE_MPI MPI_Finalize(); diff --git a/testing/adios2/engine/bp/TestBPWriteReadAsStreamADIOS2.cpp b/testing/adios2/engine/bp/TestBPWriteReadAsStreamADIOS2.cpp index e8f5cf1a21..2a4fb96bd4 100644 --- a/testing/adios2/engine/bp/TestBPWriteReadAsStreamADIOS2.cpp +++ b/testing/adios2/engine/bp/TestBPWriteReadAsStreamADIOS2.cpp @@ -1536,8 +1536,16 @@ int main(int argc, char **argv) MPI_Init(nullptr, nullptr); #endif - ::testing::InitGoogleTest(&argc, argv); - int result = RUN_ALL_TESTS(); + int result = -1; + try + { + ::testing::InitGoogleTest(&argc, argv); + result = RUN_ALL_TESTS(); + } + catch (std::exception &e) + { + result = 1; + } #ifdef ADIOS2_HAVE_MPI MPI_Finalize(); diff --git a/testing/adios2/engine/bp/TestBPWriteReadAsStreamADIOS2_Threads.cpp b/testing/adios2/engine/bp/TestBPWriteReadAsStreamADIOS2_Threads.cpp index 928151134a..26627351c8 100644 --- a/testing/adios2/engine/bp/TestBPWriteReadAsStreamADIOS2_Threads.cpp +++ b/testing/adios2/engine/bp/TestBPWriteReadAsStreamADIOS2_Threads.cpp @@ -1539,8 +1539,16 @@ int main(int argc, char **argv) MPI_Init(nullptr, nullptr); #endif - ::testing::InitGoogleTest(&argc, argv); - int result = RUN_ALL_TESTS(); + int result = -1; + try + { + ::testing::InitGoogleTest(&argc, argv); + result = RUN_ALL_TESTS(); + } + catch (std::exception &e) + { + result = 1; + } #ifdef ADIOS2_HAVE_MPI MPI_Finalize(); diff --git a/testing/adios2/engine/bp/TestBPWriteReadAttributes.cpp b/testing/adios2/engine/bp/TestBPWriteReadAttributes.cpp index 8b86d7459d..bd279dd11e 100644 --- a/testing/adios2/engine/bp/TestBPWriteReadAttributes.cpp +++ b/testing/adios2/engine/bp/TestBPWriteReadAttributes.cpp @@ -416,8 +416,16 @@ int main(int argc, char **argv) MPI_Init(nullptr, nullptr); #endif - ::testing::InitGoogleTest(&argc, argv); - int result = RUN_ALL_TESTS(); + int result = -1; + try + { + ::testing::InitGoogleTest(&argc, argv); + result = RUN_ALL_TESTS(); + } + catch (std::exception &e) + { + result = 1; + } #ifdef ADIOS2_HAVE_MPI MPI_Finalize(); diff --git a/testing/adios2/engine/bp/TestBPWriteReadAttributesADIOS2.cpp b/testing/adios2/engine/bp/TestBPWriteReadAttributesADIOS2.cpp index 007ba78947..60eeaf16f0 100644 --- a/testing/adios2/engine/bp/TestBPWriteReadAttributesADIOS2.cpp +++ b/testing/adios2/engine/bp/TestBPWriteReadAttributesADIOS2.cpp @@ -380,8 +380,16 @@ int main(int argc, char **argv) MPI_Init(nullptr, nullptr); #endif - ::testing::InitGoogleTest(&argc, argv); - int result = RUN_ALL_TESTS(); + int result = -1; + try + { + ::testing::InitGoogleTest(&argc, argv); + result = RUN_ALL_TESTS(); + } + catch (std::exception &e) + { + result = 1; + } #ifdef ADIOS2_HAVE_MPI MPI_Finalize(); diff --git a/testing/adios2/engine/bp/TestBPWriteReadfstream.cpp b/testing/adios2/engine/bp/TestBPWriteReadfstream.cpp index c6a189e35d..53917f056c 100644 --- a/testing/adios2/engine/bp/TestBPWriteReadfstream.cpp +++ b/testing/adios2/engine/bp/TestBPWriteReadfstream.cpp @@ -888,8 +888,16 @@ int main(int argc, char **argv) MPI_Init(nullptr, nullptr); #endif - ::testing::InitGoogleTest(&argc, argv); - int result = RUN_ALL_TESTS(); + int result = -1; + try + { + ::testing::InitGoogleTest(&argc, argv); + result = RUN_ALL_TESTS(); + } + catch (std::exception &e) + { + result = 1; + } #ifdef ADIOS2_HAVE_MPI MPI_Finalize(); diff --git a/testing/adios2/engine/bp/TestBPWriteReadstdio.cpp b/testing/adios2/engine/bp/TestBPWriteReadstdio.cpp index a775ac2779..fe6cffcacb 100644 --- a/testing/adios2/engine/bp/TestBPWriteReadstdio.cpp +++ b/testing/adios2/engine/bp/TestBPWriteReadstdio.cpp @@ -901,8 +901,16 @@ int main(int argc, char **argv) MPI_Init(nullptr, nullptr); #endif - ::testing::InitGoogleTest(&argc, argv); - int result = RUN_ALL_TESTS(); + int result = -1; + try + { + ::testing::InitGoogleTest(&argc, argv); + result = RUN_ALL_TESTS(); + } + catch (std::exception &e) + { + result = 1; + } #ifdef ADIOS2_HAVE_MPI MPI_Finalize(); diff --git a/testing/adios2/engine/bp/TestStreamWriteReadHighLevelAPI.cpp b/testing/adios2/engine/bp/TestStreamWriteReadHighLevelAPI.cpp index c46f46099b..af4d74d37a 100644 --- a/testing/adios2/engine/bp/TestStreamWriteReadHighLevelAPI.cpp +++ b/testing/adios2/engine/bp/TestStreamWriteReadHighLevelAPI.cpp @@ -448,8 +448,16 @@ int main(int argc, char **argv) MPI_Init(nullptr, nullptr); #endif - ::testing::InitGoogleTest(&argc, argv); - int result = RUN_ALL_TESTS(); + int result = -1; + try + { + ::testing::InitGoogleTest(&argc, argv); + result = RUN_ALL_TESTS(); + } + catch (std::exception &e) + { + result = 1; + } #ifdef ADIOS2_HAVE_MPI MPI_Finalize(); diff --git a/testing/adios2/engine/hdf5/TestHDF5WriteRead.cpp b/testing/adios2/engine/hdf5/TestHDF5WriteRead.cpp index 7a5ed2ff11..02a161bb23 100644 --- a/testing/adios2/engine/hdf5/TestHDF5WriteRead.cpp +++ b/testing/adios2/engine/hdf5/TestHDF5WriteRead.cpp @@ -1022,8 +1022,16 @@ int main(int argc, char **argv) MPI_Init(nullptr, nullptr); #endif - ::testing::InitGoogleTest(&argc, argv); - int result = RUN_ALL_TESTS(); + int result = -1; + try + { + ::testing::InitGoogleTest(&argc, argv); + result = RUN_ALL_TESTS(); + } + catch (std::exception &e) + { + result = 1; + } #ifdef ADIOS2_HAVE_MPI MPI_Finalize(); diff --git a/testing/adios2/engine/insitumpi/TestInSituMPIFunctionAssignPeers.cpp b/testing/adios2/engine/insitumpi/TestInSituMPIFunctionAssignPeers.cpp index 8112da1c8c..c84c4500ff 100644 --- a/testing/adios2/engine/insitumpi/TestInSituMPIFunctionAssignPeers.cpp +++ b/testing/adios2/engine/insitumpi/TestInSituMPIFunctionAssignPeers.cpp @@ -294,8 +294,16 @@ int main(int argc, char **argv) { MPI_Init(nullptr, nullptr); - ::testing::InitGoogleTest(&argc, argv); - int result = RUN_ALL_TESTS(); + int result = -1; + try + { + ::testing::InitGoogleTest(&argc, argv); + result = RUN_ALL_TESTS(); + } + catch (std::exception &e) + { + result = 1; + } MPI_Finalize(); return result; diff --git a/testing/adios2/engine/sst/TestSstRead.cpp b/testing/adios2/engine/sst/TestSstRead.cpp index 57af5f37dd..afb8dd24ce 100644 --- a/testing/adios2/engine/sst/TestSstRead.cpp +++ b/testing/adios2/engine/sst/TestSstRead.cpp @@ -220,8 +220,16 @@ int main(int argc, char **argv) MPI_Init(nullptr, nullptr); #endif - ::testing::InitGoogleTest(&argc, argv); - int result = RUN_ALL_TESTS(); + int result = -1; + try + { + ::testing::InitGoogleTest(&argc, argv); + result = RUN_ALL_TESTS(); + } + catch (std::exception &e) + { + result = 1; + } #ifdef ADIOS2_HAVE_MPI MPI_Finalize(); diff --git a/testing/adios2/engine/sst/TestSstWrite.cpp b/testing/adios2/engine/sst/TestSstWrite.cpp index 7518d92b40..0266a1a162 100644 --- a/testing/adios2/engine/sst/TestSstWrite.cpp +++ b/testing/adios2/engine/sst/TestSstWrite.cpp @@ -138,8 +138,16 @@ int main(int argc, char **argv) MPI_Init(nullptr, nullptr); #endif - ::testing::InitGoogleTest(&argc, argv); - int result = RUN_ALL_TESTS(); + int result = -1; + try + { + ::testing::InitGoogleTest(&argc, argv); + result = RUN_ALL_TESTS(); + } + catch (std::exception &e) + { + result = 1; + } #ifdef ADIOS2_HAVE_MPI MPI_Finalize(); diff --git a/testing/adios2/engine/staging-common/TestStagingMPMD.cpp b/testing/adios2/engine/staging-common/TestStagingMPMD.cpp index cc2a09a120..395197a3d7 100644 --- a/testing/adios2/engine/staging-common/TestStagingMPMD.cpp +++ b/testing/adios2/engine/staging-common/TestStagingMPMD.cpp @@ -345,7 +345,15 @@ int main(int argc, char **argv) << " processes " << std::endl; } - int result = RUN_ALL_TESTS(); + int result = -1; + try + { + result = RUN_ALL_TESTS(); + } + catch (std::exception &e) + { + result = 1; + } MPI_Finalize(); return result; diff --git a/testing/adios2/interface/TestADIOSDefineAttribute.cpp b/testing/adios2/interface/TestADIOSDefineAttribute.cpp index 780a64643d..c91ca33fd4 100644 --- a/testing/adios2/interface/TestADIOSDefineAttribute.cpp +++ b/testing/adios2/interface/TestADIOSDefineAttribute.cpp @@ -657,8 +657,16 @@ int main(int argc, char **argv) MPI_Init(nullptr, nullptr); #endif - ::testing::InitGoogleTest(&argc, argv); - int result = RUN_ALL_TESTS(); + int result = -1; + try + { + ::testing::InitGoogleTest(&argc, argv); + result = RUN_ALL_TESTS(); + } + catch (std::exception &e) + { + result = 1; + } #ifdef ADIOS2_HAVE_MPI MPI_Finalize(); diff --git a/testing/adios2/interface/TestADIOSDefineVariable.cpp b/testing/adios2/interface/TestADIOSDefineVariable.cpp index db627facd4..d3bc76f274 100644 --- a/testing/adios2/interface/TestADIOSDefineVariable.cpp +++ b/testing/adios2/interface/TestADIOSDefineVariable.cpp @@ -553,8 +553,16 @@ int main(int argc, char **argv) MPI_Init(nullptr, nullptr); #endif - ::testing::InitGoogleTest(&argc, argv); - int result = RUN_ALL_TESTS(); + int result = -1; + try + { + ::testing::InitGoogleTest(&argc, argv); + result = RUN_ALL_TESTS(); + } + catch (std::exception &e) + { + result = 1; + } #ifdef ADIOS2_HAVE_MPI MPI_Finalize(); diff --git a/testing/adios2/interface/TestADIOSInterfaceWrite.cpp b/testing/adios2/interface/TestADIOSInterfaceWrite.cpp index 7d36ecc853..8314f7f303 100644 --- a/testing/adios2/interface/TestADIOSInterfaceWrite.cpp +++ b/testing/adios2/interface/TestADIOSInterfaceWrite.cpp @@ -580,8 +580,16 @@ int main(int argc, char **argv) MPI_Init(nullptr, nullptr); #endif - ::testing::InitGoogleTest(&argc, argv); - int result = RUN_ALL_TESTS(); + int result = -1; + try + { + ::testing::InitGoogleTest(&argc, argv); + result = RUN_ALL_TESTS(); + } + catch (std::exception &e) + { + result = 1; + } #ifdef ADIOS2_HAVE_MPI MPI_Finalize(); diff --git a/testing/adios2/performance/manyvars/manyVars.cpp b/testing/adios2/performance/manyvars/manyVars.cpp index 38c6613f58..9c04d233b5 100644 --- a/testing/adios2/performance/manyvars/manyVars.cpp +++ b/testing/adios2/performance/manyvars/manyVars.cpp @@ -470,7 +470,15 @@ int main(int argc, char **argv) MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &numprocs); - int result = RUN_ALL_TESTS(); + int result = -1; + try + { + result = RUN_ALL_TESTS(); + } + catch (std::exception &e) + { + result = 1; + } MPI_Finalize(); return result; diff --git a/testing/adios2/transform/TestBZip2Wrapper.cpp b/testing/adios2/transform/TestBZip2Wrapper.cpp index 2c0c7d869b..8a7811affa 100644 --- a/testing/adios2/transform/TestBZip2Wrapper.cpp +++ b/testing/adios2/transform/TestBZip2Wrapper.cpp @@ -127,3 +127,27 @@ TEST_F(ADIOSBZip2Wrapper, WrongBZip2Name) adios.DefineOperator("BZip2Compressor4", "BZIP2"), std::invalid_argument); } + +int main(int argc, char **argv) +{ +#ifdef ADIOS2_HAVE_MPI + MPI_Init(&argc, &argv); +#endif + + int result = -1; + try + { + ::testing::InitGoogleTest(&argc, argv); + result = RUN_ALL_TESTS(); + } + catch (std::exception &e) + { + result = 1; + } + +#ifdef ADIOS2_HAVE_MPI + MPI_Finalize(); +#endif + + return result; +} diff --git a/testing/adios2/transform/TestZfpWrapper.cpp b/testing/adios2/transform/TestZfpWrapper.cpp index af71fc479b..bef81aa9e6 100644 --- a/testing/adios2/transform/TestZfpWrapper.cpp +++ b/testing/adios2/transform/TestZfpWrapper.cpp @@ -119,3 +119,27 @@ TEST_F(ADIOSZfpWrapper, MissingMandatoryParameter) var_Floats.m_OperatorsInfo[zfpID].Parameters), std::invalid_argument); } + +int main(int argc, char **argv) +{ +#ifdef ADIOS2_HAVE_MPI + MPI_Init(&argc, &argv); +#endif + + int result = -1; + try + { + ::testing::InitGoogleTest(&argc, argv); + result = RUN_ALL_TESTS(); + } + catch (std::exception &e) + { + result = 1; + } + +#ifdef ADIOS2_HAVE_MPI + MPI_Finalize(); +#endif + + return result; +} diff --git a/testing/adios2/xml/TestXMLConfig.cpp b/testing/adios2/xml/TestXMLConfig.cpp index 7069851708..7f6d9fa2b3 100644 --- a/testing/adios2/xml/TestXMLConfig.cpp +++ b/testing/adios2/xml/TestXMLConfig.cpp @@ -86,8 +86,16 @@ int main(int argc, char **argv) MPI_Init(&argc, &argv); #endif - ::testing::InitGoogleTest(&argc, argv); - int result = RUN_ALL_TESTS(); + int result = -1; + try + { + ::testing::InitGoogleTest(&argc, argv); + result = RUN_ALL_TESTS(); + } + catch (std::exception &e) + { + result = 1; + } #ifdef ADIOS2_HAVE_MPI MPI_Finalize();