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

Generated by: LCOV version 2.0-1