1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: PNGCompare.cxx 5 6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 7 All rights reserved. 8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 9 10 This software is distributed WITHOUT ANY WARRANTY; without even 11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 12 PURPOSE. See the above copyright notice for more information. 13 14 =========================================================================*/ 15 16 #include "vtkNew.h" 17 #include "vtkTesting.h" 18 #include "vtkTestingInteractor.h" 19 20 #include <string> 21 #include <cstdio> // For remove 22 PNGCompare(int argc,char * argv[])23int PNGCompare(int argc, char *argv[]) 24 { 25 // Grab the test image 26 std::string testImageFileName; 27 for (int i = 0; i < argc; ++i) 28 { 29 if (i < argc-1 && strcmp(argv[i],"--test-file") == 0) 30 { 31 testImageFileName = std::string(argv[i+1]); 32 break; 33 } 34 } 35 36 if (testImageFileName.empty()) 37 { 38 cout << "Error: No reference image specified (use --test-file <png file>)" 39 << endl; 40 return EXIT_FAILURE; 41 } 42 43 // Set up testing object (modeled after vtkTestingInteractor::Start()) 44 vtkNew<vtkTesting> testing; 45 46 // Location of the temp directory for testing 47 testing->AddArgument("-T"); 48 testing->AddArgument(vtkTestingInteractor::TempDirectory.c_str()); 49 50 // Location of the Data directory 51 testing->AddArgument("-D"); 52 testing->AddArgument(vtkTestingInteractor::DataDirectory.c_str()); 53 54 // The name of the valid baseline image 55 testing->AddArgument("-V"); 56 testing->AddArgument(vtkTestingInteractor::ValidBaseline.c_str()); 57 58 // Regression test the image 59 int result = testing->RegressionTest(testImageFileName, 60 vtkTestingInteractor::ErrorThreshold); 61 62 vtkTestingInteractor::TestReturnStatus = result; 63 64 if (result == vtkTesting::PASSED) 65 { 66 // Coverity complains that we don't check the result of remove(), but 67 // we really don't care about it. Suppressing: 68 // coverity[CHECKED_RETURN] 69 remove(testImageFileName.c_str()); 70 return EXIT_SUCCESS; 71 } 72 else 73 { 74 return EXIT_FAILURE; 75 } 76 } 77