diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -1269,7 +1269,7 @@ return True return False - def isAArch64SVE(self): + def hasLinuxCPUInfoFeature(self, feature): triple = self.dbg.GetSelectedPlatform().GetTriple() # TODO other platforms, please implement this function @@ -1283,14 +1283,18 @@ else: cpuinfo_path = "/proc/cpuinfo" - try: - f = open(cpuinfo_path, 'r') - cpuinfo = f.read() - f.close() - except: + with open(cpuinfo_path, 'r') as f: + for line in f.readlines(): + if line.startswith("Features"): + features = line.split(':')[1].split() + return feature in features return False - return " sve " in cpuinfo + def isAArch64SVE(self): + return self.hasLinuxCPUInfoFeature("sve") + + def isAArch64MTE(self): + return self.hasLinuxCPUInfoFeature("mte") def hasLinuxVmFlags(self): """ Check that the target machine has "VmFlags" lines in