LCOV - code coverage report
Current view: top level - conffwk/test/apps - config_test_object.cxx (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 57 0
Test Date: 2026-10-11 15:05:20 Functions: 0.0 % 19 0

            Line data    Source code
       1              : //
       2              : // DUNE DAQ modification notice:
       3              : // This file has been modified from the original ATLAS config source for the DUNE DAQ project.
       4              : // Fork baseline commit: 67a24e731 (2022-10-27).
       5              : // Renamed since fork: yes (from test/config_test_object.cpp to test/apps/config_test_object.cxx).
       6              : //
       7              : 
       8              : #include <stdlib.h>
       9              : 
      10              : #include <iostream>
      11              : #include <string>
      12              : 
      13              : #include "conffwk/ConfigObject.hpp"
      14              : #include "conffwk/Configuration.hpp"
      15              : 
      16              : using namespace dunedaq::conffwk;
      17              : 
      18            0 : ERS_DECLARE_ISSUE(conffwk_test_object, BadCommandLine, "bad command line: " << reason, ((const char*)reason))
      19              : 
      20            0 : ERS_DECLARE_ISSUE(conffwk_test_object, ConfigException, "caught dunedaq::conffwk::Exception exception", )
      21              : 
      22              : static void
      23            0 : usage()
      24              : {
      25            0 :   std::cout << "Usage: conffwk_test_object -d | --database dbspec\n"
      26              :                "                          -c | --class-name class\n"
      27              :                "                          -o | --object-id object\n"
      28              :                "\n"
      29              :                "Options/Arguments:\n"
      30              :                "       -d dbspec    database specification in format plugin-name:parameters\n"
      31              :                "       -c class     name of the class to dump\n"
      32              :                "       -o object    optional id of the object to dump\n"
      33              :                "\n"
      34              :                "Description:\n"
      35            0 :                "       The utility tests object existence.\n\n";
      36            0 : }
      37              : 
      38              : static void
      39            0 : no_param(const char* s)
      40              : {
      41            0 :   std::ostringstream text;
      42            0 :   text << "no parameter for " << s << " provided";
      43            0 :   ers::fatal(conffwk_test_object::BadCommandLine(ERS_HERE, text.str().c_str()));
      44            0 :   exit(EXIT_FAILURE);
      45            0 : }
      46              : 
      47              : int
      48            0 : main(int argc, char* argv[])
      49              : {
      50            0 :   const char* db_name = 0;
      51            0 :   const char* class_name = 0;
      52            0 :   const char* object_id = 0;
      53              : 
      54            0 :   for (int i = 1; i < argc; i++) {
      55            0 :     const char* cp = argv[i];
      56              : 
      57            0 :     if (!strcmp(cp, "-h") || !strcmp(cp, "--help")) {
      58            0 :       usage();
      59            0 :       return 0;
      60            0 :     } else if (!strcmp(cp, "-d") || !strcmp(cp, "--database")) {
      61            0 :       if (++i == argc) {
      62            0 :         no_param(cp);
      63              :       } else {
      64            0 :         db_name = argv[i];
      65              :       }
      66            0 :     } else if (!strcmp(cp, "-c") || !strcmp(cp, "--class-name")) {
      67            0 :       if (++i == argc) {
      68            0 :         no_param(cp);
      69              :       } else {
      70            0 :         class_name = argv[i];
      71              :       }
      72            0 :     } else if (!strcmp(cp, "-o") || !strcmp(cp, "--object-id")) {
      73            0 :       if (++i == argc) {
      74            0 :         no_param(cp);
      75              :       } else {
      76            0 :         object_id = argv[i];
      77              :       }
      78              :     } else {
      79            0 :       std::ostringstream text;
      80            0 :       text << "unexpected parameter: \'" << cp << "\'; run command with --help to see valid command line options.";
      81            0 :       ers::fatal(conffwk_test_object::BadCommandLine(ERS_HERE, text.str().c_str()));
      82            0 :       return (EXIT_FAILURE);
      83            0 :     }
      84              :   }
      85              : 
      86            0 :   if (!db_name) {
      87            0 :     ers::fatal(conffwk_test_object::BadCommandLine(ERS_HERE, "no database name given"));
      88            0 :     return (EXIT_FAILURE);
      89              :   }
      90              : 
      91            0 :   if (!class_name) {
      92            0 :     ers::fatal(conffwk_test_object::BadCommandLine(ERS_HERE, "no class name given"));
      93            0 :     return (EXIT_FAILURE);
      94              :   }
      95              : 
      96            0 :   if (!object_id) {
      97            0 :     ers::fatal(conffwk_test_object::BadCommandLine(ERS_HERE, "no object id given"));
      98            0 :     return (EXIT_FAILURE);
      99              :   }
     100              : 
     101            0 :   try {
     102            0 :     Configuration db(db_name);
     103              : 
     104            0 :     if (db.test_object(class_name, object_id)) {
     105            0 :       std::cout << "object \'" << object_id << '@' << class_name << "\' exists" << std::endl;
     106              :     } else {
     107            0 :       std::cout << "object \'" << object_id << '@' << class_name << "\' does not exist" << std::endl;
     108              :     }
     109              : 
     110            0 :     return 0;
     111            0 :   } catch (dunedaq::conffwk::Exception& ex) {
     112            0 :     ers::fatal(conffwk_test_object::ConfigException(ERS_HERE, ex));
     113            0 :   }
     114              : 
     115            0 :   return (EXIT_FAILURE);
     116              : }
        

Generated by: LCOV version 2.0-1