Add a test for NatController.
Bug: 9580643
Change-Id: I6ac3b754ec0b720674c6221e3a776314e86fe58c
diff --git a/server/IptablesBaseTest.cpp b/server/IptablesBaseTest.cpp
index 9e75cb6..b52ff9b 100644
--- a/server/IptablesBaseTest.cpp
+++ b/server/IptablesBaseTest.cpp
@@ -38,11 +38,14 @@
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 @@
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) {