Skip to content

Commit a9ece2d

Browse files
committed
[lldb] Skip some Host::GetProcessInfo tests for macos
Some of the tests moved in #134354 do not currently pass on a mac. Disable them. The test for testing process priority also does not build on a mac. I'm not moving it (back) to the linux, since it's "almost" fine -- we'd just need to implement the RLIMIT_NICE logic differently. I'm not doing that now since (apart from linux) there are no systems which are able to retrieve the process priority.
1 parent ace8cea commit a9ece2d

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

lldb/unittests/Host/posix/HostTest.cpp

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,39 +34,37 @@ class HostTest : public testing::Test {
3434
TEST_F(HostTest, GetProcessInfo) {
3535
llvm::Triple triple = HostInfo::GetTargetTriple();
3636

37-
ASSERT_TRUE(
38-
(triple.getOS() == llvm::Triple::OSType::Linux) ||
39-
(triple.hasEnvironment() &&
40-
triple.getEnvironment() == llvm::Triple::EnvironmentType::Android));
41-
4237
ProcessInstanceInfo Info;
4338

4439
ASSERT_FALSE(Host::GetProcessInfo(LLDB_INVALID_PROCESS_ID, Info));
4540

4641
ASSERT_TRUE(Host::GetProcessInfo(getpid(), Info));
4742

48-
ASSERT_TRUE(Info.ProcessIDIsValid());
43+
EXPECT_TRUE(Info.ProcessIDIsValid());
4944
EXPECT_EQ(lldb::pid_t(getpid()), Info.GetProcessID());
5045

51-
ASSERT_TRUE(Info.ParentProcessIDIsValid());
46+
EXPECT_TRUE(Info.ParentProcessIDIsValid());
5247
EXPECT_EQ(lldb::pid_t(getppid()), Info.GetParentProcessID());
5348

54-
ASSERT_TRUE(Info.ProcessGroupIDIsValid());
49+
// Not currently set on apple systems.
50+
#ifndef __APPLE__
51+
EXPECT_TRUE(Info.ProcessGroupIDIsValid());
5552
EXPECT_EQ(lldb::pid_t(getpgrp()), Info.GetProcessGroupID());
5653

57-
ASSERT_TRUE(Info.ProcessSessionIDIsValid());
54+
EXPECT_TRUE(Info.ProcessSessionIDIsValid());
5855
EXPECT_EQ(lldb::pid_t(getsid(getpid())), Info.GetProcessSessionID());
56+
#endif
5957

60-
ASSERT_TRUE(Info.EffectiveUserIDIsValid());
58+
EXPECT_TRUE(Info.EffectiveUserIDIsValid());
6159
EXPECT_EQ(geteuid(), Info.GetEffectiveUserID());
6260

63-
ASSERT_TRUE(Info.EffectiveGroupIDIsValid());
61+
EXPECT_TRUE(Info.EffectiveGroupIDIsValid());
6462
EXPECT_EQ(getegid(), Info.GetEffectiveGroupID());
6563

66-
ASSERT_TRUE(Info.UserIDIsValid());
64+
EXPECT_TRUE(Info.UserIDIsValid());
6765
EXPECT_EQ(geteuid(), Info.GetUserID());
6866

69-
ASSERT_TRUE(Info.GroupIDIsValid());
67+
EXPECT_TRUE(Info.GroupIDIsValid());
7068
EXPECT_EQ(getegid(), Info.GetGroupID());
7169

7270
EXPECT_TRUE(Info.GetArchitecture().IsValid());
@@ -90,14 +88,19 @@ TEST_F(HostTest, GetProcessInfo) {
9088
ProcessInstanceInfo::timespec next_user_time = Info.GetUserTime();
9189
ASSERT_TRUE(user_time.tv_sec <= next_user_time.tv_sec ||
9290
user_time.tv_usec <= next_user_time.tv_usec);
91+
}
9392

94-
#ifndef _AIX
93+
// Only linux currently sets these.
94+
#ifdef __linux__
95+
TEST_F(HostTest, GetProcessInfoSetsPriority) {
96+
ProcessInstanceInfo Info;
9597
struct rlimit rlim;
9698
EXPECT_EQ(getrlimit(RLIMIT_NICE, &rlim), 0);
9799
// getpriority can return -1 so we zero errno first
98100
errno = 0;
99-
int prio = getpriority(PRIO_PROCESS, PRIO_PROCESS);
101+
int prio = getpriority(PRIO_PROCESS, 0);
100102
ASSERT_TRUE((prio < 0 && errno == 0) || prio >= 0);
103+
ASSERT_TRUE(Host::GetProcessInfo(getpid(), Info));
101104
ASSERT_EQ(Info.GetPriorityValue(), prio);
102105
// If we can't raise our nice level then this test can't be performed.
103106
int max_incr = PRIO_MAX - rlim.rlim_cur;
@@ -110,5 +113,5 @@ TEST_F(HostTest, GetProcessInfo) {
110113
}
111114
ASSERT_TRUE(Info.IsZombie().has_value());
112115
ASSERT_FALSE(Info.IsZombie().value());
113-
#endif /* ifndef _AIX */
114116
}
117+
#endif

0 commit comments

Comments
 (0)