SolidSyslog coverage report
Current view: top level - Core/Source - SolidSyslogStreamOpenHealth.c (source / functions) Coverage Total Hit
Test: SolidSyslog Lines: 100.0 % 17 17
Test Date: 2026-11-12 23:14:35 Functions: 100.0 % 4 4
Branches: 100.0 % 10 10

             Branch data     Line data    Source code
       1                 :             : /* SPDX-FileCopyrightText: Copyright 2026 Cozens Software Solutions Limited
       2                 :             :  * SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0 OR LicenseRef-PolyForm-Internal-Use-1.0.0 OR LicenseRef-COSOSO-Commercial
       3                 :             :  */
       4                 :             : 
       5                 :             : #include "SolidSyslogStreamOpenHealth.h"
       6                 :             : 
       7                 :             : #include "SolidSyslogError.h"
       8                 :             : 
       9                 :             : static inline bool StreamOpenHealth_Admit(struct SolidSyslogStreamOpenHealth* self, int32_t detail);
      10                 :             : 
      11                 :         384 : void SolidSyslogStreamOpenHealth_ReportFailure(
      12                 :             :     struct SolidSyslogStreamOpenHealth* self,
      13                 :             :     const struct SolidSyslogErrorSource* source,
      14                 :             :     enum SolidSyslogSeverity severity,
      15                 :             :     uint16_t category,
      16                 :             :     int32_t detail
      17                 :             : )
      18                 :             : {
      19         [ +  + ]:         384 :     if (StreamOpenHealth_Admit(self, detail))
      20                 :             :     {
      21                 :         351 :         SolidSyslog_Error(severity, source, category, detail);
      22                 :             :     }
      23                 :         384 : }
      24                 :             : 
      25                 :             : /* Whether this failure is news, latching it when it is. A run is one detail
      26                 :             :  * repeating; the native code behind it may vary (a different errno for the
      27                 :             :  * same refusal) without being news. */
      28                 :         468 : static inline bool StreamOpenHealth_Admit(struct SolidSyslogStreamOpenHealth* self, int32_t detail)
      29                 :             : {
      30   [ +  +  +  + ]:         468 :     bool isNews = !(self->Failing && (self->FailedDetail == detail));
      31         [ +  + ]:         468 :     if (isNews)
      32                 :             :     {
      33                 :         429 :         self->Failing = true;
      34                 :         429 :         self->FailedDetail = detail;
      35                 :             :     }
      36                 :         468 :     return isNews;
      37                 :             : }
      38                 :             : 
      39                 :          84 : void SolidSyslogStreamOpenHealth_ReportFailureWithNativeCode(
      40                 :             :     struct SolidSyslogStreamOpenHealth* self,
      41                 :             :     const struct SolidSyslogErrorSource* source,
      42                 :             :     enum SolidSyslogSeverity severity,
      43                 :             :     uint16_t category,
      44                 :             :     int32_t detail,
      45                 :             :     int32_t nativeCode
      46                 :             : )
      47                 :             : {
      48         [ +  + ]:          84 :     if (StreamOpenHealth_Admit(self, detail))
      49                 :             :     {
      50                 :          78 :         SolidSyslog_ErrorWithNativeCode(severity, source, category, detail, nativeCode);
      51                 :             :     }
      52                 :          84 : }
      53                 :             : 
      54                 :         834 : void SolidSyslogStreamOpenHealth_Opened(struct SolidSyslogStreamOpenHealth* self)
      55                 :             : {
      56                 :         834 :     self->Failing = false;
      57                 :         834 : }
        

Generated by: LCOV version 2.0-1