예제 #1
0
파일: utiltest.py 프로젝트: pombr/conary
    def testCountOpenFileDescriptors(self):
        # CNY-2536
        startCount = util.countOpenFileDescriptors()
        fdarr = [ open('/dev/null') for x in range(200) ]
        endCount = util.countOpenFileDescriptors()
        self.assertEqual(startCount + len(fdarr), endCount)

        fdarr = None
        endCount = util.countOpenFileDescriptors()
        self.assertEqual(startCount, endCount)
예제 #2
0
파일: utiltest.py 프로젝트: sweptr/conary
    def testCountOpenFileDescriptors(self):
        # CNY-2536
        startCount = util.countOpenFileDescriptors()
        fdarr = [ open('/dev/null') for x in range(200) ]
        endCount = util.countOpenFileDescriptors()
        self.assertEqual(startCount + len(fdarr), endCount)

        fdarr = None
        endCount = util.countOpenFileDescriptors()
        self.assertEqual(startCount, endCount)
예제 #3
0
    def run(self, *args, **kw):
        from conary.lib import util
        fdCount = util.countOpenFileDescriptors()
        if fdCount != len(self.openFds):
            self.openFds = self._openFdSet()

        prePid = os.getpid()

        try:
            unittest.TestCase.run(self, *args, **kw)
        finally:
            # Make sure some test didn't accidentally fork the
            # testsuite.
            postPid = os.getpid()
            if prePid != postPid:
                sys.stderr.write("\n*** CHILD RE-ENTERED TESTSUITE ***\n")
                sys.stderr.write("A forked process was allowed to return to "
                    "the testsuite handler, probably due\nto an exception. "
                    "Find it and kill it!\n")
                sys.stderr.write("PID was: %d  now: %d\n" % (prePid, postPid))
                os._exit(2)

            self.unmock()
            mock.unmockAll()

            # ask gc to run to see if we can avoid "leaked -1 file descriptors"
            gc.collect()
            fdCount = util.countOpenFileDescriptors()
            if False and fdCount != len(self.openFds):
                try:
                    methodName = self.__testMethodName
                except AttributeError:
                    methodName = self._testMethodName
                sys.stderr.write("\nTest %s.%s leaked %s file descriptors\n"
                    % (self.__module__, methodName,
                        fdCount - len(self.openFds)))
                newOpenFds = self._openFdSet()
                for (fd, contents) in newOpenFds - self.openFds:
                    if contents and ((fd, contents) not in self.openFds):
                        print '%s: %s' % (fd, contents)
                self.openFds = newOpenFds
예제 #4
0
 def testExtractRpmPayloadFdLeak(self):
     fdCount0 = util.countOpenFileDescriptors()
     self.testExtractRpmPayload()
     fdCount1 = util.countOpenFileDescriptors()
     self.assertEqual(fdCount1 - fdCount0, 0)
예제 #5
0
 def testExtractRpmPayloadFdLeak(self):
     fdCount0 = util.countOpenFileDescriptors()
     self.testExtractRpmPayload()
     fdCount1 = util.countOpenFileDescriptors()
     self.assertEqual(fdCount1 - fdCount0, 0)