[gs-cvs] rev 7854 - in trunk/gs/toolbin: . search tests

thomasd at ghostscript.com thomasd at ghostscript.com
Mon Apr 16 07:45:44 PDT 2007


Author: thomasd
Date: 2007-04-16 07:45:42 -0700 (Mon, 16 Apr 2007)
New Revision: 7854

Added:
   trunk/gs/toolbin/python/
   trunk/gs/toolbin/search/
   trunk/gs/toolbin/search/README
   trunk/gs/toolbin/testfiles/
   trunk/gs/toolbin/tests/build_revision.py
   trunk/gs/toolbin/tests/collate.py
   trunk/gs/toolbin/tests/compare_checksumdb.py
   trunk/gs/toolbin/tests/compare_checksums.py
   trunk/gs/toolbin/tests/dump_checksum.py
   trunk/gs/toolbin/tests/dump_checksum_plus.py
   trunk/gs/toolbin/tests/dump_checksum_raw.py
   trunk/gs/toolbin/tests/find_unique_file.py
   trunk/gs/toolbin/tests/get_baseline_log.py
   trunk/gs/toolbin/tests/get_baselines.py
   trunk/gs/toolbin/tests/gscheck_testfiles.py
   trunk/gs/toolbin/tests/gsvalidate.py
   trunk/gs/toolbin/tests/make_baselinedb.py
   trunk/gs/toolbin/tests/regen_baseline.py
   trunk/gs/toolbin/tests/regen_filelist.py
   trunk/gs/toolbin/tests/run_nightly.py
   trunk/gs/toolbin/tests/run_regression.py
   trunk/gs/toolbin/tests/run_series.py
   trunk/gs/toolbin/tests/testdiff.py
   trunk/gs/toolbin/tests/testing.cfg
   trunk/gs/toolbin/tests/update_baseline.py
   trunk/gs/toolbin/tests/updatelist.py
   trunk/gs/toolbin/tests/updatelistpdf.py
   trunk/gs/toolbin/tests/validate.py
Removed:
   trunk/gs/toolbin/tests/dump_testdb
   trunk/gs/toolbin/tests/get_baselines
   trunk/gs/toolbin/tests/run_regression
   trunk/gs/toolbin/tests/testdiff
   trunk/gs/toolbin/tests/update_baseline
   trunk/gs/toolbin/tests/update_pdfbaseline
Modified:
   trunk/gs/toolbin/tests/check_source.py
   trunk/gs/toolbin/tests/gscheck_all.py
   trunk/gs/toolbin/tests/gscheck_fuzzypdf.py
   trunk/gs/toolbin/tests/gscheck_pdfwrite.py
   trunk/gs/toolbin/tests/gscheck_raster.py
   trunk/gs/toolbin/tests/gsconf.py
   trunk/gs/toolbin/tests/gsparamsets.py
   trunk/gs/toolbin/tests/gssum.py
   trunk/gs/toolbin/tests/gstestgs.py
   trunk/gs/toolbin/tests/gstestutils.py
   trunk/gs/toolbin/tests/rasterdb.py
Log:
Checkin the work on regression, search, testfiles.  Mostly Python scripts.
See README files for documentation of use and structure.


Added: trunk/gs/toolbin/search/README
===================================================================
--- trunk/gs/toolbin/search/README	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/search/README	2007-04-16 14:45:42 UTC (rev 7854)
@@ -0,0 +1,33 @@
+README for toolbin/search
+
+Scripts for searching gs revision
+Typically the goal is to find a revision that either changed the checksum of an image, or changed an image in a "significant" way.
+
+
+run.py for one revision, one device tuple, one testfile
+	supports pdfwrite
+	"standard directories":
+		/home/regression/comparefiles
+		pnm/ for output files
+		pdf/ for pdfwrite output files
+		logs/ for log files
+	normal: 
+		calculate checksum and delete the output file, 
+		capture output in logs/<long file name>, E.g. logs/000-00.ps.7800.ppmraw.300.0.pnm.stderr
+
+
+
+runlist.py
+	for {range of revisions on one testfile, a list of testfiles on one revision, a range of revisions on a list of testfiles}
+	only one device tuple
+
+common use:
+	nice runlist.py --low=7437 --high=7806 --listfile=<listfile> --dochecksum --cleanup
+	<listfile> would be a list of testfiles, with support for # as comment character
+
+TO DO:
+	in run.py change to use stdin for all testfiles, since a few require it 119* -- DONE
+
+	allow control of device tuples, including support for pdfwrite
+
+	collect elapsed time (use exec* procedures) and output file size 
\ No newline at end of file

Added: trunk/gs/toolbin/tests/build_revision.py
===================================================================
--- trunk/gs/toolbin/tests/build_revision.py	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/build_revision.py	2007-04-16 14:45:42 UTC (rev 7854)
@@ -0,0 +1,421 @@
+#!/usr/bin/python
+# -*- Mode: python -*-
+
+#    Copyright (C) 2001-2006 Artifex Software Inc.
+# 
+# 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 the license contained in the file LICENSE in this distribution.
+# 
+# For more information about licensing, please refer to
+# http://www.ghostscript.com/licensing/. For information on
+# commercial licensing, go to http://www.artifex.com/licensing/ or
+# contact Artifex Software, Inc., 101 Lucas Valley Road #110,
+# San Rafael, CA  94903, U.S.A., +1(415)492-9861.
+
+# This script builds a revision of gs, including svn update, configure, make, install
+# 
+# If the revision is HEAD, make install is done; and the svn tree is put (HEAD) and installed
+# 	into gsconf.gsroot (usually /home/regression/gshead)
+# 
+# If the revision is not HEAD, no install is done; and the tree is put into gs.<revision>
+# 
+# If release is not None, then a release is built - in progress
+# 
+
+
+import os, sys, shutil
+import time
+import optparse, myoptparse
+import string, re
+import gsconf
+
+myself="build_revision.py"
+myversion="1.00"
+
+def logMessage(message,file,revision,printMessage=True):
+    message_time=time.strftime("%Y-%m-%d-%H:%M:%S", time.localtime())
+    message=myself+" "+revision+" "+message_time+" "+message
+    if printMessage:
+        print message
+    if file:
+        message+="\n"
+        file.write(message)
+        file.flush()
+
+def read_all_lines(f):
+    file = open(f, 'r')
+    lines = file.readlines()
+    file.close()
+    return string.join(lines, '')
+
+def get_revision(dir=None):
+    if dir:
+        cwd=os.getcwd()
+        os.chdir(dir)
+    p = os.popen("svn info")
+    for line in p:
+        if "Revision:" in line:
+            revision=line.strip('Revision: ')
+            revision=revision.strip('\n')
+	    break
+    else:
+        revision = None
+    if dir:
+        os.chdir(cwd)
+    return revision
+
+def change_gsproduct(file):
+    tmpfile = "%s.tmp" % (file,)
+
+    startre = re.compile("^#ifndef\ GS_PRODUCT$")
+    changere = re.compile("^.*?\"[A-Za-z -]+\".*?$")
+    endre = re.compile("^$")
+
+    old = open(file, "r")
+    new = open(tmpfile, "w")
+
+    state = 0
+    for line in old.readlines():
+        if state == 0:
+            m = startre.search(line)
+            if m:
+                state = 1
+                
+            new.write(line)
+        elif state == 1:
+            m = changere.search(line)
+            if m:
+                state = 2
+                new.write("\t\"AFPL Ghostscript\"\n")
+            else:
+                new.write(line)
+        elif state == 2:
+            m = endre.search(line)
+            if m:
+                state = 0
+
+            new.write(line)
+
+    old.close()
+    new.close()
+
+    os.unlink(file)
+    os.rename(tmpfile, file)
+
+def update_ghostscript(revision,release,
+                       gsroot,
+                       options,
+                       update_stdout,update_stderr,
+                       config_stdout,config_stderr,
+                       make_stdout,make_stderr,
+                       install_stdout,install_stderr,
+                       cumulative_file
+                       ):
+
+    myself=options.myself+" update_ghostscript"
+
+    if options and options.__dict__.has_key("verbose") and options.verbose:
+        print myself,gsroot
+
+    if release:
+        print myself,"release not yet supported"
+
+    if options and options.__dict__.has_key("capture") and options.capture:
+        captureOutput = True
+    else:
+        captureOutput = False
+
+    update_stdout_file = open(update_stdout, "w")
+    message="update_stdout"
+    logMessage(message,update_stdout_file,revision,printMessage=False)
+    update_stdout_file.close()
+
+    update_stderr_file = open(update_stderr, "w")
+    message="update_stderr"
+    logMessage(message,update_stderr_file,revision,printMessage=False)
+    update_stderr_file.close()
+
+    cwd=os.getcwd()
+
+    revision_file = gsroot+"revision"   # remove history until we have successfully completed the update"
+    if os.path.exists(revision_file):
+        os.unlink(revision_file)
+
+    # to prevent errors from left-over installations, remove the install tree
+    if revision == "HEAD":
+        installtree=gsconf.installtree
+        if os.path.exists(installtree):
+            message="remove old installation directory tree "+installtree
+            logMessage(message,cumulative_file,revision)
+            # do a check for sanity of the path
+            if os.path.exists(installtree+"/bin") and os.path.exists(installtree+"/bin/gs"):
+                shutil.rmtree(installtree+"/bin",ignore_errors=True)
+                shutil.rmtree(installtree+"/man",ignore_errors=True)
+                shutil.rmtree(installtree+"/share",ignore_errors=True)
+
+    update_stdout_file = open(update_stdout, "w")
+
+    if options and options.__dict__.has_key("svn") and options.svn:
+
+        product_file = "%ssrc/gscdef.c" % (gsroot)
+        if os.path.exists(product_file):
+            os.unlink(product_file)
+
+        # make the source tree corrrect from svn repository
+
+        message="svn checkout "+gsroot
+        logMessage(message,update_stdout_file,revision,printMessage=False)
+        logMessage(message,cumulative_file,revision)
+
+        host="http://svn.ghostscript.com:8080/ghostscript/trunk/gs "
+
+        if os.path.exists(gsroot):
+            revisionarg="-r"+revision+" "
+            command="svn update "+revisionarg+gsroot
+        else:
+            revisionarg="-r"+revision+" "
+            command="svn co "+revisionarg+host+gsroot
+
+        logMessage(message,update_stdout_file,revision,printMessage=False)
+        logMessage(command,cumulative_file,revision)
+
+        if captureOutput:
+            capture=" >> "+update_stdout
+            command+=capture
+        if os.system(command) != 0:
+            msg = "Ghostscript update failed during svn update\n\n"
+            msg = msg + "stdout log:\n\n"
+            msg = msg + read_all_lines(update_stdout)
+            msg = msg + "\nstderr log:\n\n"
+            msg = msg + read_all_lines(update_stderr)
+            logMessage(message,cumulative_file,revision)
+            return (1,msg)
+
+        if revision == "HEAD":
+            revision_value=get_revision(gsroot)
+        else:
+            revision_value = revision
+            
+        sys.modules["gsconf"].__dict__["revision"] = revision_value
+
+
+    os.chdir(gsroot)
+
+    message="revision is " + str(revision)
+    logMessage(message,update_stdout_file,revision,printMessage=False)
+    logMessage(message,cumulative_file,revision)
+
+    if options and options.__dict__.has_key("configure") and options.configure:
+        change_gsproduct(product_file)
+
+        message="product change complete:"+product_file
+        logMessage(message,update_stdout_file,revision,printMessage=False)
+        logMessage(message,cumulative_file,revision,)
+	
+        if revision == "HEAD":
+            installpath=gsconf.installtree
+            command="./autogen.sh --prefix=" + installpath
+        else:
+            command="./autogen.sh"
+            
+        logMessage(command,update_stdout_file,revision,printMessage=False)
+        logMessage(command,cumulative_file,revision)
+        if captureOutput:
+            capture=" > " +  config_stdout + " 2> " + config_stderr
+            command+=capture
+        if os.system(command) != 0:
+            msg = "Ghostscript update failed during configuration.\n\n"
+            msg = msg + "stdout log:\n\n"
+            msg = msg + read_all_lines(make_stdout)
+            msg = msg + "\nstderr log:\n\n"
+            msg = msg + read_all_lines(make_stderr)
+            logMessage(message,cumulative_file,revision)
+            return (1,msg)
+
+        message="configuration complete"
+        logMessage(message,update_stdout_file,revision,printMessage=False)
+        logMessage(message,cumulative_file,revision)
+
+
+    if options and options.__dict__.has_key("makeclean") and options.makeclean:
+        command ="make clean "
+        logMessage(command,update_stdout_file,revision,printMessage=False)
+        logMessage(command,cumulative_file,revision)
+        if captureOutput:
+            capture=" > /dev/null 2> /dev/null"
+            command+=capture
+        if os.system(command) != 0:
+            msg = "Ghostscript update failed during make clean\n\n"
+            logMessage(message,cumulative_file,revision)
+            return (1,msg)
+
+        message="make clean complete"
+        logMessage(message,update_stdout_file,revision,printMessage=False)
+        logMessage(message,cumulative_file,revision)
+    
+    if options and options.__dict__.has_key("make") and options.make:
+        command="make "
+        logMessage(command,update_stdout_file,revision,printMessage=False)
+        logMessage(command,cumulative_file,revision)
+        if captureOutput:
+            capture="> " + make_stdout + " 2> " + make_stderr
+            command+=capture
+        if os.system(command) != 0:
+            msg = "Ghostscript update failed during make\n\n"
+            msg = msg + "stdout log:\n\n"
+            msg = msg + read_all_lines(make_stdout)
+            msg = msg + "\nstderr log:\n\n"
+            msg = msg + read_all_lines(make_stderr)
+            logMessage(message,cumulative_file,revision)
+            return (1,msg)
+
+        message="make complete"
+        logMessage(message,update_stdout_file,revision,printMessage=False)
+        logMessage(message,cumulative_file,revision)
+
+    if revision == "HEAD":
+        command="make install "
+        logMessage(command,update_stdout_file,revision,printMessage=False)
+        logMessage(command,cumulative_file,revision)
+        if captureOutput:
+            capture="> " + install_stdout + " 2> " + install_stderr
+            command+=capture
+        if os.system(command) != 0:
+            msg = "Ghostscript update failed during install\n\n"
+            msg = msg + "stdout log:\n\n"
+            msg = msg + read_all_lines(install_stdout)
+            msg = msg + "\nstderr log:\n\n"
+            msg = msg + read_all_lines(install_stderr)
+            logMessage(message,cumulative_file,revision)
+            return (1,msg)
+
+        message="make install complete"
+        logMessage(message,update_stdout_file,revision,printMessage=False)
+        logMessage(message,cumulative_file,revision)
+
+        message="installation directory tree is "+gsroot
+        logMessage(message,cumulative_file,revision)
+
+    revision_file_name="revision"
+    revision_file = open(revision_file_name, "w")    
+    message=revision_value+"\n"
+    revision_file.write(message)
+    revision_file.close()
+    
+    os.chdir(cwd) # return to directory 
+
+    update_stdout_file.close()
+    
+    return (0,"success")
+
+#########################################################
+
+if __name__ == "__main__":
+
+    os.umask(0002)
+    
+    optionsParser=optparse.OptionParser()
+
+    optionsParser.add_option('--version',action='store_true',help="get my version")
+
+    optionsParser.add_option('--revision',action='store',help="under contruction",default="HEAD")
+    optionsParser.add_option('--release',action='store',help="under contruction",default=None)
+
+    optionsParser.add_option('--time','-m',action='store',help="provide start time",default=None)
+
+    optionsParser.add_option('--nosvn',action='store_true',help="do not update the revision source from the svn repository")
+    optionsParser.add_option('--noconfigure',action='store_true',help="do not run auto configure")
+    optionsParser.add_option('--nomakeclean',action='store_true',help="do not make clean before make")
+    optionsParser.add_option('--nomake',action='store_true',help="do not make")
+
+    optionsParser.add_option('--nocapture',action='store_true',help="do not capture stdout and stderr from commands")
+
+    optionsParser.add_option('--remove',action='store_true',help="remove the built directories")
+    
+    (options,arguments)=myoptparse.parseCommandLineBasic(optionsParser)
+    
+    myself=options.myself
+
+    if options.version:
+        print options.myself,"version",myversion
+        sys.exit(1)
+
+    options.svn       = not options.nosvn
+    options.configure = not options.noconfigure
+    options.make      = not options.nomake
+    options.makeclean = not options.nomakeclean
+
+    options.capture   = not options.nocapture
+
+    revision          = options.revision
+    release           = options.release
+    
+    now=options.time
+
+    logdir=gsconf.logdir
+    if not os.path.exists(logdir):
+        os.mkdir(logdir)
+
+    if now:
+        pass # use command line value of time
+    else:
+        now=time.strftime("%Y-%m-%d-%H:%M:%S", time.localtime())
+    
+    print myself,revision
+    if revision == "HEAD":
+        prefix=logdir+now+"."
+        gsroot=gsconf.gsroot
+        gspath=gsconf.installtree+"bin/gs"
+        gsinstall=gsconf.installtree
+    else:
+        prefix=logdir+revision+"."+now+"."
+        gsroot=gsconf.root+"gs."+revision+"/"
+        gspath=gsroot+"bin/gs"
+        gsinstall=None
+        
+    update_stdout=prefix+gsconf.update_stdout
+    update_stderr=prefix+gsconf.update_stderr
+    config_stdout=prefix+gsconf.config_stdout
+    config_stderr=prefix+gsconf.config_stderr
+    make_stdout=prefix+gsconf.make_stdout
+    make_stderr=prefix+gsconf.make_stderr
+    install_stdout=prefix+gsconf.install_stdout
+    install_stderr=prefix+gsconf.install_stderr
+        
+    cumulative_file=None
+
+    (err,message) = update_ghostscript(revision,release,
+                             gsroot,
+                             options,
+                             update_stdout,update_stderr,
+                             config_stdout,config_stderr,
+                             make_stdout,make_stderr,
+                             install_stdout,install_stderr,
+                             cumulative_file=None
+                             )
+    if err != 0:
+        print message
+        sys.exit(1)
+
+    revision=get_revision(gsroot)
+        
+    if not os.path.exists(gspath):
+        message=myself+" FATAL "+"the gs executable does not exist "+gspath
+        logMessage(message,None,revision)
+        sys.exit(1)
+
+    if options.remove:
+        if os.path.exists(gsroot):
+            print "shutil.rmtree(gsroot)",gsroot
+            shutil.rmtree(gsroot)
+            if gsinstall:
+                print "shutil.rmtree(gsinstall)",gsinstall
+                shutil.rmtree(gsinstall)            
+
+    print myself,revision,"done"
+
+    sys.exit(0)


