LCOV - code coverage report
Current view: top level - appmodel/test/apps - generate_modules_test.cxx (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 52 0
Test Date: 2025-12-21 13:07:08 Functions: 0.0 % 1 0

            Line data    Source code
       1              : /**
       2              :  * @file gen_readout_modules.cxx
       3              :  *
       4              :  * Quick test/demonstration of ReadoutApplication's dal method
       5              :  *
       6              :  * This is part of the DUNE DAQ Application Framework, copyright 2020.
       7              :  * Licensing/copyright details are in the COPYING file that you should have
       8              :  * received with this code.
       9              :  */
      10              : 
      11              : #include "logging/Logging.hpp"
      12              : 
      13              : #include "conffwk/Configuration.hpp"
      14              : 
      15              : #include "confmodel/Session.hpp"
      16              : #include "confmodel/Connection.hpp"
      17              : #include "confmodel/DaqModule.hpp"
      18              : 
      19              : #include "appmodel/DFApplication.hpp"
      20              : #include "appmodel/DFOApplication.hpp"
      21              : #include "appmodel/ReadoutApplication.hpp"
      22              : #include "appmodel/SmartDaqApplication.hpp"
      23              : #include "appmodel/TriggerApplication.hpp"
      24              : #include "appmodel/MLTApplication.hpp"
      25              : #include "appmodel/TPReplayApplication.hpp"
      26              : #include "appmodel/TPStreamWriterApplication.hpp"
      27              : 
      28              : #include "appmodel/appmodelIssues.hpp"
      29              : 
      30              : #include <string>
      31              : using namespace dunedaq;
      32              : 
      33            0 : int main(int argc, char* argv[]) {
      34            0 :   if (argc < 4) {
      35            0 :     std::cout << "Usage: " << argv[0] << " <session> <smart-app> <database-file>\n";
      36            0 :     return 0;
      37              :   }
      38              : 
      39            0 :   std::string sessionName(argv[1]);
      40            0 :   std::string appName(argv[2]);
      41            0 :   std::string dbfile(argv[3]);
      42              : 
      43            0 :   logging::Logging::setup("test", "generate_module");
      44              : 
      45            0 :   conffwk::Configuration* confdb;
      46            0 :   try {
      47            0 :     confdb = new conffwk::Configuration("oksconflibs:" + dbfile);
      48              :   }
      49            0 :   catch (conffwk::Generic& exc) {
      50            0 :     std::cout << "Failed to load OKS database: " << exc << std::endl;
      51            0 :     return 0;
      52            0 :   }
      53              : 
      54            0 :   auto session = confdb->get<confmodel::Session>(sessionName);
      55            0 :   if (session == nullptr) {
      56            0 :     std::cout << "Failed to get Session " << sessionName
      57            0 :               << " from database\n";
      58              :     return 0;
      59              :   }
      60            0 :   auto daqapp = confdb->get<appmodel::SmartDaqApplication>(appName);
      61            0 :   if (daqapp) {
      62            0 :     std::cout << appName << " is of class " << daqapp->class_name() << std::endl;
      63              : 
      64            0 :     auto res = daqapp->cast<confmodel::Resource>();
      65            0 :     if (res && res->is_disabled(*session)) {
      66            0 :       std::cout << "Application " << appName << " is disabled" << std::endl;
      67            0 :       return 0;
      68              :     }
      69              : 
      70            0 :     try {
      71            0 :       daqapp->generate_modules(session);
      72              :     }
      73            0 :     catch (appmodel::BadConf& exc) {
      74            0 :       std::cout << "Caught BadConf exception: " << exc << std::endl;
      75            0 :       exit(-1);
      76            0 :     }
      77              : 
      78            0 :     auto modules = daqapp->get_modules();
      79            0 :     std::cout << "Generated " << modules.size() << " modules" << std::endl;
      80            0 :     for (auto daq_module: modules) {
      81            0 :       std::cout << "module " << daq_module->UID() << std::endl;
      82            0 :       daq_module->config_object().print_ref(std::cout, *confdb, "  ");
      83            0 :       std::cout  << " input objects "  << std::endl;
      84            0 :       for (auto input : daq_module->get_inputs()) {
      85            0 :         auto iObj = input->config_object();
      86            0 :         iObj.print_ref(std::cout, *confdb, "    ");
      87            0 :       }
      88            0 :       std::cout  << " output objects "  << std::endl;
      89            0 :       for (auto output : daq_module->get_outputs()) {
      90            0 :         auto oObj = output->config_object();
      91            0 :         oObj.print_ref(std::cout, *confdb, "    ");
      92            0 :       }
      93            0 :       std::cout << std::endl;
      94              :     }
      95            0 :   }
      96              :   else {
      97            0 :     std::cout << "Failed to get SmartDaqApplication " << appName
      98            0 :               << " from database\n";
      99              :     return 0;
     100              :   }
     101            0 : }
        

Generated by: LCOV version 2.0-1