From de09e9c079964dd99b360aeb1220c4233352eeb9 Mon Sep 17 00:00:00 2001 From: Matt Morehouse Date: Tue, 5 Dec 2017 17:13:17 +0000 Subject: [libFuzzer] Make redirects happen in proper sequence. "> file" must come before "2>&1" to have redirection occur correctly in all cases. Fixes a regression on minimize_two_crashes.test. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@319792 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/fuzzer/FuzzerCommand.h | 4 ++-- lib/fuzzer/tests/FuzzerUnittest.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/fuzzer/FuzzerCommand.h b/lib/fuzzer/FuzzerCommand.h index 358f89094..c5500ed21 100644 --- a/lib/fuzzer/FuzzerCommand.h +++ b/lib/fuzzer/FuzzerCommand.h @@ -143,10 +143,10 @@ public: std::stringstream SS; for (auto arg : getArguments()) SS << arg << " "; - if (isOutAndErrCombined()) - SS << "2>&1 "; if (hasOutputFile()) SS << ">" << getOutputFile() << " "; + if (isOutAndErrCombined()) + SS << "2>&1 "; std::string result = SS.str(); if (!result.empty()) result = result.substr(0, result.length() - 1); diff --git a/lib/fuzzer/tests/FuzzerUnittest.cpp b/lib/fuzzer/tests/FuzzerUnittest.cpp index bba4fd6b9..c11299954 100644 --- a/lib/fuzzer/tests/FuzzerUnittest.cpp +++ b/lib/fuzzer/tests/FuzzerUnittest.cpp @@ -923,7 +923,7 @@ TEST(FuzzerCommand, SetOutput) { EXPECT_TRUE(Cmd.isOutAndErrCombined()); CmdLine = Cmd.toString(); - EXPECT_EQ(CmdLine, makeCmdLine("", "2>&1 >thud")); + EXPECT_EQ(CmdLine, makeCmdLine("", ">thud 2>&1")); } int main(int argc, char **argv) { -- cgit v1.2.3