simulavr-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Simulavr-devel] doRun() and doStep() - how to use it?


From: Andrey Gill
Subject: [Simulavr-devel] doRun() and doStep() - how to use it?
Date: Sun, 22 Jan 2012 04:04:57 -0800 (PST)

Good day!

Try to use simulavr to unit-testing my firmware. In example folder found python 
examples, but - found absolutely no documentation about python API. Is it means 
that there is no such documentation, only source code?
Tried to understand work of the some simple function. Took for example 
functions doRun() and doStep(). As I think now, first of it makes virtual MCU 
to do some steps of debugging program, and next - to do only one step. And then 
I can see where is program counter by value of self.device.PC?
So I wrote such a simplest assempler file:

.include "m128def.inc"
.text
.org 0 
   jmp init     ; Reset vector
.org SPMRaddr
init:
  nop
   nop
   nop
; ---------- Main (endless) cycle: --------------
main:
   nop 
   jmp main

Then I modified example python file to make it as simple as possible:

# -*- coding: UTF-8 -*-
# Python test script as demonstration of using pysimulavr in unit tests
from unittest import TestSuite, TextTestRunner, TestCase, defaultTestLoader
from sys import argv

import pysimulavr
from ex_utils import SimulavrAdapter

class TestBaseClass(TestCase, SimulavrAdapter):

def setUp(self):
proc, elffile = argv[1].split(":")
self.device = self.loadDevice(proc, elffile)

def tearDown(self):
del self.device

def test_03(self):
"check PC and PC size"
self.assertEqual(self.device.PC_size, 2)
self.doRun(0)
self.assertEqual(self.device.PC, 0x8c / 2)

if __name__ == "__main__":

allTestsFrom = defaultTestLoader.loadTestsFromTestCase
suite = TestSuite()
suite.addTests(allTestsFrom(TestBaseClass))
TextTestRunner(verbosity = 2).run(suite)

# EOF

Sorry for long listing, but I do not know python, and do not know how to attach 
large files in it mailing-list.
Then I run test - and get a message:

AssertionError: 0 != 70.


All right, simulation is on the very beginning, on reset vector. Then I make 
next step: change string "self.doRun(0)" on "self.doRun(1)".
The message is:

AssertionError: 34 != 70


This is means that simulation is on Init label? But decimal addres of Init 
label is 68! Is it 34*2? May be. But when I try to do next change, 
"self.doRun(2)", or "self.doRun(10)", or "self.doRun(anything else)" - I get 
the same message, 34 != 70. Do this mean that simulation is not going further 
than Init label? I want to get messages 35 != 70, 36 != 70 and so on, 
corresponds 'nop' instructions of my assembler code. What is my mistake? Maybe 
I can read about it somewhere else?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]