[Lldb-commits] [lldb] [lldb][test] Unify and extend test infrastructure for checking CPU features (PR #153914)
David Spickett via lldb-commits
lldb-commits at lists.llvm.org
Wed Sep 24 05:06:48 PDT 2025
================
@@ -0,0 +1,68 @@
+"""
+Platform-agnostic helper to query for CPU features.
+"""
+
+import re
+
+
+class CPUFeature:
+ def __init__(self, linux_cpu_info_flag: str = None, darwin_sysctl_key: str = None):
+ self.cpu_info_flag = linux_cpu_info_flag
+ self.sysctl_key = darwin_sysctl_key
+
+ def __str__(self):
+ return self.cpu_info_flag
+
+ def is_supported(self, triple, cmd_runner):
+ if re.match(".*-.*-linux", triple):
+ err_msg, res = self._is_supported_linux(cmd_runner)
+ elif re.match(".*-apple-.*", triple):
+ err_msg, res = self._is_supported_darwin(cmd_runner)
+ else:
+ err_msg, res = None, False
+
+ if err_msg:
+ print(f"CPU feature check failed: {err_msg}")
+
+ return res
+
+ def _is_supported_linux(self, cmd_runner):
+ if not self.cpu_info_flag:
+ return "Unspecified cpuinfo flag", False
----------------
DavidSpickett wrote:
Format the message like "unspecified cpu info flag for <somehow get the class name>".
https://github.com/llvm/llvm-project/pull/153914
More information about the lldb-commits
mailing list