Commit 2978105f authored by Ivan Tyagov's avatar Ivan Tyagov

Unhard coded XvFb display ID.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@31741 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ca8e2cf1
...@@ -51,6 +51,7 @@ smtp_host = '' ...@@ -51,6 +51,7 @@ smtp_host = ''
email_subject = 'ERP5' email_subject = 'ERP5'
run_only='' run_only=''
portal_url = '' portal_url = ''
xvfb_display = '123'
tests_framework_home = os.path.dirname(os.path.abspath(__file__)) tests_framework_home = os.path.dirname(os.path.abspath(__file__))
# handle 'system global' instance # handle 'system global' instance
...@@ -87,12 +88,13 @@ def parseArgs(): ...@@ -87,12 +88,13 @@ def parseArgs():
global portal_url global portal_url
global run_only global run_only
global email_subject global email_subject
global xvfb_display
try: try:
opts, args = getopt.getopt(sys.argv[1:], opts, args = getopt.getopt(sys.argv[1:],
"hsd", ["help", "stdout", "debug", "hsd", ["help", "stdout", "debug",
"email_to_address=", "host=", "port=", "email_to_address=", "host=", "port=",
"portal_name=", "run_only=", "portal_name=", "run_only=",
"email_subject=", "smtp_host="] ) "email_subject=", "smtp_host=", "xvfb_display="] )
except getopt.GetoptError, msg: except getopt.GetoptError, msg:
usage(sys.stderr, msg) usage(sys.stderr, msg)
sys.exit(2) sys.exit(2)
...@@ -120,6 +122,8 @@ def parseArgs(): ...@@ -120,6 +122,8 @@ def parseArgs():
run_only = arg run_only = arg
elif opt == "--email_subject": elif opt == "--email_subject":
email_subject = arg email_subject = arg
elif opt == "--xvfb_display":
xvfb_display = arg
if not stdout: if not stdout:
send_mail = 1 send_mail = 1
...@@ -144,8 +148,8 @@ def launchFuntionalTest(): ...@@ -144,8 +148,8 @@ def launchFuntionalTest():
firefox_pid = None firefox_pid = None
try: try:
if not debug: if not debug:
xvfb_pid = runXvfb() xvfb_pid = runXvfb(xvfb_display)
firefox_pid = runFirefox() firefox_pid = runFirefox(xvfb_display)
while True: while True:
sleep(10) sleep(10)
cur_status = getStatus() cur_status = getStatus()
...@@ -165,14 +169,14 @@ def startZope(): ...@@ -165,14 +169,14 @@ def startZope():
def stopZope(): def stopZope():
os.system('%s/bin/zopectl stop' % instance_home) os.system('%s/bin/zopectl stop' % instance_home)
def runXvfb(): def runXvfb(xvfb_display):
pid = os.spawnlp(os.P_NOWAIT, 'Xvfb', 'Xvfb', ':123') pid = os.spawnlp(os.P_NOWAIT, 'Xvfb', 'Xvfb', ':%s' %xvfb_display)
display = os.environ.get('DISPLAY') display = os.environ.get('DISPLAY')
if display: if display:
auth = Popen(['xauth', 'list', display], stdout=PIPE).communicate()[0] auth = Popen(['xauth', 'list', display], stdout=PIPE).communicate()[0]
if auth: if auth:
(displayname, protocolname, hexkey) = auth.split() (displayname, protocolname, hexkey) = auth.split()
Popen(['xauth', 'add', 'localhost/unix:123', protocolname, hexkey]) Popen(['xauth', 'add', 'localhost/unix:%s' %xvfb_display, protocolname, hexkey])
print 'Xvfb : %d' % pid print 'Xvfb : %d' % pid
return pid return pid
...@@ -215,7 +219,7 @@ user_pref("capability.principal.codebase.p1.subjectName", "");""" % \ ...@@ -215,7 +219,7 @@ user_pref("capability.principal.codebase.p1.subjectName", "");""" % \
pref_file.write(prefs_js) pref_file.write(prefs_js)
pref_file.close() pref_file.close()
def runFirefox(): def runFirefox(xvfb_display):
prepareFirefox() prepareFirefox()
if debug: if debug:
try: try:
...@@ -223,7 +227,7 @@ def runFirefox(): ...@@ -223,7 +227,7 @@ def runFirefox():
except IOError: except IOError:
pass pass
else: else:
os.environ['DISPLAY'] = ':123' os.environ['DISPLAY'] = ':%s' %xvfb_display
os.environ['MOZ_NO_REMOTE'] = '1' os.environ['MOZ_NO_REMOTE'] = '1'
os.environ['HOME'] = profile_dir os.environ['HOME'] = profile_dir
# check if old zelenium or new zelenium # check if old zelenium or new zelenium
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment