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 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
|
#!/usr/bin/env python
# -*- Mode: python -*-
# Copyright (C) 2001 Artifex Software Inc.
# All Rights Reserved.
#
# This software is provided AS-IS with no warranty, either express or
# implied.
#
# This software is distributed under license and may not be copied, modified
# or distributed except as expressly authorized under the terms of that
# license. Refer to licensing information at http://www.artifex.com/
# or contact Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134,
# San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information.
# $Id: testdiff,v 1.5 2004/05/02 19:23:01 ray Exp $
#
# testdiff <start date> [<end date>]
#
# this script provides the difference between two sets of regression results.
# if end date is omitted, the current date will be used.
#
# dates should be specified as YYYYMMDD
version="2.1"
import sys, os
import re
import time
import anydbm
import gsconf
def usage():
print "testdiff <old_name> [<new_name>]",version
print
print "if new_name is omitted, the current date will be used."
print
sys.exit(1)
args=sys.argv[:]
myself=os.path.basename(args.pop(0))
if len(sys.argv) == 2:
old_name = sys.argv[1]
new_name = time.strftime("%Y%m%d", time.localtime(time.time()))
elif len(sys.argv) == 3:
old_name = sys.argv[1]
new_name = sys.argv[2]
elif len(sys.argv) == 4:
old_name = sys.argv[1]
new_name = sys.argv[2]
daily_db = sys.argv[3]
else:
usage()
old_dbname = gsconf.dailydir + old_name + '.db'
new_dbname = gsconf.dailydir + new_name + '.db'
baseline_db_path = gsconf.baselinedb
print myself,gsconf.dailydir,old_name,new_name,baseline_db_path
try:
old_db = anydbm.open(old_dbname, 'r')
except:
old_db=None
print myself,"ERROR: Test results for %s %s were not found." % (old_name,old_dbname)
try:
new_db = anydbm.open(new_dbname, 'r')
except:
new_db=None
print myself,"ERROR: Test results for %s %s were not found." % (new_name,new_dbname)
try:
baseline_db = anydbm.open(baseline_db_path, 'r')
except:
baseline_db=None
print myself,"ERROR: Baseline database could not be opened %s." % (baseline_db_path)
if not old_db:
print myself,"empty checksum database",old_dbname
if not new_db:
print myself,"empty checksum database",new_dbname
if not baseline_db:
print myself,"empty checksum database",baseline_dbname
if not new_db or not old_db or not baseline_db:
sys.exit(1)
# find any checksum in new that is a new mis-match from baseline, then compare with old
normal_re = re.compile("^(.*?)\.(p[bgpk]mraw)\.(\d+)\.(\d+)$")
pdfwrite_re = re.compile("^(.*?)\.(ps|pdf)\.pdf\.(p[bgpk]mraw)\.(\d+)\.(\d+)$")
new_diffs = []
all_diffs = []
keys = new_db.keys()
for k in keys:
if k in baseline_db.keys():
if new_db[k] != baseline_db[k]:
all_diffs.append(k)
if k in old_db.keys():
if old_db[k] == baseline_db[k]:
new_diffs.append(k) # new mismatch
continue
list = []
for d in new_diffs:
type = ''
filename = ''
device = ''
dpi = 0
banded = 0
m = pdfwrite_re.search(d)
if m:
type = 'pdfwrite'
filename = m.group(1) + "." + m.group(2)
device = m.group(3)
dpi = int(m.group(4))
banded = int(m.group(5))
else:
m = normal_re.search(d)
if m:
type = 'normal '
filename = m.group(1)
device = m.group(2)
dpi = int(m.group(3))
banded = int(m.group(4))
if not type:
print myself,"WARNING: unknown device",d
continue
if banded:
bandstr = "banded"
else:
bandstr = "noband"
list.append((type, filename, device, dpi, bandstr))
length = len(list)
if length>0:
print
print myself,new_name,"new differences from",old_name,"(",str(length)," differences)"
list.sort()
for l in list:
print "%s %s (%s/%d/%s)" % (l[0], l[1], l[2], l[3], l[4])
else:
print myself,new_name,"0 differences from",old_name
list = []
for d in all_diffs:
type = ''
filename = ''
device = ''
dpi = 0
banded = 0
m = pdfwrite_re.search(d)
if m:
type = 'pdfwrite'
filename = m.group(1) + "." + m.group(2)
device = m.group(3)
dpi = int(m.group(4))
banded = int(m.group(5))
else:
m = normal_re.search(d)
if m:
type = 'normal '
filename = m.group(1)
device = m.group(2)
dpi = int(m.group(3))
banded = int(m.group(4))
if not type:
print myself,"WARNING: unknown device",d
continue
if banded:
bandstr = "banded"
else:
bandstr = "noband"
list.append((type, filename, device, dpi, bandstr))
length = len(list)
if length > 0:
print
print myself,new_name,"differences from baseline""(",str(length)," differences)"
list.sort()
for l in list:
print "%s %s (%s/%d/%s)" % (l[0], l[1], l[2], l[3], l[4])
else:
print myself,new_name,"0 differences from baseline",baseline_db_path
|