LCOV - code coverage report
Current view: top level - root/contrail/src/contrail-common/base - misc_utils.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 7 8 87.5 %
Date: 2026-08-03 02:19:58 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
       3             :  */
       4             : 
       5             : #ifndef ctrlplane_misc_utils_h
       6             : #define ctrlplane_misc_utils_h
       7             : 
       8             : #include <sandesh/sandesh_trace.h>
       9             : #include <sandesh/common/vns_types.h>
      10             : #include <sandesh/common/vns_constants.h>
      11             : #include <string>
      12             : #include <vector>
      13             : #include <map>
      14             : #include <ctime>
      15             : 
      16             : #define VERSION_TRACE_BUF "VersionTrace"
      17             : 
      18             : extern SandeshTraceBufferPtr VersionTraceBuf;
      19             : 
      20             : #define VERSION_TRACE(obj, ...) do {                                  \
      21             :     obj::TraceMsg(VersionTraceBuf, __FILE__, __LINE__, ##__VA_ARGS__); \
      22             : } while (false)
      23             : 
      24             : #define VERSION_LOG(obj, categ, ...)\
      25             :     do {\
      26             :             obj::Send(g_vns_constants.CategoryNames.find(categ)->second,\
      27             :                                   SandeshLevel::SYS_INFO, __FILE__, __LINE__, ##__VA_ARGS__);\
      28             :     } while (false)
      29             : 
      30             : #if (__cplusplus < 201103L)
      31             :    #define ARRAYBYTES_FILL(obj, val) (obj).assign((val));
      32             :    #define GENERIC_RAW_ARRAY(obj) obj.c_array()
      33             : #else
      34             :    #define ARRAYBYTES_FILL(obj, val) (obj).fill((val));
      35             :    #define GENERIC_RAW_ARRAY(obj) obj.data()
      36             : #endif
      37             : 
      38             : 
      39             : class MiscUtils {
      40             : public:
      41             :     enum BuildModule {
      42             :         Agent,
      43             :         Analytics,
      44             :         ControlNode,
      45             :         Dns,
      46             :         MaxModules
      47             :     };
      48         216 :     static std::map<BuildModule, std::string> MapInit() {
      49         216 :         std::map<BuildModule, std::string> m;
      50         216 :          m[Agent] = "contrail-vrouter-agent ";
      51         216 :          m[Analytics] = "contrail-analytics ";
      52         216 :          m[ControlNode] = "contrail-control ";
      53         216 :          m[Dns] = "contrail-dns ";
      54         216 :          return m;
      55           0 :     }
      56             :     static const std::map<BuildModule, std::string> BuildModuleNames;
      57             :     typedef std::multimap<std::time_t, std::string> FileMMap;
      58             :     static const std::string ContrailVersionCmd;
      59             :     static const std::string CoreFileDir;
      60             :     static const int MaxCoreFiles;
      61             : 
      62             :     static void GetHostIp(const std::string name, std::vector<std::string> &ip_list);
      63             :     static void LogVersionInfo(const std::string str, Category::type categ);
      64             :     static time_t GetUpTimeSeconds();
      65             :     static time_t set_startup_time_secs();
      66             : 
      67             : private:
      68             :     static std::string BaseName(std::string filename);
      69             :     static time_t startup_time_secs_;
      70             : };
      71             : 
      72             : #endif // ctrlplane_misc_utils_h

Generated by: LCOV version 1.14