Author: sebastien.lelong
Date: Wed Nov 19 08:03:05 2008
New Revision: 578

Added:
    trunk/tools/jallib_matrix_generate.sh   (contents, props changed)
    trunk/tools/test_result.tmpl
    trunk/unvalidated/doc/html/tests/
Modified:
    trunk/tools/Makefile
    trunk/tools/jallib.py
    trunk/tools/testing_matrix.tmpl
    trunk/unvalidated/sample/testing_matrix.yaml

Log:
generate matrix page + dedicated test result pages for each PIC + add a  
prune option: if sample does not exist, removed from the matrix

Modified: trunk/tools/Makefile
==============================================================================
--- trunk/tools/Makefile        (original)
+++ trunk/tools/Makefile        Wed Nov 19 08:03:05 2008
@@ -50,6 +50,9 @@
  doc:
        ./jalapi_generate.sh ../${ENV}

+matrix:
+       ./jallib_matrix_generate.sh ../${ENV}
+
  export:
        # prepare distrib dir
        mkdir distrib

Modified: trunk/tools/jallib.py
==============================================================================
--- trunk/tools/jallib.py       (original)
+++ trunk/tools/jallib.py       Wed Nov 19 08:03:05 2008
@@ -454,6 +454,7 @@
                sys.exit(255)
        
        do_update = False
+       do_prune = False
        do_generate = False
        do_add = False
        do_delete = False
@@ -464,16 +465,19 @@
        sample_dir = None
        test_str = None
        tmpl_file = None
+       tmpl_file_pic = None
        html_file = None
        pic = None
        outfile = None
-       only_passed = False
+       only_tested = False
        each_pic_tmpl = None
        selected_pics = None
        sub_matrix = None
        for o,v in opts:
                if o == '-u':
                        do_update = True
+               elif o == '-e':
+                       do_prune = True
                elif o == '-a':
                        do_add = True
                        test_str = v
@@ -484,9 +488,12 @@
                        sample_dir = v
                elif o == '-f':
                        outfile = v
-               elif o == '-g':
+               elif o == '-G':
                        do_html = True
                        tmpl_file = v
+               elif o == '-g':
+                       do_html = True
+                       tmpl_file_pic = v
                elif o == '-o':
                        got_html = True
                        html_file = v
@@ -494,7 +501,7 @@
                        do_print = True
                        pic = v
                elif o == '-1':
-                       only_passed = True
+                       only_tested = True
                elif o == '-t':
                        each_pic_tmpl = v
                elif o == '-n':
@@ -514,6 +521,8 @@
                sample_dir = os.environ.get('JALLIB_SAMPLEDIR',os.path.curdir)
        if do_update:
                update_testing_matrix(sample_dir,outfile,selected_pics)
+       elif do_prune:
+               prune_testing_matrix(sample_dir,outfile,selected_pics)
        elif do_add:
                add_update_test(test_str,outfile,sample_dir)
        elif do_delete:
@@ -523,7 +532,7 @@
        elif do_html:
                if not got_html:
                        html_file = ".".join(tmpl_file.split(".")[:-1]) + 
".html"
-                
generate_html(tmpl_file,html_file,outfile,sample_dir,only_passed,each_pic_tmpl)
+                
generate_html(tmpl_file,tmpl_file_pic,html_file,outfile,sample_dir,only_tested,each_pic_tmpl)
        elif do_print:
                display_test_results(pic,outfile)
        else:
@@ -556,7 +565,7 @@
                        if jalfile.startswith(".") or not 
jalfile.endswith(".jal"):
                                continue
                        matrix[device]['samples'].setdefault(jalfile,{'pass' :  
None, 'revision' : None})
-       
+
        def analyse_sampledir(dir):
                if not "by_device" in os.listdir(dir):
                        print >> sys.stderr, "Sample dir '%s' does not contain 
'by_device'  
map." % dir
@@ -607,11 +616,28 @@
                                else:
                                        print >> sys.stderr, "Compilation 
failed for test '%s' with pic '%s'  
(status=%s)" % (test,pic,status)

+
        analyse_sampledir(sample_dir)
        analyse_testdir(sample_dir)
        
        save_matrix(matrix,outfile)

