File indexing completed on 2024-04-06 12:12:28
0001
0002
0003
0004
0005
0006
0007 #include "FWCore/Framework/test/MockEventProcessor.h"
0008
0009 #include <boost/program_options.hpp>
0010
0011 #include <string>
0012 #include <iostream>
0013 #include <fstream>
0014
0015 int main(int argc, char* argv[]) try {
0016 std::cout << "Running test in statemachine_t.cc\n";
0017
0018
0019 std::string inputFile;
0020 std::string outputFile;
0021 boost::program_options::options_description desc("Allowed options");
0022 desc.add_options()("help,h", "produce help message")(
0023 "inputFile,i", boost::program_options::value<std::string>(&inputFile)->default_value(""))(
0024 "outputFile,o",
0025 boost::program_options::value<std::string>(&outputFile)->default_value("statemachine_test_output.txt"));
0026 boost::program_options::variables_map vm;
0027 boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm);
0028 boost::program_options::notify(vm);
0029 if (vm.count("help")) {
0030 std::cout << desc << "\n";
0031 return 1;
0032 }
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044 std::string mockData = "s 1";
0045 if (inputFile != "") {
0046 std::ifstream input;
0047 input.open(inputFile.c_str());
0048 if (input.fail()) {
0049 std::cerr << "Error, Unable to open mock input file named " << inputFile << "\n";
0050 return 1;
0051 }
0052 std::getline(input, mockData, '.');
0053 }
0054
0055 std::ofstream output(outputFile.c_str());
0056
0057 std::vector<bool> fileModes;
0058 fileModes.push_back(true);
0059 fileModes.push_back(false);
0060
0061 for (auto mode : fileModes) {
0062 output << "\nMachine parameters: ";
0063 if (mode)
0064 output << "mode = NOMERGE";
0065 else
0066 output << "mode = FULLMERGE";
0067
0068 output << "\n";
0069
0070 edm::MockEventProcessor mockEventProcessor(mockData, output, mode);
0071 try {
0072 mockEventProcessor.runToCompletion();
0073 } catch (edm::MockEventProcessor::TestException const& e) {
0074 output << "caught test exception\n";
0075 }
0076 }
0077 return 0;
0078 } catch (std::exception const& e) {
0079 std::cerr << e.what() << std::endl;
0080 return 1;
0081 }