Hi again,

I've tried to assemble some of PICShell code (very quick and dirty) in order
to run tests from command line, bypassing the GUI and running them as a
batch. I've tracked calls in UI and get "inspiration" from your dev doc. So
far so good, it's working !

Attached is a script with a test :

1. compile the test: jallib compile test_pins.jal (or jalv2 -s ... , or just
use attached files)
2. run the script from commandline: python pscmd.py test_pins.jal
test_pins.asm test_pins.hex


The only weird thing I had to deal with is the varValue() function from
UIManager. I think (but correct me if I'm wrong) this function shouldn't be
tied to UIManager: from what I understanding, it's not related to UI. In my
script, I had to import UIManager because of this (and thus script requires
wxPython libs...). Maybe passing "emu" var to function should be enough to
make this function independent from UIManager.

Anyway, I may give a try integrate this in jallib wrapper script.


Cheers,
Seb


Hi Olivier,
>
>
>
> I'm back on this topic... I've made some tests, in order to have an idea
> about what can be done. Here are some remarks I have, may you could enlight
> me :)
>
> I tried to perform tests on pins, and validate pins can be passed as
> parameters:
>
> ---
> test_bit(bit in t) is
> end test_bit
>
>
> procedure test_pin_high(volatile bit out pin) is
>    pin = high
> end procedure
>
> test_pin_high(pin_a5)
> test_bit(pin_a5) ;@assertEquals 1 test_pin_is_high
> ---
>
>
> but it just doesn't work. I think this is because pin_a5 is a
> pseudo-variable, and PICShell doesn't "resolve" pseudo-variables when
> "joining" asm and jal code (no "pin_a5" in varAdrMapping python dict)
>
> I also tried to define an alias with "var bit level is pin_a5", but no
> trace of a "level" variable in asm due to compiler optimization.
>
> So I tried this:
>
> PORTA = low
> test_pin_high(pin_a5)
> test(PORTA) ;@assertEquals 32 test_only_a5_is_high
>
> And... it won't work, but using lowercased "porta" will work (asm contains
> lowecases). Since jalv2 is case insensitive, maybe PICShell should be the
> same. I think this can be done in picshell.util.AssertUtil.parse() function.
>
> var = firstPart.split(")")[0].lower()
>
>
> Do you see any other options to test pin's values ?
>
>
> Talking about this assert util function, I also think it could be valuable
> to be able to check compiler's internal when unit testing. That is, being
> able to test values from variables not declared in code, any variables found
> in asm. Something like:
>
> test(whatever) ;@assertEquals varToTest valueToTest comment
>
>
> Depending on the number of elements you have, you can decide either to get
> var between parenthesis, or from comment. Something like:
>
>     @staticmethod
>     def parse(lineCode):
>         label=""
>         var =""
>         ref = ""
>
>         parts = lineCode.strip().split("@assertEquals")
>         assertParts = parts[1].split(" ")
>         if len(assertParts) == 4:
>             var = assertParts[1]
>             ref = Format.toNumber(assertParts[2])
>             label = assertParts[3]
>         else:
>             ref = Format.toNumber(assertParts[1])
>             label = assertParts[2]
>             firstPart = parts[0].split("(")[1]
>             var = firstPart.split(")")[0]
>
>         return {"label":label,"var":var,"ref":ref}
>
>
>
> Unfortunatly, Picshell cannot be used by command line, I will try to change
>> that (but I really have few free time for now...)
>
>
> I've seen there's a dev doc, showing what should be imported in python
> code. I think I'll give a try a maybe find a way to bypass the GUI. I let
> you know.
>
>
> Olivier (by the way I'm french speacking, are you ?)
>
>
> Exact ! Mais tu sais, les hollandais ne comprennent pas vraiment le
> français, même si on les voit souvent sur nos belles plages :)
>
>
> Cheers,
> Seb
>
>
>
> Hi Sébastien
>>
>> Unfortunatly, Picshell cannot be used by command line, I will try to
>> change that (but I really have few free time for now...)
>> The homepage for the projet is now http://picshell.ovh.org/ps/ (I just
>> updated my google page)
>>
>> Picshell can freely be distribued, you can even make money with it, I
>> really don't care as far as I cannot be taken responsible for bug, damage on
>> your system, blablabla .... ;)
>>
>> I suppose the best way to distibute Picshell is to include both windows
>> executable and source code for linux people.
>> Picshell is still under developpement, but again I really have few spare
>> time for now.
>>
>> Cheers
>>
>> Olivier (by the way I'm french speacking, are you ?)
>>
>>
>>
>>
>>
>> 2009/3/30 Sebastien Lelong <[email protected]>
>>
>> Hi Olivier,
>>>
>>> It's been a while I wanted to ask you a couple of questions about
>>> PICShell. At jallib (this email being CC), we're trying to build centralized
>>> and reliable set of jalv2 libraries(http://jallib.googlecode.com). I
>>> know PICShell is able to perform unit testing on Jal code. This feature
>>> really could help us. So here my questions:
>>>
>>>   - is it possible to run tests directly from command line, and avoid GUI
>>> ? (so tests can be setup in a batch/script ?)
>>>   - could you give your opinion about designing tests with PICShell ?
>>> Like regression tests, which could also be used for jalv2 compiler ? How far
>>> can we test and how confident can we be about them ? What would be your
>>> general advice/felling about this ?
>>>   - I can't find PICShell's website (memebot.com or the like seems
>>> down). There's Google Code, but I can remember having seen a video about
>>> PICShell I can't find anymore... And, is PICShell still under developement ?
>>>
>>> We also plan to integrate PICShell in a "JalPack", which contains last
>>> compiler, jallib libraries & samples, JalEdit. Would you agree on this ?
>>> What would be the prefered way to integrate it (which package should be
>>> used) ?
>>>
>>> Thanks for your help and advices !
>>>
>>> Cheers,
>>> Seb
>>> --
>>> Sébastien Lelong
>>> http://www.sirloon.net
>>> http://sirbot.org
>>>
>>
>>
>
>
> --
> Sébastien Lelong
> http://www.sirloon.net
> http://sirbot.org
>



-- 
Sébastien Lelong
http://www.sirloon.net
http://sirbot.org

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

import sys

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

jalFileName = sys.argv[1]
asmFileName = sys.argv[2]
hexFileName = sys.argv[3]

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)

emu = PicEngine.newInstance(State(),hexFileName)
# needed to access varValue function
ui = UIManager()
ui.emu = emu


def unitTestCallBack(address):
	line = langParser.adrToLine[address]
	if line != None:
		txt = code[line].line
		if "@assertEquals" in txt:
			res = AssertUtil.parse(txt)
			var = res["var"]
			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) :
					print ": OK"
				else :
					print ": FAIL"


def _runTo(to,unitTestCallBack=None):
	threadEngine = PicThreadEngine(emu,unitTestCallBack)
	threadEngine.runTillAddress = to
	threadEngine.start()
	def stopit(_trash):
		threadEngine.stop()
	threadEngine.callback = stopit


lastAddressArray = [0] * 8192
for i in range(0,len(lastAddressArray)):
	lastAddressArray[i] = False
lastAddressArray[emu.lastAddress] = True


_runTo(lastAddressArray,unitTestCallBack)


Attachment: test_pins.jal
Description: Binary data

Attachment: test_pins.asm
Description: Binary data

Attachment: test_pins.hex
Description: Binary data

Reply via email to