diff options
| author | Lorenzo Colitti <lorenzo@google.com> | 2017-04-28 11:09:07 +0900 |
|---|---|---|
| committer | Lorenzo Colitti <lorenzo@google.com> | 2017-04-28 17:09:16 +0900 |
| commit | f4dfa682f436398d74e8b55d610b8cca53877246 (patch) | |
| tree | dca6b65bb305557958b361c5ff6f625f24851ccb /server/BandwidthControllerTest.cpp | |
| parent | 680ff87319d206a70efc162eb3c95ad0c429c44d (diff) | |
Add test coverage for BandwidthController app commands.
Bug: 32073253
Test: netd_{unit,integration}_test pass
Change-Id: I55c6ffd39383f9bb974fa40985d9f03fddfafd7d
Diffstat (limited to 'server/BandwidthControllerTest.cpp')
| -rw-r--r-- | server/BandwidthControllerTest.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/server/BandwidthControllerTest.cpp b/server/BandwidthControllerTest.cpp index 487b7d8b..ad4745cc 100644 --- a/server/BandwidthControllerTest.cpp +++ b/server/BandwidthControllerTest.cpp @@ -436,3 +436,23 @@ TEST_F(BandwidthControllerTest, IptablesAlertFwdCmd) { EXPECT_EQ(0, runIptablesAlertFwdCmd(IptOp::IptOpDelete, "MyWonderfulAlert", 123456)); expectIptablesRestoreCommands(expected); } + +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", + }; + EXPECT_EQ(0, mBw.addNiceApps(appUids.size(), const_cast<char**>(&appUids[0]))); + expectIptablesCommands(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", + }; + EXPECT_EQ(0, mBw.removeNaughtyApps(appUids.size(), const_cast<char**>(&appUids[0]))); + expectIptablesCommands(expected); +} |
