Line data Source code
1 : /* 2 : * 3 : * Copyright (c) 2020 Project CHIP Authors 4 : * Copyright (c) 2016-2017 Nest Labs, Inc. 5 : * 6 : * Licensed under the Apache License, Version 2.0 (the "License"); 7 : * you may not use this file except in compliance with the License. 8 : * You may obtain a copy of the License at 9 : * 10 : * http://www.apache.org/licenses/LICENSE-2.0 11 : * 12 : * Unless required by applicable law or agreed to in writing, software 13 : * distributed under the License is distributed on an "AS IS" BASIS, 14 : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 : * See the License for the specific language governing permissions and 16 : * limitations under the License. 17 : */ 18 : 19 : /** 20 : * @file 21 : * Implementation of the fault-injection utilities for Inet. 22 : */ 23 : 24 : #include "InetFaultInjection.h" 25 : 26 : #include <nlassert.h> 27 : 28 : namespace chip { 29 : namespace Inet { 30 : namespace FaultInjection { 31 : 32 : static nl::FaultInjection::Record sFaultRecordArray[kFault_NumItems]; 33 : static class nl::FaultInjection::Manager sInetFaultInMgr; 34 : static const nl::FaultInjection::Name sManagerName = "Inet"; 35 : static const nl::FaultInjection::Name sFaultNames[] = { 36 : "DNSResolverNew", 37 : "Send", 38 : "SendNonCritical", 39 : }; 40 : 41 : /** 42 : * Get the singleton FaultInjection::Manager for Inet faults 43 : */ 44 107 : nl::FaultInjection::Manager & GetManager() 45 : { 46 107 : if (0 == sInetFaultInMgr.GetNumFaults()) 47 : { 48 5 : sInetFaultInMgr.Init(kFault_NumItems, sFaultRecordArray, sManagerName, sFaultNames); 49 : } 50 107 : return sInetFaultInMgr; 51 : } 52 : 53 : } // namespace FaultInjection 54 : } // namespace Inet 55 : } // namespace chip