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

Generated by: LCOV version 2.0-1