From 4c4ad39c0dca8621c6f8c00a9402b28cc760306c Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Thu, 21 Feb 2019 16:12:40 -0500 Subject: Output requested images/buffers on probe failure. (#316) This Cl updates the sample app to allow dumping of image and buffer data even if the probes fail to execute. Fixes #314. --- samples/amber.cc | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'samples') diff --git a/samples/amber.cc b/samples/amber.cc index 9bfa950..7f27d00 100644 --- a/samples/amber.cc +++ b/samples/amber.cc @@ -339,7 +339,8 @@ int main(int argc, const char** argv) { if (!result.IsSuccess()) { std::cerr << file << ": " << result.Error() << std::endl; failures.push_back(file); - continue; + // Note, we continue after failure to allow dumping the buffers which may + // give clues as to the failure. } if (!options.image_filename.empty()) { @@ -360,19 +361,20 @@ int main(int argc, const char** argv) { break; } } - if (!result.IsSuccess()) { + if (result.IsSuccess()) { + std::ofstream image_file; + image_file.open(options.image_filename, + std::ios::out | std::ios::binary); + if (!image_file.is_open()) { + std::cerr << "Cannot open file for image dump: "; + std::cerr << options.image_filename << std::endl; + continue; + } + image_file << image; + image_file.close(); + } else { std::cerr << result.Error() << std::endl; - continue; - } - std::ofstream image_file; - image_file.open(options.image_filename, std::ios::out | std::ios::binary); - if (!image_file.is_open()) { - std::cerr << "Cannot open file for image dump: "; - std::cerr << options.image_filename << std::endl; - continue; } - image_file << image; - image_file.close(); } if (!options.buffer_filename.empty()) { -- cgit v1.2.3