def testProcessId(self):
        """Test the ProcessId function.
        """

        handle = os.spawnv(os.P_NOWAIT, self.bin,
                           [self.bin, "-c", '"import time; time.sleep(3)"'])
        pid = toolhelp32.GetProcessId(handle)
        self.failUnless(pid)

        self.failUnlessRaises(pywintypes.error, toolhelp32.GetProcessId, 0)
    def testFindModules(self):
        """Test the FindModules function.

        XXX understand why this fails.
        """

        handle = os.spawnv(os.P_NOWAIT, self.bin,
                           [self.bin, "-c", '"import time; time.sleep(3)"'])
        pid = toolhelp32.GetProcessId(handle)

        modules = [info.szModule for info in toolhelp32.FindModules(pid)]

        self.failUnless("msvcrt.dll" in modules)

        # XXX this is valid only for Python 2.4?
        if 1:
            self.failUnless("MSVCR71.dll" in modules)
Пример #3
0
    def testKillILL(self):
        """Test of a forced shutdown od a Twisted process.
        """

        handle = os.spawnv(os.P_NOWAIT, self.bin, 
                           [self.bin, "twisted_process.py"])

        time.sleep(1)  # XXX give time to reactor to start
        pid = toolhelp32.GetProcessId(handle)
        kill32.kill(pid, signal.SIGILL)

        os.waitpid(handle, os.P_WAIT)
        lines = file(".out").readlines()

        self.failIf("shutdown\n" in lines)
        self.failIf("timeout\n" in lines)
        
        os.remove(".out")
Пример #4
0
    def testKillTERMPython(self):
        """Test of a clean shutdown of a Python process.
        """

        handle = os.spawnv(os.P_NOWAIT, self.bin,
                           [self.bin, "python_process.py"])

        time.sleep(1) # XXX give time to process to start
        pid = toolhelp32.GetProcessId(handle)
        kill32.kill(pid, signal.SIGTERM)

        os.waitpid(handle, os.P_WAIT)
        lines = file(".out").readlines()

        self.failUnless("signal handler\n" in lines)
        self.failUnless("atexit\n" in lines)

        os.remove(".out")