diff options
author | Ken Martin <ken.martin@kitware.com> | 2004-04-01 21:07:30 (GMT) |
---|---|---|
committer | Ken Martin <ken.martin@kitware.com> | 2004-04-01 21:07:30 (GMT) |
commit | c92c5e4e15f5f6297d9862d40f50af848acb7bfe (patch) | |
tree | 90abc6176f77e9e2fad68928a605d2756e8b2494 /Source/cmCTest.cxx | |
parent | cb90652dcac8f779b02a9974f445764576e879d2 (diff) | |
download | CMake-c92c5e4e15f5f6297d9862d40f50af848acb7bfe.zip CMake-c92c5e4e15f5f6297d9862d40f50af848acb7bfe.tar.gz CMake-c92c5e4e15f5f6297d9862d40f50af848acb7bfe.tar.bz2 |
fix for missing valid images
Diffstat (limited to 'Source/cmCTest.cxx')
-rw-r--r-- | Source/cmCTest.cxx | 76 |
1 files changed, 51 insertions, 25 deletions
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 13d3e48..940b0e3 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -2949,37 +2949,63 @@ std::string cmCTest::GenerateRegressionImages(const std::string& xml) if ( cmSystemTools::FileExists(filename.c_str()) ) { long len = cmSystemTools::FileLength(filename.c_str()); - std::ifstream ifs(filename.c_str(), std::ios::in + if ( len == 0 ) + { + std::string k1 = measurementfile.match(1); + std::string v1 = measurementfile.match(2); + std::string k2 = measurementfile.match(3); + std::string v2 = measurementfile.match(4); + if ( cmSystemTools::LowerCase(k1) == "type" ) + { + v1 = "text/string"; + } + if ( cmSystemTools::LowerCase(k2) == "type" ) + { + v2 = "text/string"; + } + + ostr + << "\t\t\t<NamedMeasurement" + << " " << k1 << "=\"" << v1 << "\"" + << " " << k2 << "=\"" << v2 << "\"" + << " encoding=\"none\"" + << "><Value>Image " << filename.c_str() + << " is empty</Value></NamedMeasurement>"; + } + else + { + std::ifstream ifs(filename.c_str(), std::ios::in #ifdef _WIN32 - | std::ios::binary + | std::ios::binary #endif - ); - unsigned char *file_buffer = new unsigned char [ len + 1 ]; - ifs.read(reinterpret_cast<char*>(file_buffer), len); - unsigned char *encoded_buffer = new unsigned char [ static_cast<int>(len * 1.5 + 1) ]; - - unsigned long rlen = cmsysBase64_Encode(file_buffer, len, encoded_buffer, 1); - unsigned long cc; - - ostr - << "\t\t\t<NamedMeasurement" + ); + unsigned char *file_buffer = new unsigned char [ len + 1 ]; + ifs.read(reinterpret_cast<char*>(file_buffer), len); + unsigned char *encoded_buffer = new unsigned char [ static_cast<int>(len * 1.5 + 5) ]; + + unsigned long rlen = cmsysBase64_Encode(file_buffer, len, encoded_buffer, 1); + unsigned long cc; + + ostr + << "\t\t\t<NamedMeasurement" << " " << measurementfile.match(1) << "=\"" << measurementfile.match(2) << "\"" - << " " << measurementfile.match(3) << "=\"" << measurementfile.match(4) << "\"" - << " encoding=\"base64\"" - << ">" << std::endl << "\t\t\t\t<Value>"; - for ( cc = 0; cc < rlen; cc ++ ) - { - ostr << encoded_buffer[cc]; - if ( cc % 60 == 0 && cc ) + << " " << measurementfile.match(3) << "=\"" << measurementfile.match(4) << "\"" + << " encoding=\"base64\"" + << ">" << std::endl << "\t\t\t\t<Value>"; + for ( cc = 0; cc < rlen; cc ++ ) { - ostr << std::endl; + ostr << encoded_buffer[cc]; + if ( cc % 60 == 0 && cc ) + { + ostr << std::endl; + } } + ostr + << "</Value>" << std::endl << "\t\t\t</NamedMeasurement>" + << std::endl; + delete [] file_buffer; + delete [] encoded_buffer; } - ostr - << "</Value>" << std::endl << "\t\t\t</NamedMeasurement>" - << std::endl; - delete [] file_buffer; - delete [] encoded_buffer; } else { |