|
30 | 30 |
|
31 | 31 | import mozdebug
|
32 | 32 | import six
|
| 33 | +from mozgeckoprofiler import ( |
| 34 | + symbolicate_profile_json, |
| 35 | + view_gecko_profile, |
| 36 | +) |
33 | 37 | from mozserve import Http3Server
|
34 | 38 |
|
35 | 39 | try:
|
@@ -224,6 +228,7 @@ def __init__(
|
224 | 228 | self.timeoutAsPass = kwargs.get("timeoutAsPass")
|
225 | 229 | self.crashAsPass = kwargs.get("crashAsPass")
|
226 | 230 | self.conditionedProfileDir = kwargs.get("conditionedProfileDir")
|
| 231 | + self.profiler = kwargs.get("profiler") |
227 | 232 | if self.runFailures:
|
228 | 233 | self.retry = False
|
229 | 234 |
|
@@ -859,6 +864,18 @@ def run_test(self):
|
859 | 864 | if self.test_object.get("subprocess") == "true":
|
860 | 865 | self.env["PYTHON"] = sys.executable
|
861 | 866 |
|
| 867 | + if self.profiler: |
| 868 | + if not self.singleFile: |
| 869 | + self.log.error( |
| 870 | + "The --profiler flag is currently only supported when running a single test" |
| 871 | + ) |
| 872 | + else: |
| 873 | + self.env["MOZ_PROFILER_STARTUP"] = "1" |
| 874 | + profile_path = os.path.join( |
| 875 | + self.profileDir, "profile_" + os.path.basename(name) + ".json" |
| 876 | + ) |
| 877 | + self.env["MOZ_PROFILER_SHUTDOWN"] = profile_path |
| 878 | + |
862 | 879 | if (
|
863 | 880 | self.test_object.get("headless", "true" if self.headless else None)
|
864 | 881 | == "true"
|
@@ -1041,6 +1058,9 @@ def run_test(self):
|
1041 | 1058 |
|
1042 | 1059 | finally:
|
1043 | 1060 | self.postCheck(proc)
|
| 1061 | + if self.profiler and self.singleFile: |
| 1062 | + symbolicate_profile_json(profile_path, self.symbolsPath) |
| 1063 | + view_gecko_profile(profile_path) |
1044 | 1064 | self.clean_temp_dirs(path)
|
1045 | 1065 |
|
1046 | 1066 | if gotSIGINT:
|
@@ -1832,6 +1852,7 @@ def runTests(self, options, testClass=XPCShellTestThread, mobileArgs=None):
|
1832 | 1852 | self.conditionedProfile = options.get("conditionedProfile")
|
1833 | 1853 | self.repeat = options.get("repeat", 0)
|
1834 | 1854 | self.variant = options.get("variant", "")
|
| 1855 | + self.profiler = options.get("profiler") |
1835 | 1856 |
|
1836 | 1857 | if self.variant == "msix":
|
1837 | 1858 | self.appPath = options.get("msixAppPath")
|
@@ -1999,6 +2020,7 @@ def runTests(self, options, testClass=XPCShellTestThread, mobileArgs=None):
|
1999 | 2020 | "crashAsPass": self.crashAsPass,
|
2000 | 2021 | "conditionedProfileDir": self.conditioned_profile_dir,
|
2001 | 2022 | "repeat": self.repeat,
|
| 2023 | + "profiler": self.profiler, |
2002 | 2024 | }
|
2003 | 2025 |
|
2004 | 2026 | if self.sequential:
|
|
0 commit comments