From 63912dfc4a25b4e1dbf7a80e63894f350f95e474 Mon Sep 17 00:00:00 2001 From: "Peter D. Barnes, Jr" Date: Fri, 20 Jan 2023 14:12:22 -0800 Subject: [PATCH] core: fix output redirection in example-as-test --- src/core/model/example-as-test.cc | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/core/model/example-as-test.cc b/src/core/model/example-as-test.cc index 255f49c91..3f1695776 100644 --- a/src/core/model/example-as-test.cc +++ b/src/core/model/example-as-test.cc @@ -85,18 +85,22 @@ ExampleAsTestCase::DoRun() SetDataDir(m_dataDir); std::string refFile = CreateDataDirFilename(GetName() + ".reflog"); std::string testFile = CreateTempDirFilename(GetName() + ".reflog"); + std::string post = GetPostProcessingCommand(); std::stringstream ss; ss << "python3 ./ns3 run " << m_program << " --no-build --command-template=\"" - << GetCommandTemplate() - << "\"" + << GetCommandTemplate() << "\""; - // redirect std::clog, std::cerr to std::cout - << " 2>&1 " - // Suppress the waf lines from output; waf output contains directory paths which will - // obviously differ during a test run - << " " << GetPostProcessingCommand() << " > " << testFile; + if (post.empty()) + { + // redirect to testfile, then std::clog, std::cerr to std::cout + ss << " > " << testFile << " 2>&1"; + } + else + { + ss << " 2>&1 " << post << " > " << testFile; + } int status = std::system(ss.str().c_str());