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 % 27 27
Test Date: 2026-07-28 10:53:44 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 :         ADIAG_ERR("enqueue failed, ret = %d.", ret);
      35            3 :         return TRACE_FAILURE;
      36              :     }
      37           28 :     return TRACE_SUCCESS;
      38              : }
      39              : 
      40           49 : TraceNode *TraceTsPopNode(SessionNode *sessionNode)
      41              : {
      42           49 :     if (sessionNode == NULL) {
      43            1 :         ADIAG_ERR("invalid input for node searching.");
      44            1 :         return NULL;
      45              :     }
      46           48 :     TraceNode *node = NULL;
      47           48 :     TraStatus ret = TraceQueueDequeue(sessionNode->queue, &node);
      48           48 :     if ((ret != TRACE_SUCCESS) && (ret != TRACE_QUEUE_NULL)) {
      49            2 :         ADIAG_ERR("trace node dequeue failed, ret = %d.", ret);
      50            2 :         return NULL;
      51              :     }
      52           46 :     return node;
      53              : }
        

Generated by: LCOV version 2.0-1