+def prune_testing_matrix(sample_dir,outfile,selected_pics=[]):
+       if not "by_device" in os.listdir(sample_dir):
+               print >> sys.stderr, "Sample dir '%s' does not contain 
'by_device'  
map." % bydevicedir
+               sys.exit(1)
+       bydevicedir = os.path.join(sample_dir,"by_device")
+
+       matrix = get_matrix(outfile)
+       pics = selected_pics and selected_pics or matrix.keys()
+       for pic in pics:
+               for s in matrix[pic]['samples'].keys():
+                       if not os.path.isfile(os.path.join(bydevicedir,pic,s)):
+                               print "PIC: %s, sample '%s' doesn't exist, 
removing from the  
matrix..." % (pic,s)
+                               del matrix[pic]['samples'][s]
+
+       save_matrix(matrix,outfile)
+

  def add_update_test(test_str,outfile,sample_dir):
        matrix = get_matrix(outfile)
@@ -706,24 +732,62 @@
                print >> sys.stderr, "Unable to delete '%s' from PIC %s, cannot 
 
find '%s'" % (testfile,pic,e)
                sys.exit(1)

+def get_meter_label(meter):
+       if meter < 0:
+               return "not supported"
+       elif meter == 0:
+          return "not tested"
+       elif meter <= 10:
+          return "poor"
+       elif meter <= 30:
+          return "risky"
+       elif meter <= 50:
+          return "average"
+       elif meter <= 60:
+          return "nice"
+       elif meter <= 70:
+          return "good"
+       elif meter <= 80:
+          return "very good"
+       elif meter <= 90:
+          return "awesome"
+       elif meter <= 100:
+          return "oh my..."
+       else:
+          return "can't be serious"
+
+def sample_stat(data):
+       true = false = none = 0
+       for what in ('samples','tests'):
+               true += len([s for s in data[what] if data[what][s]['pass'] == 
True])
+               false += len([s for s in data[what] if data[what][s]['pass'] == 
False])
+               none += len([s for s in data[what] if data[what][s]['pass'] == 
None])
+       return (true,false,none)
+
+def compute_meter(data):
+       sample_num = len(data['samples']) + len(data['tests'])
+       if sample_num == 0:
+          return 0.0
+       true,false,none = sample_stat(data)
+       print "true_samples: %s, false_samples: %s, none_samples: %s --- %s  
sample_num" % (true,false,none,sample_num)
+       note = ((float(true) - float(false)) / float(sample_num)) * 100.0
+       return note
+
+
  def find_includes(jalfile):
        content = file(jalfile).read()
        return re.findall("^\s*include\s+(\w+)\s*",content,re.MULTILINE)


-def  
generate_html(tmpl_file,html_file,outfile,sample_dir,only_passed=False,for_each_pic_tmpl=None):
+def  
generate_html(tmpl_file,tmpl_file_pic,html_file,outfile,sample_dir,only_tested=False,for_each_pic_tmpl=None):
        if not has_cheetah:
                print >> sys.stderr, "You can't use this action, because 
cheetah module  
is not installed"
                sys.exit(255)
                
        matrix = get_matrix(outfile)
-       tmplsrc = "".join(file(tmpl_file,"r").readlines())
-       klass = Cheetah.Template.Template.compile(tmplsrc)
-       tmpl = klass()
-
        # TODO
+       newtr = {}
        for pic,res in matrix.items():
-               newtr = {}
                libs = {True : [], False : [], None: []}
                # build libds list for all samples attached to this PIC
                # and also a list of libs for each samples
@@ -740,15 +804,41 @@
                # unique
                for k in libs.keys():
                        libs[k] = list(set(libs[k]))
-               if only_passed and len(libs[True]) == 0:
+               if only_tested and len(libs[True]) == 0 and len(libs[False]) == 
0:
                        continue
                else:
-                       matrix[pic]['libs'] = libs
+                       newtr[pic] = res
+                       newtr[pic]['libs'] = libs

-       tmpl.test_results = matrix
+       # generate global matrix
+       tmplsrc = "".join(file(tmpl_file,"r").readlines())
+       klass = Cheetah.Template.Template.compile(tmplsrc)
+       tmpl = klass()
+       tmpl.test_results = newtr
+       tmpl.sample_stat = sample_stat
+       tmpl.compute_meter = compute_meter
+       tmpl.get_meter_label = get_meter_label
        fout = file(html_file,"w")
        print >> fout, tmpl.main()