Property changes on: trunk/gs/toolbin/tests/build_revision.py
___________________________________________________________________
Name: svn:executable
   + *

Modified: trunk/gs/toolbin/tests/check_source.py
===================================================================
--- trunk/gs/toolbin/tests/check_source.py	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/check_source.py	2007-04-16 14:45:42 UTC (rev 7854)
@@ -123,7 +123,7 @@
 
 gsSourceSets = [
     ('doc', ['*'], ['Changes.htm', 'gsdoc.el', 'FTL.txt']),
-    ('lib', ['eps', 'ps'], ['jobseparator.ps']),
+    ('lib', ['eps', 'ps'], []),
     ('man', ['*'], []),
     ('src', ['c', 'cpp', 'h', 'mak'], []),
     ('toolbin', ['*'], ['pre.chk'])

Added: trunk/gs/toolbin/tests/collate.py
===================================================================
--- trunk/gs/toolbin/tests/collate.py	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/collate.py	2007-04-16 14:45:42 UTC (rev 7854)
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+
+import os, time
+
+command="dump_baseline_plus.py "
+
+now=time.strftime("%Y-%m-%d-%H:%M:%S", time.localtime())
+YESTERDAY = time.strftime("%Y%m%d", time.localtime(time.time() - (24*60*60)))
+
+collate_filename='collate.'+now
+collate_sort_filename='collate.sort.'+now
+
+commandfull=command+"baseline.db >"+collate_filename
+print commandfull
+os.system(commandfull)
+
+commandfull=command+"daily/20070312.db >>"+collate_filename
+print commandfull
+os.system(commandfull)
+
+commandfull=command+"daily/20070313.db >>"+collate_filename
+print commandfull
+os.system(commandfull)
+
+commandfull="sort "+collate_filename+" > "+collate_sort_filename
+print commandfull
+os.system(commandfull)


Property changes on: trunk/gs/toolbin/tests/collate.py
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/gs/toolbin/tests/compare_checksumdb.py
===================================================================
--- trunk/gs/toolbin/tests/compare_checksumdb.py	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/compare_checksumdb.py	2007-04-16 14:45:42 UTC (rev 7854)
@@ -0,0 +1,173 @@
+#!/usr/bin/env python
+# -*- Mode: python -*-
+
+#    Copyright (C) 2001 Artifex Software Inc.
+#
+# 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 the license contained in the file LICENSE in this distribution.
+#
+# For more information about licensing, please refer to
+# http://www.ghostscript.com/licensing/. For information on
+# commercial licensing, go to http://www.artifex.com/licensing/ or
+# contact Artifex Software, Inc., 101 Lucas Valley Road #110,
+# San Rafael, CA  94903, U.S.A., +1(415)492-9861.
+
+# $Id: testdiff,v 1.5 2004/05/02 19:23:01 ray Exp $
+
+#
+# compare_checksumdb.py firstname secondname
+#
+# this script provides the difference between two sets of checksums
+# the files must be anydbm files, ususally with the testfile name as the key
+
+version="1.0"
+
+import sys, os
+import optparse, myoptparse
+import anydbm
+
+if __name__ == "__main__":
+    
+    optionsParser=optparse.OptionParser()
+    optionsParser.add_option('--option',action='store_true',help="sample additional option")
+    optionsParser.add_option('--nosvn',action='store_true',help="no not update from svn")
+    optionsParser.add_option('--nomake',action='store_true',help="no not make")
+
+    (options,arguments)=myoptparse.parseCommandLine(optionsParser)
+    print options.revision
+
+    old_dbname=arguments.pop(0)
+    new_dbname=arguments.pop(0)
+
+    print myself,old_dbname,new_dbname
+
+    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)
+
+    if not old_db:
+        print myself,"empty checksum database",old_dbname
+    if not new_db:
+        print myself,"empty checksum database",new_dbname
+
+
+    if not new_db or not old_db:
+
+    normal_re = re.compile("^(.*?)\.(p[bgpk]mraw)\.(\d+)\.(\d+)$")
+    pdfwrite_re = re.compile("^(.*?)\.(ps|pdf)\.pdf\.(p[bgpk]mraw)\.(\d+)\.(\d+)$")
+
+    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


Property changes on: trunk/gs/toolbin/tests/compare_checksumdb.py
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/gs/toolbin/tests/compare_checksums.py
===================================================================
--- trunk/gs/toolbin/tests/compare_checksums.py	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/compare_checksums.py	2007-04-16 14:45:42 UTC (rev 7854)
@@ -0,0 +1,38 @@
+#!/usr/bin/python
+# -*- Mode: python -*-
+
+import os,sys
+import optparse, myoptparse
+
+if __name__ == "__main__":
+
+    optionsParser=optparse.OptionParser()
+    optionsParser.add_option('--checksum1',action='store',help="path to checksum db 1")
+    optionsParser.add_option('--checksum2',action='store',help="path to checksum db 2")
+    (options,arguments)=myoptparse.parseCommandLineBasic(optionsParser)
+    
+    myself=options.myself
+    checksum1=options.checksum1
+    checksum2=options.checksum2
+
+    if not checksum1 or not checksum2:
+        print myself,"both checksum files are required"
+        sys.exit(1)
+
+    try:
+        print checksum1
+        checksum1_db = anydbm.open(checksum1, 'r')
+    except:
+        checksum1_db=None
+        print myself,"ERROR: cannot open "+checksum1
+
+    try:
+        print checksum2
+        checksum2_db = anydbm.open(checksum2, 'r')
+    except:
+        checksum2_db=None
+        print myself,"ERROR: cannot open "+checksum2        
+    
+    if not checksum1 or not checksum2:
+        sys.exit(1)
+    


Property changes on: trunk/gs/toolbin/tests/compare_checksums.py
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/gs/toolbin/tests/dump_checksum.py
===================================================================
--- trunk/gs/toolbin/tests/dump_checksum.py	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/dump_checksum.py	2007-04-16 14:45:42 UTC (rev 7854)
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+# -*- Mode: python -*-
+
+#    Copyright (C) 2001 Artifex Software Inc.
+# 
+# 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 the license contained in the file LICENSE in this distribution.
+# 
+# For more information about licensing, please refer to
+# http://www.ghostscript.com/licensing/. For information on
+# commercial licensing, go to http://www.artifex.com/licensing/ or
+# contact Artifex Software, Inc., 101 Lucas Valley Road #110,
+# San Rafael, CA  94903, U.S.A., +1(415)492-9861.
+
+# $Id: dump_testdb,v 1.7 2004/07/14 18:21:24 ray Exp $
+
+#
+# dump_baseline.py [<dbfile>]
+#
+# dumps (prints out) the contents of the baselinedb
+
+import string, sys, anydbm, gsconf, os, optparse, myoptparse
+
+if __name__ == "__main__":
+
+    optionsParser=optparse.OptionParser()
+    (options,arguments)=myoptparse.parseCommandLineBasic(optionsParser)
+
+    if len(arguments) == 1:
+        filename=arguments.pop(0)
+    else:
+        filename=gsconf.baselinedb
+
+    if not os.path.exists(filename):
+        print "cannot open",filename
+        sys.exit(1)
+
+    print "opening ", filename
+    db = anydbm.open(filename)
+
+    if db:
+        keys=db.keys()
+        keys.sort()
+
+        count=0
+        for k in keys:
+            count+=1
+            if options.verbose:
+                print '%s %s' % (db[k], k)
+
+        print options.myself,"number of entries",count,"in database",filename
+
+    else:
+        print options.myself,"no entries in database",filename


Property changes on: trunk/gs/toolbin/tests/dump_checksum.py
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/gs/toolbin/tests/dump_checksum_plus.py
===================================================================
--- trunk/gs/toolbin/tests/dump_checksum_plus.py	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/dump_checksum_plus.py	2007-04-16 14:45:42 UTC (rev 7854)
@@ -0,0 +1,49 @@
+#!/usr/bin/env python
+# -*- Mode: python -*-
+
+#    Copyright (C) 2001 Artifex Software Inc.
+# 
+# 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 the license contained in the file LICENSE in this distribution.
+# 
+# For more information about licensing, please refer to
+# http://www.ghostscript.com/licensing/. For information on
+# commercial licensing, go to http://www.artifex.com/licensing/ or
+# contact Artifex Software, Inc., 101 Lucas Valley Road #110,
+# San Rafael, CA  94903, U.S.A., +1(415)492-9861.
+
+# $Id: dump_testdb,v 1.7 2004/07/14 18:21:24 ray Exp $
+
+#
+# dump_baseline_plus.py [<dbfile> [name]]
+#
+# dumps (prints out) the contents of the baselinedb
+
+import sys, anydbm, gsconf, os
+
+args=sys.argv
+myself=args.pop(0)
+
+if len(args) > 0:
+    name=args.pop(0)
+else:
+    print "no database name"
+    sys.exit(1)
+
+if not os.path.exists(name):
+    print "cannot open",name
+    sys.exit(1)
+    
+db = anydbm.open(name)
+
+base=os.path.basename(name)
+
+keys=db.keys()
+keys.sort()
+for k in keys:
+    print "%50s %15s %s" % (k, base, db[k])
+


Property changes on: trunk/gs/toolbin/tests/dump_checksum_plus.py
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/gs/toolbin/tests/dump_checksum_raw.py
===================================================================
--- trunk/gs/toolbin/tests/dump_checksum_raw.py	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/dump_checksum_raw.py	2007-04-16 14:45:42 UTC (rev 7854)
@@ -0,0 +1,50 @@
+#!/usr/bin/env python
+# -*- Mode: python -*-
+
+#    Copyright (C) 2001 Artifex Software Inc.
+# 
+# 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 the license contained in the file LICENSE in this distribution.
+# 
+# For more information about licensing, please refer to
+# http://www.ghostscript.com/licensing/. For information on
+# commercial licensing, go to http://www.artifex.com/licensing/ or
+# contact Artifex Software, Inc., 101 Lucas Valley Road #110,
+# San Rafael, CA  94903, U.S.A., +1(415)492-9861.
+
+# $Id: dump_testdb,v 1.7 2004/07/14 18:21:24 ray Exp $
+
+#
+# dump_baseline.py [<dbfile>]
+#
+# dumps (prints out) the contents of the baselinedb
+
+import string, sys, anydbm, gsconf, os
+
+def compare_field_2(s1, s2):
+    if string.split(s1,' ')[1] < string.split(s2,' ')[1]:
+    	return -1
+    else:
+    	return 1
+
+if len(sys.argv) == 2:
+    name=sys.argv[1]
+else:
+    name=gsconf.baselinedb
+
+if not os.path.exists(name):
+    print "cannot open",name
+    sys.exit(1)
+
+print "opening ", name
+db = anydbm.open(name)
+
+# collect the database as strings
+dump = []
+for k in db.keys():
+    print '-%50s- %s' % (k,db[k])
+


Property changes on: trunk/gs/toolbin/tests/dump_checksum_raw.py
___________________________________________________________________
Name: svn:executable
   + *

Deleted: trunk/gs/toolbin/tests/dump_testdb
===================================================================
--- trunk/gs/toolbin/tests/dump_testdb	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/dump_testdb	2007-04-16 14:45:42 UTC (rev 7854)
@@ -1,50 +0,0 @@
-#!/usr/bin/env python
-# -*- Mode: python -*-
-
-#    Copyright (C) 2001 Artifex Software Inc.
-# 
-# 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 the license contained in the file LICENSE in this distribution.
-# 
-# For more information about licensing, please refer to
-# http://www.ghostscript.com/licensing/. For information on
-# commercial licensing, go to http://www.artifex.com/licensing/ or
-# contact Artifex Software, Inc., 101 Lucas Valley Road #110,
-# San Rafael, CA  94903, U.S.A., +1(415)492-9861.
-
-# $Id$
-
-#
-# dump_testdb [<dbfile>]
-#
-# dumps (prints out) the contents of the testdatadb
-
-import string, sys, anydbm, gsconf
-
-def compare_field_2(s1, s2):
-    if string.split(s1,' ')[1] < string.split(s2,' ')[1]:
-    	return -1
-    else:
-    	return 1
-
-if len(sys.argv) == 2:
-    print "opening ", sys.argv[1]
-    db = anydbm.open(sys.argv[1])
-else:
-    db = anydbm.open(gsconf.testdatadb)
-
-# collect the database as strings
-dump = []
-for k in db.keys():
-    dump.append('%s %s' % (db[k], k))
-
-# Sort on field 2 (the file name)
-dump.sort(compare_field_2)
-
-# Print the sorted list
-for line in dump:
-    print line

Added: trunk/gs/toolbin/tests/find_unique_file.py
===================================================================
--- trunk/gs/toolbin/tests/find_unique_file.py	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/find_unique_file.py	2007-04-16 14:45:42 UTC (rev 7854)
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+# -*- Mode: python -*-
+import sys, os, re
+import anydbm
+import gsconf
+import myoptparse, optparse
+
+def find_unique(filename):
+    file=open(filename)
+    lines=file.readlines()
+    file.close()
+
+    no_checksum=re.compile(".*no baseline checksum")
+
+    testfiles={}
+    comparefiledir=gsconf.comparefiledir
+    discard_leader=re.compile(".*"+comparefiledir)
+    for line in lines:
+        line=line.strip('\n')
+        if discard_leader.match(line):
+            if no_checksum.match(line):
+                testfile = discard_leader.sub("",line)
+                value=""
+                testfiles[testfile]=value
+
+    testfilelist=testfiles.keys()
+    testfilelist.sort()
+    for testfile in testfilelist:
+        print testfile
+
+if __name__ == "__main__":
+
+    optionsParser=optparse.OptionParser()
+    optionsParser.add_option('--file','-f',action='store_true',help="file to be parsed - find unique testfiles")
+    (options,arguments)=myoptparse.parseCommandLine(optionsParser,revisionSkip=True,testfileSkip=True,listfileSkip=True,deviceSkip=True)
+
+    args=sys.argv[:]
+    options.myself=args.pop(0)
+    while len(arguments)> 0:
+           filename = arguments.pop(0)
+           if os.path.exists(filename):
+               find_unique(filename)
+           else:
+               print options.myself,"cannot open",filename
+
+    sys.exit(0)


Property changes on: trunk/gs/toolbin/tests/find_unique_file.py
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/gs/toolbin/tests/get_baseline_log.py
===================================================================
--- trunk/gs/toolbin/tests/get_baseline_log.py	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/get_baseline_log.py	2007-04-16 14:45:42 UTC (rev 7854)
@@ -0,0 +1,80 @@
+#!/usr/bin/env python
+# -*- Mode: python -*-
+
+#    Copyright (C) 2001 Artifex Software Inc.
+#
+# 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 the license contained in the file LICENSE in this distribution.
+#
+# For more information about licensing, please refer to
+# http://www.ghostscript.com/licensing/. For information on
+# commercial licensing, go to http://www.artifex.com/licensing/ or
+# contact Artifex Software, Inc., 101 Lucas Valley Road #110,
+# San Rafael, CA  94903, U.S.A., +1(415)492-9861.
+
+# $Id: get_baselines,v 1.3 2004/05/02 19:23:01 ray Exp $
+
+#
+# get_baseline_log <date>
+#
+# This script gets the baseline log entries since DATE.  DATE should
+# be provided in ctime format (eg: 'Thu Jun 12 12:17:28 2003')
+
+import sys
+import time
+import string
+
+import gsconf
+
+def usage():
+    print "usage: get_baselines <date>"
+    print "date must be in ctime format."
+    sys.exit(1)
+
+if len(sys.argv) == 2:
+    try:
+        from_date = time.mktime(time.strptime(sys.argv[1]))
+    except:
+        print "ERROR: Could not parse date."
+        sys.exit(1)
+else:
+    usage()
+
+name=gsconf.baseline_log
+try:
+    baseline_log = open(name,'r')
+except:
+    print "ERROR: cannot open baseline log",name
+    sys.exit(1)
+
+changes = {}
+for line in baseline_log.readlines():
+    line = line[:-1]
+    if len(line) == 0:
+        continue
+    tokens = string.split(line)
+    time_tokens=tokens[:5]
+    time_tokens=string.join(time_tokens)
+    try:
+        tm = time.mktime(time.strptime(time_tokens))
+    except ValueError:
+        print "bad",tokens
+        changes[string.join(tokens[5:])] = 1
+        continue
+    
+    if from_date <= tm:
+        changes[string.join(tokens[5:])] = 1
+
+if len(changes) > 0:
+    keylist=changes.keys()
+    for k in keylist:
+        print k
+else:
+    print "No baseline updates."
+
+   


Property changes on: trunk/gs/toolbin/tests/get_baseline_log.py
___________________________________________________________________
Name: svn:executable
   + *

Deleted: trunk/gs/toolbin/tests/get_baselines
===================================================================
--- trunk/gs/toolbin/tests/get_baselines	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/get_baselines	2007-04-16 14:45:42 UTC (rev 7854)
@@ -1,70 +0,0 @@
-#!/usr/bin/env python
-# -*- Mode: python -*-
-
-#    Copyright (C) 2001 Artifex Software Inc.
-#
-# 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 the license contained in the file LICENSE in this distribution.
-#
-# For more information about licensing, please refer to
-# http://www.ghostscript.com/licensing/. For information on
-# commercial licensing, go to http://www.artifex.com/licensing/ or
-# contact Artifex Software, Inc., 101 Lucas Valley Road #110,
-# San Rafael, CA  94903, U.S.A., +1(415)492-9861.
-
-# $Id$
-
-#
-# get_baselines <date>
-#
-# This script gets the baseline log entries since DATE.  DATE should
-# be provided in ctime format (eg: 'Thu Jun 12 12:17:28 2003')
-
-import sys
-import time
-import string
-
-import gsconf
-
-def usage():
-    print "usage: get_baselines <date>"
-    print
-    print "Dates should be specificied in ctime format."
-    print
-    sys.exit(1)
-
-if len(sys.argv) == 2:
-    try:
-        from_date = time.mktime(time.strptime(sys.argv[1]))
-    except:
-        print "ERROR: Could not parse date."
-        sys.exit(1)
-else:
-    usage()
-
-try:
-    baseline_log = open(gsconf.log_baseline)
-except:
-    print "ERROR: Could not open baseline log."
-    sys.exit(1)
-
-changes = {}
-for line in baseline_log.readlines():
-    line = line[:-1]
-    tokens = string.split(line)
-    tm = time.mktime(time.strptime(string.join(tokens[:5])))
-    if from_date <= tm:
-        changes[string.join(tokens[5:])] = 1
-
-if len(changes) > 0:
-    for k in changes.keys():
-        print k
-else:
-    print "No baseline updates."
-
-   

