From afebccabdc081109e1f6ebe46abac0ee9ebb2e6f Mon Sep 17 00:00:00 2001 From: Martin Polanka Date: Fri, 4 May 2018 21:41:12 +0200 Subject: [PATCH] Add carboncopy options to sandbox_config --- src/config/sandbox_config.h | 12 ++++++++++++ src/helpers/config.cpp | 6 ++++++ tests/job_config.cpp | 4 ++++ 3 files changed, 22 insertions(+) diff --git a/src/config/sandbox_config.h b/src/config/sandbox_config.h index af520d08..926d85bb 100644 --- a/src/config/sandbox_config.h +++ b/src/config/sandbox_config.h @@ -38,6 +38,18 @@ class sandbox_config * If true then stdout and stderr will be written in the results. */ bool output = false; + /** + * File to which stdout will be copied after execution. + * Global worker limit for carboncopies is applied. + * @note Path is outside the sandbox. + */ + std::string carboncopy_stdout = ""; + /** + * File to which stderr will be copied after execution. + * Global worker limit for carboncopies is applied. + * @note Path is outside the sandbox. + */ + std::string carboncopy_stderr = ""; /** * Change working directory to subdirectory inside the sandbox. * @note Path must be accessible from inside of sandbox. diff --git a/src/helpers/config.cpp b/src/helpers/config.cpp index ecf7c26d..032948f9 100644 --- a/src/helpers/config.cpp +++ b/src/helpers/config.cpp @@ -125,6 +125,12 @@ std::shared_ptr helpers::build_job_metadata(const YAML::Node &conf if (ctask["sandbox"]["output"] && ctask["sandbox"]["output"].IsScalar()) { sandbox->output = ctask["sandbox"]["output"].as(); } // can be ommited... no throw + if (ctask["sandbox"]["carboncopy-stdout"] && ctask["sandbox"]["carboncopy-stdout"].IsScalar()) { + sandbox->carboncopy_stdout = ctask["sandbox"]["carboncopy-stdout"].as(); + } // can be ommited... no throw + if (ctask["sandbox"]["carboncopy-stderr"] && ctask["sandbox"]["carboncopy-stderr"].IsScalar()) { + sandbox->carboncopy_stderr = ctask["sandbox"]["carboncopy-stderr"].as(); + } // can be ommited... no throw if (ctask["sandbox"]["chdir"] && ctask["sandbox"]["chdir"].IsScalar()) { sandbox->chdir = ctask["sandbox"]["chdir"].as(); } // can be ommited... no throw diff --git a/tests/job_config.cpp b/tests/job_config.cpp index d770ae1d..77aa21f0 100644 --- a/tests/job_config.cpp +++ b/tests/job_config.cpp @@ -200,6 +200,8 @@ TEST(job_config_test, config_data) " stdout: 01.out\n" " stderr: 01.err\n" " stderr-to-stdout: true\n" + " carboncopy-stdout: carbon-copy-stdout\n" + " carboncopy-stderr: carbon-copy-stderr\n" " chdir: /eval\n" " working-directory: working\n" " limits:\n" @@ -257,6 +259,8 @@ TEST(job_config_test, config_data) ASSERT_EQ(task2->sandbox->std_output, "01.out"); ASSERT_EQ(task2->sandbox->std_error, "01.err"); ASSERT_TRUE(task2->sandbox->stderr_to_stdout); + ASSERT_EQ(task2->sandbox->carboncopy_stdout, "carbon-copy-stdout"); + ASSERT_EQ(task2->sandbox->carboncopy_stderr, "carbon-copy-stderr"); ASSERT_EQ(task2->sandbox->chdir, "/eval"); ASSERT_EQ(task2->sandbox->working_directory, "working");