[Lldb-commits] [lldb] 266a927 - [lldb] Fix typo in CumulativeSystemTimeIsValid check (#89680)
via lldb-commits
lldb-commits at lists.llvm.org
Fri Apr 26 11:57:09 PDT 2024
Author: Marc Auberer
Date: 2024-04-26T20:57:04+02:00
New Revision: 266a9274dd14d06d559ca8a37e2d1b5f985a5398
URL: https://github.com/llvm/llvm-project/commit/266a9274dd14d06d559ca8a37e2d1b5f985a5398
DIFF: https://github.com/llvm/llvm-project/commit/266a9274dd14d06d559ca8a37e2d1b5f985a5398.diff
LOG: [lldb] Fix typo in CumulativeSystemTimeIsValid check (#89680)
Resolves #89674
Added:
Modified:
lldb/include/lldb/Utility/ProcessInfo.h
lldb/unittests/Host/HostTest.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Utility/ProcessInfo.h b/lldb/include/lldb/Utility/ProcessInfo.h
index e9fe71e1b851d1..54ac000dc7fc28 100644
--- a/lldb/include/lldb/Utility/ProcessInfo.h
+++ b/lldb/include/lldb/Utility/ProcessInfo.h
@@ -234,7 +234,7 @@ class ProcessInstanceInfo : public ProcessInfo {
bool CumulativeSystemTimeIsValid() const {
return m_cumulative_system_time.tv_sec > 0 ||
- m_cumulative_system_time.tv_sec > 0;
+ m_cumulative_system_time.tv_usec > 0;
}
void Dump(Stream &s, UserIDResolver &resolver) const;
diff --git a/lldb/unittests/Host/HostTest.cpp b/lldb/unittests/Host/HostTest.cpp
index 5e01a6835c03dc..a1d8a3b7f485a3 100644
--- a/lldb/unittests/Host/HostTest.cpp
+++ b/lldb/unittests/Host/HostTest.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "lldb/Host/Host.h"
+#include "lldb/Utility/ProcessInfo.h"
#include "gtest/gtest.h"
using namespace lldb_private;
@@ -25,3 +26,23 @@ TEST(Host, GetEnvironment) {
ASSERT_EQ("Host::GetEnvironment",
Host::GetEnvironment().lookup("LLDB_TEST_ENVIRONMENT_VAR"));
}
+
+TEST(Host, ProcessInstanceInfoCumulativeUserTimeIsValid) {
+ ProcessInstanceInfo info;
+ info.SetCumulativeUserTime(ProcessInstanceInfo::timespec{0, 0});
+ EXPECT_FALSE(info.CumulativeUserTimeIsValid());
+ info.SetCumulativeUserTime(ProcessInstanceInfo::timespec{0, 1});
+ EXPECT_TRUE(info.CumulativeUserTimeIsValid());
+ info.SetCumulativeUserTime(ProcessInstanceInfo::timespec{1, 0});
+ EXPECT_TRUE(info.CumulativeUserTimeIsValid());
+}
+
+TEST(Host, ProcessInstanceInfoCumulativeSystemTimeIsValid) {
+ ProcessInstanceInfo info;
+ info.SetCumulativeSystemTime(ProcessInstanceInfo::timespec{0, 0});
+ EXPECT_FALSE(info.CumulativeSystemTimeIsValid());
+ info.SetCumulativeSystemTime(ProcessInstanceInfo::timespec{0, 1});
+ EXPECT_TRUE(info.CumulativeSystemTimeIsValid());
+ info.SetCumulativeSystemTime(ProcessInstanceInfo::timespec{1, 0});
+ EXPECT_TRUE(info.CumulativeSystemTimeIsValid());
+}
\ No newline at end of file
More information about the lldb-commits
mailing list