CTest output submitted to the dashboard is now compressed by default.
This commit is contained in:
parent
019e6db332
commit
ff916b48bd
|
@ -15,6 +15,9 @@
|
||||||
#include "cmCTest.h"
|
#include "cmCTest.h"
|
||||||
#include "cmSystemTools.h"
|
#include "cmSystemTools.h"
|
||||||
|
|
||||||
|
#include <cm_zlib.h>
|
||||||
|
#include <cmsys/Base64.h>
|
||||||
|
|
||||||
cmCTestRunTest::cmCTestRunTest(cmCTestTestHandler* handler)
|
cmCTestRunTest::cmCTestRunTest(cmCTestTestHandler* handler)
|
||||||
{
|
{
|
||||||
this->CTest = handler->CTest;
|
this->CTest = handler->CTest;
|
||||||
|
@ -26,6 +29,9 @@ cmCTestRunTest::cmCTestRunTest(cmCTestTestHandler* handler)
|
||||||
this->TestResult.Status = 0;
|
this->TestResult.Status = 0;
|
||||||
this->TestResult.TestCount = 0;
|
this->TestResult.TestCount = 0;
|
||||||
this->TestResult.Properties = 0;
|
this->TestResult.Properties = 0;
|
||||||
|
this->ProcessOutput = "";
|
||||||
|
this->CompressedOutput = "";
|
||||||
|
this->CompressionRatio = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmCTestRunTest::~cmCTestRunTest()
|
cmCTestRunTest::~cmCTestRunTest()
|
||||||
|
@ -52,7 +58,7 @@ bool cmCTestRunTest::CheckOutput()
|
||||||
{
|
{
|
||||||
// Store this line of output.
|
// Store this line of output.
|
||||||
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
||||||
this->GetIndex() << ": " << line << std::endl);
|
this->GetIndex() << ": " << line << std::endl);
|
||||||
this->ProcessOutput += line;
|
this->ProcessOutput += line;
|
||||||
this->ProcessOutput += "\n";
|
this->ProcessOutput += "\n";
|
||||||
}
|
}
|
||||||
|
@ -64,9 +70,72 @@ bool cmCTestRunTest::CheckOutput()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------
|
||||||
|
// Streamed compression of test output. The compressed data
|
||||||
|
// is appended to this->CompressedOutput
|
||||||
|
void cmCTestRunTest::CompressOutput()
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
z_stream strm;
|
||||||
|
|
||||||
|
unsigned char* in =
|
||||||
|
reinterpret_cast<unsigned char*>(
|
||||||
|
const_cast<char*>(this->ProcessOutput.c_str()));
|
||||||
|
//zlib makes the guarantee that this is the maximum output size
|
||||||
|
int outSize = static_cast<int>(this->ProcessOutput.size() * 1.001 + 13);
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
//log deflate init error?
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
strm.avail_in = this->ProcessOutput.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->CTest, ERROR_MESSAGE, "Error initializing stream "
|
||||||
|
"compression. Sending uncompressed output." << std::endl);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
(void)deflateEnd(&strm);
|
||||||
|
|
||||||
|
unsigned char *encoded_buffer
|
||||||
|
= new unsigned char[static_cast<int>(outSize * 1.5)];
|
||||||
|
|
||||||
|
unsigned long rlen
|
||||||
|
= cmsysBase64_Encode(out, strm.total_out, encoded_buffer, 1);
|
||||||
|
|
||||||
|
for(unsigned long i = 0; i < rlen; i++)
|
||||||
|
{
|
||||||
|
this->CompressedOutput += encoded_buffer[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
this->CompressionRatio = static_cast<double>(strm.total_out) /
|
||||||
|
static_cast<double>(strm.total_in);
|
||||||
|
|
||||||
|
delete [] encoded_buffer;
|
||||||
|
delete [] out;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------
|
//---------------------------------------------------------
|
||||||
bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
|
bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
|
||||||
{
|
{
|
||||||
|
if (this->CTest->ShouldCompressTestOutput())
|
||||||
|
{
|
||||||
|
this->CompressOutput();
|
||||||
|
}
|
||||||
|
|
||||||
//restore the old environment
|
//restore the old environment
|
||||||
if (this->ModifyEnv)
|
if (this->ModifyEnv)
|
||||||
{
|
{
|
||||||
|
@ -261,7 +330,11 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
|
||||||
// record the results in TestResult
|
// record the results in TestResult
|
||||||
if(started)
|
if(started)
|
||||||
{
|
{
|
||||||
this->TestResult.Output = this->ProcessOutput;
|
bool compress = this->CompressionRatio < 1 &&
|
||||||
|
this->CTest->ShouldCompressTestOutput();
|
||||||
|
this->TestResult.Output = compress ? this->CompressedOutput
|
||||||
|
: this->ProcessOutput;
|
||||||
|
this->TestResult.CompressOutput = compress;
|
||||||
this->TestResult.ReturnValue = this->TestProcess->GetExitValue();
|
this->TestResult.ReturnValue = this->TestProcess->GetExitValue();
|
||||||
this->TestResult.CompletionStatus = "Completed";
|
this->TestResult.CompletionStatus = "Completed";
|
||||||
this->TestResult.ExecutionTime = this->TestProcess->GetTotalTime();
|
this->TestResult.ExecutionTime = this->TestProcess->GetTotalTime();
|
||||||
|
@ -310,6 +383,7 @@ bool cmCTestRunTest::StartTest(size_t total)
|
||||||
std::vector<std::string>& args = this->TestProperties->Args;
|
std::vector<std::string>& args = this->TestProperties->Args;
|
||||||
this->TestResult.Properties = this->TestProperties;
|
this->TestResult.Properties = this->TestProperties;
|
||||||
this->TestResult.ExecutionTime = 0;
|
this->TestResult.ExecutionTime = 0;
|
||||||
|
this->TestResult.CompressOutput = false;
|
||||||
this->TestResult.ReturnValue = -1;
|
this->TestResult.ReturnValue = -1;
|
||||||
this->TestResult.CompletionStatus = "Failed to start";
|
this->TestResult.CompletionStatus = "Failed to start";
|
||||||
this->TestResult.Status = cmCTestTestHandler::BAD_COMMAND;
|
this->TestResult.Status = cmCTestTestHandler::BAD_COMMAND;
|
||||||
|
|
|
@ -45,6 +45,9 @@ public:
|
||||||
// Read and store output. Returns true if it must be called again.
|
// Read and store output. Returns true if it must be called again.
|
||||||
bool CheckOutput();
|
bool CheckOutput();
|
||||||
|
|
||||||
|
// Compresses the output, writing to CompressedOutput
|
||||||
|
void CompressOutput();
|
||||||
|
|
||||||
//launch the test process, return whether it started correctly
|
//launch the test process, return whether it started correctly
|
||||||
bool StartTest(size_t total);
|
bool StartTest(size_t total);
|
||||||
//capture and report the test results
|
//capture and report the test results
|
||||||
|
@ -79,6 +82,8 @@ private:
|
||||||
//stores the original environment if we are modifying it
|
//stores the original environment if we are modifying it
|
||||||
std::vector<std::string> OrigEnv;
|
std::vector<std::string> OrigEnv;
|
||||||
std::string ProcessOutput;
|
std::string ProcessOutput;
|
||||||
|
std::string CompressedOutput;
|
||||||
|
double CompressionRatio;
|
||||||
//The test results
|
//The test results
|
||||||
cmCTestTestHandler::cmCTestTestResult TestResult;
|
cmCTestTestHandler::cmCTestTestResult TestResult;
|
||||||
int Index;
|
int Index;
|
||||||
|
|
|
@ -1186,7 +1186,10 @@ void cmCTestTestHandler::GenerateDartOutput(std::ostream& os)
|
||||||
}
|
}
|
||||||
os
|
os
|
||||||
<< "\t\t\t<Measurement>\n"
|
<< "\t\t\t<Measurement>\n"
|
||||||
<< "\t\t\t\t<Value>";
|
<< "\t\t\t\t<Value"
|
||||||
|
<< (result->CompressOutput ?
|
||||||
|
" encoding=\"base64\" compression=\"gzip\">"
|
||||||
|
: ">");
|
||||||
os << cmXMLSafe(result->Output);
|
os << cmXMLSafe(result->Output);
|
||||||
os
|
os
|
||||||
<< "</Value>\n"
|
<< "</Value>\n"
|
||||||
|
|
|
@ -114,6 +114,7 @@ public:
|
||||||
double ExecutionTime;
|
double ExecutionTime;
|
||||||
int ReturnValue;
|
int ReturnValue;
|
||||||
int Status;
|
int Status;
|
||||||
|
bool CompressOutput;
|
||||||
std::string CompletionStatus;
|
std::string CompletionStatus;
|
||||||
std::string Output;
|
std::string Output;
|
||||||
std::string RegressionImages;
|
std::string RegressionImages;
|
||||||
|
|
Loading…
Reference in New Issue