mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-23 23:02:25 +00:00
mac: improve shutdown and clean-up after the test of the macintosh packaging
This commit is contained in:
parent
4a4a47a66d
commit
d2132213e3
@ -15,7 +15,7 @@
|
||||
|
||||
# allmydata-tahoe: 1.4.1-r3916 (/home/zooko/playground/allmydata/tahoe/trunk/trunk/src), foolscap: 0.4.1 (/usr/local/lib/python2.6/dist-packages/foolscap-0.4.1-py2.6.egg), pycryptopp: 0.5.10 (/home/zooko/playground/allmydata/tahoe/trunk/trunk/support/lib/python2.6/site-packages/pycryptopp-0.5.10-py2.6-linux-x86_64.egg), zfec: 1.4.2 (/usr/local/lib/python2.6/dist-packages/zfec-1.4.2-py2.6-linux-x86_64.egg), Twisted: 8.2.0-r26987 (/usr/local/lib/python2.6/dist-packages/Twisted-8.2.0_r26987-py2.6-linux-x86_64.egg), Nevow: 0.9.32 (/home/zooko/playground/allmydata/tahoe/trunk/trunk/support/lib/python2.6/site-packages/Nevow-0.9.32-py2.6.egg), zope.interface: 3.4.0 (/usr/lib/python2.6/dist-packages), python: 2.6.2 (/usr/bin/python), platform: Linux-Ubuntu_9.04-x86_64-64bit_ELF (None), sqlite: 3.6.10 (unknown), simplejson: 2.0.1 (/usr/local/lib/python2.6/dist-packages/simplejson-2.0.1-py2.6-linux-x86_64.egg), argparse: 0.8.0 (/usr/local/lib/python2.6/dist-packages/argparse-0.8.0-py2.6.egg), pyOpenSSL: 0.7 (/home/zooko/playground/allmydata/tahoe/trunk/trunk/support/lib/python2.6/site-packages/pyOpenSSL-0.7-py2.6-linux-x86_64.egg), pyutil: 1.3.30 (/usr/local/lib/python2.6/dist-packages/pyutil-1.3.30-py2.6.egg), zbase32: 1.1.1 (/usr/local/lib/python2.6/dist-packages/zbase32-1.1.1-py2.6.egg), setuptools: 0.6c12dev (/home/zooko/playground/allmydata/tahoe/trunk/trunk/support/lib/python2.6/site-packages/setuptools-0.6c12dev.egg), pysqlite: 2.4.1 (/usr/lib/python2.6/sqlite3)
|
||||
|
||||
import os, re, subprocess, time
|
||||
import fcntl, os, re, subprocess, time
|
||||
|
||||
def test_mac_diskimage(appname, version):
|
||||
""" Return True on success, raise exception on failure. """
|
||||
@ -39,20 +39,27 @@ def test_mac_diskimage(appname, version):
|
||||
DEV=mo.group(1)
|
||||
MOUNTPOINT=mo.group(2)
|
||||
|
||||
callitpid = None
|
||||
try:
|
||||
basedir = MOUNTPOINT + '/' + appname + '.app/Contents/Resources'
|
||||
|
||||
os.chdir(basedir)
|
||||
|
||||
callit = subprocess.Popen(['../MacOS/' + appname, '--version-and-path'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
cmd = ['../MacOS/' + appname, '--version-and-path']
|
||||
callit = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
callitpid = callit.pid
|
||||
assert callitpid
|
||||
deadline = time.time() + 2 # If it takes longer than 2 seconds to do this then it fails.
|
||||
while True:
|
||||
rc = callit.poll()
|
||||
if rc is not None:
|
||||
break
|
||||
if time.time() > deadline:
|
||||
os.kill(callit.pid, 9)
|
||||
raise Exception("FAIL: it took longer than 2 seconds to invoke $appname --version-and-path.")
|
||||
flags = fcntl.fcntl(callit.stdout.fileno(), fcntl.F_GETFL)
|
||||
fcntl.fcntl(callit.stdout.fileno(), fcntl.F_SETFL, flags | os.O_NONBLOCK)
|
||||
flags = fcntl.fcntl(callit.stderr.fileno(), fcntl.F_GETFL)
|
||||
fcntl.fcntl(callit.stderr.fileno(), fcntl.F_SETFL, flags | os.O_NONBLOCK)
|
||||
raise Exception("FAIL: it took longer than 2 seconds to invoke $appname --version-and-path. stdout: %r, stderr: %r" % (callit.stdout.read(), callit.stderr.read()))
|
||||
time.sleep(0.05)
|
||||
|
||||
if rc != 0:
|
||||
@ -68,5 +75,7 @@ def test_mac_diskimage(appname, version):
|
||||
|
||||
return True # success!
|
||||
finally:
|
||||
subprocess.call(['hdiutil', 'detach', DEV])
|
||||
|
||||
if callitpid:
|
||||
os.kill(callitpid, 9)
|
||||
os.waitpid(callitpid, 0)
|
||||
subprocess.call(['hdiutil', 'detach', '-Force', DEV])
|
||||
|
Loading…
Reference in New Issue
Block a user