summaryrefslogtreecommitdiff
path: root/server/IptablesBaseTest.cpp
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2016-07-09 14:24:08 +0900
committerLorenzo Colitti <lorenzo@google.com>2016-07-10 12:28:39 +0900
commit8e1cee9064af5b2e0d8095d5a6a05953616d7d4c (patch)
tree355f2e1db923d030ea86b5bbc0c555105b94ec16 /server/IptablesBaseTest.cpp
parentbbeaf9a4d272eefb11748d7d40c6bd117ab468fb (diff)
downloadnetd-8e1cee9064af5b2e0d8095d5a6a05953616d7d4c.tar.gz
Add a test for NatController.
Bug: 9580643 Change-Id: I6ac3b754ec0b720674c6221e3a776314e86fe58c
Diffstat (limited to 'server/IptablesBaseTest.cpp')
-rw-r--r--server/IptablesBaseTest.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/server/IptablesBaseTest.cpp b/server/IptablesBaseTest.cpp
index 9e75cb63..b52ff9b9 100644
--- a/server/IptablesBaseTest.cpp
+++ b/server/IptablesBaseTest.cpp
@@ -38,11 +38,14 @@ IptablesBaseTest::IptablesBaseTest() {
int IptablesBaseTest::fake_android_fork_exec(int argc, char* argv[], int *status, bool, bool) {
std::string cmd = argv[0];
for (int i = 1; i < argc; i++) {
+ if (argv[i] == NULL) break; // NatController likes to pass in invalid argc values.
cmd += " ";
cmd += argv[i];
}
sCmds.push_back(cmd);
- *status = 0;
+ if (status) {
+ *status = 0;
+ }
return 0;
}
@@ -128,6 +131,15 @@ void IptablesBaseTest::expectIptablesCommands(const ExpectedIptablesCommands& ex
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 (auto cmd : expectedCmds) {