From f2cb1b66bc2542db6b30a5625418174fd99d505d Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sun, 11 Nov 2012 15:05:40 +0100 Subject: [PATCH] Add script to generate .expected files using a real PSP and psplink --- .gitignore | 1 + gentest.py | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ test.py | 24 ++++++++++++++---- 3 files changed, 93 insertions(+), 5 deletions(-) create mode 100644 gentest.py diff --git a/.gitignore b/.gitignore index ebcff6c41..bce69f10c 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ gen libs obj *.exp +.pspsh.hist GameLogNotes.txt Windows/x64 Windows/ipch diff --git a/gentest.py b/gentest.py new file mode 100644 index 000000000..ce8a78019 --- /dev/null +++ b/gentest.py @@ -0,0 +1,73 @@ +# Utility to make it slightly easier to get the results from a test back +# and put it as an "expected" file. +# I can't seem to get pspsh to automatically wait for the psp app to exit, +# unfortunately. + +import sys +import io +import os +import subprocess +import shutil +import time + +PSPSH = "pspsh" +TEST_ROOT = "pspautotests/tests/" +PORT = 3000 +TEST = "cpu/cpu/cpu" +OUTFILE = "__testoutput.txt" +OUTFILE2 = "__testerror.txt" + + +tests_to_generate = [ + "cpu/cpu/cpu", + "cpu/icache/icache", + "cpu/lsu/lsu", + "cpu/fpu/fpu", +] + + +def gen_test(test): + print("Running test " + test + " on the PSP...") + + if os.path.exists(OUTFILE): + os.unlink(OUTFILE) + if os.path.exists(OUTFILE2): + os.unlink(OUTFILE2) + + prx_path = TEST_ROOT + test + ".prx" + expected_path = TEST_ROOT + test + ".expected" + + # First, write a command file for PSPSH + + f = open("cmdfile.txt", "w") + f.write(prx_path) + f.close() + + os.system("pspsh -p %i cmdfile.txt" % (PORT,)) + + # Allow the test a second to execute - TODO: tweak + time.sleep(1) + + if os.path.exists(OUTFILE): + # Should check for size as well... + shutil.move(OUTFILE, expected_path) + print "Expected file written: " + expected_path + else: + print "ERROR: No " + OUTFILE + " was written, can't write .expected" + + os.unlink("cmdfile.txt") + + # Allow the system a couple of seconds to reconnect to the PSP + time.sleep(2) + +def main(): + args = sys.argv[1:] + + tests = tests_to_generate + if len(args): + tests = args + + for test in tests: + gen_test(test) + +main() diff --git a/test.py b/test.py index 9b8778916..aa3707751 100644 --- a/test.py +++ b/test.py @@ -6,7 +6,7 @@ import os import subprocess -PPSSPP_EXECUTABLES = [ "Windows/Release/PPSSPPHeadless.exe", "SDL/build/ppsspp-headless" ] +PPSSPP_EXECUTABLES = [ "Windows\\Release\\PPSSPPHeadless.exe", "SDL/build/ppsspp-headless" ] PPSSPP_EXE = None TEST_ROOT = "pspautotests/tests/" @@ -103,10 +103,20 @@ def run_tests(test_list, args): flags = "" for test in test_list: - elf_filename = TEST_ROOT + test + ".elf" + # Try prx first expected_filename = TEST_ROOT + test + ".expected" + elf_filename = TEST_ROOT + test + ".prx" + + if not os.path.exists(elf_filename): + elf_filename = TEST_ROOT + test + ".elf" + + if not os.path.exists(elf_filename): + print("ERROR: PRX/ELF file missing, failing test: " + test) + tests_failed.append(test) + continue + if not os.path.exists(expected_filename): - print("WARNING: expects file missing, failing test: " + expected_filename) + print("WARNING: expects file missing, failing test: " + test) tests_failed.append(test) continue @@ -126,7 +136,7 @@ def run_tests(test_list, args): expected_lines = expected_output.splitlines() output_lines = output.splitlines() - for i in range(0, len(expected_lines)): + for i in range(0, min(len(output_lines), len(expected_lines))): if output_lines[i] != expected_lines[i]: #print "First different line (output vs expected):" #print output_lines[i] @@ -135,11 +145,15 @@ def run_tests(test_list, args): different = True break + if len(output_lines) != len(expected_lines): + print "*** Different number of lines!" + different = True + if not different: print " " + test + " - passed!" tests_passed.append(test) else: - print test + " failed ============== output:" + print "============== output from failed " + test + " :" print output print "============== expected output:" print expected_output