2 * Copyright 2016 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 * IptablesBaseTest.h - utility class for tests that use iptables
19 #include "NetdConstants.h"
21 class IptablesBaseTest : public ::testing::Test {
25 typedef std::vector<std::pair<IptablesTarget, std::string>> ExpectedIptablesCommands;
27 static int fake_android_fork_exec(int argc, char* argv[], int *status, bool, bool);
28 static int fakeExecIptables(IptablesTarget target, ...);
29 static int fakeExecIptablesRestore(IptablesTarget target, const std::string& commands);
30 void expectIptablesCommands(const std::vector<std::string>& expectedCmds);
31 void expectIptablesCommands(const ExpectedIptablesCommands& expectedCmds);
32 void expectIptablesRestoreCommands(const std::vector<std::string>& expectedCmds);
33 void expectIptablesRestoreCommands(const ExpectedIptablesCommands& expectedCmds);
36 static std::vector<std::string> sCmds;
37 static ExpectedIptablesCommands sRestoreCmds;
38 int expectIptablesCommand(IptablesTarget target, int pos, const std::string& cmd);