LCOV - code coverage report
Current view: top level - conffwk/test/apps - config_test_rw.cxx (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 343 0
Test Date: 2026-07-12 15:23:06 Functions: 0.0 % 67 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_rw.cpp to test/apps/config_test_rw.cxx).
       6              : //
       7              : 
       8              : //#include <stdlib.h>
       9              : #include <stdint.h>
      10              : 
      11              : #include <iostream>
      12              : #include <string>
      13              : 
      14              : #include "conffwk/Configuration.hpp"
      15              : #include "conffwk/ConfigObject.hpp"
      16              : 
      17              : using namespace dunedaq::conffwk;
      18              : 
      19            0 : ERS_DECLARE_ISSUE(
      20              :   conffwk_test_rw,
      21              :   BadCommandLine,
      22              :   "bad command line: " << reason,
      23              :   ((const char*)reason)
      24              : )
      25              : 
      26            0 : ERS_DECLARE_ISSUE(
      27              :   conffwk_test_rw,
      28              :   ConfigException,
      29              :   "caught dunedaq::conffwk::Exception exception",
      30              : )
      31              : 
      32              : static void
      33            0 : usage()
      34              : {
      35            0 :   std::cout << 
      36              :     "Usage: conffwk_test_rw -d data_name -s schema_name -p plugin_spec\n"
      37              :     "\n"
      38              :     "Options/Arguments:\n"
      39              :     "       -d data_name      name of creating data file\n"
      40              :     "       -s schema_name    name of including schema file\n"
      41              :     "       -p plugin_spec    conffwk plugin specification (oksconflibs | rdbconffwk:server-name)\n"
      42              :     "\n"
      43              :     "Description:\n"
      44            0 :     "       The utility tests creation of files and objects using different plugins.\n\n";
      45            0 : }
      46              : 
      47              : static void
      48            0 : no_param(const char * s)
      49              : {
      50            0 :   std::ostringstream text;
      51            0 :   text << "no parameter for " << s << " provided";
      52            0 :   ers::fatal(conffwk_test_rw::BadCommandLine(ERS_HERE, text.str().c_str()));
      53            0 :   exit(EXIT_FAILURE);
      54            0 : }
      55              : 
      56              : ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      57              : 
      58            0 : template<class T> void set_value(ConfigObject& o, const std::string& name, T value)
      59              : {
      60            0 :   o.set_by_val(name, value);
      61            0 : }
      62              : 
      63            0 : template<class T> void set_ref(ConfigObject& o, const std::string& name, T value)
      64              : {
      65            0 :   o.set_by_ref(name, value);
      66            0 : }
      67              : 
      68            0 : template<class T> void check_value(ConfigObject& o, const std::string& name, T v1)
      69              : {
      70            0 :   T v2;
      71            0 :   o.get(name, v2);
      72            0 :   if(v1 != v2) {
      73            0 :     std::cerr << "ERROR reading attribute: \'" << name << '\'' << std::endl; 
      74              :   }
      75              :   else {
      76            0 :     std::cout << "TEST " << name << " of " << o << " is OK\n";
      77              :   }
      78            0 : }
      79              : 
      80            0 : void check_object(ConfigObject& o, const std::string& name, ConfigObject * o1)
      81              : {
      82            0 :   ConfigObject o2;
      83            0 :   o.get(name, o2);
      84            0 :   if(o1 == 0) {
      85            0 :     if(!o2.is_null()) {
      86            0 :       std::cerr << "ERROR reading relationship: \'" << name << "\' (read an object instead of NULL)" << std::endl; 
      87              :     }
      88              :   }
      89              :   else {
      90            0 :     if(o2.is_null()) {
      91            0 :       std::cerr << "ERROR reading relationship: \'" << name << "\' (read NULL instead of object)" << std::endl; 
      92              :     }
      93              :     else {
      94            0 :       if(!(o2 == *o1)) {
      95            0 :         std::cerr << "ERROR reading relationship: \'" << name << "\' (read and wrote objects are different)" << std::endl; 
      96              :       }
      97              :     }
      98              :   }
      99              : 
     100            0 :   std::cout << "TEST value of " << name << " relationship of object " << o << " is OK: read " << o2 << std::endl;
     101            0 : }
     102              : 
     103            0 : void check_objects(ConfigObject& o, const std::string& name, const std::vector<const ::ConfigObject*> o1)
     104              : {
     105            0 :   std::vector<ConfigObject> o2;
     106              : 
     107            0 :   o.get(name, o2);
     108              : 
     109            0 :   if(o1.size() != o2.size()) {
     110            0 :     std::cerr << "ERROR reading relationship: \'" << name << "\' (read vector of different size)" << std::endl; 
     111              :   }
     112              :   else {
     113            0 :     for(unsigned int i = 0; i < o1.size(); ++i) {
     114            0 :       if(!(*o1[i] == o2[i])) {
     115            0 :         std::cerr << "ERROR reading relationship: \'" << name << "\' (objects " << i << " are different)" << std::endl; 
     116              :       }
     117              :     }
     118              :   }
     119              : 
     120            0 :   std::cout << "TEST values of " << name << " relationship of object " << o << " is OK: read ";
     121            0 :   for(unsigned int i = 0; i < o1.size(); ++i) {
     122            0 :     if(i != 0) std::cout << ", ";
     123            0 :     std::cout << o2[i];
     124              :   } 
     125            0 :   std::cout << std::endl; 
     126            0 : }
     127              : 
     128            0 : void check_file_path(ConfigObject& o, const std::string& file_name)
     129              : {
     130            0 :   std::string value = o.contained_in();
     131              : 
     132            0 :   std::cout << "TEST object " << &o << " is contained in \'" << value << "\': ";
     133              : 
     134            0 :   if(value == file_name)
     135              :     {
     136            0 :       std::cout << "OK\n";
     137              :     }
     138              :   else
     139              :     {
     140            0 :       std::cout << "FAILED (expected \'" << file_name << "\')\n";
     141              :     }
     142            0 : }
     143              : 
     144              : 
     145            0 : void check_rename(ConfigObject& o, const std::string& name)
     146              : {
     147            0 :   std::cout << "TEST object " << &o << " was renamed to \'" << name << "\': ";
     148              : 
     149            0 :   if(name == o.UID())
     150              :     {
     151            0 :       std::cout << "OK\n";
     152              :     }
     153              :   else
     154              :     {
     155            0 :       std::cout << "FAILED\n";
     156              :     }
     157            0 : }
     158              : 
     159              : 
     160              : #define INIT(T, X, V)            \
     161              : for(T v = X - 16; v <= X;) {     \
     162              :   V.push_back(++v);              \
     163              : }
     164              : 
     165              : ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     166              : 
     167              : 
     168              : 
     169            0 : int main(int argc, char *argv[])
     170              : {
     171            0 :   const char * schema_name = 0;
     172            0 :   const char * data_name = 0;
     173            0 :   const char * plugin_name = 0;
     174              : 
     175            0 :   for(int i = 1; i < argc; i++) {
     176            0 :     const char * cp = argv[i];
     177              : 
     178            0 :     if(!strcmp(cp, "-h") || !strcmp(cp, "--help")) {
     179            0 :       usage();
     180            0 :       return 0;
     181              :     }
     182            0 :     else if(!strcmp(cp, "-d") || !strcmp(cp, "--data-name")) {
     183            0 :       if(++i == argc) { no_param(cp); } else { data_name = argv[i]; }
     184              :     }
     185            0 :     else if(!strcmp(cp, "-s") || !strcmp(cp, "--schema-name")) {
     186            0 :       if(++i == argc) { no_param(cp); } else { schema_name = argv[i]; }
     187              :     }
     188            0 :     else if(!strcmp(cp, "-p") || !strcmp(cp, "--plugin-spec")) {
     189            0 :       if(++i == argc) { no_param(cp); } else { plugin_name = argv[i]; }
     190              :     }
     191              :     else {
     192            0 :       std::ostringstream text;
     193            0 :       text << "unexpected parameter: \'" << cp << "\'; run command with --help to see valid command line options.";
     194            0 :       ers::fatal(conffwk_test_rw::BadCommandLine(ERS_HERE, text.str().c_str()));
     195            0 :       return (EXIT_FAILURE);
     196            0 :     }
     197              :   }
     198              : 
     199            0 :   if(!data_name) {
     200            0 :     ers::fatal(conffwk_test_rw::BadCommandLine(ERS_HERE, "no data filename given"));
     201            0 :     return (EXIT_FAILURE);
     202              :   }
     203              : 
     204            0 :   if(!schema_name) {
     205            0 :     ers::fatal(conffwk_test_rw::BadCommandLine(ERS_HERE, "no schema filename given"));
     206            0 :     return (EXIT_FAILURE);
     207              :   }
     208              : 
     209            0 :   if(!plugin_name) {
     210            0 :     ers::fatal(conffwk_test_rw::BadCommandLine(ERS_HERE, "no plugin specification given (oksconflibs, rdbconffwk:server-name)"));
     211            0 :     return (EXIT_FAILURE);
     212              :   }
     213              : 
     214            0 :   try {
     215            0 :     ::Configuration db(plugin_name);
     216              : 
     217            0 :     db.create(data_name, std::list<std::string>(1,schema_name));
     218              : 
     219            0 :     ConfigObject o1;
     220            0 :     db.create(data_name, "Dummy", "#1", o1);
     221              : 
     222            0 :     ConfigObject o2;
     223            0 :     db.create(data_name, "Dummy", "#2", o2);
     224              : 
     225            0 :     ConfigObject o3;
     226            0 :     db.create(data_name, "Second", "#3", o3);
     227              : 
     228            0 :     ConfigObject o4;
     229            0 :     db.create(data_name, "Third", "#4", o4);
     230              : 
     231            0 :     ConfigObject o5;
     232            0 :     db.create(data_name, "Third", "#5", o5);
     233              : 
     234            0 :     ConfigObject o6;
     235            0 :     db.create(data_name, "Third", "#6", o6);
     236              : 
     237              : 
     238              :        // put objects into implementation cache
     239              : 
     240            0 :     check_value(o1, "bool", false);
     241            0 :     check_value(o2, "bool", false);
     242            0 :     check_value(o3, "bool", false);
     243            0 :     check_value(o4, "bool", false);
     244            0 :     check_value(o5, "bool", false);
     245            0 :     check_value(o6, "bool", false);
     246              : 
     247              : 
     248            0 :     bool        bool_value   (true);
     249            0 :     int8_t      int8_value   (0x7F);
     250            0 :     uint8_t     uint8_value  (0xFF);
     251            0 :     int16_t     int16_value  (0x7FFF);
     252            0 :     uint16_t    uint16_value (0xFFFF);
     253            0 :     int32_t     int32_value  (0x7FFFFFFF);
     254            0 :     int32_t     uint32_value (0xFFFFFFFF);
     255            0 :     int64_t     int64_value  ((uint64_t)(-1)/2-1);
     256            0 :     uint64_t    uint64_value ((uint64_t)(-1));
     257            0 :     float       float_value  (123.456);
     258            0 :     double      double_value (1234567890.123456);
     259            0 :     std::string string_value ("This is a test string.");
     260            0 :     std::string enum_value   ("FIRST");
     261            0 :     std::string class_value  ("Third");
     262              : 
     263            0 :     std::vector<bool>        bool_values;    bool_values.push_back(true); bool_values.push_back(false); bool_values.push_back(true);
     264            0 :     std::vector<int8_t>      int8_values;    INIT(int8_t, 0x7E, int8_values);
     265            0 :     std::vector<uint8_t>     uint8_values;   INIT(uint8_t, 0xFE, uint8_values);
     266            0 :     std::vector<int16_t>     int16_values;   INIT(int16_t, 0x7FFE, int16_values);
     267            0 :     std::vector<uint16_t>    uint16_values;  INIT(uint16_t, 0xFFFE, uint16_values);
     268            0 :     std::vector<int32_t>     int32_values;   INIT(int32_t, 0x7FFFFFFE, int32_values);
     269            0 :     std::vector<int32_t>     uint32_values;  INIT(uint32_t, 0xFFFFFFFE, uint32_values);
     270            0 :     std::vector<int64_t>     int64_values;   INIT(int64_t, (std::numeric_limits<int64_t>::max()-2), int64_values);
     271            0 :     std::vector<uint64_t>    uint64_values;  INIT(uint64_t, (std::numeric_limits<uint64_t>::max()-1), uint64_values);
     272            0 :     std::vector<float>       float_values;   INIT(float, 123.456, float_values);
     273            0 :     std::vector<double>      double_values;  INIT(double, 1234567890.123456, double_values);
     274            0 :     std::vector<std::string> strings_values; strings_values.push_back("test20"); strings_values.push_back("test30"); strings_values.push_back("test10");
     275            0 :     std::vector<std::string> enum_values;    enum_values.push_back("THIRD"); enum_values.push_back("SECOND"); enum_values.push_back("FIRST");
     276            0 :     std::vector<std::string> class_values;   class_values.push_back("Dummy"); class_values.push_back("Second"); class_values.push_back("Third");
     277              : 
     278            0 :     set_ref(o1, "bool_vector", bool_values);
     279            0 :     set_ref(o1, "sint8_vector", int8_values);
     280            0 :     set_ref(o1, "uint8_vector", uint8_values);
     281            0 :     set_ref(o1, "sint16_vector", int16_values);
     282            0 :     set_ref(o1, "uint16_vector", uint16_values);
     283            0 :     set_ref(o1, "sint32_vector", int32_values);
     284            0 :     set_ref(o1, "uint32_vector", int32_values);
     285            0 :     set_ref(o1, "sint64_vector", int64_values);
     286            0 :     set_ref(o1, "uint64_vector", uint64_values);
     287            0 :     set_ref(o1, "float_vector", float_values);
     288            0 :     set_ref(o1, "double_vector", double_values);
     289            0 :     set_ref(o1, "string_vector", strings_values);
     290            0 :     o1.set_enum("enum_vector", enum_values);
     291            0 :     o1.set_class("classref_vector", class_values);
     292              : 
     293            0 :     set_value(o1, "bool",   bool_value);
     294            0 :     set_value(o1, "sint8",  int8_value);
     295            0 :     set_value(o1, "uint8",  uint8_value);
     296            0 :     set_value(o1, "sint16", int16_value);
     297            0 :     set_value(o1, "uint16", uint16_value);
     298            0 :     set_value(o1, "sint32", int32_value);
     299            0 :     set_value(o1, "uint32", uint32_value);
     300            0 :     set_value(o1, "sint64", int64_value);
     301            0 :     set_value(o1, "uint64", uint64_value);
     302            0 :     set_value(o1, "float",  float_value);
     303            0 :     set_value(o1, "double", double_value);
     304            0 :     set_ref(o1, "string", string_value);
     305            0 :     o1.set_enum("enum", enum_value);
     306            0 :     o1.set_class("classref", class_value);
     307              : 
     308            0 :     std::vector<const ::ConfigObject*> vec4; vec4.push_back(&o1); vec4.push_back(&o2);
     309            0 :     std::vector<const ::ConfigObject*> vec5; vec5.push_back(&o3); vec5.push_back(&o4);
     310            0 :     std::vector<const ::ConfigObject*> vec6; vec6.push_back(&o3);
     311              : 
     312            0 :     o3.set_objs("Dummy", vec4);
     313            0 :     o3.set_obj("Another", &o1);
     314              : 
     315            0 :     o4.set_objs("Dummy", vec4);
     316            0 :     o4.set_obj("Another", &o2);
     317            0 :     o4.set_obj("Single", &o6);
     318              : 
     319            0 :     o5.set_objs("Dummy", vec4);
     320            0 :     o5.set_obj("Another", &o3);
     321            0 :     o5.set_obj("Single", 0);
     322            0 :     o5.set_objs("Seconds", vec5);
     323              : 
     324            0 :     o6.set_objs("Dummy", vec4);
     325            0 :     o6.set_obj("Another", &o3);
     326            0 :     o6.set_obj("Single", 0);
     327            0 :     o6.set_objs("Seconds", vec6);
     328              : 
     329            0 :     check_value(o1, "bool",   bool_value);
     330            0 :     check_value(o1, "sint8",  int8_value);
     331            0 :     check_value(o1, "uint8",  uint8_value);
     332            0 :     check_value(o1, "sint16", int16_value);
     333            0 :     check_value(o1, "uint16", uint16_value);
     334            0 :     check_value(o1, "sint32", int32_value);
     335            0 :     check_value(o1, "uint32", uint32_value);
     336            0 :     check_value(o1, "sint64", int64_value);
     337            0 :     check_value(o1, "uint64", uint64_value);
     338            0 :     check_value(o1, "float",  float_value);
     339            0 :     check_value(o1, "double", double_value);
     340            0 :     check_value(o1, "string", string_value);
     341            0 :     check_value(o1, "enum", enum_value);
     342            0 :     check_value(o1, "classref", class_value);
     343            0 :     check_value(o1, "bool_vector", bool_values);
     344            0 :     check_value(o1, "sint8_vector", int8_values);
     345            0 :     check_value(o1, "uint8_vector", uint8_values);
     346            0 :     check_value(o1, "sint16_vector", int16_values);
     347            0 :     check_value(o1, "uint16_vector", uint16_values);
     348            0 :     check_value(o1, "sint32_vector", int32_values);
     349            0 :     check_value(o1, "uint32_vector", int32_values);
     350            0 :     check_value(o1, "sint64_vector", int64_values);
     351            0 :     check_value(o1, "uint64_vector", uint64_values);
     352            0 :     check_value(o1, "float_vector", float_values);
     353            0 :     check_value(o1, "double_vector", double_values);
     354            0 :     check_value(o1, "string_vector", strings_values);
     355            0 :     check_value(o1, "enum_vector", enum_values);
     356            0 :     check_value(o1, "classref_vector", class_values);
     357              : 
     358            0 :     check_objects(o3, "Dummy", vec4);
     359            0 :     check_object(o3, "Another", &o1);
     360            0 :     check_objects(o4, "Dummy", vec4);
     361            0 :     check_object(o4, "Another", &o2);
     362            0 :     check_object(o4, "Single", &o6);
     363            0 :     check_objects(o5, "Seconds", vec5);
     364            0 :     check_objects(o6, "Dummy", vec4);
     365            0 :     check_object(o6, "Another", &o3);
     366            0 :     check_object(o6, "Single", 0);
     367            0 :     check_objects(o6, "Seconds", vec6);
     368              : 
     369            0 :     check_file_path(o1, data_name);
     370            0 :     check_file_path(o3, data_name);
     371            0 :     check_file_path(o4, data_name);
     372              : 
     373            0 :     {
     374            0 :       std::list<std::string> modified;
     375              : 
     376            0 :       db.get_updated_dbs(modified);
     377              : 
     378            0 :       std::cout << "There are updated " << modified.size() << " files:\n";
     379            0 :       for(std::list<std::string>::const_iterator i = modified.begin(); i != modified.end(); ++i) {
     380            0 :         std::cout << " * \"" << *i << "\"" << std::endl;
     381              :       }
     382            0 :     }
     383              : 
     384            0 :     db.commit("test application (conffwk/test/conffwk_test_rw.cpp): create first data");
     385              : 
     386              : 
     387              :       // create file names for 2 intermediate and 4 leave files;
     388              :       // file $F1 will include $F11 and $F12
     389              :       // file $F2 will include $F21, $F22 and $F12
     390              :       // existing file $data_name will include $F1 and $F2
     391              : 
     392            0 :     std::string f11(data_name); f11 += ".1.1"; 
     393            0 :     std::string f12(data_name); f12 += ".1.2"; 
     394            0 :     std::string f21(data_name); f21 += ".2.1"; 
     395            0 :     std::string f22(data_name); f22 += ".2.2"; 
     396              : 
     397            0 :     db.create(f11, std::list<std::string>(1,schema_name));
     398            0 :     db.create(f12, std::list<std::string>(1,schema_name));
     399            0 :     db.create(f21, std::list<std::string>(1,schema_name));
     400            0 :     db.create(f22, std::list<std::string>(1,schema_name));
     401              : 
     402            0 :     std::string f1(data_name); f1 += ".1"; 
     403            0 :     std::string f2(data_name); f2 += ".2"; 
     404              : 
     405            0 :     {
     406            0 :       std::list<std::string> includes(1,schema_name); includes.push_back(f11); includes.push_back(f12);
     407            0 :       db.create(f1, includes);
     408            0 :     }
     409              : 
     410            0 :     {
     411            0 :       std::list<std::string> includes(1,schema_name); includes.push_back(f21); includes.push_back(f22); includes.push_back(f12);
     412            0 :       db.create(f2, includes);
     413            0 :     }
     414              : 
     415            0 :     struct {
     416              :       const std::string * file;
     417              :       const char * id;
     418            0 :     } data [12] = {
     419              :       {&f1, "f1-1"},
     420              :       {&f1, "f1-2"},
     421              :       {&f2, "f2-1"},
     422              :       {&f2, "f2-2"},
     423              :       {&f11, "f11-1"},
     424              :       {&f11, "f11-2"},
     425              :       {&f12, "f12-1"},
     426              :       {&f12, "f12-2"},
     427              :       {&f21, "f21-1"},
     428              :       {&f21, "f21-2"},
     429              :       {&f22, "f22-1"},
     430              :       {&f22, "f22-2"}
     431            0 :     };
     432              : 
     433            0 :     for(int i = 0; i < 12; ++i) {
     434            0 :       ConfigObject o;
     435            0 :       db.create(*data[i].file, "Dummy", data[i].id, o);
     436            0 :       check_file_path(o, *data[i].file);
     437            0 :     }
     438              : 
     439            0 :     db.add_include(data_name, f1);
     440            0 :     db.add_include(data_name, f2);
     441              : 
     442            0 :     db.commit("test application (conffwk/test/conffwk_test_rw.cpp): create 6 nested files");
     443              : 
     444            0 :     std::cout << "\n\nTEST VALIDITY OF OBJECTS AFTER REMOVAL OF INCLUDES: Removing include \"" << f1 << "\"\n\n";
     445              : 
     446            0 :     db.remove_include(data_name, f1);
     447              : 
     448            0 :     const char * removed_objects_by_include[] = {"f1-1", "f1-2", "f11-1", "f11-2"}; // these objects have to be removed (note, f12 is still included by f2)
     449              : 
     450            0 :     for(int i = 0; i < 12; ++i) {
     451            0 :       std::cout << "TEST object " << data[i].id << " existence after removal of includes: ";
     452            0 :       bool state(false);
     453            0 :       try {
     454            0 :         ConfigObject o;
     455            0 :         db.get("Dummy", data[i].id, o);
     456            0 :         for(int j = 0; j < 4; ++j) {
     457            0 :           if(!strcmp(removed_objects_by_include[j], data[i].id)) {
     458            0 :             std::cout << "FAILED, object was not removed"; state = true; break;
     459              :           }
     460              :         }
     461            0 :         if(state == false) {
     462            0 :           std::cout << "OK, object was not removed";
     463              :         }
     464            0 :       }
     465            0 :       catch(dunedaq::conffwk::NotFound& ex) {
     466            0 :         for(int j = 0; j < 4; ++j) {
     467            0 :           if(!strcmp(removed_objects_by_include[j], data[i].id)) {
     468            0 :             std::cout << "OK, object was removed"; state = true; break;
     469              :           }
     470              :         }
     471            0 :         if(state == false) {
     472            0 :           std::cout << "FAILED, object was removed";
     473              :         }
     474            0 :       }
     475            0 :       std::cout << std::endl;
     476              :     }
     477              : 
     478            0 :     std::cout << "\n\nTEST VALIDITY OF OBJECTS AFTER REMOVAL OF COMPOSITE PARENT: Destroying object \"" << o5 << "\"\n\n";
     479              : 
     480            0 :     const char * existing_objects[] = {"#1", "#2", "#3", "#4", "#5", "#6" };
     481            0 :     const char * removed_objects_by_composite_parent[] = {"#4", "#5"};  // these objects have to be removed (note, #3 is still referenced by #6
     482              : 
     483            0 :     db.destroy_obj(o5);
     484              : 
     485            0 :     std::cout << "TEST deleted object " << o5.UID() << " existence: " << (o5.is_deleted() ? "OK (is_deleted returns TRUE)" : "FAILED (is_deleted returns FALSE)") << std::endl;
     486              : 
     487            0 :     check_file_path(o1, data_name);
     488            0 :     check_file_path(o3, data_name);
     489            0 :     check_file_path(o6, data_name);
     490              : 
     491            0 :     for(int i = 0; i < 6; ++i) {
     492            0 :       std::cout << "TEST object " << existing_objects[i] << " existence: ";
     493              : 
     494            0 :       bool state(false);
     495            0 :       try {
     496            0 :         ConfigObject o;
     497            0 :         db.get("Dummy", existing_objects[i], o);
     498            0 :         for(int j = 0; j < 2; ++j) {
     499            0 :           if(!strcmp(removed_objects_by_composite_parent[j], existing_objects[i])) {
     500            0 :             std::cout << "FAILED, object was not removed"; state = true; break;
     501              :           }
     502              :         }
     503            0 :         if(state == false) {
     504            0 :           std::cout << "OK, object was not removed";
     505              :         }
     506            0 :       }
     507            0 :       catch(dunedaq::conffwk::NotFound& ex) {
     508            0 :         for(int j = 0; j < 2; ++j) {
     509            0 :           if(!strcmp(removed_objects_by_composite_parent[j], existing_objects[i])) {
     510            0 :             std::cout << "OK, object was removed"; state = true; break;
     511              :           }
     512              :         }
     513            0 :         if(state == false) {
     514            0 :           std::cout << "FAILED, object was removed";
     515              :         }
     516            0 :       }
     517            0 :       std::cout << std::endl;
     518              :     }
     519              : 
     520              : 
     521            0 :     std::cout << "\n\nTEST INCLUDES\n\n";
     522              : 
     523            0 :     std::list<std::string> includes;
     524            0 :     db.get_includes(data_name, includes);
     525              : 
     526            0 :     std::cout << "* file \"" << data_name << "\" includes " << includes.size() << " files:\n";
     527            0 :     for (auto& x : includes)
     528            0 :       std::cout << " - " << x << std::endl;
     529              : 
     530            0 :     std::cout << "test " << ((includes.size() == 2) ? "PASSED" : "FAILED") << std::endl;
     531              : 
     532            0 :     includes.clear();
     533            0 :     db.get_includes("", includes);
     534              : 
     535            0 :     std::cout << "* there is " << includes.size() << " top-level files:\n";
     536            0 :     for (auto& x : includes)
     537            0 :       std::cout << " - " << x << std::endl;
     538              : 
     539            0 :     std::cout << "test " << ((includes.size() == 1) ? "PASSED" : "FAILED") << std::endl;
     540              : 
     541              : 
     542            0 :     std::cout << "\n\nTEST RENAME\n\n";
     543              : 
     544            0 :     o1.rename("#new1");
     545            0 :     check_rename(o1, "#new1");
     546              : 
     547              :     // rename existing object to deleted
     548              : 
     549            0 :     std::cout << "TEST deleted object " << o4.UID() << " existence: " << (o4.is_deleted() ? "OK" : "FAILED") << std::endl;
     550            0 :     const std::string deleted_name(o4.UID());
     551            0 :     o6.rename(deleted_name);
     552            0 :     check_rename(o6, deleted_name);
     553            0 :     std::cout << "TEST deleted object " << deleted_name << " after renamed existing object to it's ID: " << (!o4.is_deleted() ? "OK" : "FAILED") << std::endl;
     554            0 :     check_rename(o4, deleted_name);
     555              : 
     556            0 :     return 0;
     557            0 :   }
     558            0 :   catch (dunedaq::conffwk::Exception & ex) {
     559            0 :     ers::fatal(conffwk_test_rw::ConfigException(ERS_HERE, ex));
     560            0 :   }
     561              : 
     562            0 :   return (EXIT_FAILURE);
     563              : }
        

Generated by: LCOV version 2.0-1