Skip to content

Commit

Permalink
RegTest: Port to new host abstractions
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Oct 13, 2022
1 parent c9cba5e commit 5498ddf
Show file tree
Hide file tree
Showing 10 changed files with 834 additions and 671 deletions.
39 changes: 38 additions & 1 deletion scripts/check_regression_tests.py
Expand Up @@ -7,6 +7,25 @@

from pathlib import Path

FILE_HEADER = """
<!DOCTYPE html>
<html>
<head>
<title>Comparison</title>
</head>
<body>
"""

FILE_FOOTER = """
</body>
</html>
"""

outfile = None
def write(line):
outfile.write(line + "\n")


def compare_frames(path1, path2):
try:
with open(path1, "rb") as f:
Expand Down Expand Up @@ -37,15 +56,25 @@ def check_regression_test(baselinedir, testdir, name):
continue

framenum = int(matches[1])

path1 = os.path.join(dir1, imagename)
path2 = os.path.join(dir2, imagename)
if not os.path.isfile(path2):
print("--- Frame %u for %s is missing in test set" % (framenum, name))
write("<h1>{}</h1>".format(name))
write("--- Frame %u for %s is missing in test set" % (framenum, name))
return False

if not compare_frames(path1, path2):
print("*** Difference in frame %u for %s" % (framenum, name))

imguri1 = Path(path1).as_uri()
imguri2 = Path(path2).as_uri()
write("<h1>{}</h1>".format(name))
write("<table width=\"100%\">")
write("<tr><td colspan=\"2\">Frame {}</td></tr>".format(framenum))
write("<tr><td><img src=\"{}\" /></td><td><img src=\"{}\" /></td></tr>".format(imguri1, imguri2))
write("</table>")
return False

return True
Expand All @@ -71,11 +100,19 @@ def check_regression_tests(baselinedir, testdir):
parser = argparse.ArgumentParser(description="Check frame dump images for regression tests")
parser.add_argument("-baselinedir", action="store", required=True, help="Directory containing baseline frames to check against")
parser.add_argument("-testdir", action="store", required=True, help="Directory containing frames to check")
parser.add_argument("outfile", action="store", help="The file to write the output to")

args = parser.parse_args()

outfile = open(args.outfile, "w")
write(FILE_HEADER)

if not check_regression_tests(os.path.realpath(args.baselinedir), os.path.realpath(args.testdir)):
write(FILE_FOOTER)
outfile.close()
sys.exit(1)
else:
outfile.close()
os.remove(args.outfile)
sys.exit(0)

3 changes: 2 additions & 1 deletion src/core/cdrom.cpp
Expand Up @@ -1352,7 +1352,6 @@ void CDROM::ExecuteCommand(TickCount ticks_late)
case Command::Reset:
{
Log_DebugPrintf("CDROM reset command");
SendACKAndStat();

if (m_command_second_response == Command::Reset)
{
Expand All @@ -1361,6 +1360,8 @@ void CDROM::ExecuteCommand(TickCount ticks_late)
return;
}

SendACKAndStat();

if (IsSeeking())
UpdatePositionWhileSeeking();

Expand Down
3 changes: 1 addition & 2 deletions src/duckstation-regtest/CMakeLists.txt
@@ -1,8 +1,7 @@
add_executable(duckstation-regtest
regtest_host_display.cpp
regtest_host_display.h
regtest_host_interface.cpp
regtest_host_interface.h
regtest_host.cpp
)

target_link_libraries(duckstation-regtest PRIVATE core common frontend-common scmversion)
3 changes: 1 addition & 2 deletions src/duckstation-regtest/duckstation-regtest.vcxproj
Expand Up @@ -6,11 +6,10 @@
</PropertyGroup>
<ItemGroup>
<ClCompile Include="regtest_host_display.cpp" />
<ClCompile Include="regtest_host_interface.cpp" />
<ClCompile Include="regtest_host.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="regtest_host_display.h" />
<ClInclude Include="regtest_host_interface.h" />
</ItemGroup>
<Import Project="..\..\dep\msvc\vsprops\ConsoleApplication.props" />
<Import Project="..\frontend-common\frontend-common.props" />
Expand Down
3 changes: 1 addition & 2 deletions src/duckstation-regtest/duckstation-regtest.vcxproj.filters
@@ -1,11 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="regtest_host_interface.cpp" />
<ClCompile Include="regtest_host.cpp" />
<ClCompile Include="regtest_host_display.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="regtest_host_interface.h" />
<ClInclude Include="regtest_host_display.h" />
</ItemGroup>
</Project>

0 comments on commit 5498ddf

Please sign in to comment.