Added: trunk/gs/toolbin/tests/get_baselines.py
===================================================================
--- trunk/gs/toolbin/tests/get_baselines.py	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/get_baselines.py	2007-04-16 14:45:42 UTC (rev 7854)
@@ -0,0 +1,71 @@
+#!/usr/bin/env python
+# -*- Mode: python -*-
+
+#    Copyright (C) 2001 Artifex Software Inc.
+#
+# 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 the license contained in the file LICENSE in this distribution.
+#
+# For more information about licensing, please refer to
+# http://www.ghostscript.com/licensing/. For information on
+# commercial licensing, go to http://www.artifex.com/licensing/ or
+# contact Artifex Software, Inc., 101 Lucas Valley Road #110,
+# San Rafael, CA  94903, U.S.A., +1(415)492-9861.
+
+# $Id: get_baselines,v 1.3 2004/05/02 19:23:01 ray Exp $
+
+#
+# get_baselines <date>
+#
+# This script gets the baseline log entries since DATE.  DATE should
+# be provided in ctime format (eg: 'Thu Jun 12 12:17:28 2003')
+
+import sys
+import time
+import string
+
+import gsconf
+
+def usage():
+    print "usage: get_baselines <date>"
+    print
+    print "Dates should be specificied in ctime format."
+    print
+    sys.exit(1)
+
+if len(sys.argv) == 2:
+    try:
+        from_date = time.mktime(time.strptime(sys.argv[1]))
+    except:
+        print "ERROR: Could not parse date."
+        sys.exit(1)
+else:
+    usage()
+
+
+try:
+    baseline_log = open(name)
+except:
+    print "ERROR: cannot open baseline log",name
+    sys.exit(1)
+
+changes = {}
+for line in baseline_log.readlines():
+    line = line[:-1]
+    tokens = string.split(line)
+    tm = time.mktime(time.strptime(string.join(tokens[:5])))
+    if from_date <= tm:
+        changes[string.join(tokens[5:])] = 1
+
+if len(changes) > 0:
+    for k in changes.keys():
+        print k
+else:
+    print "No baseline updates."
+
+   


Property changes on: trunk/gs/toolbin/tests/get_baselines.py
___________________________________________________________________
Name: svn:executable
   + *

Modified: trunk/gs/toolbin/tests/gscheck_all.py
===================================================================
--- trunk/gs/toolbin/tests/gscheck_all.py	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/gscheck_all.py	2007-04-16 14:45:42 UTC (rev 7854)
@@ -21,9 +21,9 @@
 
 from gstestutils import gsRunTestsMain
 
-def addTests(suite, **args):
-    import gscheck_raster; gscheck_raster.addTests(suite, **args)
-    import gscheck_pdfwrite; gscheck_pdfwrite.addTests(suite, **args)
+def addTests(suite, gsroot, now, options=None, **args):
+    import gscheck_raster; gscheck_raster.addTests(suite,gsroot,now,options=options,**args)
+    import gscheck_pdfwrite; gscheck_pdfwrite.addTests(suite,gsroot,now,options=options, **args)
 
 if __name__ == "__main__":
     gsRunTestsMain(addTests)

Modified: trunk/gs/toolbin/tests/gscheck_fuzzypdf.py
===================================================================
--- trunk/gs/toolbin/tests/gscheck_fuzzypdf.py	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/gscheck_fuzzypdf.py	2007-04-16 14:45:42 UTC (rev 7854)
@@ -92,17 +92,19 @@
 # Add the tests defined in this file to a suite
 
 def add_compare_test(suite, f, device, dpi, band):
-    suite.addTest(GSFuzzyCompareTestCase(gs=gsconf.comparegs, file=gsconf.comparefiledir + f, device=device, dpi=dpi, band=band))
+    suite.addTest(GSFuzzyCompareTestCase(gsroot, file=gsconf.comparefiledir + f, device=device, dpi=dpi, band=band))
 
 def addTests(suite, gsroot, **args):
     # get a list of test files
     comparefiles = os.listdir(gsconf.comparefiledir)
 
 
-    for f in comparefiles:
-        if f[-3:] == '.ps':
+    for testfile in comparefiles:
+
+# this comparison is not good...
+        if testfile[-3:] == '.ps':
 	    for params in gsparamsets.testparamsets:
-	        add_compare_test(suite, f, params.device, params.resolution, params.banding)
+	        add_compare_test(suite, gsroot,testfile, params.device, params.resolution, params.banding)
 
 if __name__ == "__main__":
     gstestutils.gsRunTestsMain(addTests)

Modified: trunk/gs/toolbin/tests/gscheck_pdfwrite.py
===================================================================
--- trunk/gs/toolbin/tests/gscheck_pdfwrite.py	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/gscheck_pdfwrite.py	2007-04-16 14:45:42 UTC (rev 7854)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 
-#    Copyright (C) 2001-2007 Artifex Software Inc.
+#    Copyright (C) 2001-2004 Artifex Software Inc.
 # 
 # This file is part of AFPL Ghostscript.
 # 
@@ -25,36 +25,39 @@
 # compares Ghostscript against a baseline made from file->pdf->raster->md5sum.
 # this test tries to detect Ghostscript changes that affect the pdfwrite driver.
 
-import os
+myself="gscheck_pdfwrite.py"
+
+import os, stat
 import calendar, string, time
 import gstestutils
 import gsconf, gstestgs, gsparamsets, gssum, gsutil
-import rasterdb
 
 class GSPDFWriteCompareTestCase(gstestgs.GhostscriptTestCase):
-    def makefilename(self):
-        return "%s.pdf.%s.%d.%d" % (self.file[string.rindex(self.file, '/') + 1:], self.device, self.dpi, self.band)
-	
     def shortDescription(self):
-        file = self.makefilename()
-	if not rasterdb.exists(file):
-		os.system(gsconf.codedir + "update_pdfbaseline '%s'" %
-                          (os.path.basename(self.file),))
-		self.skip = 1
-        try:
-            ct = time.localtime(rasterdb.mtime(file))
-            baseline_date = "%s %d, %4d %02d:%02d" % (
-                calendar.month_abbr[ct[1]], ct[2], ct[0], ct[3], ct[4])
-        except:
-            self.skip = 1
+        file = "%s.pdf.%s.%d.%d" % (self.file[string.rindex(self.file, '/') + 1:], self.device, self.dpi, self.band)
+	rasterfilename = gsconf.rasterdbdir + file + ".gz"
 
-        if self.band: banded = "banded"
-        else: banded = "noband"
-        if hasattr(self, "skip") and self.skip:
-      	    return "Skipping pdfwrite %s (%s/%ddpi/%s) [no previous raster data found]" % (os.path.basename(self.file), self.device, self.dpi, banded)
+        if self.band:
+            banded = "banded"
         else:
-	    return "Checking pdfwrite of %s (%s/%ddpi/%s) against baseline set on %s" % (os.path.basename(self.file), self.device, self.dpi, banded, baseline_date)
+            banded = "noband"
+        filename_base= os.path.basename(self.file)
+        filename_details= "%s (%s/%ddpi/%s)" % (filename_base, self.device, self.dpi,banded)
 
+        message="pdfwrite testing "+filename_details
+
+	if not os.access(rasterfilename, os.F_OK):
+		message="ERROR \ncannot find "+rasterfilename+" for "+filename_details
+		print myself,message
+		self.skip = 1
+        else:
+            ct = time.localtime(os.stat(rasterfilename)[stat.ST_MTIME])
+            baseline_date = "%s %d, %4d %02d:%02d" % (calendar.month_abbr[ct[1]], ct[2], ct[0], ct[3], ct[4])
+
+            message="Checking pdfwrite of %s against baseline set on %s" % (filename_details,baseline_date)
+
+        return message
+	
     def runTest(self):
         if hasattr(self, "skip") and self.skip:
 	    self.assert_(True)
@@ -64,7 +67,8 @@
 	file2 = '%s.pdf.%s.%d.%d' % (self.file[string.rindex(self.file, '/') + 1:], self.device, self.dpi, self.band)
 
 	gs = gstestgs.Ghostscript()
-	gs.command = self.gs
+
+	gs.gsroot = self.gsroot
 	gs.dpi = self.dpi
 	gs.band = self.band
 	gs.infile = self.file
@@ -74,46 +78,75 @@
 	    gs.log_stderr = self.log_stderr
 
 	# do file->PDF conversion
-
 	gs.device = 'pdfwrite'
         gs.dpi = None
-	gs.outfile = gsconf.scratchdir+file1
+	gs.outfile = file1
 	if not gs.process():
 	    self.fail("non-zero exit code trying to create pdf file from " + self.file)
 
 	# do PDF->device (pbmraw, pgmraw, ppmraw, pkmraw)
-		
 	gs.device = self.device
         gs.dpi = self.dpi
-	gs.infile = gsconf.scratchdir+file1
-	gs.outfile = gsconf.scratchdir+file2
+	gs.infile = file1
+	gs.outfile = file2
 	if not gs.process():
-	    self.fail("non-zero exit code trying to"\
-		      " rasterize " + file1)
+	    self.fail("non-zero exit code trying to rasterize " + file1)
 
-	# compare baseline
-		
-	sum = gssum.make_sum(gsconf.scratchdir+file2)
-	os.unlink(gsconf.scratchdir+file1)
-	os.unlink(gsconf.scratchdir+file2)
+        if os.path.exists(file1):
+            os.unlink(file1)
+        else:
+	    self.fail("output file "+file1+" was not created for input file: " + file1)
+            
+        if os.path.exists(file2):
+            sum = gssum.make_sum(file2)
+            if not sum:
+                self.fail("no checksum for output file "+file2+" was not created for input file: " + self.file)
+            os.unlink(file2)
+        else:
+	    self.fail("output file "+file2+" was not created for input file: " + file2)
 	
 	# add test result to daily database
 	if self.track_daily:
-	    gssum.add_file(file2, dbname=gsconf.get_dailydb_name(), sum=sum)
+            if gsconf.__dict__.has_key("checksumdb") and gsconf.checksumdb:
+                dbname=gsconf.dailydir+gsconf.checksumdb+".db"
+            else:
+                dbname=gsconf.get_dailydb_name()
+            gssum.add_file(file2, dbname=dbname, sum=sum)
 
-	self.assertEqual(sum, gssum.get_sum(file2), "md5sum did not match baseline (" + file2 + ") for file: " + self.file)
+        else:
+            outputfile=file2
+            if gssum.exists(outputfile,gsconf.baselinedb):
+                sum_baseline=gssum.get_sum(outputfile,gsconf.baselinedb)
+                message=myself+' checksum did not match baseline (' + outputfile + ') for input file: ' + self.file
+                self.assertEqual(sum,sum_baseline,message)
+            else:
+                message = myself+" no baseline checksum (" + outputfile + ") for file: " + self.file
+                self.fail(message)
 
 # Add the tests defined in this file to a suite
 
-def add_compare_test(suite, f, device, dpi, band, track):
-    suite.addTest(GSPDFWriteCompareTestCase(gs=gsconf.comparegs,
-					    file=gsconf.comparefiledir + f,
-					    device=device, dpi=dpi,
-					    band=band, track_daily=track,
-					    log_stdout=gsconf.log_stdout,
-					    log_stderr=gsconf.log_stderr))
+def add_compare_test(suite, gsroot, testfile, device, dpi, band, track, now=None):
 
-def addTests(suite, gsroot, **args):
+    logdir=gsconf.logdir
+    if now == None:
+        now=time.strftime("%Y-%m-%d-%H:%M:%S", time.localtime())
+    prefix=logdir+now+"."
+
+    log_stdout=prefix+gsconf.gs_stdout
+    log_stderr=prefix+gsconf.gs_stderr
+
+    suite.addTest(GSPDFWriteCompareTestCase(gsroot=gsroot,
+					    file=gsconf.comparefiledir + testfile,
+					    device=device,dpi=dpi,band=band, 
+                                            log_stdout=log_stdout,
+                                            log_stderr=log_stderr,
+                                            track_daily=track,now=now)
+                  )
+
+def addTests(suite,gsroot,now,options=None, **args):
+    if options:
+        pass # future implementation possible
+    
     if args.has_key('track'):
         track = args['track']
     else:
@@ -121,13 +154,16 @@
     
     # get a list of test files
     comparefiles = os.listdir(gsconf.comparefiledir)
+    comparefiles.sort()
 
-    for f in comparefiles:
-        if gsutil.check_extension(f):
+#    for testfile in comparefiles:
+#        print myself,testfile
+
+    for testfile in comparefiles:
+        if gsutil.check_extension(testfile):
 	    for params in gsparamsets.pdftestparamsets:
-	        add_compare_test(suite, f, params.device,
-				 params.resolution,
-				 params.banding, track)
+	        add_compare_test(suite,
+                                 gsroot,testfile,params.device,params.resolution,params.banding,track)
 
 if __name__ == "__main__":
     gstestutils.gsRunTestsMain(addTests)

Modified: trunk/gs/toolbin/tests/gscheck_raster.py
===================================================================
--- trunk/gs/toolbin/tests/gscheck_raster.py	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/gscheck_raster.py	2007-04-16 14:45:42 UTC (rev 7854)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 
-#    Copyright (C) 2001-2007 Artifex Software Inc.
+#    Copyright (C) 2001-2004 Artifex Software Inc.
 # 
 # This software is provided AS-IS with no warranty, either express or
 # implied.
@@ -24,87 +24,103 @@
 # against known baselines
 #
 
-
-import os
+myself="gscheck_raster.py"
+import sys, os, stat
 import string, calendar, time
 import gstestutils
 import gssum, gsconf, gstestgs, gsparamsets, gsutil
-import rasterdb
 
 class GSCompareTestCase(gstestgs.GhostscriptTestCase):
-    def makefilename(self):
-        file = "%s.%s.%d.%d" % (self.file[string.rindex(self.file, '/') + 1:], self.device, self.dpi, self.band)
-	return file
 
     def shortDescription(self):
-	file = self.makefilename()
-	if not rasterdb.exists(file):
-		os.system(gsconf.codedir + "update_baseline '%s'" %
-                          (os.path.basename(self.file),))
-		self.skip = 1
-	try:
-		ct = time.localtime(rasterdb.mtime(file))
-		baseline_date = "%s %d, %4d %02d:%02d" % ( calendar.month_abbr[ct[1]], ct[2], ct[0], ct[3], ct[4] )
-	except:
-		self.skip = 1
+        file = "%s.%s.%d.%d" % (self.file[string.rindex(self.file, '/') + 1:], self.device, self.dpi, self.band)
+	rasterfilename = gsconf.rasterdbdir + file + ".gz"
 
-	if self.band: banded = "banded"
-	else: banded = "noband"
-	if hasattr(self, "skip") and self.skip:
-		return "Skipping %s (%s/%ddpi/%s) [no previous raster data found]" % (os.path.basename(self.file), self.device, self.dpi, banded)
-	else:
-		return "Checking %s (%s/%ddpi/%s) against baseline set on %s" % (os.path.basename(self.file), self.device, self.dpi, banded, baseline_date)
+        if self.band:
+            banded = "banded"
+        else:
+            banded = "noband"
+        filename_base= os.path.basename(self.file)
+        filename_details= "%s (%s/%ddpi/%s)" % (filename_base, self.device, self.dpi,banded)
 
+	if not os.access(rasterfilename, os.F_OK):
+            message="ERROR \ncannot find "+rasterfilename+" for "+filename_details
+            print myself,message
+            self.skip = 1
+        else:
+            ct = time.localtime(os.stat(rasterfilename)[stat.ST_MTIME])
+            baseline_date = "%s %d, %4d %02d:%02d" % ( calendar.month_abbr[ct[1]], ct[2], ct[0], ct[3], ct[4] )
+            message="Checking %s against baseline set on %s" % (filename_details,baseline_date)
+
+        return message
+
     def runTest(self):
         if hasattr(self, "skip") and self.skip == 1:
 	    self.assert_(True)
 	    return
 
-	file = self.makefilename()
+	outputfile = "%s.%s.%d.%d" % (self.file[string.rindex(self.file, '/') + 1:], self.device, self.dpi, self.band)
 
 	gs = gstestgs.Ghostscript()
-	gs.command = self.gs
+
+	gs.gsroot = self.gsroot
 	gs.device = self.device
 	gs.dpi = self.dpi
 	gs.band = self.band
 	gs.infile = self.file
-	gs.outfile = gsconf.scratchdir+file
+	gs.outfile = outputfile
 	if self.log_stdout:
 	    gs.log_stdout = self.log_stdout
 	if self.log_stderr:
 	    gs.log_stderr = self.log_stderr
 
 	if gs.process():
-	    sum = gssum.make_sum(gsconf.scratchdir+file)
+	    sum = gssum.make_sum(outputfile)
         else:
 	    sum = ''
-	os.unlink(gsconf.scratchdir+file)
 
-	# add test result to daily database
-	if self.track_daily:
-	    gssum.add_file(file, dbname=gsconf.get_dailydb_name(), sum=sum)
+        if os.path.exists(outputfile):
+            os.unlink(outputfile)
 
+	if sum and self.track_daily:	                                                  # add test result to daily database
+            if gsconf.__dict__.has_key("checksumdb") and gsconf.checksumdb:
+                dbname=gsconf.dailydir+gsconf.checksumdb+".db"
+            else:
+                dbname=gsconf.get_dailydb_name()
+            gssum.add_file(outputfile, dbname=dbname, sum=sum)
+
 	if not sum:
-	    self.fail("output file could not be created "\
-		      "for file: " + self.file)
+	    message=myself+" output file "+outputfile+" was not created for input file: " + self.file
+	    self.fail(message)
         else:
-	    self.assertEqual(sum, gssum.get_sum(file),
-			     'md5sum did not match baseline (' +
-			     file + ') for file: ' + self.file)
+            if gssum.exists(outputfile,gsconf.baselinedb):
+                sum_baseline=gssum.get_sum(outputfile,gsconf.baselinedb)
+                message=myself+' checksum did not match baseline (' + outputfile + ') for input file: ' + self.file
+                self.assertEqual(sum,sum_baseline,message)
+            else:
+                message = myself+" no baseline checksum (" + outputfile + ") for file: " + self.file
+                self.fail(message)
 
-
 # add compare tests
-def add_compare_test(suite, f, device, dpi, band, track):
-    suite.addTest(GSCompareTestCase(gs=gsconf.comparegs,
-                                    file=gsconf.comparefiledir + f,
-                                    device=device, dpi=dpi,
-                                    band=band,
-                                    log_stdout=gsconf.log_stdout,
-                                    log_stderr=gsconf.log_stderr,
-                                    track_daily=track))
+def add_compare_test(suite, gsroot, testfile, device, dpi, band, track, now=None):
 
