fixed so that test cases can be run

git-svn-id: https://mspsim.svn.sourceforge.net/svnroot/mspsim/mspsim@8 23d1a52b-0c3c-0410-b72d-8f29ab48fe35
This commit is contained in:
joxe 2007-10-25 11:03:36 +00:00
parent 246da552f5
commit 2feebe147a
2 changed files with 20 additions and 23 deletions

View File

@ -54,8 +54,7 @@ CCARGS=-deprecation -classpath .
FIRMWAREFILE = blinker2.ihex
CPUTEST := tests/cputest.ihex
CPUTESTMAP := $(CPUTEST:.ihex=.map)
CPUTEST := tests/cputest.firmware
PACKAGES := ${addprefix se/sics/mspsim/,core platform/esb platform/sky util}
@ -79,7 +78,7 @@ help:
.PHONY: run
run: compile
java se.sics.util.IHexReader $(FIRMWAREFILE) $(MAPFILE)
java se.sics.mspsim.util.IHexReader $(FIRMWAREFILE) $(MAPFILE)
runesb: compile
java se.sics.mspsim.platform.esb.ESBNode $(FIRMWAREFILE) $(MAPFILE)
@ -91,19 +90,19 @@ runsky: compile
test: cputest
cputest: $(CPUTEST)
java se.sics.util.Test $(CPUTEST) $(CPUTESTMAP)
java se.sics.mspsim.util.Test $(CPUTEST)
$(CPUTEST):
(cd tests && $(MAKE))
test:
cd tests && make
java se.sics.util.Test $(CPUTEST) $(CPUTESTMAP)
java se.sics.mspsim.util.Test $(CPUTEST)
.PHONY: mtest
mtest: compile $(CPUTEST)
@-$(RM) mini-test_cpu.txt
java se.sics.util.Test -debug $(CPUTEST) $(CPUTESTMAP) >mini-test_cpu.txt
java se.sics.util.Test -debug $(CPUTEST) >mini-test_cpu.txt
###############################################################

View File

@ -40,9 +40,10 @@
*/
package se.sics.mspsim.util;
import se.sics.mspsim.core.*;
import java.io.IOException;
/**
* Test - tests a ihex file and exits when reporting "FAIL:" first
* Test - tests a firmware file and exits when reporting "FAIL:" first
* on a line...
*/
public class Test implements USARTListener {
@ -89,24 +90,21 @@ public class Test implements USARTListener {
index++;
}
IHexReader reader = new IHexReader();
String ihexFile = args[index++];
int[] memory = cpu.getMemory();
reader.readFile(memory, ihexFile);
cpu.reset();
try {
int[] memory = cpu.getMemory();
ELF elf = ELF.readELF(args[index++]);
elf.loadPrograms(memory);
MapTable map = elf.getMap();
cpu.getDisAsm().setMap(map);
cpu.setMap(map);
cpu.reset();
if (index < args.length && cpu.getDisAsm() != null) {
try {
MapTable map = new MapTable(args[index++]);
cpu.getDisAsm().setMap(map);
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
// Create the "tester"
new Test(cpu);
cpu.cpuloop();
} catch (IOException ioe) {
ioe.printStackTrace();
}
// Create the "tester"
new Test(cpu);
cpu.cpuloop();
}
}