/usr/share/pyshared/Pyro/ext/ServiceTest.py is in pyro 1:3.14-1.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | #############################################################################
#
# A test for the PyroNS_NTService program
# Author: Syver Enstad syver-en@online.no
#
# This is part of "Pyro" - Python Remote Objects
# Which is (c) Irmen de Jong - irmen@razorvine.net
#
#############################################################################
import unittest
import win32serviceutil
import win32service
import time
import Pyro.nsc
ServiceName = 'PyroNS'
class Test(unittest.TestCase):
def setUp(self):
win32serviceutil.StartService(ServiceName)
def testStartPending(self):
svcType, svcState, svcControls, err, svcErr, svcCP, svcWH = \
win32serviceutil.QueryServiceStatus(ServiceName)
assert svcState & win32service.SERVICE_START_PENDING
def testFullyStarted(self):
self._waitForStarted()
svcType, svcState, svcControls, err, svcErr, svcCP, svcWH = \
win32serviceutil.QueryServiceStatus(ServiceName)
assert svcType & win32service.SERVICE_WIN32_OWN_PROCESS
assert svcState & win32service.SERVICE_RUNNING
assert svcControls & win32service.SERVICE_ACCEPT_STOP
def testStop(self):
self._waitForStarted()
svcType, svcState, svcControls, err, svcErr, svcCP, svcWH = \
win32serviceutil.StopService(ServiceName)
assert svcState & win32service.SERVICE_STOPPED
assert svcType & win32service.SERVICE_WIN32_OWN_PROCESS
def testNameserverAvailable(self):
self._waitForStarted()
ctrl = Pyro.nsc.PyroNSControl()
ctrl.args(None)
ctrl.ping()
def testNameserverShutdownFromNsc(self):
self._waitForStarted()
ctrl = Pyro.nsc.PyroNSControl()
ctrl.args(None)
ctrl.shutdown()
for each in range(100):
svcType, svcState, svcControls, err, svcErr, svcCP, svcWH = \
win32serviceutil.QueryServiceStatus(ServiceName)
if svcState & win32service.SERVICE_STOPPED:
return
time.sleep(0.20)
self.fail()
def tearDown(self):
for each in range(1000):
svcType, svcState, svcControls, err, svcErr, svcCP, svcWH = \
win32serviceutil.QueryServiceStatus(ServiceName)
if svcState & win32service.SERVICE_RUNNING:
svcType, svcState, svcControls, err, svcErr, svcCP, svcWH = \
win32serviceutil.StopService(ServiceName)
time.sleep(0.1)
elif svcState & win32service.SERVICE_STOPPED:
time.sleep(0.10)
break
else:
time.sleep(0.10)
assert svcState & win32service.SERVICE_STOPPED
time.sleep(3)
def _waitForStarted(self):
for each in range(100):
svcType, svcState, svcControls, err, svcErr, svcCP, svcWH = \
win32serviceutil.QueryServiceStatus(ServiceName)
if svcState & win32service.SERVICE_RUNNING:
break
else:
time.sleep(0.10)
if __name__ == '__main__':
unittest.main()
|