summaryrefslogtreecommitdiff
path: root/simpleperf
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2022-03-25 15:36:42 -0700
committerYabin Cui <yabinc@google.com>2022-03-30 09:59:24 -0700
commit3d1348c90313e07304d0be5b689a7b8a7b548b2a (patch)
treee40ec3187f6169df2fe130abff83e1281a30a22f /simpleperf
parent9fc6ef04b019bb7411c1f43aecf0172a9ca0689c (diff)
downloadextras-3d1348c90313e07304d0be5b689a7b8a7b548b2a.tar.gz
simpleperf: sign darwin executables when testing.
Otherwise they can't run on M1 Mac. Bug: none Test: run test.py Change-Id: Idbed2c191b7c79cd13e27d5f9e38c53df7b27b9d
Diffstat (limited to 'simpleperf')
-rwxr-xr-xsimpleperf/scripts/test/do_test.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/simpleperf/scripts/test/do_test.py b/simpleperf/scripts/test/do_test.py
index 2c67bb78..b95a1fef 100755
--- a/simpleperf/scripts/test/do_test.py
+++ b/simpleperf/scripts/test/do_test.py
@@ -32,6 +32,7 @@ import multiprocessing as mp
import os
from pathlib import Path
import re
+import subprocess
import sys
import time
from tqdm import tqdm
@@ -39,7 +40,7 @@ import types
from typing import List, Optional
import unittest
-from simpleperf_utils import BaseArgumentParser, extant_dir, log_exit, remove
+from simpleperf_utils import BaseArgumentParser, extant_dir, log_exit, remove, is_darwin
from . api_profiler_test import *
from . annotate_test import *
@@ -517,6 +518,15 @@ def run_tests_in_child_process(tests: List[str], args: argparse.Namespace) -> bo
return False
+def sign_executables_on_darwin():
+ """ Sign executables on M1 Mac, otherwise they can't run. """
+ if not is_darwin():
+ return
+ bin_dir = Path(__file__).resolve().parents[1] / 'bin' / 'darwin' / 'x86_64'
+ for path in bin_dir.iterdir():
+ subprocess.run(f'codesign --force -s - {path}', shell=True, check=True)
+
+
def main() -> bool:
args = get_args()
tests = get_host_tests() if args.only_host_test else get_all_tests()
@@ -532,4 +542,5 @@ def main() -> bool:
# Switch to the test dir.
os.chdir(test_dir)
build_testdata(Path('testdata'))
+ sign_executables_on_darwin()
return run_tests_in_child_process(tests, args)