Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lldb/include/lldb/Utility/ProcessInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
21 changes: 21 additions & 0 deletions lldb/unittests/Host/HostTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//

#include "lldb/Host/Host.h"
#include "lldb/Utility/ProcessInfo.h"
#include "gtest/gtest.h"

using namespace lldb_private;
Expand All @@ -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());
}