Skip to content
Snippets Groups Projects
Commit 2e12b4b2 authored by Atkins, Charles Vernon's avatar Atkins, Charles Vernon
Browse files

Add XML tests

parent 0b728162
No related branches found
No related tags found
1 merge request!177Switch to pugixml
...@@ -6,3 +6,4 @@ ...@@ -6,3 +6,4 @@
add_subdirectory(interface) add_subdirectory(interface)
add_subdirectory(engine) add_subdirectory(engine)
add_subdirectory(bindings) add_subdirectory(bindings)
add_subdirectory(xml)
#------------------------------------------------------------------------------#
# Distributed under the OSI-approved Apache License, Version 2.0. See
# accompanying file Copyright.txt for details.
#------------------------------------------------------------------------------#
add_executable(TestXMLConfig TestXMLConfig.cpp)
target_link_libraries(TestXMLConfig adios2 gtest gtest_main)
target_compile_definitions(TestXMLConfig PRIVATE
"XML_CONFIG_DIR=${CMAKE_CURRENT_SOURCE_DIR}"
)
gtest_add_tests(TARGET TestXMLConfig)
#include <cstdint>
#include <iostream>
#include <stdexcept>
#include <adios2.h>
#include <gtest/gtest.h>
#define str_helper(X) #X
#define str(X) str_helper(X)
class XMLConfigTest : public ::testing::Test
{
public:
XMLConfigTest() : configDir(str(XML_CONFIG_DIR)) {}
protected:
// virtual void SetUp() { }
// virtual void TearDown() { }
std::string configDir;
};
TEST_F(XMLConfigTest, TwoIOs)
{
std::string configFile = configDir + "/config1.xml";
#ifdef ADIOS2_HAVE_MPI
adios2::ADIOS adios(configFile, MPI_COMM_WORLD, adios2::DebugON);
#else
adios2::ADIOS adios(configFile, adios2::DebugON);
#endif
EXPECT_NO_THROW({
adios2::IO &io = adios.GetIO("Test IO 1");
const adios2::Params &params = io.GetParameters();
ASSERT_EQ(params.size(), 5);
EXPECT_THROW(params.at("DoesNotExist"), std::out_of_range);
EXPECT_EQ(params.at("Threads"), "1");
EXPECT_EQ(params.at("ProfileUnits"), "Microseconds");
EXPECT_EQ(params.at("MaxBufferSize"), "20Mb");
EXPECT_EQ(params.at("InitialBufferSize"), "1Mb");
EXPECT_EQ(params.at("BufferGrowthFactor"), "2");
auto engine = io.Open("Test BP Writer 1", adios2::OpenMode::Write);
});
EXPECT_NO_THROW({
adios2::IO &io = adios.GetIO("Test IO 2");
const adios2::Params &params = io.GetParameters();
ASSERT_EQ(params.size(), 0);
});
}
int main(int argc, char **argv)
{
#ifdef ADIOS2_HAVE_MPI
MPI_Init(nullptr, nullptr);
#endif
::testing::InitGoogleTest(&argc, argv);
int result = RUN_ALL_TESTS();
#ifdef ADIOS2_HAVE_MPI
MPI_Finalize();
#endif
return result;
}
<?xml version="1.0"?>
<adios-config>
<io name="Test IO 1">
<engine type="BPFileWriter">
<parameter key="Threads" value="1"/>
<parameter key="ProfileUnits" value="Microseconds"/>
<parameter key="MaxBufferSize" value="20Mb"/>
<parameter key="InitialBufferSize" value="1Mb"/>
<parameter key="BufferGrowthFactor" value="2"/>
</engine>
<transport type="File">
<parameter key="Library" value="POSIX"/>
<parameter key="ProfileUnits" value="Milliseconds"/>
</transport>
</io>
<io name="Test IO 2">
<engine type="BPFileWriter" />
</io>
</adios-config>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment