Revision: 1359 Author: [email protected] Date: Mon Sep 28 15:23:55 2009 Log: Moved part of unittest script to picshell fix seven_segment comment in test file so sample is generated properly http://code.google.com/p/jallib/source/detail?r=1359
Modified: /trunk/sample/16f877a_seven_segment.jal /trunk/sample/18f4550_seven_segment.jal /trunk/test/external/seven_segment/test_seven_segment.jal /trunk/tools/jallib.py ======================================= --- /trunk/sample/16f877a_seven_segment.jal Sun Sep 20 15:28:01 2009 +++ /trunk/sample/16f877a_seven_segment.jal Mon Sep 28 15:23:55 2009 @@ -10,7 +10,7 @@ -- This file is part of jallib (http://jallib.googlecode.com) -- Released under the BSD license (http://www.opensource.org/licenses/bsd-license.php) -- --- Description: Testing seven segment LED display +-- Description: Testing seven segment LED display -- -- -- This file defines a test for JALLIB testing, using a test-board -- defined by a BOARD file . @@ -24,7 +24,7 @@ -- -- This file has been generated from: -- * board: board_16f877a_dwarf.jal --- * test : test_jseven.jal +-- * test : test_seven_segment.jal -- ;@jallib section chipdef ======================================= --- /trunk/sample/18f4550_seven_segment.jal Mon Sep 7 12:55:41 2009 +++ /trunk/sample/18f4550_seven_segment.jal Mon Sep 28 15:23:55 2009 @@ -10,7 +10,7 @@ -- This file is part of jallib (http://jallib.googlecode.com) -- Released under the BSD license (http://www.opensource.org/licenses/bsd-license.php) -- --- Description: Testing lcd_backlight +-- Description: Testing seven segment LED display -- -- -- This file defines a test for JALLIB testing, using a test-board -- defined by a BOARD file . ======================================= --- /trunk/test/external/seven_segment/test_seven_segment.jal Tue Aug 18 06:11:06 2009 +++ /trunk/test/external/seven_segment/test_seven_segment.jal Mon Sep 28 15:23:55 2009 @@ -10,7 +10,7 @@ -- This file is part of jallib (http://jallib.googlecode.com) -- Released under the BSD license (http://www.opensource.org/licenses/bsd-license.php) -- --- Description: Testing lcd_backlight +-- Description: Testing seven segment LED display -- -- -- This file defines a test for JALLIB testing, using a test-board -- defined by a BOARD file . ======================================= --- /trunk/tools/jallib.py Sun Sep 27 01:43:43 2009 +++ /trunk/tools/jallib.py Mon Sep 28 15:23:55 2009 @@ -47,12 +47,6 @@ except ImportError: has_subprocess = False -try: - import picshell.engine.core.PicEngine - has_picshell = True -except ImportError: - has_picshell = False - ######### # TOOLS # @@ -762,81 +756,6 @@ # JALAPI FUNC # #-------------# -def picshell_unittest(jalFileName,asmFileName,hexFileName): - - if not has_picshell: - print >> sys.stderr, "Can't find PICShell libraries. Install PICShell and adjust PYTHONPATH" - sys.exit(255) - - # This piece of code is loosely based on PICShell implementation. - # This is a quick & dirty assembling :) - - from picshell.parser.JalV2AsmParser import JalV2AsmParser - from picshell.parser.AnnotationParser import AnnotationParser - from picshell.engine.core.PicThreadEngine import PicThreadEngine - from picshell.engine.core.PicEngine import PicEngine - from picshell.engine.core.State import State - from picshell.util.AssertUtil import AssertUtil - - from picshell.ui.UIManager import UIManager - - asmParser = JalV2AsmParser() - wholeCode = asmParser.parseAsmFile(asmFileName, []) - varTypeDict = JalV2AsmParser.buildVarTypeDict(wholeCode) - - parseRes = AnnotationParser.parse(file(jalFileName).read()) - noDebugList = parseRes["noDebug"] - debugList = parseRes["debug"] - langParser = JalV2AsmParser() - code = langParser.parseAsmFile(asmFileName, noDebugList,debugList) - - def unittest_callback(address,oracle): - line = langParser.adrToLine[address] - if line != None: - txt = code[line].line - if "@assertEquals" in txt: - res = AssertUtil.parse(txt) - var = res["var"].lower() - label = res["label"] - ref = res["ref"] - if (langParser.varAdrMapping.has_key("v_"+str(var))): - varAddr = langParser.varAdrMapping["v_"+str(var)] - varType = type = varTypeDict.get(var,'bit') - val = ui.varValue(varAddr,varType) - res= varType+" "+var+" (@"+str(varAddr)+") = 0x%X , expected : 0x%X" %(val,ref) - - print label, - if (ref == val) : - oracle['success'] += 1 - print ": OK" - else : - oracle['failure'] += 1 - print ": FAIL, %s != %s" % (ref,val) - else: - oracle['notrun'] += 1 - print "Can't run test '%s' because var '%s' can't be found" % (label,var) - - emu = PicEngine.newInstance(State(),hexFileName) - # needed to access varValue function - ui = UIManager() - ui.emu = emu - - # success failure notrun - oracle = {'success' : 0, 'failure' : 0, 'notrun' : 0} - def run(to,emu,unittest_callback): - current_address = emu.runNext() - while current_address != to: - #unit testing ? - if unittest_callback != None: - unittest_callback(current_address,oracle) - current_address = emu.runNext() - # last call on finishing address - unittest_callback(current_address,oracle) - - run(emu.lastAddress,emu,unittest_callback) - - return oracle - def unittest(filename,verbose=False): oracle = {'success' : None, 'failure' : None, 'notrun' : None} content = file(filename).read().splitlines() @@ -847,6 +766,8 @@ fout = file(fnout,"w") ferr = file(fnerr,"w") status = do_compile([filename],exitonerror=False,clean=False,stdout=fout,stderr=ferr) + fout.close() + ferr.close() except Exception,e: print >> sys.stderr, "Error while compiling file '%s': %s" % (filename,e) raise @@ -857,15 +778,30 @@ jal = filename asm = filename.replace(".jal",".asm") hex = filename.replace(".jal",".hex") - oracle = picshell_unittest(jal,asm,hex) + + try: + from picshell.console.picshell_unittest import picshell_unittest + oracle = picshell_unittest(jal,asm,hex) + except ImportError: + print >> sys.stderr, "Can't find PICShell libraries. Install PICShell and adjust PYTHONPATH" + sys.exit(255) + oracle['failure'] = 1 + else: oracle['failure'] = 1 finally: + fout = file(fnout) + ferr = file(fnerr) + clean_compiler_products(filename) + + fout.close() + ferr.close() if verbose: - print file(fnout).read() - print file(fnerr).read() + print fout.read() + print ferr.read() + os.unlink(fnout) os.unlink(fnerr) @@ -1274,8 +1210,7 @@ tests, several sections, which are assembled on the fly (something like board/test files producing samples) -Tests is done using PICShell unittesting facilities. PIC 18F aren't -supported. Several actions can be checked: +Tests is done using PICShell unittesting facilities. Several actions can be checked: - @assertEquals: will check a variable against a value (from PICShell). --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
