LCOV - code coverage report
Current view: top level - daphnemodules/unittest - DaphneV3Interface_test.cxx (source / functions) Coverage Total Hit
Test: code.result Lines: 100.0 % 6 6
Test Date: 2025-12-21 13:07:08 Functions: 100.0 % 2 2

            Line data    Source code
       1              : /**
       2              :  * @file DaphneV3Interface_test.cxx
       3              :  *
       4              :  * Simple unittest for the daphne v3 interface
       5              :  *
       6              :  * This is part of the DUNE DAQ Software Suite, copyright 2020.
       7              :  * Licensing/copyright details are in the COPYING file that you should have
       8              :  * received with this code.
       9              :  *
      10              :  */
      11              : 
      12              : 
      13              : #define BOOST_TEST_MODULE DaphneV3InterfaceTest  // NOLINT
      14              : #include <boost/test/included/unit_test.hpp>
      15              : 
      16              : #include "DaphneV3Interface.hpp"
      17              : #include <iostream>
      18              : #include <cstdlib>
      19              : 
      20              : using namespace dunedaq::daphnemodules;
      21              : 
      22              : BOOST_AUTO_TEST_SUITE(DaphneInterfaceV3_test)
      23              : 
      24            2 : BOOST_AUTO_TEST_CASE(bad_address)
      25              : {
      26              : 
      27            4 :  BOOST_CHECK_THROW( dunedaq::daphnemodules::DaphneV3Interface i("bad/address", "v3_unittest"),
      28              :                     dunedaq::daphnemodules::InvalidIPAddress );
      29              : 
      30            4 :  BOOST_CHECK_THROW( dunedaq::daphnemodules::DaphneV3Interface i("bad.address:14q4", "v3_unittest"),
      31              :                     dunedaq::daphnemodules::InvalidIPAddress );
      32              : 
      33            4 :  BOOST_CHECK_THROW( dunedaq::daphnemodules::DaphneV3Interface i("non.existing.address", "v3_unittest"),
      34              :                     dunedaq::daphnemodules::FailedPing );
      35              : 
      36            4 :   BOOST_CHECK_THROW( dunedaq::daphnemodules::DaphneV3Interface i("non.existing.address.with.port:7954", "v3_unittest"),
      37              :                      dunedaq::daphnemodules::FailedPing );
      38              : 
      39            1 : }
      40              : 
      41              : 
      42              : BOOST_AUTO_TEST_SUITE_END()
      43              : 
      44              : 
      45              : 
      46              : // static std::string get_env_or_default(const char* name, const char* def)
      47              : // {
      48              : //   if (const char* v = std::getenv(name))
      49              : //     return v;
      50              : //   return def;
      51              : // }
      52              : 
      53              : 
      54              : 
      55              : // BOOST_AUTO_TEST_CASE(connection_test)
      56              : // {
      57              : //   std::string ip   = get_env_or_default("DAPHNE_IP", "");
      58              : //   std::string port = get_env_or_default("DAPHNE_PORT", "");
      59              : 
      60              : //   const auto& args = boost::unit_test::framework::master_test_suite().argv;
      61              : //   const int argc   = boost::unit_test::framework::master_test_suite().argc;
      62              : 
      63              : //   for (int i = 1; i < argc; ++i) {
      64              : //     std::string a = args[i];
      65              : //     if (a == "--ip" && i + 1 < argc) ip = args[++i];
      66              : //     else if (a == "--port" && i + 1 < argc) port = args[++i];
      67              : //   }
      68              : 
      69              : //   if (ip.empty()) {
      70              : //     BOOST_FAIL("No IP provided (use -- --ip <addr> [--port <num>] or DAPHNE_IP env)");
      71              : //   }
      72              : 
      73              : //   std::string address = ip;
      74              : //   if (!port.empty())
      75              : //     address += ":" + port;
      76              : 
      77              : //   std::cout << "[TEST] Connecting to " << address << std::endl;
      78              : 
      79              : //   std::chrono::milliseconds timeout(3000);
      80              : //   DaphneV3Interface iface(address, "v3_unittest", timeout);
      81              : 
      82              : //   uint64_t val = 0;
      83              : //   bool ok = iface.read_test_register(val);
      84              : 
      85              : //   std::cout << "[TEST] Test register value: 0x" << std::hex << val << std::dec << std::endl;
      86              : 
      87              : //   BOOST_CHECK_MESSAGE(ok, "Failed to read test register");
      88              : //   BOOST_CHECK_EQUAL(val, 0xDEADBEEF);
      89              : // }
        

Generated by: LCOV version 2.0-1