|
|
@ -15,9 +15,10 @@ |
|
|
|
import json, platform, os, shutil, sys, subprocess, tempfile, threading |
|
|
|
import json, platform, os, shutil, sys, subprocess, tempfile, threading |
|
|
|
import time, urllib, urllib2, hashlib, re, base64, uuid, socket, errno |
|
|
|
import time, urllib, urllib2, hashlib, re, base64, uuid, socket, errno |
|
|
|
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer |
|
|
|
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer |
|
|
|
import SocketServer |
|
|
|
from SocketServer import ThreadingMixIn |
|
|
|
from optparse import OptionParser |
|
|
|
from optparse import OptionParser |
|
|
|
from urlparse import urlparse, parse_qs |
|
|
|
from urlparse import urlparse, parse_qs |
|
|
|
|
|
|
|
from threading import Lock |
|
|
|
|
|
|
|
|
|
|
|
USAGE_EXAMPLE = "%prog" |
|
|
|
USAGE_EXAMPLE = "%prog" |
|
|
|
|
|
|
|
|
|
|
@ -35,6 +36,8 @@ BROWSER_TIMEOUT = 60 |
|
|
|
|
|
|
|
|
|
|
|
SERVER_HOST = "localhost" |
|
|
|
SERVER_HOST = "localhost" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lock = Lock() |
|
|
|
|
|
|
|
|
|
|
|
class TestOptions(OptionParser): |
|
|
|
class TestOptions(OptionParser): |
|
|
|
def __init__(self, **kwargs): |
|
|
|
def __init__(self, **kwargs): |
|
|
|
OptionParser.__init__(self, **kwargs) |
|
|
|
OptionParser.__init__(self, **kwargs) |
|
|
@ -134,8 +137,8 @@ class Result: |
|
|
|
self.failure = failure |
|
|
|
self.failure = failure |
|
|
|
self.page = page |
|
|
|
self.page = page |
|
|
|
|
|
|
|
|
|
|
|
class TestServer(SocketServer.TCPServer): |
|
|
|
class TestServer(ThreadingMixIn, HTTPServer): |
|
|
|
allow_reuse_address = True |
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
class TestHandlerBase(BaseHTTPRequestHandler): |
|
|
|
class TestHandlerBase(BaseHTTPRequestHandler): |
|
|
|
# Disable annoying noise by default |
|
|
|
# Disable annoying noise by default |
|
|
@ -243,40 +246,41 @@ class UnitTestHandler(TestHandlerBase): |
|
|
|
return |
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
def do_POST(self): |
|
|
|
def do_POST(self): |
|
|
|
url = urlparse(self.path) |
|
|
|
with lock: |
|
|
|
numBytes = int(self.headers['Content-Length']) |
|
|
|
url = urlparse(self.path) |
|
|
|
content = self.rfile.read(numBytes) |
|
|
|
numBytes = int(self.headers['Content-Length']) |
|
|
|
|
|
|
|
content = self.rfile.read(numBytes) |
|
|
|
# Process special utility requests |
|
|
|
|
|
|
|
if url.path == '/ttx': |
|
|
|
# Process special utility requests |
|
|
|
self.translateFont(content) |
|
|
|
if url.path == '/ttx': |
|
|
|
return |
|
|
|
self.translateFont(content) |
|
|
|
|
|
|
|
return |
|
|
|
self.send_response(200) |
|
|
|
|
|
|
|
self.send_header('Content-Type', 'text/plain') |
|
|
|
self.send_response(200) |
|
|
|
self.end_headers() |
|
|
|
self.send_header('Content-Type', 'text/plain') |
|
|
|
|
|
|
|
self.end_headers() |
|
|
|
result = json.loads(content) |
|
|
|
|
|
|
|
browser = result['browser'] |
|
|
|
result = json.loads(content) |
|
|
|
UnitTestState.lastPost[browser] = int(time.time()) |
|
|
|
browser = result['browser'] |
|
|
|
if url.path == "/tellMeToQuit": |
|
|
|
UnitTestState.lastPost[browser] = int(time.time()) |
|
|
|
tellAppToQuit(url.path, url.query) |
|
|
|
if url.path == "/tellMeToQuit": |
|
|
|
UnitTestState.browsersRunning -= 1 |
|
|
|
tellAppToQuit(url.path, url.query) |
|
|
|
UnitTestState.lastPost[browser] = None |
|
|
|
UnitTestState.browsersRunning -= 1 |
|
|
|
return |
|
|
|
UnitTestState.lastPost[browser] = None |
|
|
|
elif url.path == '/info': |
|
|
|
return |
|
|
|
print result['message'] |
|
|
|
elif url.path == '/info': |
|
|
|
elif url.path == '/submit_task_results': |
|
|
|
print result['message'] |
|
|
|
status, description = result['status'], result['description'] |
|
|
|
elif url.path == '/submit_task_results': |
|
|
|
UnitTestState.numRun += 1 |
|
|
|
status, description = result['status'], result['description'] |
|
|
|
if status == 'TEST-UNEXPECTED-FAIL': |
|
|
|
UnitTestState.numRun += 1 |
|
|
|
UnitTestState.numErrors += 1 |
|
|
|
if status == 'TEST-UNEXPECTED-FAIL': |
|
|
|
message = status + ' | ' + description + ' | in ' + browser |
|
|
|
UnitTestState.numErrors += 1 |
|
|
|
if 'error' in result: |
|
|
|
message = status + ' | ' + description + ' | in ' + browser |
|
|
|
message += ' | ' + result['error'] |
|
|
|
if 'error' in result: |
|
|
|
print message |
|
|
|
message += ' | ' + result['error'] |
|
|
|
else: |
|
|
|
print message |
|
|
|
print 'Error: uknown action' + url.path |
|
|
|
else: |
|
|
|
|
|
|
|
print 'Error: uknown action' + url.path |
|
|
|
|
|
|
|
|
|
|
|
class PDFTestHandler(TestHandlerBase): |
|
|
|
class PDFTestHandler(TestHandlerBase): |
|
|
|
|
|
|
|
|
|
|
@ -310,36 +314,37 @@ class PDFTestHandler(TestHandlerBase): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def do_POST(self): |
|
|
|
def do_POST(self): |
|
|
|
numBytes = int(self.headers['Content-Length']) |
|
|
|
with lock: |
|
|
|
|
|
|
|
numBytes = int(self.headers['Content-Length']) |
|
|
|
self.send_response(200) |
|
|
|
|
|
|
|
self.send_header('Content-Type', 'text/plain') |
|
|
|
self.send_response(200) |
|
|
|
self.end_headers() |
|
|
|
self.send_header('Content-Type', 'text/plain') |
|
|
|
|
|
|
|
self.end_headers() |
|
|
|
url = urlparse(self.path) |
|
|
|
|
|
|
|
if url.path == "/tellMeToQuit": |
|
|
|
url = urlparse(self.path) |
|
|
|
tellAppToQuit(url.path, url.query) |
|
|
|
if url.path == "/tellMeToQuit": |
|
|
|
return |
|
|
|
tellAppToQuit(url.path, url.query) |
|
|
|
|
|
|
|
return |
|
|
|
result = json.loads(self.rfile.read(numBytes)) |
|
|
|
|
|
|
|
browser = result['browser'] |
|
|
|
result = json.loads(self.rfile.read(numBytes)) |
|
|
|
State.lastPost[browser] = int(time.time()) |
|
|
|
browser = result['browser'] |
|
|
|
if url.path == "/info": |
|
|
|
State.lastPost[browser] = int(time.time()) |
|
|
|
print result['message'] |
|
|
|
if url.path == "/info": |
|
|
|
return |
|
|
|
print result['message'] |
|
|
|
|
|
|
|
return |
|
|
|
id, failure, round, page, snapshot = result['id'], result['failure'], result['round'], result['page'], result['snapshot'] |
|
|
|
|
|
|
|
taskResults = State.taskResults[browser][id] |
|
|
|
id, failure, round, page, snapshot = result['id'], result['failure'], result['round'], result['page'], result['snapshot'] |
|
|
|
taskResults[round].append(Result(snapshot, failure, page)) |
|
|
|
taskResults = State.taskResults[browser][id] |
|
|
|
if State.saveStats: |
|
|
|
taskResults[round].append(Result(snapshot, failure, page)) |
|
|
|
stat = { |
|
|
|
if State.saveStats: |
|
|
|
'browser': browser, |
|
|
|
stat = { |
|
|
|
'pdf': id, |
|
|
|
'browser': browser, |
|
|
|
'page': page, |
|
|
|
'pdf': id, |
|
|
|
'round': round, |
|
|
|
'page': page, |
|
|
|
'stats': result['stats'] |
|
|
|
'round': round, |
|
|
|
} |
|
|
|
'stats': result['stats'] |
|
|
|
State.stats.append(stat) |
|
|
|
} |
|
|
|
|
|
|
|
State.stats.append(stat) |
|
|
|
|
|
|
|
|
|
|
|
def isTaskDone(): |
|
|
|
def isTaskDone(): |
|
|
|
numPages = result["numPages"] |
|
|
|
numPages = result["numPages"] |
|
|
|