Fix makefile and directory where the tests are run
authorMichal Sojka <sojkam1@fel.cvut.cz>
Fri, 3 Dec 2010 23:34:37 +0000 (00:34 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Fri, 3 Dec 2010 23:34:37 +0000 (00:34 +0100)
gw-tests/Makefile
gw-tests/genhtml/genhtml.py
gw-tests/lib.sh

index d496337..9819160 100644 (file)
@@ -16,4 +16,4 @@ plot:
 
 .PHONY: html
 html:
-       ./genhtml.py results
+       ./genhtml/genhtml.py results
index 90c4e5f..08a6dac 100755 (executable)
@@ -7,150 +7,150 @@ import urllib
 
 class DimValue:
     def __init__(self, dim, value):
-        self.dim = dim
-        self.value = value
+       self.dim = dim
+       self.value = value
     def __repr__(self):
-        return repr(self.value)
+       return repr(self.value)
     def htmlLabel(self):
-        return self.dim.htmlLabel(self.value)
+       return self.dim.htmlLabel(self.value)
 
 class Dimension(dict):
     def __init__(self, atype, name=None):
-        self.type = atype
-        if (name):
-            self.name = name
-        else:
-            self.name = atype            
+       self.type = atype
+       if (name):
+           self.name = name
+       else:
+           self.name = atype
 
     def __iter__(self):
-        keys = self.keys()
-        keys.sort()
-        for k in keys:
-            yield self[k]
+       keys = self.keys()
+       keys.sort()
+       for k in keys:
+           yield self[k]
 
     def addValue(self, *values):
-        for value in values:
-            if value not in self:
-                self[value] = DimValue(self, value)
+       for value in values:
+           if value not in self:
+               self[value] = DimValue(self, value)
     def htmlLabel(self, v):
-        return v
+       return v
 
 class DimensionKern(Dimension):
     def __init__(self):
-        Dimension.__init__(self, 'kern', 'Kernel')
+       Dimension.__init__(self, 'kern', 'Kernel')
     def htmlLabel(self, v):
-        i=v.find(":")
-        if i>0: kver=v[:i]
-        else: kver=v
-        return v+"<br><a href='config-%s'>config</a>"%(urllib.quote(kver))
+       i=v.find(":")
+       if i>0: kver=v[:i]
+       else: kver=v
+       return v+"<br><a href='config-%s'>config</a>"%(urllib.quote(kver))
     def versions(self):
-        for v in self.values:
-            i=v.find(":")
-            if i>0: kver=v[:i]
-            else: kver=v
-            yield kver
-        
+       for v in self.values:
+           i=v.find(":")
+           if i>0: kver=v[:i]
+           else: kver=v
+           yield kver
+
 class DimensionTest(Dimension):
     def __init__(self):
-        Dimension.__init__(self, 'test', 'Test')
+       Dimension.__init__(self, 'test', 'Test')
     def htmlLabel(self, v):
-        return v+"<br><a href='%s.sh.html'>source</a>"%(urllib.quote(v))
+       return v+"<br><a href='%s.sh.html'>source</a>"%(urllib.quote(v))
 
 class Test:
     @classmethod
     def isOnPath(cls, path):
-        f = os.path.join(path, 'plot.gp')
-        return os.path.isfile(f)
+       f = os.path.join(path, 'plot.gp')
+       return os.path.isfile(f)
     def __init__(self, path):
-        self.path = path
+       self.path = path
     def printThumbLink(self, file):
-        for img in dircache.listdir(self.path+'/thumb'):
-            print >>file, "<a href='%s/%s'><img src='%s/thumb/%s'></a>" % \
-                (urllib.quote(self.path), img, urllib.quote(self.path), img)
+       for img in dircache.listdir(self.path+'/thumb'):
+           print >>file, "<a href='%s/%s'><img src='%s/thumb/%s'></a>" % \
+               (urllib.quote(self.path), img, urllib.quote(self.path), img)
 
 def iterDimValues(dimensions):
     idx = [0 for i in xrange(len(dimensions))]
     done=False
     while not done:
-        values=[]
-        for i in xrange(len(dimensions)):
-            values.append(dimensions[i].values()[idx[i]])
-        yield values
-        done=True
-        for i in xrange(len(dimensions)):
-            idx[i] += 1
-            if idx[i] < len(dimensions[i]):
-                done=False
-                break
-            idx[i] = 0
+       values=[]
+       for i in xrange(len(dimensions)):
+           values.append(dimensions[i].values()[idx[i]])
+       yield values
+       done=True
+       for i in xrange(len(dimensions)):
+           idx[i] += 1
+           if idx[i] < len(dimensions[i]):
+               done=False
+               break
+           idx[i] = 0
 
 class Tests(dict):
     """Represents all tests organized along several dimensions"""
     def __init__(self, rootpath, *dimensions):
-        dict.__init__(self)
-        self.dimensions = dimensions
-        if (rootpath):
-            self.populate(rootpath)
+       dict.__init__(self)
+       self.dimensions = dimensions
+       if (rootpath):
+           self.populate(rootpath)
     def getTest(self, key):
-        realkey=[]
-        for d in self.dimensions:
-            for i in key:
-                if i.dim == d:
-                    realkey.append(i.value)
-        if len(realkey) != len(self.dimensions):
-            raise KeyError("The coordinates in key do not match dimensions")
-        return self[tuple(realkey)]
-        
+       realkey=[]
+       for d in self.dimensions:
+           for i in key:
+               if i.dim == d:
+                   realkey.append(i.value)
+       if len(realkey) != len(self.dimensions):
+           raise KeyError("The coordinates in key do not match dimensions")
+       return self[tuple(realkey)]
+
     def addTest(self, test, coordinates):
-        if len(coordinates) != len(self.dimensions):
-            raise KeyError("The number coordinates do not match the number of dimensions")
-        self[tuple(coordinates)] = test
-        for i in xrange(len(coordinates)):
-            self.dimensions[i].addValue(coordinates[i])
+       if len(coordinates) != len(self.dimensions):
+           raise KeyError("The number coordinates do not match the number of dimensions")
+       self[tuple(coordinates)] = test
+       for i in xrange(len(coordinates)):
+           self.dimensions[i].addValue(coordinates[i])
 
     def populate(self, rootpath):
-        for root, dirs, files in os.walk(rootpath):
-            if (root.find(rootpath) == 0):
-                coordinates = root[len(rootpath):]
-            else:
-                coordinates = rootpath
-            if Test.isOnPath(root):
-                self.addTest(Test(root), coordinates.split("/"))
+       for root, dirs, files in os.walk(rootpath):
+           if (root.find(rootpath) == 0):
+               coordinates = root[len(rootpath):]
+           else:
+               coordinates = rootpath
+           if Test.isOnPath(root):
+               self.addTest(Test(root), coordinates.split("/"))
     def iterDimensionPairs(self):
-        for i in xrange(len(self.dimensions)):
-            for j in xrange(i+1, len(self.dimensions)):
-                yield (self.dimensions[i], self.dimensions[j])
-                yield (self.dimensions[j], self.dimensions[i])
+       for i in xrange(len(self.dimensions)):
+           for j in xrange(i+1, len(self.dimensions)):
+               yield (self.dimensions[i], self.dimensions[j])
+               yield (self.dimensions[j], self.dimensions[i])
     def iterRemainingDimensions(self, dimensionPair):
-        for d in self.dimensions:
-            if d not in dimensionPair:
-                yield d
+       for d in self.dimensions:
+           if d not in dimensionPair:
+               yield d
     def generateHtml(self):
-        for pair in self.iterDimensionPairs():
-            remdims = [d for d in self.iterRemainingDimensions(pair)]
-            for vals in iterDimValues(remdims):
-                page = Page(pair, remdims, vals, self)
-                page.generate()
-        try:
-            os.remove("index.html")
-        except OSError: pass
-        os.symlink(page.getName(), "index.html")
-
-        os.system("source-highlight -d --output-dir=. ../*.sh")
+       for pair in self.iterDimensionPairs():
+           remdims = [d for d in self.iterRemainingDimensions(pair)]
+           for vals in iterDimValues(remdims):
+               page = Page(pair, remdims, vals, self)
+               page.generate()
+       try:
+           os.remove("index.html")
+       except OSError: pass
+       os.symlink(page.getName(), "index.html")
+
+       os.system("source-highlight -d --output-dir=. ../*.sh")
 
 class Page:
     def __init__(self, dimPair, dimOther, valsOther, tests):
-        self.dimy, self.dimx = dimPair
-        self.dimOther = dimOther
-        self.valsOther = valsOther
-        self.tests = tests
+       self.dimy, self.dimx = dimPair
+       self.dimOther = dimOther
+       self.valsOther = valsOther
+       self.tests = tests
     def getName(self):
-        return "%s-vs-%s-%s.html"%(self.dimy.type, self.dimx.type, "-".join([v.value for v in self.valsOther]))
+       return "%s-vs-%s-%s.html"%(self.dimy.type, self.dimx.type, "-".join([v.value for v in self.valsOther]))
     def generate(self):
-        html = open(self.getName(), "w")
-        title = "CAN gateway timing analysis" + ", ".join([v.dim.name+" "+v.value for v in self.valsOther])
-        print >> html, """<html>
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
+       html = open(self.getName(), "w")
+       title = "CAN gateway timing analysis" + ", ".join([v.dim.name+" "+v.value for v in self.valsOther])
+       print >> html, """<html>
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
 <title>%s</title>
 <style>
@@ -161,8 +161,8 @@ th, td { border: 1px solid lightgray; padding: 4px;}
 </head>
 <body>
 <h1>%s</h1>"""  % (title, title)
-        for d in self.dimOther:
-            pass
+       for d in self.dimOther:
+           pass
 #             print >>html, "View for %s: " % str(ps.pageclass.name)
 #             for v in ps.values:
 #                 print >>html, "<a href='%s-%s.html'>%s</a> | "%(ps.values.type, urllib.quote(v), v)
@@ -172,22 +172,22 @@ th, td { border: 1px solid lightgray; padding: 4px;}
 #             except Exception:
 #                 pass
 
-        print >>html, "<table><thead><tr><td> </td>"
-        for x in self.dimx:
-            print >>html, "<th>%s</th>" % x.htmlLabel()
-        print >>html, "</tr></thead>"
-        for y in self.dimy:
-            print >>html, "<tr><th>%s</th>" % y.htmlLabel()
-
-            for x in self.dimx:
-                print >>html, "<td>"
-                idx = [x,y]
-                idx.extend(self.valsOther)
-                test = tests.getTest(idx)
-                test.printThumbLink(html)
-                print >>html, "</td>"
-            print >>html, "</tr>"
-        print >> html, """
+       print >>html, "<table><thead><tr><td> </td>"
+       for x in self.dimx:
+           print >>html, "<th>%s</th>" % x.htmlLabel()
+       print >>html, "</tr></thead>"
+       for y in self.dimy:
+           print >>html, "<tr><th>%s</th>" % y.htmlLabel()
+
+           for x in self.dimx:
+               print >>html, "<td>"
+               idx = [x,y]
+               idx.extend(self.valsOther)
+               test = tests.getTest(idx)
+               test.printThumbLink(html)
+               print >>html, "</td>"
+           print >>html, "</tr>"
+       print >> html, """
 </table>
 <div style="font-size: small; color: gray; margin-top: 1em;">Authors: Michal Sojka, Pavel Píša, Copyright © 2010 Czech Technical University in Prague</div>
 </body>
@@ -199,4 +199,3 @@ if __name__ == "__main__":
     tests = Tests("by-kern/", DimensionKern(), DimensionTest())
     tests.generateHtml()
     sys.exit(0)
-
index 46031a4..5d3507f 100644 (file)
@@ -122,6 +122,7 @@ _run() {
        if [[ ! "$OPT_PLOT_DISABLE" ]]; then
            _plot
        fi
+       cd -
     done
     done
 }