+       # then dedicated page
+       if tmpl_file_pic:
+               outdir = os.path.dirname(html_file)
+               tmplsrc = "".join(file(tmpl_file_pic,"r").readlines())
+               klass = Cheetah.Template.Template.compile(tmplsrc)
+               tmpl2 = klass()
+               for pic,res in newtr.items():
+                       tmpl2.sample_stat = sample_stat
+                       tmpl2.compute_meter = compute_meter
+                       tmpl2.get_meter_label = get_meter_label
+                       tmpl2.data = res
+                       print "res: %s" % res
+                       tmpl2.picname = pic
+                       fout = file(os.path.join(outdir,"test_%s.html" % 
pic),"w")
+                       print >> fout, tmpl2.main()
+               
+               
+
  def display_test_results(pic,outfile):
        matrix = get_matrix(outfile)
        try:
@@ -933,6 +1023,11 @@
          tests are not relevant to all target chips). This won't erase
          previous testing results, but will potentially add new sample
          lines to the testing matrix file.
+       
+       -e: erase samples which are declared in the matrix, but don't exist
+               anymore on the filesystem/repository. Ex: when samples are 
renamed
+               the matrix needs to be updated (-u) to include renamed samples,
+               then it needs to be pruned (-e) to remove old samples.

      -a: add or update a test result. If the test does not exist, it's
          added to the matrix, else results will be updated.
@@ -970,18 +1065,22 @@
          are comma separated. Ex:
              -n 16f88,16f877,16f877a

-    -g: generate HTML a testing matrix from tests results, and dedicated
+    -G: generate HTML a testing matrix from tests results, and dedicated
          test result pages for each PIC, from both samples and tests.

+    -g: generate all dedicated test results page for each PIC
+
      -1: only generate testing matrix for PIC which have at least one test
-        passed.
+        executed, whether passed or failed.

      -t: also generate dedidated test result pages for each PIC, using given
          template. The output file will be named as: test_<picname>.html
          (not implemented yet)

-    -o: specify output HTML file. Used with -g option. If omitted, will be
+    -o: specify output HTML file. Used with -G option. If omitted, will be
          named the same as the template file, with ".html" extension
+        If -g is also specified, then param's dirname will be used to  
produre html
+        files for each PICs.

      -f: file storing the testing matrix results. YAML formatted. If not
          specified, will look for a JALLIB_MATRIX environment variable.
