Home | History | Annotate | Download | only in testutils
      1 /*
      2  * Copyright 2018 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef VTS_HAL_NET_NETD_TEST_UTILS_H
     18 #define VTS_HAL_NET_NETD_TEST_UTILS_H
     19 
     20 #include <android/multinetwork.h>
     21 
     22 #define EXPECT_STATUS(expectedStatus, ret)  \
     23     do {                                    \
     24         EXPECT_TRUE((ret).isOk());          \
     25         EXPECT_EQ((expectedStatus), (ret)); \
     26     } while (0)
     27 
     28 constexpr const char* IP_PATH = "/system/bin/ip";
     29 
     30 // Checks that the given network exists.
     31 // Returns 0 if it exists or -errno if it does not.
     32 int checkNetworkExists(net_handle_t netHandle);
     33 
     34 // Checks that the given network provides reachability to the given address.
     35 // Returns 0 if it so or -errno if not.
     36 int checkReachability(net_handle_t netHandle, const char* addrStr);
     37 
     38 // Counts the number of IPv4 and IPv6 routing rules that match the given regexp string.
     39 int countMatchingIpRules(const std::string& regexString);
     40 
     41 // Counts the number of IPv4 and IPv6 routing rules that select the specified fwmark.
     42 int countRulesForFwmark(const uint32_t fwmark);
     43 
     44 #endif
     45