diff options
author | Lorenzo Colitti <lorenzo@google.com> | 2017-08-10 18:50:10 +0900 |
---|---|---|
committer | Lorenzo Colitti <lorenzo@google.com> | 2017-08-19 11:15:46 +0900 |
commit | 5c68b9c1e4b7d8cf05b6ce9f6d1458ffda225eac (patch) | |
tree | b23ef57941b2c6501b8b736694fad62965bb2e79 /server/IptablesBaseTest.cpp | |
parent | eb7eb3ecea2e06e84fa9528b68d0a618b16b1ad9 (diff) | |
download | netd-5c68b9c1e4b7d8cf05b6ce9f6d1458ffda225eac.tar.gz |
Delete all remaining callers of iptables.
Also move to binder_test.cpp some string constants that are used
only there.
Bug: 28362720
Test: bullhead builds,boots
Test: netd_{unit,integration}_test pass
Change-Id: I9eee599aafa696cbf3a1f65c3814a33ed99d65fc
Diffstat (limited to 'server/IptablesBaseTest.cpp')
-rw-r--r-- | server/IptablesBaseTest.cpp | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/server/IptablesBaseTest.cpp b/server/IptablesBaseTest.cpp index 57071b06..c9bf67b2 100644 --- a/server/IptablesBaseTest.cpp +++ b/server/IptablesBaseTest.cpp @@ -61,30 +61,6 @@ int IptablesBaseTest::fake_android_fork_exec(int argc, char* argv[], int *status return ret; } -int IptablesBaseTest::fakeExecIptables(IptablesTarget target, ...) { - std::string cmd = " -w"; - va_list args; - va_start(args, target); - const char *arg; - do { - arg = va_arg(args, const char *); - if (arg != nullptr) { - cmd += " "; - cmd += arg; - } - } while (arg); - va_end(args); - - if (target == V4 || target == V4V6) { - sCmds.push_back(IPTABLES_PATH + cmd); - } - if (target == V6 || target == V4V6) { - sCmds.push_back(IP6TABLES_PATH + cmd); - } - - return 0; -} - FILE *IptablesBaseTest::fake_popen(const char * /* cmd */, const char *type) { if (sPopenContents.empty() || strcmp(type, "r") != 0) { return NULL; @@ -120,59 +96,6 @@ int IptablesBaseTest::fakeExecIptablesRestoreCommand(IptablesTarget target, return fakeExecIptablesRestoreWithOutput(target, fullCmd, output); } -int IptablesBaseTest::expectIptablesCommand(IptablesTarget target, int pos, - const std::string& cmd) { - - if ((unsigned) pos >= sCmds.size()) { - ADD_FAILURE() << "Expected too many iptables commands, want command " - << pos + 1 << "/" << sCmds.size(); - return -1; - } - - if (target == V4 || target == V4V6) { - EXPECT_EQ("/system/bin/iptables -w " + cmd, sCmds[pos++]); - } - if (target == V6 || target == V4V6) { - EXPECT_EQ("/system/bin/ip6tables -w " + cmd, sCmds[pos++]); - } - - return target == V4V6 ? 2 : 1; -} - -void IptablesBaseTest::expectIptablesCommands(const std::vector<std::string>& expectedCmds) { - ExpectedIptablesCommands expected; - for (const auto& cmd : expectedCmds) { - expected.push_back({ V4V6, cmd }); - } - expectIptablesCommands(expected); -} - -void IptablesBaseTest::expectIptablesCommands(const ExpectedIptablesCommands& expectedCmds) { - size_t pos = 0; - for (size_t i = 0; i < expectedCmds.size(); i ++) { - const auto& target = expectedCmds[i].first; - const auto& cmd = expectedCmds[i].second; - int numConsumed = expectIptablesCommand(target, pos, cmd); - if (numConsumed < 0) { - // Read past the end of the array. - break; - } - pos += numConsumed; - } - - EXPECT_EQ(pos, sCmds.size()); - sCmds.clear(); -} - -void IptablesBaseTest::expectIptablesCommands( - const std::vector<ExpectedIptablesCommands>& snippets) { - ExpectedIptablesCommands expected; - for (const auto& snippet: snippets) { - expected.insert(expected.end(), snippet.begin(), snippet.end()); - } - expectIptablesCommands(expected); -} - void IptablesBaseTest::expectIptablesRestoreCommands(const std::vector<std::string>& expectedCmds) { ExpectedIptablesCommands expected; for (const auto& cmd : expectedCmds) { |