@@ -1008,7 +1107,7 @@
  ACTIONS = {
                'compile'       : {'callback' : do_compile, 'options' : 'R:E:', 
'help' :  
compile_help},
                'validate'      : {'callback' : do_validate, 'options' : '', 
'help' :  
validate_help},
-               'test'          : {'callback' :  
do_test, 'options' : 's:uf:a:g:d:o:p:t:1n:m:', 'help' : test_help},
+               'test'          : {'callback' :  
do_test, 'options' : 's:uef:a:G:g:d:o:p:t:1n:m:', 'help' : test_help},
                'help'          : {'callback' : do_help, 'options' : '', 'help' 
: None},
                'license'       : {'callback' : do_license, 'options' : '', 
'help' : None},
                'sample'        : {'callback' : do_sample, 'options' : 
'b:t:o:', 'help' : None},

Added: trunk/tools/jallib_matrix_generate.sh
==============================================================================
--- (empty file)
+++ trunk/tools/jallib_matrix_generate.sh       Wed Nov 19 08:03:05 2008
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+ROOT=$1
+TESTSDIR=$ROOT/doc/html/tests
+DOCDIR="$ROOT/doc"
+
+python jallib.py -f testing_matrix.yaml -G testing_matrix.tmpl  -g  
test_result.tmpl -o $TESTSDIR/index.html
+
+for htmlfile in `ls $TESTSDIR/*.html`
+do
+   notinsvn=`svn st $htmlfile| grep -c ^?`
+   if [ "X$notinsvn" = "X1" ]
+   then
+         svn add $htmlfile
+   fi
+   svn ps svn:mime-type text/html $htmlfile #> /dev/null 2>&1
+done
+
+

Added: trunk/tools/test_result.tmpl
==============================================================================
--- (empty file)
+++ trunk/tools/test_result.tmpl        Wed Nov 19 08:03:05 2008
@@ -0,0 +1,132 @@
+##
+## Title: template for test result page (per PIC)
+## Author: Sebastien Lelong, Copyright (c) 2008, all rights reserved.
+## Adapted-by:
+## Compiler:
+##
+## This file is part of jallib (http://jallib.googlecode.com)
+## Released under the BSD license  
(http://www.opensource.org/licenses/bsd-license.php)
+##
+## Description: template to create test results page for each PIC
+##
+
+#def header
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
+<html>
+        <head>
+        </head>
+        <body>
+        <h1>$picname.upper() test results</h1>
+#end def
+
+#def device
+       <h3>Device file</h3>
+       <i>some details about device files</i>
+#end def
+
+#def meter
+   #set note = int($compute_meter($data))
+   #set label = $get_meter_label($note)
+       <h3>Jallib-O-Meter</h3>
+   <img  
src="http://chart.apis.google.com/chart?chs=225x125&cht=gom&chd=t:$note&chl=$label&nonsense=t${picname}.png"/>
+#end def
+
+#def liboverview
+       #set true_libs = set($data['libs'][True])
+       #set none_libs = set($data['libs'][None]).difference(true_libs)
+       #set false_libs =  
set($data['libs'][False]).difference(none_libs).difference(true_libs)
+       <h3>Libraries involved in tests</h2>
+       <table width="50%" border="1">
+       <tr valign="top">
+               <td><b>success</b></td>
+               #set disp = ", ".join(sorted(true_libs))
+               <td><span style="color:green;">$disp</span></td>
+       </tr>
+       <tr valign="top">
+               <td><b>untested</b></td>
+               #set disp = ", ".join(sorted(none_libs))
+               <td><span style="color:blue;">$disp</span></td>
+       </tr>
+       <tr valign="top">
+               <td><b>failed</b></td>
+               #set disp = ", ".join(sorted(false_libs))
+               <td><span style="color:red;">$disp</span></td>
+       </tr>
+       </table>
+#end def
+
+#def testoverview
+       <h3>Tests overview</h3>
+       #set true,false,none = $sample_stat($data)
+       #set sample_num = sum([true,false,none])
+       <table>
+       <tr>
+               <td width="1%" align="right"><b>$sample_num</b></td>
+               <td>samples available for this chip</td>
+       </tr>
+       <tr>
+               <td width="1%" align="right"><span 
style="color:green;">$true</span></td>
+               <td>sample(s) successfully tested</td>
+       </tr>
+       <tr>
+               <td width="1%" align="right"><span 
style="color:blue;">$none</span></td>
+               <td>sample(s) not tested yet</td>
+       </tr>
+       <tr>
+               <td width="1%" align="right"><span 
style="color:red;">$false</span></td>
+               <td>sample(s) failed</td>
+       </tr>
+       </table>
+#end def
+
+#def summary
+       <h2>Summary</h2>
+       <table>
+       <tr valign="top"><td>$meter</td><td>$testoverview</td></tr>
+       <tr><td colspan="2">$liboverview</td></tr>
+       <tr><td colspan="2">$device</td></tr>
+       </table>
+#end def
+
+#def details
+       <h2>Details</h2>
+       <table>
+       <tr>
+               <th>Test file</th>
+               <th>Result (revision)</th>
+               <th>Used libraries</th>
+       </tr>
+       #for name,res in sorted($data['samples'].items(),cmp=lambda x,y:  
cmp(x[0],y[0]))
+       <tr>
+               <td>$name</td>
+               #set disp = ", ".join(res['libs'])
+               #set rev = res['revision'] or "unknown"
+               #set tpass = '<span style="color:blue;">???</span>'
+               #if res['pass'] is True
+                       #silent tpass = '<span style="color:green;">OK</span>'
+               #elif res['pass'] is False
+                       #silent tpass = '<span style="color:red;">KO</span>'
+               #end if
+               <td>$tpass ($rev)</td>
+               <td>$disp</td>
+       </tr>
+       #end for
+       </table>
+#end def
+
+#def results
+   $summary
+   <br/>
+   $details
+#end def
+
+#def footer
+       </body>
+</html>
+#end def
+
+#def main
+   $header
+   $results
+   $footer
+#end def

Modified: trunk/tools/testing_matrix.tmpl
==============================================================================
--- trunk/tools/testing_matrix.tmpl     (original)
+++ trunk/tools/testing_matrix.tmpl     Wed Nov 19 08:03:05 2008
@@ -1,3 +1,14 @@
+##
+## Title: template for testing matrix
+## Author: Sebastien Lelong, Copyright (c) 2008, all rights reserved.
+## Adapted-by:
+## Compiler:
+##
+## This file is part of jallib (http://jallib.googlecode.com)
+## Released under the BSD license  
(http://www.opensource.org/licenses/bsd-license.php)
+##
+## Description: template to create the main testing matrix
+##

  #def header
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
@@ -5,56 +16,7 @@
         <head>
         </head>
         <body>
-#end def
-
-#def get_meter_label(meter)
-       #silent print "met:er %s" % repr(meter)
-       #if meter < 0
-               #return "not supported"
-       #elif meter == 0
-               #return "not tested"
-       #elif meter <= 10
-               #return "poor"
-       #elif meter <= 30
-               #return "risky"
-       #elif meter <= 50
-               #return "average"
-       #elif meter <= 60
-               #return "nice"
-       #elif meter <= 70
-               #return "good"
-       #elif meter <= 80
-               #return "very good"
-       #elif meter <= 90
-               #return "awesome"
-       #elif meter <= 100
-               #return "oh my..."
-       #else
-               #return "can't be serious"
-       #end if
-#end def
-
-#def sample_stat(data)
-       #set true = false = none = 0
-       #for what in ('samples','tests')
-               #silent true += len([s for s in data[what] if 
data[what][s]['pass'] ==  
True])
-               #silent false += len([s for s in data[what] if 
data[what][s]['pass'] ==  
False])
-               #silent none += len([s for s in data[what] if 
data[what][s]['pass'] ==  
None])
-       #end for
-       #return (true,false,none)
-#end def
-
-#def compute_meter(data)
-       #silent print "data: %s" % data
-       #set sample_num = len(data['samples']) + len(data['tests'])
-       #if sample_num == 0
-               #return 0.0
-       #end if
-       #set true,false,none = $sample_stat(data)
-       #silent print "true_samples: %s, false_samples: %s, none_samples: %s  
--- %s sample_num" % (true,false,none,sample_num)
-       #set note = ((float(true) - float(false)) / float(sample_num)) * 100.0
-       #silent print "note: %s" % note
-       #return note
+        <h1>jallib testing matrix</h1>
  #end def

  #def matrix
