Update gcmtest.py

This commit is contained in:
tmpz23 2022-01-18 07:49:52 +01:00 committed by GitHub
parent 036c05c302
commit 279f2e914b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,7 +5,7 @@ import os
import shutil import shutil
__version__ = "0.0.2" __version__ = "0.0.3"
__author__ = "rigodron, algoflash, GGLinnk" __author__ = "rigodron, algoflash, GGLinnk"
__license__ = "MIT" __license__ = "MIT"
__status__ = "developpement" __status__ = "developpement"
@ -19,8 +19,8 @@ __status__ = "developpement"
roms_path = Path("../ROM") roms_path = Path("../ROM")
dolphin_unpack_path = Path("dolphin_unpack") dolphin_unpack_path = Path("dolphin_unpack")
unpack_path = Path("unpack") unpack_path = Path("unpack")
repack_path = Path("repack")
unpack2_path = Path("unpack2") unpack2_path = Path("unpack2")
repack_path = Path("repack")
# if there is a way to create symlinks on GCM filesystem, it could create strange situations # if there is a way to create symlinks on GCM filesystem, it could create strange situations
@ -70,15 +70,16 @@ def verify_GCM_sha256(folder1: Path, folder2: Path):
raise Exception(f"\"{path1}/\" and \"{path2}\" are different.") raise Exception(f"\"{path1}/\" and \"{path2}\" are different.")
print("# Cleaning tests folder") print("###############################################################################")
# Remove tests folders print("# Checking tests folder")
if unpack_path.is_dir(): print("###############################################################################")
shutil.rmtree(unpack_path) # Check if tests folders exist
if repack_path.is_dir(): if unpack_path.is_dir() or unpack2_path.is_dir() or repack_path.is_dir():
shutil.rmtree(repack_path) raise Exception(f"Error - Please remove:\n-{unpack_path}\n-{unpack2_path}\n{repack_path}")
if unpack2_path.is_dir():
shutil.rmtree(unpack2_path) print("###############################################################################")
print("# Comparing unpacked ROMs with dolphin extracts") print("# Comparing unpacked ROMs with dolphin extracts")
print("###############################################################################")
# unpack ROM in unpack_path # unpack ROM in unpack_path
unpack_path.mkdir(parents=True) unpack_path.mkdir(parents=True)
for iso_path in roms_path.glob("*"): for iso_path in roms_path.glob("*"):
@ -90,7 +91,9 @@ for iso_path in roms_path.glob("*"):
for folder_path in unpack_path.glob("*"): for folder_path in unpack_path.glob("*"):
verify_GCM_sha256(folder_path, dolphin_unpack_path / folder_path.name) verify_GCM_sha256(folder_path, dolphin_unpack_path / folder_path.name)
print("###############################################################################")
print("# Comparing iso->[1:unpacked]->repacked->[2:unpacked]") print("# Comparing iso->[1:unpacked]->repacked->[2:unpacked]")
print("###############################################################################")
# repack unpack_path repack_path # repack unpack_path repack_path
repack_path.mkdir() repack_path.mkdir()
for folder_path in unpack_path.glob("*"): for folder_path in unpack_path.glob("*"):
@ -113,7 +116,9 @@ for folder_path in unpack_path.glob("*"):
# remove unpack2_path # remove unpack2_path
shutil.rmtree(unpack2_path) shutil.rmtree(unpack2_path)
print("###############################################################################")
print("# Comparing iso->[1:unpacked]->rebuild_fst->repack->[2:unpacked]") print("# Comparing iso->[1:unpacked]->rebuild_fst->repack->[2:unpacked]")
print("###############################################################################")
# rebuild unpack_path FSTs # rebuild unpack_path FSTs
for folder_path in unpack_path.glob("*"): for folder_path in unpack_path.glob("*"):
if os.system(f"python gcmtool.py -r \"{folder_path}\"") != 0: if os.system(f"python gcmtool.py -r \"{folder_path}\"") != 0:
@ -139,8 +144,12 @@ for folder_path in unpack_path.glob("*"):
verify_GCM_sha256(folder_path, unpack2_path / folder_path.name) verify_GCM_sha256(folder_path, unpack2_path / folder_path.name)
# remove unpack_path unpack2_path # remove unpack_path unpack2_path
print(f"# Removing {unpack_path} and {unpack2_path}.") print("###############################################################################")
print(f"# Cleaning test folders.")
print("###############################################################################")
shutil.rmtree(unpack_path) shutil.rmtree(unpack_path)
shutil.rmtree(unpack2_path) shutil.rmtree(unpack2_path)
print("###############################################################################")
print("# All tests are OK") print("# All tests are OK")
print("###############################################################################")