friss created this revision. friss added reviewers: zturner, labath. Herald added a reviewer: serge-sans-paille. Herald added a subscriber: jdoerfert.
dotest's version comparision function is just a lexicographical compare of the version strings. This is obviously wrong. This patch implements a numerical comparision of the individual version components instead. Python is not my language of choice, please suggest a better implementation! https://reviews.llvm.org/D58219 Files: packages/Python/lldbsuite/test/lldbtest.py Index: packages/Python/lldbsuite/test/lldbtest.py =================================================================== --- packages/Python/lldbsuite/test/lldbtest.py +++ packages/Python/lldbsuite/test/lldbtest.py @@ -1351,14 +1351,31 @@ if (version is None): return True + + def compare_version_strings(v1, v2): + split1 = v1.split('.') + split2 = v2.split('.') + while len(split1) > len(split2): + split2.append("0") + while len(split2) > len(split1): + split1.append("0") + + versions = zip(split1, split2) + for (subv1, subv2) in versions: + diff = int(subv1) - int(subv2) + if diff != 0: + return diff + + return 0 + if (operator == '>'): - return self.getCompilerVersion() > version + return compare_version_strings(self.getCompilerVersion(), version) > 0 if (operator == '>=' or operator == '=>'): - return self.getCompilerVersion() >= version + return compare_version_strings(self.getCompilerVersion(), version) >= 0 if (operator == '<'): - return self.getCompilerVersion() < version + return compare_version_strings(self.getCompilerVersion(), version) < 0 if (operator == '<=' or operator == '=<'): - return self.getCompilerVersion() <= version + return compare_version_strings(self.getCompilerVersion(), version) <= 0 if (operator == '!=' or operator == '!' or operator == 'not'): return str(version) not in str(self.getCompilerVersion()) return str(version) in str(self.getCompilerVersion())
Index: packages/Python/lldbsuite/test/lldbtest.py =================================================================== --- packages/Python/lldbsuite/test/lldbtest.py +++ packages/Python/lldbsuite/test/lldbtest.py @@ -1351,14 +1351,31 @@ if (version is None): return True + + def compare_version_strings(v1, v2): + split1 = v1.split('.') + split2 = v2.split('.') + while len(split1) > len(split2): + split2.append("0") + while len(split2) > len(split1): + split1.append("0") + + versions = zip(split1, split2) + for (subv1, subv2) in versions: + diff = int(subv1) - int(subv2) + if diff != 0: + return diff + + return 0 + if (operator == '>'): - return self.getCompilerVersion() > version + return compare_version_strings(self.getCompilerVersion(), version) > 0 if (operator == '>=' or operator == '=>'): - return self.getCompilerVersion() >= version + return compare_version_strings(self.getCompilerVersion(), version) >= 0 if (operator == '<'): - return self.getCompilerVersion() < version + return compare_version_strings(self.getCompilerVersion(), version) < 0 if (operator == '<=' or operator == '=<'): - return self.getCompilerVersion() <= version + return compare_version_strings(self.getCompilerVersion(), version) <= 0 if (operator == '!=' or operator == '!' or operator == 'not'): return str(version) not in str(self.getCompilerVersion()) return str(version) in str(self.getCompilerVersion())
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits