|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--jfrace.CPUTestEngine
Test engine for testing implementations of the CPU
interface. A test is performed by invoking the method
makeTest
with a test script. A test script contains
a header, comments (starting with '#
')
and many test description lines.
The header defines the CPU used and configures the RAM. It contains two lines with the following syntax:
CPU = <class name> <offset in address space>
and
RAM = <first address> <size>
[<mode mask>]
The meaning of the parameters are:
<class name> |
Complete name of the CPU class |
<offset in address space> |
Mapping of the First cell the CPU can address onto
an address in the AddressSpace |
<first address> |
Address of the first cell of the RAM in
the AddressSpace |
<size> |
Number of cells of the RAM |
<mode mask> |
Optional mode mask |
With the test description lines the behavior of the CPU
will be tested on specified op-codes. A test description line
contains information in order to prepare the CPU state and
the RAM and exceptions about the state of CPU and RAM after
execution of the next
method. If there is
a difference between expection and the true state an
error message will be printed.
Here is the syntax (in EBNF) of a test description line:
testDescriptionLine := initialState ">" numberOfOpCodeCycles expectations initialState := statement | statement ";" initialState numberOfOpCodeCycles := number expectations := statement | statement ";" expectations statement := registerName {"="|"=="} number | address {"="|"=="} numbers address := "(" {number | registerName} ")" numbers := number | number "," numbers number := binaryNumber | octalNumber | decimalNumber | hexNumber binaryNumber := {"0b"|"0B"} binaryDigit* binaryDigit := "0" | "1" octalNumber := "0" octalDigit* octalDigit := "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" decimalNumber := nonZeroDigit digit* nonZeroDigit := "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" digit := "0" | nonZeroDigit hexNumber := {"0x"|"0X"} hexDigit* hexDigit := digit | "a" | "A" | "b" | "B" | "c" | "C" | "d" | "D" | "e" | "E" | "f" | "F"
Here is an example of a test script:
# Header CPU = jfrace.cpu.FJE5 0 RAM = 0 0x400 # test description lines SP==1000; PC=0x123; (0x123)==0 > 1 PC=0x124 SP==1000; PC=123; (123)==1; A=0b10111; I=0b01100 > 1 PC=124; A=0b01100; I=0b10111 SP==1000; PC=0x333; (0x333)==2,23; A=0b10111; I==0b01100 > 2 PC=0x335; A=23 SP==1000; PC=12; (12)==3,30; A==22; I=11 > 2 PC=14; I=30A
registerName
is either the name of a single
register of the CPU (as given by
CPU.getRegister(index).getName()
) or concatenation
of possible register names.
A statement
contains either a =
or a
==
. In the later case
such a statement
of the initialState
will be duplicated to the statement
list of the
expectations
.
Before preparation RAM will be reseted by invoking the method
reset
).
In addition all CPU registers will be set to zero
(invoking reset
would not do the job in CPUs like
6502).
The returned value of next
will be checked with
numberOfOpCodeCycles
in the test description line.
Not only the exceptions describe in the test decription line
are tested but also the unmentioned registers and memory cells
are tested against their default values.
Constructor Summary | |
CPUTestEngine(boolean onSystemOutFlag)
Create a new instance. |
Method Summary | |
java.lang.String |
getProtocol()
Return the protocol. |
static void |
main(java.lang.String[] scripts)
Run the test engine for one or several test scripts. |
boolean |
makeTest(java.lang.String testScript)
Run the test with the given test script. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public CPUTestEngine(boolean onSystemOutFlag)
onSystemOutFlag
- If true
output goes onto
System.out
otherwise
it will be stored in a StringBuffer
which can be obtained by the method
getProtocol
.Method Detail |
public static void main(java.lang.String[] scripts)
scripts
- File names of the test scripts.public java.lang.String getProtocol()
public boolean makeTest(java.lang.String testScript)
testScript
- Script with the test statements.true
for a successful test.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |