From 8024c53389df3ef404725e3d0c5d91a8f7eafbfc Mon Sep 17 00:00:00 2001 From: Zach Mullen Date: Fri, 29 Apr 2011 12:12:26 -0400 Subject: [PATCH 1/3] Dynamic analysis test output should not be compressed. --- Source/CTest/cmCTestRunTest.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index 42a4cff05..e9cefae00 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -135,7 +135,7 @@ void cmCTestRunTest::CompressOutput() //--------------------------------------------------------- bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started) { - if (this->CTest->ShouldCompressTestOutput()) + if (!this->TestHandler->MemCheck && this->CTest->ShouldCompressTestOutput()) { this->CompressOutput(); } @@ -332,7 +332,8 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started) // record the results in TestResult if(started) { - bool compress = this->CompressionRatio < 1 && + bool compress = !this->TestHandler->MemCheck && + this->CompressionRatio < 1 && this->CTest->ShouldCompressTestOutput(); this->TestResult.Output = compress ? this->CompressedOutput : this->ProcessOutput; From 9c3a0b9f140f8503bb177c97aadab26fbdded197 Mon Sep 17 00:00:00 2001 From: Zach Mullen Date: Thu, 26 May 2011 14:42:41 -0400 Subject: [PATCH 2/3] We will actually compress memcheck output if the server supports it. This change won't be functional until the next release of CDash due to the version comparison. --- Source/CTest/cmCTestMemCheckHandler.cxx | 14 ++++- Source/CTest/cmCTestRunTest.cxx | 15 +++-- Source/cmCTest.cxx | 80 ++++++++++++++++++++++++- Source/cmCTest.h | 7 ++- Source/cmSystemTools.cxx | 2 +- 5 files changed, 105 insertions(+), 13 deletions(-) diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index 13a25cb5c..06124491a 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -344,9 +344,21 @@ void cmCTestMemCheckHandler::GenerateDartOutput(std::ostream& os) } this->MemoryTesterGlobalResults[kk] += memcheckresults[kk]; } + + std::string logTag; + if(this->CTest->ShouldCompressMemCheckOutput()) + { + this->CTest->CompressString(memcheckstr); + logTag = "\t\n"; + } + else + { + logTag = "\t\n"; + } + os << "\t\t\n" - << "\t\n" << memcheckstr << std::endl + << logTag << memcheckstr << std::endl << "\t\n"; this->WriteTestResultFooter(os, result); if ( current < cc ) diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index e9cefae00..b5b46f60b 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -135,7 +135,10 @@ void cmCTestRunTest::CompressOutput() //--------------------------------------------------------- bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started) { - if (!this->TestHandler->MemCheck && this->CTest->ShouldCompressTestOutput()) + if ((!this->TestHandler->MemCheck && + this->CTest->ShouldCompressTestOutput()) || + (this->TestHandler->MemCheck && + this->CTest->ShouldCompressMemCheckOutput())) { this->CompressOutput(); } @@ -279,11 +282,11 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started) // Output since that is what is parsed by cmCTestMemCheckHandler if(!this->TestHandler->MemCheck && started) { - this->TestHandler->CleanTestOutput(this->ProcessOutput, - static_cast - (this->TestResult.Status == cmCTestTestHandler::COMPLETED ? - this->TestHandler->CustomMaximumPassedTestOutputSize : - this->TestHandler->CustomMaximumFailedTestOutputSize)); + this->TestHandler->CleanTestOutput(this->ProcessOutput, + static_cast + (this->TestResult.Status == cmCTestTestHandler::COMPLETED ? + this->TestHandler->CustomMaximumPassedTestOutputSize : + this->TestHandler->CustomMaximumFailedTestOutputSize)); } this->TestResult.Reason = reason; if (this->TestHandler->LogFile) diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 70b1c011c..60f01aa9a 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -50,6 +50,9 @@ #include // auto_ptr +#include +#include + #if defined(__BEOS__) && !defined(__HAIKU__) #include /* disable_debugger() API. */ #endif @@ -308,7 +311,7 @@ cmCTest::cmCTest() this->UseHTTP10 = false; this->PrintLabels = false; this->CompressTestOutput = true; - this->ComputedCompressOutput = false; + this->CompressMemCheckOutput = true; this->TestModel = cmCTest::EXPERIMENTAL; this->MaxTestNameWidth = 30; this->InteractiveDebugMode = true; @@ -325,6 +328,8 @@ cmCTest::cmCTest() this->SuppressUpdatingCTestConfiguration = false; this->DartVersion = 1; this->OutputTestOutputOnTestFailure = false; + this->ComputedCompressTestOutput = false; + this->ComputedCompressMemCheckOutput = false; if(cmSystemTools::GetEnv("CTEST_OUTPUT_ON_FAILURE")) { this->OutputTestOutputOnTestFailure = true; @@ -394,7 +399,7 @@ void cmCTest::SetParallelLevel(int level) //---------------------------------------------------------------------------- bool cmCTest::ShouldCompressTestOutput() { - if(!this->ComputedCompressOutput) + if(!this->ComputedCompressTestOutput) { std::string cdashVersion = this->GetCDashVersion(); //version >= 1.6? @@ -403,11 +408,26 @@ bool cmCTest::ShouldCompressTestOutput() cmSystemTools::VersionCompare(cmSystemTools::OP_EQUAL, cdashVersion.c_str(), "1.6"); this->CompressTestOutput &= cdashSupportsGzip; - this->ComputedCompressOutput = true; + this->ComputedCompressTestOutput = true; } return this->CompressTestOutput; } +//---------------------------------------------------------------------------- +bool cmCTest::ShouldCompressMemCheckOutput() +{ + if(!this->ComputedCompressMemCheckOutput) + { + std::string cdashVersion = this->GetCDashVersion(); + + bool compressionSupported = cmSystemTools::VersionCompare( + cmSystemTools::OP_GREATER, cdashVersion.c_str(), "1.9.0"); + this->CompressMemCheckOutput &= compressionSupported; + this->ComputedCompressMemCheckOutput = true; + } + return this->CompressMemCheckOutput; +} + //---------------------------------------------------------------------------- std::string cmCTest::GetCDashVersion() { @@ -1926,6 +1946,7 @@ void cmCTest::HandleCommandLineArguments(size_t &i, if(this->CheckArgument(arg, "--no-compress-output")) { this->CompressTestOutput = false; + this->CompressMemCheckOutput = false; } if(this->CheckArgument(arg, "--print-labels")) @@ -3055,3 +3076,56 @@ void cmCTest::OutputTestErrors(std::vector const &process_output) } cmCTestLog(this, HANDLER_OUTPUT, test_outputs << std::endl << std::flush); } + +//---------------------------------------------------------------------- +bool cmCTest::CompressString(std::string& str) +{ + int ret; + z_stream strm; + + unsigned char* in = reinterpret_cast( + const_cast(str.c_str())); + //zlib makes the guarantee that this is the maximum output size + int outSize = static_cast( + static_cast(str.size()) * 1.001 + 13.0); + unsigned char* out = new unsigned char[outSize]; + + strm.zalloc = Z_NULL; + strm.zfree = Z_NULL; + strm.opaque = Z_NULL; + ret = deflateInit(&strm, -1); //default compression level + if (ret != Z_OK) + { + return false; + } + + strm.avail_in = str.size(); + strm.next_in = in; + strm.avail_out = outSize; + strm.next_out = out; + ret = deflate(&strm, Z_FINISH); + + if(ret == Z_STREAM_ERROR || ret != Z_STREAM_END) + { + cmCTestLog(this, ERROR_MESSAGE, "Error during gzip compression." + << std::endl); + return false; + } + + (void)deflateEnd(&strm); + + // Now base64 encode the resulting binary string + unsigned char* base64EncodedBuffer + = new unsigned char[static_cast(outSize * 1.5)]; + + unsigned long rlen + = cmsysBase64_Encode(out, strm.total_out, base64EncodedBuffer, 1); + + str = ""; + str.append(reinterpret_cast(base64EncodedBuffer), rlen); + + delete [] base64EncodedBuffer; + delete [] out; + + return true; +} diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 3b0274848..44a534907 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -219,6 +219,8 @@ public: bool ShouldPrintLabels() { return this->PrintLabels; } bool ShouldCompressTestOutput(); + bool ShouldCompressMemCheckOutput(); + bool CompressString(std::string& str); std::string GetCDashVersion(); @@ -430,7 +432,8 @@ private: bool RunConfigurationScript; //flag for lazy getter (optimization) - bool ComputedCompressOutput; + bool ComputedCompressTestOutput; + bool ComputedCompressMemCheckOutput; int GenerateNotesFile(const char* files); @@ -487,8 +490,8 @@ private: bool ShortDateFormat; bool CompressXMLFiles; - bool CompressTestOutput; + bool CompressMemCheckOutput; void InitStreams(); std::ostream* StreamOut; diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 7bc89a4c4..db1ddce40 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -2603,7 +2603,7 @@ bool cmSystemTools::VersionCompare(cmSystemTools::CompareOp op, else if(lhs[i] > rhs[i]) { // lhs > rhs, so true if operation is GREATER - return op == cmSystemTools::OP_GREATER; + return op == cmSystemTools::OP_GREATER; } } // lhs == rhs, so true if operation is EQUAL From 0e591ed4c24cdcea2727f07eae1502700d10efb1 Mon Sep 17 00:00:00 2001 From: Zach Mullen Date: Fri, 27 May 2011 10:45:41 -0400 Subject: [PATCH 3/3] Fix type conversion warning --- Source/cmCTest.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 60f01aa9a..75a564e78 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -3099,7 +3099,7 @@ bool cmCTest::CompressString(std::string& str) return false; } - strm.avail_in = str.size(); + strm.avail_in = static_cast(str.size()); strm.next_in = in; strm.avail_out = outSize; strm.next_out = out;