diff options
author | perkj@webrtc.org <perkj@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d> | 2014-05-13 08:15:48 +0000 |
---|---|---|
committer | perkj@webrtc.org <perkj@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d> | 2014-05-13 08:15:48 +0000 |
commit | 50daa5310285079d9e5155b2bc0c95210756e593 (patch) | |
tree | 324e54bd35c21091206bd854803a7b711723c6d7 /base/linuxfdwalk_unittest.cc | |
parent | c9ccea39fb320a846deef9ac31a66a50197a554b (diff) | |
download | webrtc-50daa5310285079d9e5155b2bc0c95210756e593.tar.gz |
Revert 6107 "Adds a modified copy of talk/base to webrtc/base. I..."
This breaks Chromium FYI builds and prevent roll of webrtc/libjingle to Chrome.
http://chromegw.corp.google.com/i/chromium.webrtc.fyi/builders/Win%20Builder/builds/457
> Adds a modified copy of talk/base to webrtc/base. It is the first step in migrating talk/base to webrtc/base.
>
> BUG=N/A
> R=andrew@webrtc.org, wu@webrtc.org
>
> Review URL: https://webrtc-codereview.appspot.com/12199004
TBR=henrike@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/14479004
git-svn-id: http://webrtc.googlecode.com/svn/trunk/webrtc@6116 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'base/linuxfdwalk_unittest.cc')
-rw-r--r-- | base/linuxfdwalk_unittest.cc | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/base/linuxfdwalk_unittest.cc b/base/linuxfdwalk_unittest.cc deleted file mode 100644 index bba48e88..00000000 --- a/base/linuxfdwalk_unittest.cc +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2009 The WebRTC Project Authors. All rights reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include <set> -#include <sstream> - -#include "webrtc/base/gunit.h" -#include "webrtc/base/linuxfdwalk.h" - -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <unistd.h> - -static const int kArbitraryLargeFdNumber = 424; - -static void FdCheckVisitor(void *data, int fd) { - std::set<int> *fds = static_cast<std::set<int> *>(data); - EXPECT_EQ(1U, fds->erase(fd)); -} - -static void FdEnumVisitor(void *data, int fd) { - std::set<int> *fds = static_cast<std::set<int> *>(data); - EXPECT_TRUE(fds->insert(fd).second); -} - -// Checks that the set of open fds is exactly the given list. -static void CheckOpenFdList(std::set<int> fds) { - EXPECT_EQ(0, fdwalk(&FdCheckVisitor, &fds)); - EXPECT_EQ(0U, fds.size()); -} - -static void GetOpenFdList(std::set<int> *fds) { - fds->clear(); - EXPECT_EQ(0, fdwalk(&FdEnumVisitor, fds)); -} - -TEST(LinuxFdWalk, TestFdWalk) { - std::set<int> fds; - GetOpenFdList(&fds); - std::ostringstream str; - // I have observed that the open set when starting a test is [0, 6]. Leaked - // fds would change that, but so can (e.g.) running under a debugger, so we - // can't really do an EXPECT. :( - str << "File descriptors open in test executable:"; - for (std::set<int>::const_iterator i = fds.begin(); i != fds.end(); ++i) { - str << " " << *i; - } - LOG(LS_INFO) << str.str(); - // Open some files. - int fd1 = open("/dev/null", O_RDONLY); - EXPECT_LE(0, fd1); - int fd2 = open("/dev/null", O_WRONLY); - EXPECT_LE(0, fd2); - int fd3 = open("/dev/null", O_RDWR); - EXPECT_LE(0, fd3); - int fd4 = dup2(fd3, kArbitraryLargeFdNumber); - EXPECT_LE(0, fd4); - EXPECT_TRUE(fds.insert(fd1).second); - EXPECT_TRUE(fds.insert(fd2).second); - EXPECT_TRUE(fds.insert(fd3).second); - EXPECT_TRUE(fds.insert(fd4).second); - CheckOpenFdList(fds); - EXPECT_EQ(0, close(fd1)); - EXPECT_EQ(0, close(fd2)); - EXPECT_EQ(0, close(fd3)); - EXPECT_EQ(0, close(fd4)); -} |