-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is approximately a 10x speedup on the test suite including compilation.
- Loading branch information
1 parent
07581f9
commit b661ecf
Showing
2 changed files
with
72 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import rars.AssemblyException; | ||
import rars.SimulationException; | ||
import rars.api.Options; | ||
import rars.api.Program; | ||
import rars.simulator.Simulator; | ||
|
||
import java.io.File; | ||
|
||
public class Test { | ||
public static void main(String[] args){ | ||
Options opt = new Options(); | ||
opt.startAtMain = true; | ||
opt.maxSteps = 500; | ||
Program p = new Program(opt); | ||
File[] tests = new File("./test").listFiles(), riscv_tests = new File("./test/riscv-tests").listFiles(); | ||
if(tests == null){ | ||
System.out.println("./test doesn't exist"); | ||
return; | ||
} | ||
StringBuilder total = new StringBuilder("\n"); | ||
for(File test : tests){ | ||
if(test.isFile() && test.getName().endsWith(".s")){ | ||
String errors = run(test.getPath(),p); | ||
if(errors.equals("")) { | ||
System.out.print('.'); | ||
}else{ | ||
System.out.print('X'); | ||
total.append(errors).append('\n'); | ||
} | ||
} | ||
} | ||
if(riscv_tests == null){ | ||
System.out.println("./test/riscv-tests doesn't exist"); | ||
return; | ||
} | ||
for(File test : riscv_tests){ | ||
if(test.isFile() && test.getName().endsWith(".s")){ | ||
String errors = run(test.getPath(),p); | ||
if(errors.equals("")) { | ||
System.out.print('.'); | ||
}else{ | ||
System.out.print('X'); | ||
total.append(errors).append('\n'); | ||
} | ||
} | ||
} | ||
System.out.println(total); | ||
} | ||
public static String run(String path, Program p){ | ||
try { | ||
p.assemble(path); | ||
p.setup(null,""); | ||
Simulator.Reason r = p.simulate(); | ||
if(r != Simulator.Reason.NORMAL_TERMINATION){ | ||
return "Ending abnormally while executing " + path; | ||
}else{ | ||
if(p.getExitCode() == 42){ | ||
return ""; | ||
}else{ | ||
return "Final exit code was wrong for " + path; | ||
} | ||
} | ||
} catch (AssemblyException ae){ | ||
return "Failed to assemble " + path; | ||
} catch (SimulationException se){ | ||
return "Crashed while executing " + path; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,4 @@ | ||
#!/bin/bash | ||
RUN="java -jar -ea ./rars.jar" | ||
ERRORS="" | ||
for f in ./test/*.s ./test/riscv-tests/*.s | ||
do | ||
$RUN $f > /dev/null | ||
if [ $? -eq 42 ] | ||
then | ||
printf "." | ||
else | ||
printf "X" | ||
ERRORS="$ERRORS\nFailure on file $f" | ||
fi | ||
done | ||
|
||
printf "$ERRORS\n" | ||
javac -cp rars.jar Test.java | ||
java -cp rars.jar Test | ||
rm Test.class |