+    logdir=gsconf.logdir
+    if now == None:
+        now=time.strftime("%Y-%m-%d-%H:%M:%S", time.localtime())
+    prefix=logdir+now+"."
 
-def addTests(suite, gsroot, **args):
+    log_stdout=prefix+gsconf.gs_stdout
+    log_stderr=prefix+gsconf.gs_stderr
+
+    suite.addTest(GSCompareTestCase(gsroot=gsroot,
+                                    file=gsconf.comparefiledir + testfile,
+                                    device=device,dpi=dpi,band=band,
+                                    log_stdout=log_stdout,
+                                    log_stderr=log_stderr,
+                                    track_daily=track,now=now)
+                  )
+
+def addTests(suite,gsroot,now,options=None, **args):
     if args.has_key('track'):
         track = args['track']
     else:
@@ -112,14 +128,21 @@
 
     # get a list of test files
     comparefiles = os.listdir(gsconf.comparefiledir)
+    comparefiles.sort()
 
-    for f in comparefiles:
-        if gsutil.check_extension(f):
+    if sys.modules["gsconf"].__dict__.has_key("revision"):
+        print myself,gsconf.revision
+    
+#    for testfile in comparefiles:
+#        print myself,testfile
+
+    for testfile in comparefiles:
+        if gsutil.check_extension(testfile):
 	    for params in gsparamsets.testparamsets:
-	        add_compare_test(suite, f, params.device,
-				 params.resolution, params.banding, track)
+	        add_compare_test(suite,
+                                 gsroot,testfile,
+                                 params.device,params.resolution,params.banding,
+                                 track,now)
 
-
 if __name__ == '__main__':
     gstestutils.gsRunTestsMain(addTests)
-

Added: trunk/gs/toolbin/tests/gscheck_testfiles.py
===================================================================
--- trunk/gs/toolbin/tests/gscheck_testfiles.py	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/gscheck_testfiles.py	2007-04-16 14:45:42 UTC (rev 7854)
@@ -0,0 +1,71 @@
+#!/usr/bin/env python
+
+#    Copyright (C) 2001-2004 Artifex Software Inc.
+# 
+# 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 the license contained in the file LICENSE in this distribution.
+# 
+# For more information about licensing, please refer to
+# http://www.ghostscript.com/licensing/. For information on
+# commercial licensing, go to http://www.artifex.com/licensing/ or
+# contact Artifex Software, Inc., 101 Lucas Valley Road #110,
+# San Rafael, CA  94903, U.S.A., +1(415)492-9861.
+
+# $Id: gscheck_raster.py 6300 2005-12-28 19:56:24Z giles $
+
+#
+# gscheck_raster.py
+#
+# rasterizes input files in several configurations and checks them
+# against known baselines
+#
+
+myself="gscheck_testfiles.py"
+import sys, os
+import gsconf, gstestutils
+
+
+def add_compare_test(suite, gsroot, testfile, device, dpi, band, track, now=None):
+
+    logdir=gsconf.logdir
+    if now == None:
+        now=time.strftime("%Y-%m-%d-%H:%M:%S", time.localtime())
+    prefix=logdir+now+"."
+
+    log_stdout=prefix+gsconf.gs_stdout
+    log_stderr=prefix+gsconf.gs_stderr
+
+    suite.addTest(GSCompareTestCase(gsroot=gsroot,
+                                    file=gsconf.comparefiledir + testfile,
+                                    device=device,dpi=dpi,band=band,
+                                    log_stdout=log_stdout,
+                                    log_stderr=log_stderr,
+                                    track_daily=track,now=now)
+                  )
+
+def addTests(suite,gsroot,now,options=None, **args):
+    if args.has_key('track'):
+        track = args['track']
+    else:
+        track = 0
+
+    # get a list of test files
+    comparefiles = os.listdir(gsconf.comparefiledir)
+    comparefiles.sort()
+
+    if sys.modules["gsconf"].__dict__.has_key("revision"):
+        print myself,gsconf.revision
+    
+#    for testfile in comparefiles:
+#        print myself,testfile
+
+    for testfile in comparefiles:
+        if gsutil.check_extension(testfile):
+            print testfile
+
+if __name__ == '__main__':
+    gstestutils.gsRunTestsMain(addTests)


Property changes on: trunk/gs/toolbin/tests/gscheck_testfiles.py
___________________________________________________________________
Name: svn:executable
   + *

Modified: trunk/gs/toolbin/tests/gsconf.py
===================================================================
--- trunk/gs/toolbin/tests/gsconf.py	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/gsconf.py	2007-04-16 14:45:42 UTC (rev 7854)
@@ -54,11 +54,4 @@
 def get_dailydb_name():
     return dailydir + time.strftime("%Y%m%d", time.localtime()) + ".db"
 
-try:
-  # MPI version - node specific config
-  node=os.environ["PBS_NODENUM"]
-  parse_config(configdir+"testing.cfg."+node)
-except KeyError:
-  # normal version
-  parse_config()
-
+parse_config()

Modified: trunk/gs/toolbin/tests/gsparamsets.py
===================================================================
--- trunk/gs/toolbin/tests/gsparamsets.py	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/gsparamsets.py	2007-04-16 14:45:42 UTC (rev 7854)
@@ -20,49 +20,82 @@
 # Parameter sets for regression testing with gs
 
 class _GSParamSet:
-
     def __init__(self, device, resolution, banding):
         self.device = device
         self.resolution = resolution
         self.banding = banding
+ 
+testparamsets_name = ""
 
