// Manage the files for the testing program // Obtains the name of an executable file as well as names of directories // containing test input and expected output for that input // Creates a report noting when the actual output obtained from running the // program on the test input differs from the expected output // Beth Katz, August 2004 #include #include #include #include #include "testing.h" using namespace std; int main (int argc, char * const argv[]) { if (argc != 4) { cerr << "Need exactly 3 command line arguments: " << "executableName inputDirectory expectedOutputDirectory\n"; cerr << argc << " arguments provided" << endl; exit(2); } else { string execName(argv[1]); string inputDirName(argv[2]); string expectedOutDirName(argv[3]); vector fileList; vector outputList; string command; string outputFilename; int result; if (fileExists(argv[1])) { cout << "Will run " << execName << endl; } else { cerr << "Executable file doesn't exist. Quitting.\n"; exit(4); } fillFileList(argv[2], fileList); if (fileList.empty( )) { cerr << "No testing input files. Quitting.\n"; exit(4); } else { printFileList("Input files", fileList); fillFileList(argv[3], outputList); if (outputList.empty( )) { cerr << "No testing output files. Quitting.\n"; exit(4); } else { outputFilename = processIDstring( ) + ".out"; result = runProgram(execName, inputDirName, fileList[0], outputFilename); // at this point, the file with name outputFilename contains the // result of having run the program with name execname with input // from inputDirName/filelist[0] removeFile(outputFilename); // clean up when you're done with file // probably do this where you opened it } } } return 0; }