LCOV - code coverage report
Current view: top level - legacy/ascend950/framework/fault_recovery - recover_info.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 94.1 % 34 32
Test Date: 2026-07-28 12:11:00 Functions: 100.0 % 8 8

            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 "recover_info.h"
      11              : #include "string_util.h"
      12              : #include "invalid_params_exception.h"
      13              : 
      14              : namespace Hccl {
      15              :  
      16            3 : static void ReportRecoverInfoCheckFailed(const std::string &paraName, uint32_t localPara, uint32_t remotePara)
      17              : {
      18            3 :     THROW<InvalidParamsException>(
      19            6 :         StringFormat("[recover_info][ReportOpInfoCheckFailed]recover information %s check fail. local[%u], remote[%u]",
      20              :                      paraName.c_str(), localPara, remotePara));
      21              : }
      22              :  
      23           14 : RecoverInfo::RecoverInfo(const RecoverInfoData &recoverInfoData, RankId myRank)
      24           14 :     : recoverInfoData(recoverInfoData), myRank(myRank)
      25              : {
      26           14 : }
      27              : 
      28            1 : RecoverInfo::RecoverInfo(const std::vector<char> &v)
      29              : {
      30            1 :     size_t recoverInfoDataSize = sizeof(RecoverInfoData);
      31            1 :     if (v.size() != recoverInfoDataSize) {
      32            0 :         THROW<InternalException>(StringFormat("Vector size does not match RecoverInfoData size"));
      33              :     }
      34              :     
      35            1 :     int ret = memcpy_s(&this->recoverInfoData, recoverInfoDataSize, &v[0], v.size());
      36            1 :     if (ret != 0) {
      37            0 :         THROW<InternalException>(StringFormat("Vector size does not match RecoverInfoData size"));
      38              :     }
      39            1 : }
      40              : 
      41            1 : std::string RecoverInfo::Describe() const
      42              : {
      43            1 :     return recoverInfoData.Describe();
      44              : }
      45              : 
      46            9 : std::vector<char> RecoverInfo::GetUniqueId() const
      47              : {
      48            9 :     std::vector<char> byteVector = ReCoverCustomTypeToCharVector<RecoverInfoData>(recoverInfoData);
      49              :  
      50            9 :     return byteVector;
      51              : }
      52              : 
      53            1 : void RecoverInfo::SetCrcValue(u32 crcValue)
      54              : {
      55            1 :     recoverInfoData.crcValue = crcValue;
      56            1 : }
      57              : 
      58              : // 功能说明:一致性校验
      59              : // 输入说明:const std::vector<char> &rmtUniqueId:对端数据
      60            4 : void RecoverInfo::Check(const std::vector<char> &rmtUniqueId) const
      61              : {
      62            4 :     RecoverInfoData rmtRecoverInfoData = RecoverCharVectorToCustomType<RecoverInfoData>(rmtUniqueId);
      63            4 :     CompareRecoverInfo(rmtRecoverInfoData);
      64            1 : }
      65              : 
      66            4 : void RecoverInfo::CompareRecoverInfo(const RecoverInfoData &otherRecoverInfoData) const
      67              : {
      68            4 :     if (recoverInfoData.collOpIndex != otherRecoverInfoData.collOpIndex) {
      69            3 :         ReportRecoverInfoCheckFailed("collOpIndex", recoverInfoData.collOpIndex, otherRecoverInfoData.collOpIndex);
      70            3 :     } else if (recoverInfoData.crcValue != otherRecoverInfoData.crcValue) {
      71            3 :         ReportRecoverInfoCheckFailed("crcValue", recoverInfoData.crcValue, otherRecoverInfoData.crcValue);
      72            2 :     } else if (recoverInfoData.step != otherRecoverInfoData.step) {
      73            3 :         ReportRecoverInfoCheckFailed("step", recoverInfoData.step, otherRecoverInfoData.step);
      74              :     }
      75            1 :     return;
      76              : }
      77              : 
      78              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1