diff options
| author | Lorenzo Colitti <lorenzo@google.com> | 2017-04-28 14:34:01 +0900 |
|---|---|---|
| committer | Lorenzo Colitti <lorenzo@google.com> | 2017-04-28 23:38:27 +0900 |
| commit | 911bc4ccc96a323a8029adce3edba3aa6a030f45 (patch) | |
| tree | 0147784eba8bfc29764632ddca2d3e24bedbf36a /server/BandwidthControllerTest.cpp | |
| parent | d9db08c4a12d6a2953b597d39bb3ac37c43d3658 (diff) | |
Switch BandwidthController per-UID commands to iptables-restore
Bug: 32073253
Test: bullhead builds and boots
Test: netd_{unit,integration}_test pass
Test: Turning datasaver on/off changes rules as expected
Test: Modifying datasaver whitelist changes rules as expected when datasaver is on
Test: Adding and removing cell data limits changes rules as expected
Test: No IptablesRestoreController methods in normal usage
Change-Id: I83723db6a539b641308ef0f74ac30b4db304295c
Diffstat (limited to 'server/BandwidthControllerTest.cpp')
| -rw-r--r-- | server/BandwidthControllerTest.cpp | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/server/BandwidthControllerTest.cpp b/server/BandwidthControllerTest.cpp index ad4745cc..954db575 100644 --- a/server/BandwidthControllerTest.cpp +++ b/server/BandwidthControllerTest.cpp @@ -190,15 +190,19 @@ TEST_F(BandwidthControllerTest, TestDisableBandwidthControl) { TEST_F(BandwidthControllerTest, TestEnableDataSaver) { mBw.enableDataSaver(true); std::vector<std::string> expected = { - "-R bw_data_saver 1 --jump REJECT", + "*filter\n" + "-R bw_data_saver 1 --jump REJECT\n" + "COMMIT\n" }; - expectIptablesCommands(expected); + expectIptablesRestoreCommands(expected); mBw.enableDataSaver(false); expected = { - "-R bw_data_saver 1 --jump RETURN", + "*filter\n" + "-R bw_data_saver 1 --jump RETURN\n" + "COMMIT\n" }; - expectIptablesCommands(expected); + expectIptablesRestoreCommands(expected); } std::string kIPv4TetherCounters = android::base::Join(std::vector<std::string> { @@ -441,18 +445,22 @@ TEST_F(BandwidthControllerTest, ManipulateSpecialApps) { std::vector<const char *> appUids = { "1000", "1001", "10012" }; std::vector<std::string> expected = { - "-I bw_happy_box -m owner --uid-owner 1000 --jump RETURN", - "-I bw_happy_box -m owner --uid-owner 1001 --jump RETURN", - "-I bw_happy_box -m owner --uid-owner 10012 --jump RETURN", + "*filter\n" + "-I bw_happy_box -m owner --uid-owner 1000 --jump RETURN\n" + "-I bw_happy_box -m owner --uid-owner 1001 --jump RETURN\n" + "-I bw_happy_box -m owner --uid-owner 10012 --jump RETURN\n" + "COMMIT\n" }; EXPECT_EQ(0, mBw.addNiceApps(appUids.size(), const_cast<char**>(&appUids[0]))); - expectIptablesCommands(expected); + expectIptablesRestoreCommands(expected); expected = { - "-D bw_penalty_box -m owner --uid-owner 1000 --jump REJECT", - "-D bw_penalty_box -m owner --uid-owner 1001 --jump REJECT", - "-D bw_penalty_box -m owner --uid-owner 10012 --jump REJECT", + "*filter\n" + "-D bw_penalty_box -m owner --uid-owner 1000 --jump REJECT\n" + "-D bw_penalty_box -m owner --uid-owner 1001 --jump REJECT\n" + "-D bw_penalty_box -m owner --uid-owner 10012 --jump REJECT\n" + "COMMIT\n" }; EXPECT_EQ(0, mBw.removeNaughtyApps(appUids.size(), const_cast<char**>(&appUids[0]))); - expectIptablesCommands(expected); + expectIptablesRestoreCommands(expected); } |
