mirror of
https://github.com/intel/llvm.git
synced 2026-01-23 07:58:23 +08:00
[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.
This commit is contained in:
@@ -34,39 +34,37 @@ public:
|
||||
TEST_F(HostTest, GetProcessInfo) {
|
||||
llvm::Triple triple = HostInfo::GetTargetTriple();
|
||||
|
||||
ASSERT_TRUE(
|
||||
(triple.getOS() == llvm::Triple::OSType::Linux) ||
|
||||
(triple.hasEnvironment() &&
|
||||
triple.getEnvironment() == llvm::Triple::EnvironmentType::Android));
|
||||
|
||||
ProcessInstanceInfo Info;
|
||||
|
||||
ASSERT_FALSE(Host::GetProcessInfo(LLDB_INVALID_PROCESS_ID, Info));
|
||||
|
||||
ASSERT_TRUE(Host::GetProcessInfo(getpid(), Info));
|
||||
|
||||
ASSERT_TRUE(Info.ProcessIDIsValid());
|
||||
EXPECT_TRUE(Info.ProcessIDIsValid());
|
||||
EXPECT_EQ(lldb::pid_t(getpid()), Info.GetProcessID());
|
||||
|
||||
ASSERT_TRUE(Info.ParentProcessIDIsValid());
|
||||
EXPECT_TRUE(Info.ParentProcessIDIsValid());
|
||||
EXPECT_EQ(lldb::pid_t(getppid()), Info.GetParentProcessID());
|
||||
|
||||
ASSERT_TRUE(Info.ProcessGroupIDIsValid());
|
||||
// Not currently set on apple systems.
|
||||
#ifndef __APPLE__
|
||||
EXPECT_TRUE(Info.ProcessGroupIDIsValid());
|
||||
EXPECT_EQ(lldb::pid_t(getpgrp()), Info.GetProcessGroupID());
|
||||
|
||||
ASSERT_TRUE(Info.ProcessSessionIDIsValid());
|
||||
EXPECT_TRUE(Info.ProcessSessionIDIsValid());
|
||||
EXPECT_EQ(lldb::pid_t(getsid(getpid())), Info.GetProcessSessionID());
|
||||
#endif
|
||||
|
||||
ASSERT_TRUE(Info.EffectiveUserIDIsValid());
|
||||
EXPECT_TRUE(Info.EffectiveUserIDIsValid());
|
||||
EXPECT_EQ(geteuid(), Info.GetEffectiveUserID());
|
||||
|
||||
ASSERT_TRUE(Info.EffectiveGroupIDIsValid());
|
||||
EXPECT_TRUE(Info.EffectiveGroupIDIsValid());
|
||||
EXPECT_EQ(getegid(), Info.GetEffectiveGroupID());
|
||||
|
||||
ASSERT_TRUE(Info.UserIDIsValid());
|
||||
EXPECT_TRUE(Info.UserIDIsValid());
|
||||
EXPECT_EQ(geteuid(), Info.GetUserID());
|
||||
|
||||
ASSERT_TRUE(Info.GroupIDIsValid());
|
||||
EXPECT_TRUE(Info.GroupIDIsValid());
|
||||
EXPECT_EQ(getegid(), Info.GetGroupID());
|
||||
|
||||
EXPECT_TRUE(Info.GetArchitecture().IsValid());
|
||||
@@ -90,14 +88,19 @@ TEST_F(HostTest, GetProcessInfo) {
|
||||
ProcessInstanceInfo::timespec next_user_time = Info.GetUserTime();
|
||||
ASSERT_TRUE(user_time.tv_sec <= next_user_time.tv_sec ||
|
||||
user_time.tv_usec <= next_user_time.tv_usec);
|
||||
}
|
||||
|
||||
#ifndef _AIX
|
||||
// Only linux currently sets these.
|
||||
#ifdef __linux__
|
||||
TEST_F(HostTest, GetProcessInfoSetsPriority) {
|
||||
ProcessInstanceInfo Info;
|
||||
struct rlimit rlim;
|
||||
EXPECT_EQ(getrlimit(RLIMIT_NICE, &rlim), 0);
|
||||
// getpriority can return -1 so we zero errno first
|
||||
errno = 0;
|
||||
int prio = getpriority(PRIO_PROCESS, PRIO_PROCESS);
|
||||
int prio = getpriority(PRIO_PROCESS, 0);
|
||||
ASSERT_TRUE((prio < 0 && errno == 0) || prio >= 0);
|
||||
ASSERT_TRUE(Host::GetProcessInfo(getpid(), Info));
|
||||
ASSERT_EQ(Info.GetPriorityValue(), prio);
|
||||
// If we can't raise our nice level then this test can't be performed.
|
||||
int max_incr = PRIO_MAX - rlim.rlim_cur;
|
||||
@@ -110,5 +113,5 @@ TEST_F(HostTest, GetProcessInfo) {
|
||||
}
|
||||
ASSERT_TRUE(Info.IsZombie().has_value());
|
||||
ASSERT_FALSE(Info.IsZombie().value());
|
||||
#endif /* ifndef _AIX */
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user