Merge pull request #9830 from skylersaleh/m1-unit-tests

Apple M1: Add support for running unit tests on universal builds
This commit is contained in:
Léo Lam 2021-06-24 01:15:02 +02:00 committed by GitHub
commit cf26846225
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 56 additions and 5 deletions

View File

@ -70,6 +70,8 @@ DEFAULT_CONFIG = {
"generator": "Unix Makefiles",
"build_type": "Release",
"run_unit_tests": False,
}
# Architectures to build for. This is explicity left out of the command line
@ -114,6 +116,9 @@ def parse_args(conf=DEFAULT_CONFIG):
help="Path to .entitlements file for code signing",
default=conf["entitlements"])
parser.add_argument("--run_unit_tests", action="store_true",
default=conf["run_unit_tests"])
parser.add_argument(
"--codesign",
help="Code signing identity to use to sign the applications",
@ -323,8 +328,40 @@ def build(config):
"--verbose=2",
path])
print("Built Universal Binary successfully!")
# Build and run unit tests for each architecture
unit_test_results = {}
if config["run_unit_tests"]:
for arch in ARCHITECTURES:
if not os.path.exists(arch):
os.mkdir(arch)
print("Building and running unit tests for: {arch}")
unit_test_results[arch] = \
subprocess.call(["cmake", "--build", ".",
"--config", config["build_type"],
"--target", "unittests",
"--parallel", f"{threads}"], cwd=arch)
passed_unit_tests = True
for a in unit_test_results:
code = unit_test_results[a]
passed = code == 0
status_string = "PASSED"
if not passed:
passed_unit_tests = False
status_string = f"FAILED ({code})"
print(a + " Unit Tests: " + status_string)
if not passed_unit_tests:
exit(-1)
print("Passed all unit tests")
if __name__ == "__main__":
conf = parse_args()
build(conf)
print("Built Universal Binary successfully!")

View File

@ -33,6 +33,8 @@ class TestConversion : private JitArm64
public:
TestConversion()
{
const Common::ScopedJITPageWriteAndNoExecute enable_jit_page_writes;
AllocCodeSpace(4096);
AddChildCodeSpace(&farcode, 2048);

View File

@ -26,6 +26,8 @@ class TestFPRF : public JitArm64
public:
TestFPRF()
{
const Common::ScopedJITPageWriteAndNoExecute enable_jit_page_writes;
AllocCodeSpace(4096);
const u8* raw_fprf_single = GetCodePtr();

View File

@ -24,6 +24,8 @@ class TestFres : public JitArm64
public:
TestFres()
{
const Common::ScopedJITPageWriteAndNoExecute enable_jit_page_writes;
AllocCodeSpace(4096);
const u8* raw_fres = GetCodePtr();

View File

@ -24,6 +24,8 @@ class TestFrsqrte : public JitArm64
public:
TestFrsqrte()
{
const Common::ScopedJITPageWriteAndNoExecute enable_jit_page_writes;
AllocCodeSpace(4096);
const u8* raw_frsqrte = GetCodePtr();

View File

@ -26,8 +26,11 @@ public:
ResetCodePtr();
const u8* fn = GetCodePtr();
{
const Common::ScopedJITPageWriteAndNoExecute enable_jit_page_writes;
MOVI2R(ARM64Reg::W0, value);
RET();
}
FlushIcacheSection(const_cast<u8*>(fn), const_cast<u8*>(GetCodePtr()));
@ -40,8 +43,11 @@ public:
ResetCodePtr();
const u8* fn = GetCodePtr();
{
const Common::ScopedJITPageWriteAndNoExecute enable_jit_page_writes;
MOVI2R(ARM64Reg::X0, value);
RET();
}
FlushIcacheSection(const_cast<u8*>(fn), const_cast<u8*>(GetCodePtr()));