mirror of
https://github.com/libretro/ppsspp.git
synced 2024-11-25 09:09:49 +00:00
Add script to generate .expected files using a real PSP and psplink
This commit is contained in:
parent
dceca81a8e
commit
7457a18669
1
.gitignore
vendored
1
.gitignore
vendored
@ -24,6 +24,7 @@ gen
|
||||
libs
|
||||
obj
|
||||
*.exp
|
||||
.pspsh.hist
|
||||
GameLogNotes.txt
|
||||
Windows/x64
|
||||
Windows/ipch
|
||||
|
73
gentest.py
Normal file
73
gentest.py
Normal file
@ -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()
|
24
test.py
24
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
|
||||
|
Loading…
Reference in New Issue
Block a user