LCOV - code coverage report
Current view: top level - otsdaq/tools - otsdaq_load_json_document.cc (source / functions) Coverage Total Hit
Test: mu2edaq.info.cleaned Lines: 0.0 % 40 0
Test Date: 2026-07-30 01:56:44 Functions: 0.0 % 3 0

            Line data    Source code
       1              : #include "otsdaq/MessageFacility/MessageFacility.h"
       2              : 
       3              : #include <dirent.h>
       4              : #include <cassert>
       5              : #include <iostream>
       6              : #include <memory>
       7              : #include <string>
       8              : 
       9              : #include "otsdaq/ConfigurationInterface/ConfigurationInterface.h"
      10              : #include "otsdaq/ConfigurationInterface/ConfigurationManagerRW.h"
      11              : // #include "artdaq-database/StorageProviders/FileSystemDB/provider_filedb_index.h"
      12              : // #include "artdaq-database/JsonDocument/JSONDocument.h"
      13              : 
      14              : // Shared test utilities
      15              : #include "otsdaq/Macros/TestUtilities.h"
      16              : 
      17              : /// usage:
      18              : /// otsdaq_load_json_document <document_name_to_load> <document_version_to_load> <path_to_save_JSON>
      19              : ///
      20              : #define TRACE_NAME "LoadJSON_Document"
      21              : 
      22              : #undef __COUT__
      23              : #define __COUT__        \
      24              :         std::cout           \
      25              :             << __MF_DECOR__ \
      26              :             << __COUT_HDR_FL__  //TLOG(TLVL_DEBUG) //std::cout << __MF_DECOR__ << __COUT_HDR_FL__
      27              : 
      28              : using namespace ots;
      29              : 
      30            0 : void LoadJSON_Document(int argc, char* argv[])
      31              : {
      32            0 :         __COUT__ << "=================================================\n";
      33            0 :         __COUT__ << "=================================================\n";
      34            0 :         __COUT__ << "=================================================\n";
      35            0 :         __COUT__ << "\nLoading Trigger Document!" << std::endl;
      36              : 
      37            0 :         __COUT__ << "\n\nusage: Two arguments:\n\t <document_name_to_load> "
      38            0 :                     "<document_version_to_load> <path_to_save_JSON>"
      39            0 :                  << std::endl
      40            0 :                  << std::endl;
      41              : 
      42            0 :         __COUT__ << "argc = " << argc << std::endl;
      43            0 :         for(int i = 0; i < argc; i++)
      44            0 :                 __COUT__ << "argv[" << i << "] = " << argv[i] << std::endl;
      45              : 
      46            0 :         if(argc != 4)
      47              :         {
      48            0 :                 __COUT__ << "\n\nError! Must provide 3 parameters.\n\n" << std::endl;
      49            0 :                 return;
      50              :         }
      51              : 
      52              :         //==============================================================================
      53              :         // Define environment variables
      54              :         //      Note: normally these environment variables are set by ots script
      55              : 
      56            0 :         test::util::check_and_make_envs();
      57              : 
      58              :         ////////////////////////////////////////////////////
      59              : 
      60              :         //==============================================================================
      61              :         // get prepared with initial source db
      62              : 
      63              :         // ConfigurationManager instance immediately loads active groups
      64            0 :         __COUT__ << "Loading JSON Document..." << std::endl;
      65            0 :         ConfigurationManagerRW  cfgMgrInst("load_admin");
      66            0 :         ConfigurationManagerRW* cfgMgr = &cfgMgrInst;
      67              : 
      68            0 :         ConfigurationInterface* theInterface_ = cfgMgr->getConfigurationInterface();
      69              :         std::string             json =
      70            0 :             theInterface_->loadCustomJSON(argv[1], TableVersion(atoi(argv[2])));
      71            0 :         __COUTVS__(3, json);
      72            0 :         FILE* fp = std::fopen(argv[3], "w");
      73            0 :         if(!fp)
      74              :         {
      75            0 :                 __COUT__ << "\n\nERROR! Could not open file at " << argv[1]
      76            0 :                          << ". Error: " << errno << " - " << strerror(errno) << __E__;
      77            0 :                 return;
      78              :         }
      79            0 :         fputs(json.c_str(), fp);
      80            0 :         fclose(fp);
      81            0 :         return;
      82            0 : }  //end LoadJSON_Document()
      83              : 
      84            0 : int main(int argc, char* argv[])
      85              : {
      86            0 :         if(getenv("OTSDAQ_LOG_FHICL") == NULL)
      87            0 :                 setenv("OTSDAQ_LOG_FHICL",
      88            0 :                        (std::string(__ENV__("USER_DATA")) +
      89              :                         "/MessageFacilityConfigurations/MessageFacilityWithCout.fcl")
      90              :                            .c_str(),
      91              :                        1);
      92              : 
      93            0 :         if(getenv("OTSDAQ_LOG_ROOT") == NULL)
      94            0 :                 setenv(
      95            0 :                     "OTSDAQ_LOG_ROOT", (std::string(__ENV__("USER_DATA")) + "/Logs").c_str(), 1);
      96              : 
      97              :         // INIT_MF("LoadJSON_Document");
      98            0 :         LoadJSON_Document(argc, argv);
      99            0 :         return 0;
     100              : }
     101              : // BOOST_AUTO_TEST_SUITE_END()
        

Generated by: LCOV version 2.0-1