summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorMithun Iyer <iyerm@google.com>2021-01-07 15:06:18 -0800
committergVisor bot <gvisor-bot@google.com>2021-01-07 15:08:27 -0800
commit04b37c822022c27cb144e4af5ef21043a74127f3 (patch)
treec8188fd0887115b7acce7e1e47742a5b30ae0dfb /test
parentb1de1da318631c6d29f6c04dea370f712078f443 (diff)
Fix tuntap_test to cleanup after CreateInterfaceNoCap
PiperOrigin-RevId: 350646249
Diffstat (limited to 'test')
-rw-r--r--test/syscalls/linux/tuntap.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/test/syscalls/linux/tuntap.cc b/test/syscalls/linux/tuntap.cc
index 5ac337d1a..538652183 100644
--- a/test/syscalls/linux/tuntap.cc
+++ b/test/syscalls/linux/tuntap.cc
@@ -162,12 +162,19 @@ TEST(TuntapStaticTest, NetTunExists) {
class TuntapTest : public ::testing::Test {
protected:
+ void SetUp() override {
+ have_net_admin_cap_ =
+ ASSERT_NO_ERRNO_AND_VALUE(HaveCapability(CAP_NET_ADMIN));
+ }
+
void TearDown() override {
- if (ASSERT_NO_ERRNO_AND_VALUE(HaveCapability(CAP_NET_ADMIN))) {
+ if (have_net_admin_cap_) {
// Bring back capability if we had dropped it in test case.
ASSERT_NO_ERRNO(SetCapability(CAP_NET_ADMIN, true));
}
}
+
+ bool have_net_admin_cap_;
};
TEST_F(TuntapTest, CreateInterfaceNoCap) {