tests,stdlib: Add test to check gem5-resources downloading

This test ensures all the resources in resources.json can be downloaded
and that their md5 values are valid. This has been set as a
very-long/weekly test as downloading all the resources is costly.

Change-Id: Ia574d0a9610849af3653fc742acb214ea7496767
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/59771
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Bobby R. Bruce
2022-05-17 16:00:49 -07:00
committed by Bobby Bruce
parent 95800dc659
commit 2643f3c4ee
3 changed files with 166 additions and 0 deletions

View File

@@ -45,6 +45,21 @@ def _md5_update_from_dir(directory: Path, hash: Hash) -> Hash:
hash = _md5_update_from_dir(path, hash)
return hash
def md5(path: Path) -> str:
"""
Gets the md5 value of a file or directory. `md5_file` is used if the path
is a file and `md5_dir` is used if the path is a directory. An exception
is returned if the path is not a valid file or directory.
:param path: The path to get the md5 of.
"""
if path.is_file():
return md5_file(Path(path))
elif path.is_dir():
return md5_dir(Path(path))
else:
raise Exception(f"Path '{path}' is not a valid file or directory.")
def md5_file(filename: Path) -> str:
"""
Gives the md5 hash of a file