From 54b65fd250860f898baf0bd2fe2369e847f7667f Mon Sep 17 00:00:00 2001 From: Robert Underwood Date: Thu, 12 Dec 2019 11:41:08 -0600 Subject: [PATCH] libpressio version 0.25.1 Bug Fixes: + Modify the external metrics module to compile with C++11 on CentOS. Previously, it used move constructors on stringstreams that were not present on CentOS. + Used compat headers on some missing functions in the test cases --- CMakeLists.txt | 2 +- COPYRIGHT.txt | 2 +- docker/Dockerfile-CentOS | 2 +- src/plugins/metrics/external.cc | 29 ++++++++++++++++------------- test/test_register_compressor.cc | 5 +++-- 5 files changed, 22 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e1f5545d..797d2d12 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.13 FATAL_ERROR) -project(libpressio VERSION "0.25.0" LANGUAGES CXX C) +project(libpressio VERSION "0.25.1" LANGUAGES CXX C) #correct was to set a default build type # https://blog.kitware.com/cmake-and-the-default-build-type/ diff --git a/COPYRIGHT.txt b/COPYRIGHT.txt index 6c4a8cd8..a21859cc 100644 --- a/COPYRIGHT.txt +++ b/COPYRIGHT.txt @@ -1,6 +1,6 @@ Copyright © 2019 , UChicago Argonne, LLC All Rights Reserved -[libpressio, Version 0.25.0] +[libpressio, Version 0.25.1] Robert Underwood Argonne National Laboratory diff --git a/docker/Dockerfile-CentOS b/docker/Dockerfile-CentOS index 8174a411..4824fb00 100644 --- a/docker/Dockerfile-CentOS +++ b/docker/Dockerfile-CentOS @@ -29,7 +29,7 @@ RUN git clone https://github.com/LLNL/zfp /src/zfp && \ rm -rf build && \ mkdir build && \ cd build && \ - cmake3 .. -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_TESTS=ON -DLIBPRESSIO_HAS_MAGICK=OFF -DLIBPRESSIO_HAS_MGARD=ON -DBUILD_PYTHON_WRAPPER=ON -G Ninja && \ + cmake3 .. -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_TESTS=ON -DLIBPRESSIO_HAS_MAGICK=OFF -DLIBPRESSIO_HAS_MGARD=ON -DBUILD_PYTHON_WRAPPER=ON -DLIBPRESSIO_CXX_VERSION=11 -G Ninja && \ cmake3 --build . && \ CTEST_OUTPUT_ON_FAILURE=1 ctest3 . && \ ninja-build install diff --git a/src/plugins/metrics/external.cc b/src/plugins/metrics/external.cc index 6feb2102..e80801e7 100644 --- a/src/plugins/metrics/external.cc +++ b/src/plugins/metrics/external.cc @@ -22,8 +22,8 @@ namespace { format_error=4 }; struct extern_proc_results { - std::stringstream stdout_stream; //stdout from the command - std::stringstream stderr_stream; //stdin from the command + std::string proc_stdout; //stdout from the command + std::string proc_stderr; //stdin from the command int return_code = 0; //the return code from the external process int error_code = success; //used to report errors with run_command }; @@ -86,24 +86,26 @@ namespace { int status = 0; char buffer[2048]; + std::ostringstream stdout_stream; + std::ostringstream stderr_stream; do { //read the stdout[0] int nread; while((nread = read(stdout_pipe_fd[0], buffer, 2048)) > 0) { - results.stdout_stream.write(buffer, nread); + stdout_stream.write(buffer, nread); } //read the stderr[0] while((nread = read(stderr_pipe_fd[0], buffer, 2048)) > 0) { - results.stderr_stream.write(buffer, nread); + stderr_stream.write(buffer, nread); } //wait for the child to complete waitpid(child, &status, 0); } while (not WIFEXITED(status)); - results.stdout_stream.seekg(0); - results.stderr_stream.seekg(0); + results.proc_stdout = stdout_stream.str(); + results.proc_stderr = stderr_stream.str(); results.return_code = WEXITSTATUS(status); } @@ -146,9 +148,9 @@ class external_metric_plugin : public libpressio_metrics_plugin { //returns the version number parsed, starts at 1, zero means error - size_t api_version_number(extern_proc_results& results) { + size_t api_version_number(std::istringstream& stdout_stream) { std::string version_line; - std::getline(results.stdout_stream, version_line); + std::getline(stdout_stream, version_line); auto eq_pos = version_line.find('=') + 1; if(version_line.substr(0, eq_pos) == "external:api") { //report error @@ -159,10 +161,11 @@ class external_metric_plugin : public libpressio_metrics_plugin { void parse_result(extern_proc_results& results) { try{ - size_t api_version = api_version_number(results); + std::istringstream stdout_stream(results.proc_stdout); + size_t api_version = api_version_number(stdout_stream); switch(api_version) { case 1: - parse_v1(results); + parse_v1(stdout_stream, results); return; default: (void)0; @@ -175,17 +178,17 @@ class external_metric_plugin : public libpressio_metrics_plugin { this->results.set("external:stderr", ""); } - void parse_v1(extern_proc_results& input) { + void parse_v1(std::istringstream& stdout_stream, extern_proc_results& input) { results.clear(); - for (std::string line; std::getline(input.stdout_stream, line); ) { + for (std::string line; std::getline(stdout_stream, line); ) { auto equal_pos = line.find('='); std::string name = "external:results:" + line.substr(0, equal_pos); std::string value_s = line.substr(equal_pos + 1); double value = std::stod(value_s); results.set(name, value); } - results.set("external:stderr", input.stderr_stream.str()); + results.set("external:stderr", input.proc_stderr); results.set("external:return_code", input.return_code); results.set("external:error_code", input.return_code); } diff --git a/test/test_register_compressor.cc b/test/test_register_compressor.cc index d5456ff0..df1167b5 100644 --- a/test/test_register_compressor.cc +++ b/test/test_register_compressor.cc @@ -8,6 +8,7 @@ #include "libpressio_ext/cpp/options.h" #include "libpressio_ext/cpp/pressio.h" #include "libpressio_ext/compressors/sz.h" +#include "libpressio_ext/compat/std_compat.h" namespace { struct log_fn{ @@ -108,13 +109,13 @@ class log_transform : public libpressio_compressor_plugin { pressio_compressor compressor; }; -static pressio_register X(compressor_plugins(), "log", [](){ return std::make_unique();}); +static pressio_register X(compressor_plugins(), "log", [](){ return compat::make_unique();}); TEST(ExternalPlugin, TestLogCompressor) { pressio library; auto sz_compressor = library.get_compressor("sz"); - auto log_compressor = std::make_unique(std::move(sz_compressor)); + auto log_compressor = compat::make_unique(std::move(sz_compressor)); auto options = log_compressor->get_options(); options.set("sz:error_bound_mode", ABS); options.set("sz:abs_err_bound", 0.5);