llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-lldb Author: Ebuka Ezike (da-viper) <details> <summary>Changes</summary> #<!-- -->160333 reimplementation but at runtime instead because of broken CI. --- Full diff: https://github.com/llvm/llvm-project/pull/161385.diff 1 Files Affected: - (modified) lldb/unittests/Host/posix/HostTest.cpp (+34-7) ``````````diff diff --git a/lldb/unittests/Host/posix/HostTest.cpp b/lldb/unittests/Host/posix/HostTest.cpp index dc75b288ba76a..d4f6d10ec5d3d 100644 --- a/lldb/unittests/Host/posix/HostTest.cpp +++ b/lldb/unittests/Host/posix/HostTest.cpp @@ -17,6 +17,8 @@ #ifdef __linux__ #include <linux/version.h> +#include <sstream> +#include <sys/utsname.h> #endif // __linux__ using namespace lldb_private; @@ -98,6 +100,28 @@ TEST_F(HostTest, GetProcessInfo) { // Only linux currently sets these. #ifdef __linux__ + +int KernelVersion(int major, int minor, int patch) { + return KERNEL_VERSION(major, minor, patch); +} + +std::optional<int> GetLinuxVersion() { + struct utsname buffer; + + if (uname(&buffer) != 0) + return std::nullopt; + + std::stringstream release(buffer.release); + int major = 0; + int minor = 0; + int patch = 0; + release >> major; + release >> minor; + release >> patch; + + return KernelVersion(major, minor, patch); +} + TEST_F(HostTest, GetProcessInfoSetsPriority) { ProcessInstanceInfo Info; struct rlimit rlim; @@ -120,12 +144,15 @@ TEST_F(HostTest, GetProcessInfoSetsPriority) { ASSERT_TRUE(Info.IsZombie().has_value()); ASSERT_FALSE(Info.IsZombie().value()); - // CoreDumping was added in kernel version 4.15. -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) - ASSERT_TRUE(Info.IsCoreDumping().has_value()); - ASSERT_FALSE(Info.IsCoreDumping().value()); -#else - ASSERT_FALSE(Info.IsCoreDumping().has_value()); -#endif + std::optional<int> opt_linux_version = GetLinuxVersion(); + if (opt_linux_version.has_value()) { + + if (opt_linux_version.value() >= KernelVersion(4, 15, 0)) { + ASSERT_TRUE(Info.IsCoreDumping().has_value()); + ASSERT_FALSE(Info.IsCoreDumping().value()); + } else { + ASSERT_FALSE(Info.IsCoreDumping().has_value()); + } + } } #endif `````````` </details> https://github.com/llvm/llvm-project/pull/161385 _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