-testparamsets = [
-
+testparamsets_maximum = [
     # mono
     _GSParamSet('pbmraw', 72, 0),
     _GSParamSet('pbmraw', 72, 1),
     _GSParamSet('pbmraw', 300, 0),
     _GSParamSet('pbmraw', 300, 1),
-    #_GSParamSet('pbmraw', 600, 0),
-    #_GSParamSet('pbmraw', 600, 1),
+    _GSParamSet('pbmraw', 600, 0),
+    _GSParamSet('pbmraw', 600, 1),
 
     # grayscale
     _GSParamSet('pgmraw', 72, 0),
     _GSParamSet('pgmraw', 72, 1),
     _GSParamSet('pgmraw', 300, 0),
     _GSParamSet('pgmraw', 300, 1),
-    #_GSParamSet('pgmraw', 600, 0),
-    #_GSParamSet('pgmraw', 600, 1),
+    _GSParamSet('pgmraw', 600, 0),
+    _GSParamSet('pgmraw', 600, 1),
 
     # color
     _GSParamSet('ppmraw', 72, 0),
     _GSParamSet('ppmraw', 72, 1),
     _GSParamSet('ppmraw', 300, 0),
     _GSParamSet('ppmraw', 300, 1),
-    #_GSParamSet('ppmraw', 600, 0),
-    #_GSParamSet('ppmraw', 600, 1),
+    _GSParamSet('ppmraw', 600, 0),
+    _GSParamSet('ppmraw', 600, 1),
 
     # 1-bit CMYK
     _GSParamSet('pkmraw', 72, 0),
     _GSParamSet('pkmraw', 72, 1),
     _GSParamSet('pkmraw', 300, 0),
     _GSParamSet('pkmraw', 300, 1),
-    #_GSParamSet('pkmraw', 600, 0),
-    #_GSParamSet('pkmraw', 600, 1)
+    _GSParamSet('pkmraw', 600, 0),
+    _GSParamSet('pkmraw', 600, 1)
+]
 
+testparamsets_full = [
+    # mono
+    _GSParamSet('pbmraw', 72, 0),
+    _GSParamSet('pbmraw', 300, 0),
+    _GSParamSet('pbmraw', 300, 1),
+
+    # grayscale
+    _GSParamSet('pgmraw', 72, 0),
+    _GSParamSet('pgmraw', 300, 0),
+    _GSParamSet('pgmraw', 300, 1),
+
+    # color
+    _GSParamSet('ppmraw', 72, 0),
+    _GSParamSet('ppmraw', 300, 0),
+    _GSParamSet('ppmraw', 300, 1),
+
+    # 1-bit CMYK
+    _GSParamSet('pkmraw', 72, 0),
+    _GSParamSet('pkmraw', 300, 0),
+    _GSParamSet('pkmraw', 300, 1),
 ]
+testparamsets_minimum = [
+    # mono
+    _GSParamSet('pbmraw', 72, 0),
+    _GSParamSet('pbmraw', 300, 0),
+    _GSParamSet('pgmraw', 300, 0),
+    _GSParamSet('ppmraw', 300, 0),
+]
 
-pdftestparamsets = [
+testparamsets_one = [
+    # mono
+    _GSParamSet('pbmraw', 300, 0),
+]
+
+pdftestparamsets_full = [
     # color
     _GSParamSet('ppmraw', 72, 0),
     _GSParamSet('ppmraw', 300, 0),
@@ -70,3 +103,27 @@
     # 1-bit CMYK
     _GSParamSet('pkmraw', 300, 0)
 ]
+
+pdftestparamsets_minimum = [
+    # color
+    _GSParamSet('ppmraw', 300, 0),
+]
+
+pdftestparamsets_maximum = pdftestparamsets_full
+
+testparamsets = testparamsets_minimum
+pdftestparamsets = pdftestparamsets_minimum
+testparamsets_name = "minimum"
+
+testparamsets = testparamsets_maximum
+pdftestparamsets = pdftestparamsets_maximum
+testparamsets_name = "maximum"
+
+testparamsets = testparamsets_one
+pdftestparamsets = pdftestparamsets_minimum
+testparamsets_name = "one"
+
+testparamsets = testparamsets_full
+pdftestparamsets = pdftestparamsets_minimum
+testparamsets_name = "full"
+

Modified: trunk/gs/toolbin/tests/gssum.py
===================================================================
--- trunk/gs/toolbin/tests/gssum.py	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/gssum.py	2007-04-16 14:45:42 UTC (rev 7854)
@@ -19,41 +19,54 @@
 #
 # this module contains routines for calculating sums and managing
 # the sum database
+
 import anydbm
 import gsconf
 import os, string, md5
 from stat import *
 
-def exists(file, dbname=gsconf.testdatadb):
+myself="gssum.py"
+
+def exists(imagefile, dbname):
     db = anydbm.open(dbname)
-    exists = db.has_key(file)
+    imagefilebase=os.path.basename(imagefile)
+    exists = db.has_key(imagefilebase)
     db.close()
-
     return exists
 
-def add_file(file, dbname=gsconf.testdatadb, sum=''):
+def add_file(imagefile, dbname, sum=None):
     db = anydbm.open(dbname, 'w')
-    if len(sum) > 0:
-        db[file] = sum
+    if sum == None:
+        sum = make_sum(imagefile)
+    if sum != None:
+        imagefilebase=os.path.basename(imagefile)
+        db[imagefilebase] = sum
     else:
-        db[file] = make_sum(file)
+        print "gssum.add_file failed to create a sum for",imagefile
     db.close()
+    return sum
 
-def get_sum(file, dbname=gsconf.testdatadb):
-    db = anydbm.open(dbname)
-    sum = db[file]
+def get_sum(imagefile, dbname):
+    try:
+        db = anydbm.open(dbname)
+    except:
+        print "cannot open", dbname, "for", imagefile
+        
+    imagefilebase=os.path.basename(imagefile)
+    sum = db[imagefilebase]
     db.close()
-
     return sum
 
-def make_sum(file):
+def make_sum(imagefile):
     try:
-	mode = os.stat(file)[ST_MODE]
+	mode = os.stat(imagefile)[ST_MODE]
     except OSError:
+        print "gssum.add_file failed to stat",imagefile
 	return None
+
     if S_ISREG(mode):
 	sum = md5.new()
-	f = open(file, "r")
+	f = open(imagefile, "r")
 	data = f.read(1024)
 	while data:
 		sum.update(data)
@@ -62,4 +75,5 @@
 
         return sum.hexdigest()
     
+    print "gssum.add_file failed ISREG",imagefile
     return None

Modified: trunk/gs/toolbin/tests/gstestgs.py
===================================================================
--- trunk/gs/toolbin/tests/gstestgs.py	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/gstestgs.py	2007-04-16 14:45:42 UTC (rev 7854)
@@ -19,17 +19,18 @@
 #
 # base classes for regression testing
 
-import os
+import os, time
 import string
 import gsconf
 from gstestutils import GSTestCase
 
+myself="gstestgs.py"
+
 class Ghostscript:
 	def __init__(self):
-		self.command = '/usr/bin/gs'
+		self.device = ''
 		self.dpi = 72
 		self.band = 0
-		self.device = ''
 		self.infile = 'input'
 		if os.name == 'nt':
 			self.nullfile = 'nul'
@@ -39,88 +40,119 @@
 
 		# log file options
 		# NOTE: we always append to the log.  if it is desired to start a new
-		# log, it is the responsibility of the caller to clear/erase the old
-		# one.
+		# log, it is the responsibility of the caller to clear/erase the old one.
+
 		self.log_stdout = self.nullfile
 		self.log_stderr = self.nullfile
 
+	def log_message(self,message):
+		try:
+			log = open(self.log_stdout, "a")
+			log.write(message+"\n")
+			log.close()
+		except:
+			pass
+
 	def process(self):
 		bandsize = 30000000
 		if (self.band): bandsize = 10000
 		
-		cmd = self.command
+		gsroot=self.gsroot
+		execpath = gsroot+'bin/gs'
+
+		arguments = ' -sOutputFile=\'%s\' ' % (self.outfile,)
+
 		if gsconf.fontdir:
-			cmd = cmd + ' -I' + gsconf.fontdir
-		cmd = cmd + ' -dQUIET -dNOPAUSE -dBATCH -K1000000 '
+			FontPath=gsconf.fontdir
+		else:
+			FontPath = ''
+		ResourcePath=gsroot+'lib/'
+		IPath = ResourcePath+':'+FontPath
+		if IPath:
+			arguments+= ' -I' + IPath
+
+
+		arguments += ' -sDEVICE=%s ' % (self.device,)
 		if self.dpi:
-			cmd = cmd + '-r%d ' % (self.dpi,)
-		cmd = cmd + '-dMaxBitmap=%d ' % (bandsize,)
-		cmd = cmd + '-sDEVICE=%s ' % (self.device,)
-		cmd = cmd + '-sOutputFile=\'%s\' ' % (self.outfile,)
+			arguments += '-r%d ' % (self.dpi,)
 
-		# as of gs_init 1.93, job server emulation needs -dNOOUTERSAVE so
-		# that the 'exitserver' will restore global VM as expected.
-		# As of gs_init 1.111, job server emulation is supported (in a
-		# backward compatible fashion) so we add -dJOBSERVER.
-		cmd = cmd + '-dNOOUTERSAVE -dJOBSERVER -c false 0 startjob pop -f'
+		arguments += ' -dNOPAUSE -dBATCH -K1000000'
+		arguments += ' -dMaxBitmap=%d' % (bandsize,)
+		arguments += ' -dNOOUTERSAVE -dJOBSERVER -c false 0 startjob pop -f'
 
-		if string.lower(self.infile[-4:]) == ".pdf" or \
-		   string.lower(self.infile[-3:]) == ".ai":
-			cmd = cmd + ' -dFirstPage=1 -dLastPage=1 '
+		if string.lower(self.infile[-4:]) == ".pdf" or string.lower(self.infile[-3:]) == ".ai":
+			arguments += ' -dFirstPage=1 -dLastPage=1 '
+			infile = self.infile
 		else:
-			cmd = cmd + ' - < '
+			# for some tests, input from stdin is required - use it all the time
+			infile = ' - < '+self.infile
 
-		cmd = cmd + ' \'%s\' >> %s 2>> %s' % (self.infile, self.log_stdout, self.log_stderr)
+		if self.log_stdout and self.log_stderr:
+			capture=' >> %s 2>> %s' % (self.log_stdout, self.log_stderr)
+		else:
+			capture=''
 
+		fullcommand=execpath+arguments+" "+infile+" "+capture
+		
+		# before we execute the command which appends to the log
+		# we output a message to record the commandline that generates the log entry.
 
-		# before we execute the command which might append to the log
-		# we output a short header to show the commandline that generates
-		# the log entry.
+		infilename=os.path.basename(self.infile)
+		comment=' '.join((infilename,"to",self.outfile))
+
 		if len(self.log_stdout) > 0 and self.log_stdout != self.nullfile:
 			try:
 				log = open(self.log_stdout, "a")
-				log.write("===\n%s\n---\n" % (cmd,))
+				log.write("=== "+comment+"\n")
+				log.write(fullcommand+"\n")
+				log.write("---\n")
 				log.close()
 			except:
 				pass
 		if len(self.log_stderr) > 0 and self.log_stderr != self.nullfile:
 			try:
 				log = open(self.log_stderr, "a")
-				log.write("===\n%s\n---\n" % (cmd,))
+				log.write("==="+comment+"\n")
+				log.write(fullcommand+"\n")
+				log.write("---\n")
 				log.close()
 			except:
 				pass
-			
 
-		ret = os.system(cmd)
+		if self.__dict__.has_key("verbose") and self.verbose:
+			print fullcommand
 
-		if ret == 0:
+		gs_return=os.system(fullcommand)
+
+		if gs_return == 0:
 			return 1
 		else:
 			return 0
 
 		
 class GhostscriptTestCase(GSTestCase):
-	def __init__(self, gs='gs', dpi=72, band=0, file='test.ps', device='pdfwrite', log_stdout='', log_stderr='', track_daily=0):
-		self.gs = gs
+	def __init__(self,
+		     gsroot='gsroot',
+		     dpi=72, band=0, file='test.ps', device='pdfwrite', log_stdout='', log_stderr='', track_daily=0,now=None):
+
+		self.gsroot = gsroot
+
 		self.file = file
+		self.device = device
 		self.dpi = dpi
 		self.band = band
-		self.device = device
 		self.log_stdout = log_stdout
 		self.log_stderr = log_stderr
 		self.track_daily = track_daily
+		self.now = now
 		GSTestCase.__init__(self)
 
-
 class GSCrashTestCase(GhostscriptTestCase):
 	def runTest(self):
 		gs = Ghostscript()
-		gs.command = self.gs
+		gs.gsroot = self.gsroot
+		gs.device = self.device
 		gs.dpi = self.dpi
 		gs.band = self.band
-		gs.device = self.device
 		gs.infile = self.file
-
 		self.assert_(gs.process(), 'ghostscript failed to render file: ' + self.file)
-

Modified: trunk/gs/toolbin/tests/gstestutils.py
===================================================================
--- trunk/gs/toolbin/tests/gstestutils.py	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/gstestutils.py	2007-04-16 14:45:42 UTC (rev 7854)
@@ -132,30 +132,21 @@
 # Define a TestResult class that recognizes the GSTestFailure exception
 # as described above, and a TestRunner class that uses it.
 # The TestResult class also accepts a list or tuple of strings as the
-# error message, and prints the verbose log in a single line to
-# reduce mangling in parallel runs.
+# error message.
 
 class _GSTextTestResult(unittest._TextTestResult):
 
-    def startTest(self, test):
-	unittest.TestResult.startTest(self, test)
-
     def addFailure(self, test, err):
         self.failures.append((test, err))
         if self.showAll:
 	    lines = err[1].args[0]
 	    if (len(lines) > 18) & (lines[0:18] == "non-zero exit code"):
-		result = "ERROR"
+		self.stream.writeln("ERROR")
 	    else:
-		result = "DIFFER"
-	    self.stream.writeln(self.getDescription(test) + " ... " + result)
+		self.stream.writeln("DIFFER")
         elif self.dots:
             self.stream.write("D")
-
-    def addSuccess(self, test):
-	unittest.TestResult.addSuccess(self, test)
-	self.stream.writeln(self.getDescription(test) + " ... ok")
-
+    
     def printErrorList(self, flavor, errors):
         handoff = []
         for test, err in errors:

Added: trunk/gs/toolbin/tests/gsvalidate.py
===================================================================
--- trunk/gs/toolbin/tests/gsvalidate.py	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/gsvalidate.py	2007-04-16 14:45:42 UTC (rev 7854)
@@ -0,0 +1 @@
+#!


Property changes on: trunk/gs/toolbin/tests/gsvalidate.py
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/gs/toolbin/tests/make_baselinedb.py
===================================================================
--- trunk/gs/toolbin/tests/make_baselinedb.py	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/make_baselinedb.py	2007-04-16 14:45:42 UTC (rev 7854)
@@ -0,0 +1,128 @@
+#!/usr/bin/env python
+# -*- Mode: python -*-
+
+#    Copyright (C) 2001 Artifex Software Inc.
+# 
+# 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 the license contained in the file LICENSE in this distribution.
+# 
+# For more information about licensing, please refer to
+# http://www.ghostscript.com/licensing/. For information on
+# commercial licensing, go to http://www.artifex.com/licensing/ or
+# contact Artifex Software, Inc., 101 Lucas Valley Road #110,
+# San Rafael, CA  94903, U.S.A., +1(415)492-9861.
+
+# $Id: make_testdb,v 1.13 2004/09/19 17:05:21 jack Exp $
+
+#
+# make_testdb <dir>
+#
+# this script creates the gstestdb database and intializes it
+# with the md5sums of the test data files run through the
+# baseline ghostscript
+
+import gstestgs
+import gsconf
+import gssum
+import gsparamsets
+import rasterdb
+import anydbm
+import os, sys
+import string
+import gsutil
+
+def make_compare_entry(ifile, device, dpi, band):
+    ofile = "%s.%s.%d.%d" % (ifile, device, dpi, band)
+    print "creating entry: " + ofile + "...",
+    sys.stdout.flush()
+    
+    gs = gstestgs.Ghostscript()
+    gs.log_stdout = gsconf.log_stdout
+    gs.log_stderr = gsconf.log_stderr
+    gs.command = gsconf.baselinegs
+    gs.infile = gsconf.comparefiledir + ifile
+    gs.outfile = ofile
+    gs.device = device
+    gs.dpi = dpi
+    gs.band = band
+
+    if not gssum.exists(ofile):
+        if gs.process():
+	    try:
+       	        gssum.add_file(ofile)
+                rasterdb.put_file(ofile)
+    	        os.unlink(ofile)
+    	        print "done."
+            except OSError:
+                print "no output produced."
+        else:
+	    print "error."
+    else:
+	print "exists."
+
+def make_pdfcompare_entry(ifile, device, dpi, band):
+    ofile = "%s.pdf.%s.%d.%d" % (ifile, device, dpi, band)
+    print "creating entry: " + ofile + "...",
+    sys.stdout.flush()
+
+    if gssum.exists(ofile):
+        print "exists."
+        return
+    
+    gs = gstestgs.Ghostscript()
+    gs.log_stdout = gsconf.log_stdout
+    gs.log_stderr = gsconf.log_stderr
+    gs.command = gsconf.baselinegs
+    gs.infile = gsconf.comparefiledir + ifile
+    gs.dpi = dpi
+    gs.band = band
+
+    # make file->PDF
+
+    tfile = ofile + ".pdf"
+    gs.outfile = tfile
+    gs.device = 'pdfwrite'
+    gs.dpi = None
+
+    if not gs.process():
+        print "error."
+        return
+
+    gs.infile = tfile
+    gs.outfile = ofile
+    gs.device = device
+    gs.dpi = dpi
+
+    if gs.process():
+        try:
+            gssum.add_file(ofile)
+            rasterdb.put_file(ofile)
+            os.unlink(tfile)
+            os.unlink(ofile)
+            print "done."
+        except OSError:
+            print "no output produced."
+    else:
+        print "error."
+
+
+if __name__ == "__main__":
+    print "this script is only useful when starting a new database"
+    print "exit now"
+    sys.exit(1)
+
+    # create the baselinedb
+    db = anydbm.open(gsconf.baselinedb, 'c')
+    db.close()
+
+    files = os.listdir(gsconf.comparefiledir)
+    for f in files:
+        if gsutil.check_extension(f):
+            for params in gsparamsets.testparamsets:
+                make_compare_entry(f, params.device, params.resolution, params.banding)
+            for params in gsparamsets.pdftestparamsets:
+                make_pdfcompare_entry(f, params.device, params.resolution, params.banding)


Property changes on: trunk/gs/toolbin/tests/make_baselinedb.py
___________________________________________________________________
Name: svn:executable
   + *

Modified: trunk/gs/toolbin/tests/rasterdb.py
===================================================================
--- trunk/gs/toolbin/tests/rasterdb.py	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/rasterdb.py	2007-04-16 14:45:42 UTC (rev 7854)
@@ -1,4 +1,4 @@
-#    Copyright (C) 2001-2007 Artifex Software Inc.
+#    Copyright (C) 2001 Artifex Software Inc.
 #
 # This software is provided AS-IS with no warranty, either express or
 # implied.
@@ -24,20 +24,17 @@
 import gsconf
 
 def exists(file, dbdir=gsconf.rasterdbdir):
-    x = False
+    x = 0
+    filename=dbdir + file + '.gz'
     try:
         mode = os.stat(dbdir + file + '.gz')[ST_MODE]
         if S_ISREG(mode):
-            x = True
+            x = 1
     except:
         pass
     
     return x
 
-def mtime(file, dbdir=gsconf.rasterdbdir):
-    'return the modification time of the entry'
-    return os.stat(dbdir + file + '.gz')[ST_MTIME]
-
 def get_file(file, dbdir=gsconf.rasterdbdir, output=None):
     if exists(file, dbdir):
         if output:
@@ -52,6 +49,8 @@
             data = zf.read(1024)
         zf.close()
         f.close()
+    else:
+        print "rasterdb.get_file: does not exist",file
 
 def put_file(file, dbdir=gsconf.rasterdbdir):
     mode = os.stat(file)[ST_MODE]

Added: trunk/gs/toolbin/tests/regen_baseline.py
===================================================================
--- trunk/gs/toolbin/tests/regen_baseline.py	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/regen_baseline.py	2007-04-16 14:45:42 UTC (rev 7854)
@@ -0,0 +1,87 @@
+#!/usr/bin/python
+# -*- Mode: python -*-
+
+# change name of baseline db to baseline db.now
+# create new baseline db (anydbm)
+# regenerate baseline checksums from checksum raster files
+# for all files in raster directory
+# calculate checksum
+# add filename and checksum to db
+
+import os, time, optparse, myoptparse, gsconf, gssum, anydbm, rasterdb, re
+
+def regen_baseline(rasterdir,workdir,baselinedbname,listfile,options=None):
+    if options == None:
+        myself="regen_baseline.py"
+    else:
+        myself=options.myself
+
+    if listfile:               # listfile may be a subset of the files in rasterdir
+        print listfile
+        f=open(listfile)
+        rasterfiles=f.readlines()
+        f.close
+    else:
+        rasterfiles = os.listdir(rasterdir)
+        rasterfiles.sort()
+
+    if not os.path.exists(workdir):
+        os.mkdir(workdir)
+
+    total=len(rasterfiles)
+    all=0
+    print "%50s %s %i" % (rasterdir,"total files",total)
+    gzmatch=re.compile('.*gz$')
+    for rasterfile_raw in rasterfiles:
+        rasterfile_raw=rasterfile_raw.strip("\n")
+        fullname=rasterdir+rasterfile_raw
+#        if not os.path.isfile(fullname):
+#            print myself,"ignoring (not regular file)",fullname
+#            continue
+        if not gzmatch.match(rasterfile_raw):
+            print myself,"ignoring (not gz)",rasterfile_raw
+            continue
+
+        rasterfile=rasterfile_raw.replace(".gz","")
+        rasterfilepath=workdir+rasterfile
+
+        if not os.path.exists(rasterfilepath):
+            if options.verbose: print "gz ",rasterfile_raw
+            rasterdb.get_file(rasterfile,rasterdir,output=rasterfilepath)
+
+        if options.verbose: print rasterfilepath
+        sum=gssum.add_file(rasterfilepath,baselinedbname)
+        all+=1
+        if options.verbose: print "%100s %s %i %s %i" % (rasterfile,sum,all,"of",total)
+        if options.delete and os.path.exists(rasterfilepath):
+            os.unlink(rasterfilepath)
+
+
+if __name__ == "__main__":
+
+    optionsParser=optparse.OptionParser()
+
+    optionsParser.add_option('--new',action='store_true',help="start new db file")
+    optionsParser.add_option('--delete',action='store_true',help="delete intermediate raster files")
+    optionsParser.add_option('--listfile',action='store',help="listfile:\"list\"",default=None)
+
+    (options,arguments)=myoptparse.parseCommandLineBasic(optionsParser)
+
+    listfile=options.listfile
+
+    baselinedb=gsconf.baselinedb
+    if options.new:
+        now=time.strftime("%Y-%m-%d-%H:%M:%S", time.localtime())
+        print options.myself,now
+        if os.path.exists(baselinedb):
+            baselinedb_backup=baselinedb+"."+now
+            print "saving",baselinedb,"to",baselinedb_backup
+            os.rename(baselinedb,baselinedb_backup)
+        print options.myself,"create new baseline database"
+        db = anydbm.open(baselinedb, 'c')
+    else:
+        print options.myself,"use existing baseline database"
+        db = anydbm.open(baselinedb, 'r')
+
+    print baselinedb
+    regen_baseline(gsconf.rasterdbdir,gsconf.workdir,baselinedb,listfile=listfile,options=options)


Property changes on: trunk/gs/toolbin/tests/regen_baseline.py
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/gs/toolbin/tests/regen_filelist.py
===================================================================
--- trunk/gs/toolbin/tests/regen_filelist.py	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/regen_filelist.py	2007-04-16 14:45:42 UTC (rev 7854)
@@ -0,0 +1,89 @@
+#!/usr/bin/python
+# -*- Mode: python -*-
+
+# change name of baseline db to baseline db.now
+# create new baseline db (anydbm)
+# regenerate baseline checksums from checksum raster files
+# for all files in raster directory
+# calculate checksum
+# add filename and checksum to db
+
+import os, time, optparse, myoptparse, gsconf, gssum, anydbm, rasterdb, re
+
+def regen_baseline(rasterdir,workdir,baselinedbname,filelist,options=None):
+    if options == None:
+        myself="regen_baseline.py"
+    else:
+        myself=options.myself
+
+    if filelist:               # filelist may be a subset of the files in rasterdir
+        print filelist
+        f=open(filelist)
+        rasterfiles=f.readlines()
+        f.close
+        print rasterfiles
+    else:
+        rasterfiles = os.listdir(rasterdir)
+        rasterfiles.sort()
+
+    if not os.path.exists(workdir):
+        os.mkdir(workdir)
+
+    total=len(rasterfiles)
+    all=0
+    print "%50s %s %i" % (rasterdir,"total files",total)
+    gzmatch=re.compile('.*gz$')
+    for rasterfile_raw in rasterfiles:
+        if options.verbose: print "try",rasterfile_raw
+        fullname=rasterdir+rasterfile_raw
+        if not os.path.isfile(fullname):
+            print myself,"ignoring (not regular file)",fullname
+            continue
+        if not gzmatch.match(rasterfile_raw):
+            print myself,"ignoring (not gz)",rasterfile_raw
+            continue
+
+        rasterfile=rasterfile_raw.replace(".gz","")
+        rasterfilepath=workdir+rasterfile
+        if not gssum.exists(rasterfile,baselinedbname):
+            if not os.path.exists(rasterfilepath):
+                if options.verbose: print "gz ",rasterfile_raw
+                rasterdb.get_file(rasterfile,rasterdir,output=rasterfilepath)
+            if options.verbose: print rasterfilepath
+            gssum.add_file(rasterfilepath,baselinedbname)
+            all+=1
+            if options.verbose: print "%100s %i %s %i" % (rasterfile,all,"of",total)
+            if options.delete and os.path.exists(rasterfilepath):
+                os.unlink(rasterfilepath)
+
+
+if __name__ == "__main__":
+
+    optionsParser=optparse.OptionParser()
+    optionsParser.add_option('--delete','-d',action='store_true',help="delete intermediate raster files")
+    (options,arguments)=myoptparse.parseCommandLine(optionsParser,
+                                                    revisionSkip=True,
+                                                    deviceSkip=True,
+                                                    testfileSkip=True,
+                                                    )
+
+    if len(arguments) > 0:
+        filelist=arguments.pop(0)
+    else:
+        filelist=None
+
+    now=time.strftime("%Y-%m-%d-%H:%M:%S", time.localtime())
+    print options.myself,now
+
+    baselinedb=gsconf.baselinedb
+    if not options.nocleanup:
+        if os.path.exists(baselinedb):
+            baselinedb_backup=baselinedb+"."+now
+            print "saving",baselinedb,"to",baselinedb_backup
+            os.rename(baselinedb,baselinedb_backup)
+    else:
+        print options.myself,"no cleanup, use existing baseline database"
+
+    print baselinedb
+    db = anydbm.open(baselinedb, 'c')
+    regen_baseline(gsconf.rasterdbdir,gsconf.workdir,baselinedb,filelist=filelist,options=options)


Property changes on: trunk/gs/toolbin/tests/regen_filelist.py
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/gs/toolbin/tests/run_nightly.py
===================================================================
--- trunk/gs/toolbin/tests/run_nightly.py	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/run_nightly.py	2007-04-16 14:45:42 UTC (rev 7854)
@@ -0,0 +1,674 @@
+#!/usr/bin/python
+# -*- Mode: python -*-
+
+#    Copyright (C) 2001-2006 Artifex Software Inc.
+# 
+# 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 the license contained in the file LICENSE in this distribution.
+# 
+# For more information about licensing, please refer to
+# http://www.ghostscript.com/licensing/. For information on
+# commercial licensing, go to http://www.artifex.com/licensing/ or
+# contact Artifex Software, Inc., 101 Lucas Valley Road #110,
+# San Rafael, CA  94903, U.S.A., +1(415)492-9861.
+
+# overview
+# 	update revision (default is HEAD)
+# 	run all testfiles with all parameter sets using the gs executable - calculate each checksum
+# 	compare checksums with 1) previous results 2) baseline checksums
+# 	report baseline changes
+# 	email results
+# 
+# temporary output:
+#	the output images from gs execution are not saved
+#
+# permanent output:
+# 	checksum database for the day (an "anydbm" database [testfile-device,checksum]
+# 
+# input:
+# 	testing.cfg - configuration many significant variables (in /home/regression/regression, or .)
+# 	command line - control details of execution
+# 	files in compare file directory (ususally /home/regression/comparefiles)
+# 	The following are "anydbm" databases as described above
+#	 	database of checksums of the raster files in /home/regression/raster
+#	 	databases of past nightly runs in /home/regression/regression/daily (only the most recent is used)
+# 	baseline.log - log of updates to baseline raster files (in /home/regression/regression/baseline) [text file]
+# 	
+# Note that the raster files themselves are not used in this process.
+# 
+# Hierarchy of python scripts
+# 	run_nightly.py
+#		gsconf.py - read testing.cfg and create an object defining the environment for all other scripts
+# 		run_regression.py - execute gs, calculate checksum, insert into database
+#			gs_checkall.py
+#				gs_checkraster.py
+#				gs_checkpdfwrite.py
+#					gsparamset.py - define the "parameter set" - the set of output devices to be tested for each file
+#					gstestgs.py, gstestutil.py - run gs (used the built-in Python unit test harness)
+#					gssum.py - checksum calculation and database addition
+#			
+# 		testdiff.py - compare three checksum databases
+# 		get_baseline_log.py - extract recent changes to the baseline.log 
+#
+#
+#
+#
+
+
+# $Id: run_nightly 7013 2006-08-30 18:38:50Z giles $
+
+
+import os
+import sys, shutil
+import re
+import time
+import optparse, myoptparse
+import string
+import build_revision
+import gsconf, gsparamsets
+import anydbm
+from popen2 import Popen4
+
+# configuration variables
+
+myself="unknown"
+myversion="2.01"
+
+def logMessage(message,file,revision,printMessage=True):
+    message_time=time.strftime("%Y-%m-%d-%H:%M:%S", time.localtime())
+    message=myself+" "+revision+" "+message_time+" "+message
+    if printMessage:
+        print message
+    message+="\n"
+    if file:
+        file.write(message)
+        file.flush()
+
+def die(msg):
+    sendmail(gsconf.report_from, gsconf.report_to, "error running regression", msg)
+    sys.exit(0)
+
+def read_all_lines(f):
+    file = open(f, 'r')
+    lines = file.readlines()
+    file.close()
+    return string.join(lines, '')
+
+def get_count_in_db(dbname):
+    try:
+        db = anydbm.open(dbname, 'r')
+        if not db:
+            count=0
+        else:
+            count=len(db)
+    except:
+        count=0
+    print dbname,count
+
+def get_revision(dir=None):
+    if dir:
+        cwd=os.getcwd()
+        os.chdir(dir)
+
+    command="svn update --non-recursive"
+    if os.system(command) != 0:
+        message = "run_nightly.py:get_revision.py: cannot svn update"
+        logMessage(message,None,"unknown")
+        return "unknown"
+
+    command="svn info"
+    p = os.popen(command)
+    for line in p:
+        if "Revision:" in line:
+            revision=line.strip('Revision: ')
+            revision=revision.strip('\n')
+	    break
+    else:
+        revision = None
+    if dir:
+        os.chdir(cwd)
+    return revision
+
+def change_gsproduct(file):
+    tmpfile = "%s.tmp" % (file,)
+
+    startre = re.compile("^#ifndef\ GS_PRODUCT$")
+    changere = re.compile("^.*?\"[A-Za-z -]+\".*?$")
+    endre = re.compile("^$")
+
+    old = open(file, "r")
+    new = open(tmpfile, "w")
+
+    state = 0
+    for line in old.readlines():
+        if state == 0:
+            m = startre.search(line)
+            if m:
+                state = 1
+                
+            new.write(line)
+        elif state == 1:
+            m = changere.search(line)
+            if m:
+                state = 2
+                new.write("\t\"AFPL Ghostscript\"\n")
+            else:
+                new.write(line)
+        elif state == 2:
+            m = endre.search(line)
+            if m:
+                state = 0
+
+            new.write(line)
+
+    old.close()
+    new.close()
+
+    os.unlink(file)
+    os.rename(tmpfile, file)
+
+def sendmail(frm, to, subject, text):
+    import smtplib
+
+    keyword = gsconf.mailkeyword
+    if keyword:
+        msg = 'From: %s\r\nTo: %s\r\nSubject: %s\r\nX-Fnord: %s\r\n\r\n%s' % (frm, to, subject, keyword, text)
+    else:
+        msg = 'From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n%s' % (frm, to, subject, text)
+
+    server = smtplib.SMTP(gsconf.mail_server)
+    server.sendmail(frm, to, msg)
+    server.quit()
+
+def run_nightly(options,arguments):
+    global myself
+
+    myself=options.myself
+    # what do we work on?
+    revision      = options.revision
+    release       = options.release
+    
+    # what do we build
+    update           = not options.noupdate
+    
+    options.svn       = not options.nosvn
+    options.configure = not options.noconfigure
+    options.make      = not options.nomake
+    options.makeclean = not options.nomakeclean
+    
+    options.remove   = False  # never remove the gs executable, we need it for regression testing
+    
+    # what do we run?
+    runRegression    = not options.noregression
+    testRegression   = not options.notestregression
+    baselineChanges  = not options.nobaselinechanges
+    printRegression  = options.printregression
+    
+    # where do stdout and stderr go?
+    options.capture  = not options.nocapture
+    
+    p = os.popen('hostname -f')
+    if p:
+        hostname = string.strip(p.readline())
+        p.close()
+    else:
+        hostname = 'unknown host'
+        
+    p = os.popen('uname -m -o')
+    if p:
+        hostuname=string.strip(p.readline())
+        p.close()
+    else:
+        hostuname=""
+
+    hostname=hostname + " (" + hostuname + ')'
+
+    if release:
+        print "NOT SUPPORTED: need to build a release",release
+        sys.exit(1)
+
+    if not revision or revision == "HEAD":
+        gsroot=gsconf.gsroot
+        revision_value=get_revision(gsroot)
+        gsinstall=gsconf.installtree
+        gspath=gsconf.installtree+"bin/gs"
+        revision_full="HEAD:"+revision_value
+    else:
+        gsroot=gsconf.root+"gs."+revision+"/"
+        gsconf.checksumdb = revision
+        revision_value=revision
+        gsrevision_root=gsconf.root+"gs."+revision+"/"
+        gspath=gsrevision_root+"bin/gs"
+        gsinstall=None
+        revision_full=revision_value
+
+    logdir=gsconf.logdir
+    if not os.path.exists(logdir):
+        os.mkdir(logdir)
+
+    now=time.strftime("%Y-%m-%d-%H:%M:%S", time.localtime())
+    mail_message = now+" "+revision_value+"\n"
+
+    prefix=logdir+revision_value+"."
+
+    update_stdout=prefix+gsconf.update_stdout
+    update_stderr=prefix+gsconf.update_stderr
+    make_stdout=prefix+gsconf.make_stdout
+    make_stderr=prefix+gsconf.make_stderr
+    config_stdout=prefix+gsconf.config_stdout
+    config_stderr=prefix+gsconf.config_stderr
+    install_stdout=prefix+gsconf.install_stdout
+    install_stderr=prefix+gsconf.install_stderr
+    
+    cumulative_name=prefix+gsconf.cumulative
+    
+    history_name=logdir+gsconf.history        # permanent file, accumulates history across days
+    
+    if not os.path.exists(history_name):
+        messageHistory="creating history file "+history_name
+    else:
+        messageHistory="opening history file "+history_name
+    history_file = open(history_name, "w")    
+
+    cumulative_file = open(cumulative_name, "w")
+    message="cumulative"
+    logMessage(message,cumulative_file,revision_full,printMessage=False)
+    logMessage(messageHistory,cumulative_file,revision_full,printMessage=False)
+
+    message="running on " + hostname +" my version "+myversion
+    logMessage(message,cumulative_file,revision_full)
+    logMessage(message,history_file,revision_full,printMessage=False)
+    if options.version:
+        sys.exit(1)
+
+    if options.removeonly:
+        path=gsroot
+        message="removing "+path
+        logMessage(message,cumulative_file,revision_full)
+        shutil.rmtree(path,ignore_errors=True)
+        if gsinstall:
+            path=gsinstall
+            message="removing "+path
+            logMessage(message,cumulative_file,revision_full)
+            shutil.rmtree(path,ignore_errors=True)
+        sys.exit(1)
+
+    mail_message+=message+"\n"
+
+    comparefiles = os.listdir(gsconf.comparefiledir)
+    count=len(comparefiles)
+
+    message="comparefiles from "+gsconf.comparefiledir+" number of files "+str(count)
+    logMessage(message,cumulative_file,revision_full)
+    logMessage(message,history_file,revision_full,printMessage=False)
+    mail_message+=message+"\n"
+
+    # use the smallest that is requested
+    if options.oneset:    
+        gsparamsets.testparamsets = gsparamsets.testparamsets_one
+        gsparamsets.pdftestparamsets = gsparamsets.pdftestparamsets_one
+        gsparamsets.testparamsets_name = "one"
+    elif options.minset:
+        gsparamsets.testparamsets = gsparamsets.testparamsets_minimum
+        gsparamsets.pdftestparamsets = gsparamsets.pdftestparamsets_minimum
+        gsparamsets.testparamsets_name = "minimum"
+    elif options.maxset:    
+        gsparamsets.testparamsets = gsparamsets.testparamsets_maximum
+        gsparamsets.pdftestparamsets = gsparamsets.pdftestparamsets_full
+        gsparamsets.testparamsets_name = "maximum"
+    elif options.fullset:    
+        gsparamsets.testparamsets = gsparamsets.testparamsets_full
+        gsparamsets.pdftestparamsets = gsparamsets.pdftestparamsets_full
+        gsparamsets.testparamsets_name = "full"
+    else:
+        pass # use default in gsparamsets
+
+    message="test parameter set name: "+gsparamsets.testparamsets_name
+    logMessage(message,cumulative_file,revision_full)
+    logMessage(message,history_file,revision_full,printMessage=False)
+    mail_message+=message+"\n"
+
+    message="logging to "+prefix+"*"
+    logMessage(message,cumulative_file,revision_full)
+    mail_message+=message+"\n"
+
+    message="sending mail to "+gsconf.report_to
+    logMessage(message,cumulative_file,revision_full)
+    logMessage(message,history_file,revision_full,printMessage=False)
+
+    if update:
+        message="starting update_ghostscript"
+        logMessage(message,cumulative_file,revision_full)
+    
+        (err,message) = build_revision.update_ghostscript(revision,release,
+                                                          gsroot,
+                                                          options,
+                                                          update_stdout,update_stderr,
+                                                          config_stdout,config_stderr,
+                                                          make_stdout,make_stderr,
+                                                          install_stdout,install_stderr,
+                                                          cumulative_file
+                                                          )
+        if err != 0:
+            die(message)
+    else:
+        message="skipping update of ghostscript tree and executable"
+        logMessage(message,cumulative_file,revision_full)
+
+    prefix=logdir+revision_value+"."
+
+    baselines_name=prefix+gsconf.baselines
+    differences_name=prefix+gsconf.differences
+    regression_name=prefix+gsconf.regression
+    email_name=prefix+gsconf.email
+
+    if not os.path.exists(gspath):
+        message=myself+" FATAL "+"the gs executable does not exist "+gspath
+        logMessage(message,cumulative_file,revision_full)
+        die(message)
+
+    regression_file = open(regression_name, "w")
+    message="regression"
+    logMessage(message,regression_file,revision_full,printMessage=False)
+
+    message="revision of executable "+revision_full
+    logMessage(message,regression_file,revision_full,printMessage=False)
+    logMessage(message,history_file,revision_full,printMessage=False)
+    mail_message+=message+"\n"
+
+    revision_name=prefix+revision
+    revision_file = open(revision_name, "w")
+    revision_file.close()
+
+    # create string "regression_results" for regression results
+    regression_results = '\n'
+    if runRegression:
+        print
+
+        message="starting regression testing on "+revision
+        logMessage(message,regression_file,revision_full,printMessage=False)
+        logMessage(message,cumulative_file,revision_full)
+
+        timearg=" --time="+"\""+now+"\""
+        trackarg=" --track"
+
+        # revision can be HEAD
+        if revision != "HEAD":
+            revisionarg=" --revision="+revision
+        else: revisionarg=""
+   
+        # revision_value always has the revision number, also for HEAD
+        revision_valuearg=" --revision_value="+revision_value
+
+        if release:
+            releasearg=" --release="+release
+        else: releasearg=""
+    
+        command=gsconf.run_regression_script + releasearg + revisionarg + revision_valuearg + timearg + trackarg
+
+        if options.capture:
+            capture=" 2>&1"
+            command+=capture
+
+        message=command
+        logMessage(message,regression_file,revision_full,printMessage=False)
+        logMessage(message,cumulative_file,revision_full)
+
+        regression_results += '\nThe complete list of regressions for today:\n'
+        regression_results += command +"\n"
+
+        p = os.popen(command)
+        if p == None:
+            message="cannot open and run the regression script."
+            logMessage(message,cumulative_file,revision_full)
+            die(message)
+
+        pattern = 'ok$'
+        for line in p.readlines():
+            if printRegression: print line
+            if not re.search(pattern, line):
+                regression_results += line
+        p.close()
+
+        # count number of entries in daily db
+        if gsconf.__dict__.has_key("checksumdb") and gsconf.checksumdb:
+            newchecksum=gsconf.checksumdb
+        else:
+            newchecksum=time.strftime("%Y%m%d", time.localtime())
+
+    else:
+        message="skipping regression testing"
+        logMessage(message,regression_file,revision_full,printMessage=False)
+        logMessage(message,cumulative_file,revision_full)
+
+        regression_results+="gs regression processing was skipped"
+    # end if runRegression
+
+    regression_results += '\n'
+
+    # create string "difference_results" for regression results
+    if testRegression:
+        print
+
+        if gsconf.__dict__.has_key("checksumdb") and gsconf.checksumdb:
+            newchecksum=gsconf.checksumdb
+        else:
+            newchecksum=time.strftime("%Y%m%d", time.localtime())
+
+#        message="verify existence of the checksum database "+newchecksum
+#        logMessage(message,cumulative_file,revision_full,printMessage=False)
+#        logMessage(message,regression_file,revision_full)
+
+        message="starting difference_results"
+        logMessage(message,cumulative_file,revision_full,printMessage=False)
+        logMessage(message,regression_file,revision_full)
+
+        if options.oldrevision:
+            oldchecksum=options.oldrevision
+        else:
+            # find the most recent checksum file in the gsconf.dailydir
+            oneday=24*60*60
+            testtime=time.time()
+            for count in range(1,30):
+                testtime-=oneday
+                oldchecksum=time.strftime("%Y%m%d", time.localtime(testtime))
+                datafile=gsconf.dailydir+oldchecksum+".db"
+                if os.path.exists(datafile):
+                    try:
+                        db = anydbm.open(datafile)
+                        if db:
+                            db_hasdata=True
+                            db.close()
+                            if db_hasdata:
+                                message="old checksum database used "+datafile
+                                logMessage(message,cumulative_file,revision_full,printMessage=True)
+                                break
+                            else:
+                                message="old checksum database empty "+datafile
+                                logMessage(message,cumulative_file,revision_full,printMessage=True)
+                    except:
+                        message="old checksum database could not be opened "+datafile
+                        logMessage(message,cumulative_file,revision_full,printMessage=True)
+                else:
+                    message="old checksum database does not exist "+datafile
+                    logMessage(message,cumulative_file,revision_full,printMessage=True)
+            else:
+                message="cannot find any recent checksum database file",
+                logMessage(message,cumulative_file,revision_full)
+                message="FATAL cannot find any recent checksum database file"
+                logMessage(message,cumulative_file,revision_full)
+                die(message)
+
+        oldchecksumpath = gsconf.dailydir + oldchecksum + '.db'
+        if not os.path.exists(oldchecksumpath):
+            message=myself+" FATAL "+"the old checksum database does not exist "+oldchecksumpath
+            logMessage(message,cumulative_file,revision_full)
+            die(message)
+
+        recent_ctime = time.ctime(testtime)
+
+        message="found recent checksum database "+oldchecksum
+        logMessage(message,cumulative_file,revision_full,printMessage=False)
+        logMessage(message,regression_file,revision_full)
+        logMessage(message,history_file,revision_full,printMessage=False)
+
+        difference_results = 'The following regression changes happened since recent report: '+oldchecksum
+        difference_results += '\n'
+
+        command=gsconf.testdiff_script + " " + oldchecksum + " " + newchecksum
+        if options.capture:
+            capture=" 2>&1"
+            command+=capture
+
+        logMessage(command,regression_file,revision_full,printMessage=False)
+        logMessage(command,cumulative_file,revision_full)
+        p = os.popen(command)
+        if p:
+            for line in p.readlines():
+                if printRegression: print line
+                difference_results += line
+            p.close()
+        else:
+            difference_results = difference_results + 'no results from difference script\n'
+
+        message="get baseline updates"
+        logMessage(message,regression_file,revision_full,printMessage=False)
+        logMessage(message,cumulative_file,revision_full)
+
+        # Get updated baseline_changes
+        baseline_changes = 'The following files had their baselines updated:\n'
+
+        command=gsconf.get_baseline_log_script + " '" + recent_ctime + "'"
+        baseline_changes += command+"\n"
+
+        logMessage(command,cumulative_file,revision_full)
+        p = Popen4(command,1)
+        if p:
+            for line in p.fromchild.readlines():
+                baseline_changes += line
+                p.wait()
+        else:
+            baseline_changes = baseline_changes + 'no results from baseline script\n'
+            baseline_changes += "\n"
+
+        logMessage(baseline_changes,regression_file,revision_full)
+        logMessage(difference_results,regression_file,revision_full)
+    else:
+        difference_results="difference testing was skipped"
+    difference_results += '\n'
+    # end if testRegression
+
+    differences_file = open(differences_name, "w")
+    message="differences"
+    differences_file.write(message)
+    logMessage(message,differences_file,revision_full,printMessage=False)
+
+
+    if baselineChanges:
+        print
+
+        baselines_file = open(baselines_name, "w")
+        message="baseline changes"
+        baselines_file.write(message)
+        logMessage(baseline_changes,baselines_file,revision_full,printMessage=False)
+
+    else:
+        baseline_changes = "difference testing was skipped"
+        
+    # end if baselineChanges
+
+    mail_message+=difference_results+"\n"
+    mail_message+=regression_results+"\n"
+    mail_message+=baseline_changes+"\n"
+
+    email_file = open(email_name, "w")
+    subject='gs regression report - %s - revision: %s' % (now,revision_full)
+
+    message="subject "+subject
+    logMessage(message,cumulative_file,revision_full)
+    logMessage(message,email_file,revision_full,printMessage=False)
+
+    message="send mail to "+gsconf.report_to
+    logMessage(message,cumulative_file,revision_full)
+    logMessage(message,email_file,revision_full,printMessage=False)
+
+    logMessage(mail_message,email_file,revision_full,printMessage=False)
+    email_file.close()
+
+    if options.printmailmessage:
+        print
+        print "mail_message start"
+        print mail_message
+        print "mail_message end"    
+        print
+
+    while True:
+        try:
+            sendmail(gsconf.report_from, gsconf.report_to, subject, mail_message)
+            time.sleep(5)
+            break
+        except:
+            pass
+
+    message="done"
+    logMessage(message,cumulative_file,revision_full)
+
+    regression_file.close()
+    cumulative_file.close()
+    history_file.close()
+
+    print regression_name
+    print cumulative_name
+    print regression_name
+
+    return 0
+
+#########################################################
+
+if __name__ == "__main__":
+
+    os.umask(0002)
+
+    optionsParser=optparse.OptionParser()
+
+    optionsParser.add_option('--version',action='store_true',help="get my version")
+
+    optionsParser.add_option('--removeonly',action='store_true',help="remove the build directory - do nothing else")
+
+    optionsParser.add_option('--noupdate',action='store_true',help="do not update the gs executable")
+    # "update" includes svn, configure, makeclean, clean, install
+
+    optionsParser.add_option('--nosvn',action='store_true',help="do not update the source from the svn repository")
+    optionsParser.add_option('--noconfigure',action='store_true',help="do not run auto configure")
+    optionsParser.add_option('--nomakeclean',action='store_true',help="do not make clean before make")
+    optionsParser.add_option('--nomake',action='store_true',help="do not make")
+
+    optionsParser.add_option('--nocapture',action='store_true',help="do not capture stdout and stderr from commands")
+
+    optionsParser.add_option('--noregression',action='store_true',help="do not run regression")
+    optionsParser.add_option('--notestregression',action='store_true',help="do not test regression")
+    optionsParser.add_option('--nobaselinechanges',action='store_true',help="do not analyze baselinechanges")
+    optionsParser.add_option('--printregression',action='store_true',help="print regression output")
+    optionsParser.add_option('--printmailmessage',action='store_true',help="print mail message")
+
+    optionsParser.add_option('--fullset',action='store_true',help="full gsparamsets")
+    optionsParser.add_option('--minset',action='store_true',help="minimum gsparamsets")
+    optionsParser.add_option('--maxset',action='store_true',help="maximum gsparamsets")
+    optionsParser.add_option('--oneset',action='store_true',help="one gsparamsets")    
+
+    optionsParser.add_option('--release',action='store_true',help="under contruction")
+    optionsParser.add_option('--oldrevision',action='store',help="old revision for checksum comparison",default=None)
+
+    (options,arguments)=myoptparse.parseCommandLine(optionsParser,deviceSkip=True,testfileSkip=True,listfileSkip=True)
+
+    if options.version:
+        print options.myself,"version",myversion
+        sys.exit(1)
+
+    result = run_nightly(options,arguments)
+
+    sys.exit(result)


Property changes on: trunk/gs/toolbin/tests/run_nightly.py
___________________________________________________________________
Name: svn:executable
   + *

Deleted: trunk/gs/toolbin/tests/run_regression
===================================================================
--- trunk/gs/toolbin/tests/run_regression	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/run_regression	2007-04-16 14:45:42 UTC (rev 7854)
@@ -1,59 +0,0 @@
-#!/usr/bin/env python
-# -*- Mode: python -*-
-
-#    Copyright (C) 2001 Artifex Software Inc.
-# 
-# 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 the license contained in the file LICENSE in this distribution.
-# 
-# For more information about licensing, please refer to
-# http://www.ghostscript.com/licensing/. For information on
-# commercial licensing, go to http://www.artifex.com/licensing/ or
-# contact Artifex Software, Inc., 101 Lucas Valley Road #110,
-# San Rafael, CA  94903, U.S.A., +1(415)492-9861.
-
-# $Id$
-
-#
-# run_regression
-#
-# runs ghostscript regression tests
-
-import os,sys
-import anydbm
-import gstestutils, gsconf
-import check_all
-import gscheck_all
-
-track = 0
-if len(sys.argv) > 1:
-    if sys.argv[1] == "--track":
-        track = 1
-
-        db = anydbm.open(gsconf.get_dailydb_name(), "n")
-        db.close()
-        
-suite = gstestutils.GSTestSuite()
-
-# Add tests based on running Ghostscript.
-gscheck_all.addTests(suite, gsroot=gsconf.gsroot, track=track)
-
-# Add tests not based on actually running Ghostscript.
-try:
-  # see if we're running a parallel job
-  node = int(os.environ["PBS_NODENUM"])
-except KeyError:
-  # always run
-  node = 0
-# run these tests only once in a parallel job
-if node == 0:
-  check_all.addTests(suite, gsroot=gsconf.gsroot)
-
-# run all the tests
-runner = gstestutils.GSTestRunner(verbosity=2)
-result = runner.run(suite)
-

Added: trunk/gs/toolbin/tests/run_regression.py
===================================================================
--- trunk/gs/toolbin/tests/run_regression.py	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/run_regression.py	2007-04-16 14:45:42 UTC (rev 7854)
@@ -0,0 +1,130 @@
+#!/usr/bin/env python
+# -*- Mode: python -*-
+
+#    Copyright (C) 2001 Artifex Software Inc.
+# 
+# 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 the license contained in the file LICENSE in this distribution.
+# 
+# For more information about licensing, please refer to
+# http://www.ghostscript.com/licensing/. For information on
+# commercial licensing, go to http://www.artifex.com/licensing/ or
+# contact Artifex Software, Inc., 101 Lucas Valley Road #110,
+# San Rafael, CA  94903, U.S.A., +1(415)492-9861.
+
+# $Id: run_regression,v 1.13 2004/05/02 19:23:01 ray Exp $
+
+#
+# run_regression.py
+#
+# runs ghostscript regression tests
+
+import sys, os, time, myoptparse, optparse, shutil
+import anydbm
+import gstestutils, gsconf, gsparamsets
+import check_all
+import gscheck_all
+
+def get_revision_of_HEAD(dir=None):
+    if dir:
+        cwd=os.getcwd()
+        os.chdir(dir)
+    p = os.popen("svn info")
+    for line in p:
+        if "Revision:" in line:
+            revision=line.strip('Revision: ')
+            revision=revision.strip('\n')
+	    break
+    else:
+        revision = None
+    if dir:
+        os.chdir(cwd)
+    return revision
+
+def testAll(track,gsroot,now,options):
+    suite = gstestutils.GSTestSuite()
+
+    print options.myself,gsconf.comparefiledir
+    print options.myself,"test parameter set: "+gsparamsets.testparamsets_name
+
+    if not os.path.exists(gsroot):
+        print options.myself,"FATAL: gsroot directory does not exist",gsroot        
+        sys.exit(1)
+
+    gsexecutable=gsroot+"bin/gs"
+    if not os.path.exists(gsexecutable):
+        print options.myself,"FATAL: gsexecutable does not exist",gsexecutable        
+        sys.exit(1)
+
+    revision=get_revision_of_HEAD(dir=gsroot)
+    print options.myself,"from tree:",gsroot,"revision is:",revision
+    
+    # Add tests based on running Ghostscript.
+    gscheck_all.addTests(suite, gsroot=gsroot, track=track, now=now, options=options)
+
+    # Add tests not based on actually running Ghostscript.
+    check_all.addTests(suite, gsroot=gsroot)
+
+    # run all the tests
+    runner = gstestutils.GSTestRunner(verbosity=2)
+
+    cwd=os.getcwd()
+
+    start_time=time.strftime("%Y-%m-%d-%H:%M:%S", time.localtime())
+    print options.myself,start_time,"executing in",gsroot
+    os.chdir(gsroot)
+
+    result = runner.run(suite)
+
+    end_time=time.strftime("%Y-%m-%d-%H:%M:%S", time.localtime())
+    print options.myself,end_time,"complete",cwd
+    os.chdir(cwd)
+
+if __name__ == "__main__":
+
+    optionsParser=optparse.OptionParser()
+    optionsParser.add_option('--track',action='store_true',help="track sums in baseline db")
+    optionsParser.add_option('--time',action='store',help="provide start time",default=None)
+    optionsParser.add_option('--revision_value',action='store',help="revision - always an svn revision number",default=None)
+
+    (options,arguments)=myoptparse.parseCommandLine(optionsParser,testfileSkip=True,listfileSkip=True,deviceSkip=True)
+
+    now=options.time
+    revision=options.revision
+    revision_value=options.revision_value
+
+    if revision != "HEAD":
+        gsconf.checksumdb = gsconf.dailydir+revision+".db"
+
+    if revision != "HEAD":
+        gsroot=gsconf.root+"gs."+revision+"/"
+    else:
+        gsroot=gsconf.gsroot
+
+    if options.track:
+        if gsconf.__dict__.has_key("checksumdb") and gsconf.checksumdb:
+            dbname=gsconf.checksumdb
+        else:
+            dbname=gsconf.get_dailydb_name()
+
+        # create (truncate) the database for the daily checksums
+        db = anydbm.open(dbname, "n")
+        db.close()
+        print options.myself,"daily database for checksums",dbname
+    
+    testAll(options.track,gsroot,now,options)
+
+    if options.track:
+        if not os.path.exists(dbname):
+            print options.myself,"ERROR","the checksum database does not exist",dbname
+
+        # copy from the db by date to the db by revision
+        if revision == "HEAD":
+            dbname_by_revision_value = gsconf.dailydir+revision_value+".db"
+
+        print options.myself,"copy from",dbname,"to",dbname_by_revision_value
+        shutil.copy(dbname,dbname_by_revision_value)


Property changes on: trunk/gs/toolbin/tests/run_regression.py
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/gs/toolbin/tests/run_series.py
===================================================================
--- trunk/gs/toolbin/tests/run_series.py	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/run_series.py	2007-04-16 14:45:42 UTC (rev 7854)
@@ -0,0 +1,59 @@
+#!/usr/bin/python
+# -*- Mode: python -*-
+
+import os, sys
+import optparse, myoptparse
+
+if __name__ == "__main__":
+
+    os.umask(0002)
+
+    optionsParser=optparse.OptionParser()
+
+    optionsParser.add_option('--version',action='store_true',help="get my version")
+
+    optionsParser.add_option('--low',action='store',help="low version of range to run")
+    optionsParser.add_option('--high',action='store',help="high version of range to run")
+
+    optionsParser.add_option('--removeonly',action='store_true',help="remove the build directory - do nothing else")
+
+    optionsParser.add_option('--noupdate',action='store_true',help="do not update the gs executable")
+    # "update" includes svn, configure, makeclean, clean, install
+
+    optionsParser.add_option('--nosvn',action='store_true',help="do not update the source from the svn repository")
+    optionsParser.add_option('--noconfigure',action='store_true',help="do not run auto configure")
+    optionsParser.add_option('--nomakeclean',action='store_true',help="do not make clean before make")
+    optionsParser.add_option('--nomake',action='store_true',help="do not make")
+
+    optionsParser.add_option('--nocapture',action='store_true',help="do not capture stdout and stderr from commands")
+
+    optionsParser.add_option('--noregression',action='store_true',help="do not run regression")
+    optionsParser.add_option('--notestregression',action='store_true',help="do not test regression")
+    optionsParser.add_option('--printregression',action='store_true',help="print regression output")
+    optionsParser.add_option('--printmailmessage',action='store_true',help="print mail message")
+
+    optionsParser.add_option('--fullset',action='store_true',help="full gsparamsets",default="True")
+    optionsParser.add_option('--minset',action='store_true',help="minimum gsparamsets")
+    optionsParser.add_option('--maxset',action='store_true',help="maximum gsparamsets")
+
+    optionsParser.add_option('--release',action='store_true',help="under contruction")
+    optionsParser.add_option('--oldrevision',action='store',help="old revision for checksum comparison",default=None)
+
+    (options,arguments)=myoptparse.parseCommandLine(optionsParser,deviceSkip=True,testfileSkip=True,listfileSkip=True,revisionSkip=True)
+
+    if options.version:
+        print options.myself,"version",myversion
+        sys.exit(1)
+
+    low=int(options.low)
+    high=int(options.high)
+
+    overall_result=0
+    for revision in range(low,high+1):
+        options.revision=revision
+        result = run_nightly(options,arguments)
+        if result > 0:
+            overall_result=1
+        print options.myself,revision,"result",result
+
+    sys.exit(overall_result)


Property changes on: trunk/gs/toolbin/tests/run_series.py
___________________________________________________________________
Name: svn:executable
   + *

Deleted: trunk/gs/toolbin/tests/testdiff
===================================================================
--- trunk/gs/toolbin/tests/testdiff	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/testdiff	2007-04-16 14:45:42 UTC (rev 7854)
@@ -1,177 +0,0 @@
-#!/usr/bin/env python
-# -*- Mode: python -*-
-
-#    Copyright (C) 2001 Artifex Software Inc.
-#
-# 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 the license contained in the file LICENSE in this distribution.
-#
-# For more information about licensing, please refer to
-# http://www.ghostscript.com/licensing/. For information on
-# commercial licensing, go to http://www.artifex.com/licensing/ or
-# contact Artifex Software, Inc., 101 Lucas Valley Road #110,
-# San Rafael, CA  94903, U.S.A., +1(415)492-9861.
-
-# $Id$
-
-#
-# 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
-
-import sys
-import re
-import time
-import anydbm
-import gsconf
-
-def usage():
-    print "testdiff <start date> [<end date>]"
-    print
-    print "dates should be specified in YYYYMMDD format. if the end date"
-    print "is omitted, the current date will be used."
-    print
-    sys.exit(1)
-
-def sort_list(a, b):
-    if a[0] < b[0]:
-        return 1
-    elif a[0] > b[0]:
-        return -1
-
-    if a[1] < b[1]:
-        return 1
-    elif a[1] > b[1]:
-        return -1
-
-    if a[2] < b[2]:
-        return 1
-    elif a[2] > b[2]:
-        return -1
-
-    if a[3] < b[3]:
-        return 1
-    elif a[3] > b[3]:
-        return -1
-
-    if a[4] < b[4]:
-        return 1
-    elif a[4] > b[4]:
-        return -1
-
-    return 0
-                    
-
-normal_re = re.compile("^(.*?)\.(p[bgpk]mraw)\.(\d+)\.(\d+)$")
-pdfwrite_re = re.compile("^(.*?)\.(ps|pdf)\.pdf\.(p[bgpk]mraw)\.(\d+)\.(\d+)$")
-
-start_date = ''
-end_date = ''
-
-# process arguments
-
-if len(sys.argv) == 2:
-    start_date = sys.argv[1]
-elif len(sys.argv) == 3:
-    start_date = sys.argv[1]
-    end_date = sys.argv[2]
-else:
-    usage()
-
-if not end_date:
-    end_date = time.strftime("%Y%m%d", time.localtime(time.time()))
-
-# check if databases for both dates exist
-
-start_dbname = gsconf.dailydir + start_date + '.db'
-start_db = None
-end_dbname = gsconf.dailydir + end_date + '.db'
-end_db = None
-baseline_db = None
-
-try:
-    start_db = anydbm.open(start_dbname, 'r')
-    end_db = anydbm.open(end_dbname, 'r')
-    baseline_db = anydbm.open(gsconf.testdatadb, 'r')
-except:
-    pass
-
-if not start_db:
-    print "Test results for %s were not found." % (start_date,)
-    sys.exit(1)
-if not end_db:
-    print "Test results for %s were not found." % (end_date,)
-    sys.exit(1)
-if not baseline_db:
-    print "Baseline database could not be opened."
-    sys.exit(1)
-    
-# now find the differences, ignoring updated baselines
-
-keys = []
-diffs = []
-
-# get a list of all keys
-for k in start_db.keys():
-    if k not in keys:
-        keys.append(k)
-for k in end_db.keys():
-    if k not in keys:
-        keys.append(k)
-
-for k in keys:
-    if k not in start_db.keys():
-        if k in baseline_db.keys() and end_db[k] != baseline_db[k]:
-            diffs.append(k)
-    elif k not in end_db.keys():
-        diffs.append(k)
-    elif start_db[k] != end_db[k] and (k not in baseline_db.keys() or
-                                       end_db[k] != baseline_db[k]):
-        diffs.append(k)
-
-list = []
-
-for d in 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 "WARNING: Got a key that didn't match expressions!"
-        continue
-
-    bandstr = "noband"
-    if banded:
-        bandstr = "banded"
-
-    list.append((type, filename, device, dpi, bandstr))
-
-    
-list.sort()
-for l in list:
-    print "%s %s (%s/%d/%s)" % (l[0], l[1], l[2], l[3], l[4])

Added: trunk/gs/toolbin/tests/testdiff.py
===================================================================
--- trunk/gs/toolbin/tests/testdiff.py	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/testdiff.py	2007-04-16 14:45:42 UTC (rev 7854)
@@ -0,0 +1,202 @@
+#!/usr/bin/env python
+# -*- Mode: python -*-
+
+#    Copyright (C) 2001 Artifex Software Inc.
+#
+# 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 the license contained in the file LICENSE in this distribution.
+#
+# For more information about licensing, please refer to
+# http://www.ghostscript.com/licensing/. For information on
+# commercial licensing, go to http://www.artifex.com/licensing/ or
+# contact Artifex Software, Inc., 101 Lucas Valley Road #110,
+# San Rafael, CA  94903, U.S.A., +1(415)492-9861.
+
+# $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


Property changes on: trunk/gs/toolbin/tests/testdiff.py
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/gs/toolbin/tests/testing.cfg
===================================================================
--- trunk/gs/toolbin/tests/testing.cfg	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/testing.cfg	2007-04-16 14:45:42 UTC (rev 7854)
@@ -0,0 +1,62 @@
+# paths
+
+root		/home/regression/
+
+# latest revision built in root
+gsroot		/home/regression/HEAD/
+# latest revision installed to gshead
+installtree	/home/regression/gshead/
+headinstallpath	/home/regression/gshead/bin/gs
+# latest revision path to executable
+
+comparefiledir	/home/regression/comparefiles/
+comparefileall 	/home/regression/comparefiles/
+
+crashfiledir	/home/regression/crashfiles/
+codedir		/home/regression/regression/
+datadir		/home/regression/regression/
+logdir		/home/regression/regression/logs/
+testdir		/home/regression/regression/test/
+
+dailydir	/home/regression/regression/daily/
+rasterdbdir	/home/regression/regression/raster/
+rasterdir	/home/regression/regression/raster/
+fontdir		/home/regression/fonts/
+workdir		/home/regression/regression/work/
+
+# programs
+fuzzy		/home/regression/regression/fuzzy
+
+# data filenames
+baselinedb	/home/regression/regression/baseline/baseline.db
+baseline_log	/home/regression/regression/baseline/baseline.log
+
+# nightly report options
+mail_server	 localhost
+report_to	 gs-regression at ghostscript.com
+report_from	 gs-regression at ghostscript.com
+mailkeyword	 xefitra
+
+# scripts
+run_regression_script	/home/regression/regression/run_regression.py
+testdiff_script		/home/regression/regression/testdiff.py
+get_baseline_log_script	/home/regression/regression/get_baseline_log.py
+
+# put into logdir defined above
+update_stdout	update-stdout
+update_stderr	update-stderr
+config_stdout	config-stdout
+config_stderr	config-stderr
+make_stdout	make-stdout
+make_stderr	make-stderr
+install_stdout	install-stdout
+install_stderr	install-stderr
+gs_stdout	gs-stdout
+gs_stderr	gs-stderr
+differences	differences
+baselines	baseline_changes
+regression	regression
+cumulative	cumulative
+email		email
+history		history
+

Deleted: trunk/gs/toolbin/tests/update_baseline
===================================================================
--- trunk/gs/toolbin/tests/update_baseline	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/update_baseline	2007-04-16 14:45:42 UTC (rev 7854)
@@ -1,75 +0,0 @@
-#!/usr/bin/env python
-# -*- Mode: python -*-
-
-#    Copyright (C) 2001 Artifex Software Inc.
-# 
-# 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 the license contained in the file LICENSE in this distribution.
-# 
-# For more information about licensing, please refer to
-# http://www.ghostscript.com/licensing/. For information on
-# commercial licensing, go to http://www.artifex.com/licensing/ or
-# contact Artifex Software, Inc., 101 Lucas Valley Road #110,
-# San Rafael, CA  94903, U.S.A., +1(415)492-9861.
-
-# $Id$
-
-#
-# update_baseline <file>
-#
-# this script updates the testdata database with a new baseline sum
-# for all versions of file <file>.  use this when the comparing gs is
-# producing better output than the normal baseline (ie, when a regression
-# is really a progression
-
-import gstestgs
-import gsconf
-import gssum
-import gsparamsets
-import rasterdb
-import anydbm
-import time
-import os, sys
-import string
-import gsutil
-
-def make_entry(ifile, device, dpi, band):
-    ofile = "%s.%s.%d.%d" % (ifile, device, dpi, band)
-    print "updating entry: " + ofile + "...",
-    sys.stdout.flush()
-    
-    gs = gstestgs.Ghostscript()
-    gs.command = gsconf.comparegs
-    gs.log_stdout = gsconf.log_stdout
-    gs.log_stderr = gsconf.log_stderr
-    gs.infile = gsconf.comparefiledir + ifile
-    gs.outfile = ofile
-    gs.device = device
-    gs.dpi = dpi
-    gs.band = band
-
-    if gs.process():
-        try:
- 	    if gsconf.log_baseline:
-	        log = open(gsconf.log_baseline, "a")
-	        log.write(time.ctime() + " " + ifile + " updated\n")
-	        log.close()
-            gssum.add_file(ofile)
-            rasterdb.put_file(ofile)
-            os.unlink(ofile)
-            print "done."
-        except OSError:
-            print "no output produced."
-    else:
-	print "error."
-
-
-f = os.path.basename(sys.argv[1])
-
-if gsutil.check_extension(f):
-    for params in gsparamsets.testparamsets:
-        make_entry(f, params.device, params.resolution, params.banding)

Added: trunk/gs/toolbin/tests/update_baseline.py
===================================================================
--- trunk/gs/toolbin/tests/update_baseline.py	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/update_baseline.py	2007-04-16 14:45:42 UTC (rev 7854)
@@ -0,0 +1,212 @@
+#!/usr/bin/env python
+# -*- Mode: python -*-
+
+#    Copyright (C) 2001 Artifex Software Inc.
+# 
+# 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 the license contained in the file LICENSE in this distribution.
+# 
+# For more information about licensing, please refer to
+# http://www.ghostscript.com/licensing/. For information on
+# commercial licensing, go to http://www.artifex.com/licensing/ or
+# contact Artifex Software, Inc., 101 Lucas Valley Road #110,
+# San Rafael, CA  94903, U.S.A., +1(415)492-9861.
+
+# $Id: update_baseline,v 1.14 2004/09/19 17:05:21 jack Exp $
+
+#
+# update_baseline <file>
+#
+# this script updates the testdata database with a new baseline sum
+# for all versions of file <file>.  use this when the comparing gs is
+# producing better output than the normal baseline (ie, when a regression
+# is really a progression
+
+import gstestgs
+import gsconf
+import gssum
+import gsparamsets
+import rasterdb
+import anydbm
+import time
+import os, sys, copy
+import string
+import gsutil
+import optparse, myoptparse
+
+def update_databases(outputfile,device,dpi,band,revision,options):
+
+    log = open(gsconf.baseline_log, "a")
+
+    outputdevice=" ".join((device,str(dpi),str(band)))
+    message=time.ctime() + " " + testfile +" "+outputdevice+ " updated "+revision
+
+    if options and options.dryrun:
+        print "dryrun",message
+    else:
+        log.write(message+"\n")
+        log.close()
+
+    baselinedb=gsconf.baselinedb
+    if options and options.dryrun:
+        pass
+    else:
+        gssum.add_file(outputfile,baselinedb)
+
+    if options and options.dryrun:
+        pass
+    else:
+        rasterdb.put_file(outputfile)
+
+    if not options.nocleanup:
+        os.unlink(outputfile)
+
+def make_entry(testfile, device, dpi, band,revision,options):
+    testfilepath=gsconf.comparefileall + testfile
+    if not os.path.exists(testfilepath):
+        print options.myself,"cannot find","\""+testfilepath+"\""
+
+
+    outputfile = "%s.%s.%d.%d" % (testfile, device, dpi, band)
+    print "update_baseline.py: " + outputfile
+    sys.stdout.flush()
+
+    gs = gstestgs.Ghostscript()
+
+    gs.gsroot = gsconf.installtree
+    gs.command = gsconf.installtree+"bin/gs"
+    if not os.path.exists(gs.command):
+        print options.myself,"gs executable does not exist",gs.command
+        return
+
+    if gsconf.gs_stdout and gsconf.gs_stderr:
+        gs.log_stdout = gsconf.logdir+gsconf.gs_stdout
+        gs.log_stderr = gsconf.logdir+gsconf.gs_stderr
+    gs.infile = testfilepath
+    gs.outfile = outputfile
+    gs.device = device
+    gs.dpi = dpi
+    gs.band = band
+
+    if gs.process():
+        update_databases(outputfile,device,dpi,band,revision=revision,options=options)
+    else:
+	print options.myself,"error from gs.process",testfilepath,device,dpi,band
+
+def make_pdf_entry(testfile, device, dpi, band,revision,options):
+    testfilepath=gsconf.comparefileall + testfile
+    if not os.path.exists(testfilepath):
+        print options.myself,"cannot find","\""+testfilepath+"\""
+
+    outputfile = "%s.pdf.%s.%d.%d" % (testfile, device, dpi, band)
+    print "update_baseline.py (pdf): " + outputfile
+    sys.stdout.flush()
+
+    gs = gstestgs.Ghostscript()
+
+    gs.gsroot = gsconf.installtree
+    gs.command = gsconf.installtree+"bin/gs"
+    if not os.path.exists(gs.command):
+        print options.myself,"gs executable does not exist",gs.command
+        return
+
+    gs.log_stdout = gsconf.logdir+gsconf.gs_stdout
+    gs.log_stderr = gsconf.logdir+gsconf.gs_stderr
+
+    gs.infile = gsconf.comparefileall + testfile
+    gs.dpi = dpi
+    gs.band = band
+
+    intermediate_pdf_file = outputfile + ".pdf"
+    gs.outfile = intermediate_pdf_file
+    gs.device = 'pdfwrite'
+    gs.dpi = None
+
+    if not gs.process():
+	print options.myself,"error (->pdf)",testfilepath,device,dpi,band
+        return
+
+    gs.infile = intermediate_pdf_file
+    gs.outfile = outputfile
+    gs.device = device
+    gs.dpi = dpi
+
+    if gs.process():
+        update_databases(outputfile,device,dpi,band,revision=revision,options=options)
+    else:
+	print options.myself,"error.",testfilepath,device,dpi,band
+
+def make_entries_paramsets(testfile,options):
+    buildroot=gsconf.gsroot
+    revision_filename=buildroot+"revision"
+    if os.path.exists(revision_filename):
+        revision_file=open(revision_filename)
+        revision = revision_file.readline()
+        revision=revision.strip("\n")
+        revision_file.close()
+    else:
+        revision="unknown"
+
+    if gsutil.check_extension(testfile):
+        for params in gsparamsets.testparamsets_maximum:
+            make_entry(testfile, params.device, params.resolution, params.banding,revision=revision,options=options)
+
+def make_pdf_entries_paramsets(testfile,options):
+    buildroot=gsconf.gsroot
+    revision_filename=buildroot+"revision"
+    if os.path.exists(revision_filename):
+        revision_file=open(revision_filename)
+        revision = revision_file.readline()
+        revision=revision.strip("\n")
+        revision_file.close()
+    else:
+        revision="unknown"
+
+    if gsutil.check_extension(testfile):
+        for params in gsparamsets.pdftestparamsets_maximum:
+            make_pdf_entry(testfile, params.device, params.resolution, params.banding,revision=revision,options=options)
+
+if __name__ == '__main__':
+
+    optionsParser=optparse.OptionParser()
+    optionsParser.add_option('--dryrun',action='store_true',help="simple date format")
+    optionsParser.add_option('--nocleanup',action='store_true',help="do not delete output files")
+    optionsParser.add_option('--pdf',action='store_true',help="update pdfwrite raster")
+    optionsParser.add_option('--both',action='store_true',help="update normal and pdfwrite raster")
+    (options,arguments)=myoptparse.parseCommandLineBasic(optionsParser)
+
+    myself=options.myself
+
+    if options.pdf:
+        options.normal=False
+    else:
+        options.normal=True
+
+    if options.both:
+        options.pdf=True
+        options.normal=True
+
+    if options.normal:
+        files=copy.copy(arguments)
+        while len(files) > 0:
+            testfile = os.path.basename(files.pop(0))
+            testfilepath=gsconf.comparefileall + testfile
+            if not os.path.exists(testfilepath):
+                print myself,"cannot find","\""+testfilepath+"\""
+                continue
+            make_entries_paramsets(testfile,options)
+
+    if options.pdf:
+        files=copy.copy(arguments)
+        while len(files) > 0:
+            testfile = os.path.basename(files.pop(0))
+            testfilepath=gsconf.comparefileall + testfile
+            if not os.path.exists(testfilepath):
+                print myself,"cannot find","\""+testfilepath+"\""
+                continue
+            make_pdf_entries_paramsets(testfile,options)
+    


Property changes on: trunk/gs/toolbin/tests/update_baseline.py
___________________________________________________________________
Name: svn:executable
   + *

Deleted: trunk/gs/toolbin/tests/update_pdfbaseline
===================================================================
--- trunk/gs/toolbin/tests/update_pdfbaseline	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/update_pdfbaseline	2007-04-16 14:45:42 UTC (rev 7854)
@@ -1,90 +0,0 @@
-#!/usr/bin/env python
-# -*- Mode: python -*-
-
-#    Copyright (C) 2001 Artifex Software Inc.
-# 
-# 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 the license contained in the file LICENSE in this distribution.
-# 
-# For more information about licensing, please refer to
-# http://www.ghostscript.com/licensing/. For information on
-# commercial licensing, go to http://www.artifex.com/licensing/ or
-# contact Artifex Software, Inc., 101 Lucas Valley Road #110,
-# San Rafael, CA  94903, U.S.A., +1(415)492-9861.
-
-# $Id$
-
-#
-# update_pdfbaseline <file>
-#
-# this script updates the testdata database with a new baseline sum
-# for all versions of file <file>.  use this when the comparing gs is
-# producing better output than the normal baseline (ie, when a regression
-# is really a progression
-
-import gstestgs
-import gsconf
-import gssum
-import gsparamsets
-import anydbm
-import rasterdb
-import time
-import os, sys
-import string
-import gsutil
-
-def make_pdfcompare_entry(ifile, device, dpi, band):
-    ofile = "%s.pdf.%s.%d.%d" % (ifile, device, dpi, band)
-    print "updating entry: " + ofile + "...",
-    sys.stdout.flush()
-
-    gs = gstestgs.Ghostscript()
-    gs.log_stdout = gsconf.log_stdout
-    gs.log_stderr = gsconf.log_stderr
-    gs.command = gsconf.comparegs
-    gs.infile = gsconf.comparefiledir + ifile
-    gs.dpi = dpi
-    gs.band = band
-
-    # make file->PDF
-
-    tfile = ofile + ".pdf"
-    gs.outfile = tfile
-    gs.device = 'pdfwrite'
-    gs.dpi = None
-
-    if not gs.process():
-        print "error."
-        return
-
-    gs.infile = tfile
-    gs.outfile = ofile
-    gs.device = device
-    gs.dpi = dpi
-
-    if gs.process():
-        try:
-	    if gsconf.log_baseline:
-	        log = open(gsconf.log_baseline, "a")
-		log.write(time.ctime() + " " + ifile + " updated (pdfwrite)\n")
-		log.close()
-            gssum.add_file(ofile)
-            rasterdb.put_file(ofile)
-            os.unlink(tfile)
-            os.unlink(ofile)
-            print "done."
-        except OSError:
-            print "no output produced."
-    else:
-        print "error."
-
-
-f = os.path.basename(sys.argv[1])
-
-if gsutil.check_extension(f):
-    for params in gsparamsets.testparamsets:
-        make_pdfcompare_entry(f, params.device, params.resolution, params.banding)

Added: trunk/gs/toolbin/tests/updatelist.py
===================================================================
--- trunk/gs/toolbin/tests/updatelist.py	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/updatelist.py	2007-04-16 14:45:42 UTC (rev 7854)
@@ -0,0 +1,59 @@
+#!/usr/bin/python
+
+import sys, os, re, datetime, optparse
+
+myself=sys.argv[0]
+usage="USAGE: %prog [options] filename"
+p=optparse.OptionParser(usage=usage)
+p.add_option('--file','-f',action='store',type="string",help="filename: name of the file with a list of testfiles to be updated")
+p.add_option('--verbose','-v',action='store_true',help="noisy")
+options,arguments=p.parse_args()
+
+if len(arguments) > 0:
+	filename=arguments.pop(0)
+else:
+	print usage
+	sys.exit(1)
+
+file=open(filename,'r')
+lines=file.readlines()
+file.close()
+
+discard_trailing_whitespace=re.compile(" +$")
+extract_comment=re.compile(".*# +")
+discard_comment=re.compile(" *#.*")
+
+listlines=lines
+total=0
+for line in listlines:
+	line=line.strip('\n')
+	if len(line) > 0:
+		line=discard_trailing_whitespace.sub("",line)
+		fullline=line
+		comment=extract_comment.sub("",line)
+		line=discard_comment.sub("",line)
+		testfile=line
+		if len(testfile) > 0:
+			print testfile
+			total+=1
+		else:
+			print fullline
+
+count=0
+for line in lines:
+	line=line.strip('\n')
+	line=discard_trailing_whitespace.sub("",line)
+	comment=extract_comment.sub("",line)
+	line=discard_comment.sub("",line)
+	testfile=line
+
+	if len(testfile) > 0:
+		count+=1
+		command="./update_baseline.py "+testfile
+		print command
+		os.system(command)
+		command="./update_baseline.py --pdf "+testfile
+		print command
+		os.system(command)
+
+sys.exit(0)


Property changes on: trunk/gs/toolbin/tests/updatelist.py
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/gs/toolbin/tests/updatelistpdf.py
===================================================================
--- trunk/gs/toolbin/tests/updatelistpdf.py	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/updatelistpdf.py	2007-04-16 14:45:42 UTC (rev 7854)
@@ -0,0 +1,56 @@
+#!/usr/bin/python
+
+import sys, os, re, datetime, optparse
+
+myself=sys.argv[0]
+usage="USAGE: %prog [options] filename"
+p=optparse.OptionParser(usage=usage)
+p.add_option('--file','-f',action='store',type="string",help="filename: name of the file with a list of testfiles to be updated")
+p.add_option('--verbose','-v',action='store_true',help="noisy")
+options,arguments=p.parse_args()
+
+if len(arguments) > 0:
+	filename=arguments.pop(0)
+else:
+	print usage
+	sys.exit(1)
+
+file=open(filename,'r')
+lines=file.readlines()
+file.close()
+
+discard_trailing_whitespace=re.compile(" +$")
+extract_comment=re.compile(".*# +")
+discard_comment=re.compile(" *#.*")
+
+listlines=lines
+total=0
+for line in listlines:
+	line=line.strip('\n')
+	if len(line) > 0:
+		line=discard_trailing_whitespace.sub("",line)
+		fullline=line
+		comment=extract_comment.sub("",line)
+		line=discard_comment.sub("",line)
+		testfile=line
+		if len(testfile) > 0:
+			print testfile
+			total+=1
+		else:
+			print fullline
+
+count=0
+for line in lines:
+	line=line.strip('\n')
+	line=discard_trailing_whitespace.sub("",line)
+	comment=extract_comment.sub("",line)
+	line=discard_comment.sub("",line)
+	testfile=line
+
+	if len(testfile) > 0:
+		count+=1
+		command="./update_baseline.py --pdf "+testfile
+		print command
+		os.system(command)
+
+sys.exit(0)


Property changes on: trunk/gs/toolbin/tests/updatelistpdf.py
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/gs/toolbin/tests/validate.py
===================================================================
--- trunk/gs/toolbin/tests/validate.py	2007-04-16 11:02:19 UTC (rev 7853)
+++ trunk/gs/toolbin/tests/validate.py	2007-04-16 14:45:42 UTC (rev 7854)
@@ -0,0 +1,76 @@
+#!/usr/bin/env python
+# -*- Mode: python -*-
+
+import sys, os, anydbm
+import optparse,myoptparse
+import gsconf, gsparamsets
+
+def validate(options):
+    print "%20s %s" % ( "root",gsconf.root)
+
+    print "%20s %s" % ( "gsroot",gsconf.gsroot)
+    print "%20s %s" % ( "installtree",gsconf.installtree)
+    print "%20s %s" % ( "comparefiledir",gsconf.comparefiledir)
+    print "%20s %s" % ( "comparefileall",gsconf.comparefileall)
+    print "%20s %s" % ( "crashfiledir",gsconf.crashfiledir)
+    print "%20s %s" % ( "codedir",gsconf.codedir)
+    print "%20s %s" % ( "datadir",gsconf.datadir)
+    print "%20s %s" % ( "logdir",gsconf.logdir)
+    print "%20s %s" % ( "testdir",gsconf.testdir)
+    print "%20s %s" % ( "dailydir",gsconf.dailydir)
+    print "%20s %s" % ( "rasterdbdir",gsconf.rasterdbdir)
+    print "%20s %s" % ( "rasterdir",gsconf.rasterdir)
+    print "%20s %s" % ( "fontdir",gsconf.fontdir)
+    print "%20s %s" % ( "workdir",gsconf.workdir)
+
+
+    print
+    print "email"
+    print "%20s %s" % ( "report_to",gsconf.report_to)
+    print "%20s %s" % ( "report_from",gsconf.report_from)
+
+    print
+    print "comparefiles"
+    comparefiles = os.listdir(gsconf.comparefiledir)
+    comparefiles.sort()
+    count=len(comparefiles)
+    print "comparefiles: file count",count
+    if options.verbose:
+        for comparefile in comparefiles:
+            print comparefile
+
+    print
+    print "rasterfiles"
+    rasterfiles = os.listdir(gsconf.rasterdir)
+    rasterfiles.sort()
+    count=len(rasterfiles)
+    print "rasterfiles:   file  count",count
+
+    print
+    print "rasterfile checksum db"
+    db = anydbm.open(gsconf.baselinedb, 'r')
+    keys=db.keys()
+    keys.sort()
+    db.close()
+
+    count=len(keys)
+    
+    print "rasterfile db: entry count",count
+
+    print
+    print "gsparamsets name",gsparamsets.testparamsets_name
+    if options.verbose:
+        for params in gsparamsets.testparamsets:
+            print params.device, params.resolution, params.banding
+
+        for params in gsparamsets.pdftestparamsets:
+            print params.device, params.resolution, params.banding,"pdfwrite"
+
+    print
+
+
+if __name__ == "__main__":
+    optionsParser=optparse.OptionParser()
+    (options,arguments)=myoptparse.parseCommandLine(optionsParser)
+
+    validate(options)


Property changes on: trunk/gs/toolbin/tests/validate.py
___________________________________________________________________
Name: svn:executable
   + *



More information about the gs-cvs mailing list