LCOV - code coverage report
Current view: top level - atrace/trace_server/session_mgr - trace_node.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 29 29
Test Date: 2026-08-31 10:07:06 Functions: 100.0 % 2 2

            Line data    Source code
       1              : /**
       2              :  * Copyright (c) 2025 Huawei Technologies Co., Ltd.
       3              :  * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
       4              :  * CANN Open Software License Agreement Version 2.0 (the "License").
       5              :  * Please refer to the License for details. You may not use this file except in compliance with the License.
       6              :  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
       7              :  * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
       8              :  * See LICENSE in the root of the software repository for the full text of the License.
       9              :  */
      10              : #include "trace_node.h"
      11              : #include "trace_types.h"
      12              : #include "adiag_print.h"
      13              : #include "trace_system_api.h"
      14              : 
      15              : #define MAX_DEV_NUM 64
      16              : 
      17           33 : TraStatus TraceTsPushNode(SessionNode* sessionNode, uint8_t flag, void* data, uint32_t len)
      18              : {
      19           33 :     if ((sessionNode == NULL) || (data == NULL)) {
      20            1 :         ADIAG_ERR("invalid input for node searching");
      21            1 :         return TRACE_INVALID_PARAM;
      22              :     }
      23           32 :     TraceNode* node = (TraceNode*)AdiagMalloc(sizeof(TraceNode));
      24           32 :     if (node == NULL) {
      25            1 :         ADIAG_ERR("malloc node failed, strerr=%s.", strerror(AdiagGetErrorCode()));
      26            1 :         return TRACE_FAILURE;
      27              :     }
      28           31 :     node->data = data;
      29           31 :     node->dataLen = len;
      30           31 :     node->flag = flag;
      31           31 :     TraStatus ret = TraceQueueEnqueue(sessionNode->queue, node);
      32           31 :     if (ret != TRACE_SUCCESS) {
      33            3 :         ADIAG_SAFE_FREE(node);
      34            3 :         if (ret == TRACE_QUEUE_FULL) {
      35            2 :             return ret;
      36              :         }
      37            1 :         ADIAG_ERR("enqueue failed, ret = %d.", ret);
      38            1 :         return TRACE_FAILURE;
      39              :     }
      40           28 :     return TRACE_SUCCESS;
      41              : }
      42              : 
      43           43 : TraceNode* TraceTsPopNode(SessionNode* sessionNode)
      44              : {
      45           43 :     if (sessionNode == NULL) {
      46            1 :         ADIAG_ERR("invalid input for node searching.");
      47            1 :         return NULL;
      48              :     }
      49           42 :     TraceNode* node = NULL;
      50           42 :     TraStatus ret = TraceQueueDequeue(sessionNode->queue, &node);
      51           42 :     if ((ret != TRACE_SUCCESS) && (ret != TRACE_QUEUE_NULL)) {
      52            2 :         ADIAG_ERR("trace node dequeue failed, ret = %d.", ret);
      53            2 :         return NULL;
      54              :     }
      55           40 :     return node;
      56              : }
        

Generated by: LCOV version 2.0-1