3 * Copyright (c) 2020 Project CHIP Authors
4 * Copyright (c) 2016-2017 Nest Labs, Inc.
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 * Header file for the fault-injection utilities for Inet.
26 #include <inet/InetConfig.h>
28 #if INET_CONFIG_TEST && CHIP_WITH_NLFAULTINJECTION
30 #include <nlfaultinjection.hpp>
32 #include <support/DLLUtil.h>
34 #include <system/SystemFaultInjection.h>
38 namespace FaultInjection {
41 * @brief Fault injection points
44 * Each point in the code at which a fault can be injected
45 * is identified by a member of this enum.
49 kFault_DNSResolverNew, /**< Fail the allocation of a DNSResolver object */
50 kFault_Send, /**< Fail sending a message over TCP or UDP */
51 kFault_SendNonCritical, /**< Fail sending a UDP message returning an error considered non-critical by RMP */
53 } InetFaultInjectionID;
55 DLL_EXPORT nl::FaultInjection::Manager & GetManager();
57 } // namespace FaultInjection
62 * Execute the statements included if the Inet fault is
65 * @param[in] aFaultID An Inet fault-injection id
66 * @param[in] aStatements Statements to be executed if the fault is enabled.
68 #define INET_FAULT_INJECT(aFaultID, aStatement) nlFAULT_INJECT(Inet::FaultInjection::GetManager(), aFaultID, aStatement)
70 #else // INET_CONFIG_TEST
72 #define INET_FAULT_INJECT(aFaultID, aStatement)
74 #endif // INET_CONFIG_TEST