@@ -101,16 +63,38 @@
                </td>
        </tr>
        #end for
+       </table>
        
  #end def

  #def footer
+       <br>
+       <div align="right"><a href="http://jallib.googlecode.com";>jallib --  
http://jallib.googlecode.com</a></div>
        </body>
  </html>
  #end def

+#def desc
+       <div>
+               The following matrix shows tests performed on several target 
chips.<br/>
+               Clicking on a <b>PIC</b> name will display a detailed test 
result page,  
if available.<br/>
+               The <b>testing meter</b> is approximate measure showing how 
fully tested  
a PIC is.<br/>
+               Finally, the <b>libraries</b> shows the <span style="color:  
green;">successfully tested</span>,<br/>
+               the <span style="color:blue;">not yet tested</span> and <span  
style="color:red;">failed</span> libraries.
+       </div>
+       <br/>
+       <div>
+               <i>If your favorite PIC isn't tested yet, and poorly tested, <a 
 
href="http://groups.google.com/group/jallib";>join us</a><br/>
+               and help up improve jallib. We'll provide some test files so 
you can  
give a try a report test results.</i>
+       </div>
+       <br/>
+
+
+#end def
+
  #def main
     $header
+   $desc
     $matrix
     $footer
  #end def

Modified: trunk/unvalidated/sample/testing_matrix.yaml
==============================================================================
--- trunk/unvalidated/sample/testing_matrix.yaml        (original)
+++ trunk/unvalidated/sample/testing_matrix.yaml        Wed Nov 19 08:03:05 2008
@@ -316,8 +316,6 @@
    samples:
      blink_16f877.jal: {pass: null, revision: null}
      lcd_format_st7036.jal: {pass: null, revision: null}
-    lcd_hd44780_tmp_4_line.jal: {pass: null, revision: null}
-    lcd_hd44780_tmp_8_line.jal: {pass: null, revision: null}
      lcd_st7036_and_rtc_ds1302.jal: {pass: null, revision: null}
    tests: {}
  16f877a:
@@ -325,10 +323,12 @@
      blink_16f877a.jal: {pass: null, revision: null}
      hello_world_lcd.jal: {pass: true, revision: null}
      keyboard_lcd.jal: {pass: null, revision: null}
-    lcd_format.jal: {pass: true, revision: null}
      print_serial_numbers.jal: {pass: true, revision: null}
      pwm_led.jal: {pass: true, revision: null}
-    read_co2_t6603.jal: {pass: null, revision: null}
+    sample_co2_t6603.jal: {pass: null, revision: null}
+    sample_lcd_format.jal: {pass: null, revision: null}
+    sample_rtc_lcd.jal: {pass: null, revision: null}
+    sample_rtc_timeset.jal: {pass: null, revision: null}
    tests:
      test_blink.jal: {pass: null, revision: null}
      test_i2c_hw_l0.jal: {pass: null, revision: null}

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/jallib?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to