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:
commit
cf26846225
|
@ -70,6 +70,8 @@ DEFAULT_CONFIG = {
|
||||||
"generator": "Unix Makefiles",
|
"generator": "Unix Makefiles",
|
||||||
"build_type": "Release",
|
"build_type": "Release",
|
||||||
|
|
||||||
|
"run_unit_tests": False,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Architectures to build for. This is explicity left out of the command line
|
# 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",
|
help="Path to .entitlements file for code signing",
|
||||||
default=conf["entitlements"])
|
default=conf["entitlements"])
|
||||||
|
|
||||||
|
parser.add_argument("--run_unit_tests", action="store_true",
|
||||||
|
default=conf["run_unit_tests"])
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--codesign",
|
"--codesign",
|
||||||
help="Code signing identity to use to sign the applications",
|
help="Code signing identity to use to sign the applications",
|
||||||
|
@ -323,8 +328,40 @@ def build(config):
|
||||||
"--verbose=2",
|
"--verbose=2",
|
||||||
path])
|
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__":
|
if __name__ == "__main__":
|
||||||
conf = parse_args()
|
conf = parse_args()
|
||||||
build(conf)
|
build(conf)
|
||||||
print("Built Universal Binary successfully!")
|
|
||||||
|
|
|
@ -33,6 +33,8 @@ class TestConversion : private JitArm64
|
||||||
public:
|
public:
|
||||||
TestConversion()
|
TestConversion()
|
||||||
{
|
{
|
||||||
|
const Common::ScopedJITPageWriteAndNoExecute enable_jit_page_writes;
|
||||||
|
|
||||||
AllocCodeSpace(4096);
|
AllocCodeSpace(4096);
|
||||||
AddChildCodeSpace(&farcode, 2048);
|
AddChildCodeSpace(&farcode, 2048);
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,8 @@ class TestFPRF : public JitArm64
|
||||||
public:
|
public:
|
||||||
TestFPRF()
|
TestFPRF()
|
||||||
{
|
{
|
||||||
|
const Common::ScopedJITPageWriteAndNoExecute enable_jit_page_writes;
|
||||||
|
|
||||||
AllocCodeSpace(4096);
|
AllocCodeSpace(4096);
|
||||||
|
|
||||||
const u8* raw_fprf_single = GetCodePtr();
|
const u8* raw_fprf_single = GetCodePtr();
|
||||||
|
|
|
@ -24,6 +24,8 @@ class TestFres : public JitArm64
|
||||||
public:
|
public:
|
||||||
TestFres()
|
TestFres()
|
||||||
{
|
{
|
||||||
|
const Common::ScopedJITPageWriteAndNoExecute enable_jit_page_writes;
|
||||||
|
|
||||||
AllocCodeSpace(4096);
|
AllocCodeSpace(4096);
|
||||||
|
|
||||||
const u8* raw_fres = GetCodePtr();
|
const u8* raw_fres = GetCodePtr();
|
||||||
|
|
|
@ -24,6 +24,8 @@ class TestFrsqrte : public JitArm64
|
||||||
public:
|
public:
|
||||||
TestFrsqrte()
|
TestFrsqrte()
|
||||||
{
|
{
|
||||||
|
const Common::ScopedJITPageWriteAndNoExecute enable_jit_page_writes;
|
||||||
|
|
||||||
AllocCodeSpace(4096);
|
AllocCodeSpace(4096);
|
||||||
|
|
||||||
const u8* raw_frsqrte = GetCodePtr();
|
const u8* raw_frsqrte = GetCodePtr();
|
||||||
|
|
|
@ -26,8 +26,11 @@ public:
|
||||||
ResetCodePtr();
|
ResetCodePtr();
|
||||||
|
|
||||||
const u8* fn = GetCodePtr();
|
const u8* fn = GetCodePtr();
|
||||||
MOVI2R(ARM64Reg::W0, value);
|
{
|
||||||
RET();
|
const Common::ScopedJITPageWriteAndNoExecute enable_jit_page_writes;
|
||||||
|
MOVI2R(ARM64Reg::W0, value);
|
||||||
|
RET();
|
||||||
|
}
|
||||||
|
|
||||||
FlushIcacheSection(const_cast<u8*>(fn), const_cast<u8*>(GetCodePtr()));
|
FlushIcacheSection(const_cast<u8*>(fn), const_cast<u8*>(GetCodePtr()));
|
||||||
|
|
||||||
|
@ -40,8 +43,11 @@ public:
|
||||||
ResetCodePtr();
|
ResetCodePtr();
|
||||||
|
|
||||||
const u8* fn = GetCodePtr();
|
const u8* fn = GetCodePtr();
|
||||||
MOVI2R(ARM64Reg::X0, value);
|
{
|
||||||
RET();
|
const Common::ScopedJITPageWriteAndNoExecute enable_jit_page_writes;
|
||||||
|
MOVI2R(ARM64Reg::X0, value);
|
||||||
|
RET();
|
||||||
|
}
|
||||||
|
|
||||||
FlushIcacheSection(const_cast<u8*>(fn), const_cast<u8*>(GetCodePtr()));
|
FlushIcacheSection(const_cast<u8*>(fn), const_cast<u8*>(GetCodePtr()));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue