Author: Pavel Labath
Date: 2025-04-29T09:28:43+02:00
New Revision: a9ece2dc68e623ebdfdbf7431dac2150a87b2717

URL: 
https://github.com/llvm/llvm-project/commit/a9ece2dc68e623ebdfdbf7431dac2150a87b2717
DIFF: 
https://github.com/llvm/llvm-project/commit/a9ece2dc68e623ebdfdbf7431dac2150a87b2717.diff

LOG: [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.

Added: 
    

Modified: 
    lldb/unittests/Host/posix/HostTest.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/unittests/Host/posix/HostTest.cpp 
b/lldb/unittests/Host/posix/HostTest.cpp
index b4b3a33e7ddc1..6d38655b03ed0 100644
--- a/lldb/unittests/Host/posix/HostTest.cpp
+++ b/lldb/unittests/Host/posix/HostTest.cpp
@@ -34,39 +34,37 @@ class HostTest : public testing::Test {
 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


        
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to