Snap for 11698527 from 2d49c5c1efba4adea9cbd7ff5bb12f95cdc29fc7 to mainline-appsearch-release

Change-Id: I5bce3b92e46034eac00e15fe64ad145bf2a86c3b
diff --git a/tests/fcntl_test.cpp b/tests/fcntl_test.cpp
index 862f498..f9bfb30 100644
--- a/tests/fcntl_test.cpp
+++ b/tests/fcntl_test.cpp
@@ -361,5 +361,5 @@
 }
 
 TEST(fcntl_DeathTest, fcntl_F_SETFD) {
-  EXPECT_DEATH(fcntl(0, F_SETFD, O_NONBLOCK), "non-FD_CLOEXEC");
+  EXPECT_DEATH(fcntl(0, F_SETFD, O_NONBLOCK), "FD_CLOEXEC");
 }
diff --git a/tests/grp_pwd_test.cpp b/tests/grp_pwd_test.cpp
index 65a54a6..3d5a933 100644
--- a/tests/grp_pwd_test.cpp
+++ b/tests/grp_pwd_test.cpp
@@ -442,16 +442,33 @@
     return result;
   };
 
-  // AID_PRNG_SEEDER (1092) was added in TM-QPR2, but CTS is shared
-  // across Android 13 versions so we may or may not find it in this
-  // test (b/253185870).
-  if (android::base::GetIntProperty("ro.build.version.sdk", 0) == __ANDROID_API_T__) {
-#ifndef AID_PRNG_SEEDER
-#define AID_PRNG_SEEDER 1092
+  // AID_UPROBESTATS (1093) was added in V, but "trunk stable" means
+  // that the 2024Q builds don't have branches like the QPR builds used
+  // to, and are tested with the _previous_ release's CTS.
+  if (android::base::GetIntProperty("ro.build.version.sdk", 0) == __ANDROID_API_U__) {
+#if !defined(AID_UPROBESTATS)
+#define AID_UPROBESTATS 1093
 #endif
-    ids.erase(AID_PRNG_SEEDER);
-    expected_ids.erase(AID_PRNG_SEEDER);
+    ids.erase(AID_UPROBESTATS);
+    expected_ids.erase(AID_UPROBESTATS);
+    if (getpwuid(AID_UPROBESTATS)) {
+      EXPECT_STREQ(getpwuid(AID_UPROBESTATS)->pw_name, "uprobestats");
+    }
   }
+  // AID_VIRTUALMACHINE (3013) was added in V, but "trunk stable" means
+  // that the 2024Q builds don't have branches like the QPR builds used
+  // to, and are tested with the _previous_ release's CTS.
+  if (android::base::GetIntProperty("ro.build.version.sdk", 0) == __ANDROID_API_U__) {
+#if !defined(AID_VIRTUALMACHINE)
+#define AID_VIRTUALMACHINE 3013
+#endif
+    ids.erase(AID_VIRTUALMACHINE);
+    expected_ids.erase(AID_VIRTUALMACHINE);
+    if (getpwuid(AID_VIRTUALMACHINE)) {
+      EXPECT_STREQ(getpwuid(AID_VIRTUALMACHINE)->pw_name, "virtualmachine");
+    }
+  }
+
   EXPECT_EQ(expected_ids, ids) << return_differences();
 }
 #endif
diff --git a/tests/sys_statvfs_test.cpp b/tests/sys_statvfs_test.cpp
index 1761e6a..73b2a96 100644
--- a/tests/sys_statvfs_test.cpp
+++ b/tests/sys_statvfs_test.cpp
@@ -28,9 +28,19 @@
   EXPECT_EQ(4096U, sb.f_bsize);
   EXPECT_EQ(0U, sb.f_bfree);
   EXPECT_EQ(0U, sb.f_ffree);
-  EXPECT_EQ(0U, sb.f_fsid);
   EXPECT_EQ(255U, sb.f_namemax);
 
+  // Linux 6.7 requires that all filesystems have a non-zero fsid.
+  if (sb.f_fsid != 0U) {
+    // fs/libfs.c reuses the filesystem's device number.
+    struct stat proc_sb;
+    ASSERT_EQ(0, stat("/proc", &proc_sb));
+    EXPECT_EQ(proc_sb.st_dev, sb.f_fsid);
+  } else {
+    // Prior to that, the fsid for /proc was just 0.
+    EXPECT_EQ(0U, sb.f_fsid);
+  }
+
   // The kernel sets a private bit to indicate that f_flags is valid.
   // This flag is not supposed to be exposed to libc clients.
   static const uint32_t ST_VALID = 0x0020;
diff --git a/tests/sys_vfs_test.cpp b/tests/sys_vfs_test.cpp
index 242f8d4..363e49b 100644
--- a/tests/sys_vfs_test.cpp
+++ b/tests/sys_vfs_test.cpp
@@ -28,10 +28,21 @@
   EXPECT_EQ(4096, static_cast<int>(sb.f_bsize));
   EXPECT_EQ(0U, sb.f_bfree);
   EXPECT_EQ(0U, sb.f_ffree);
-  EXPECT_EQ(0, sb.f_fsid.__val[0]);
-  EXPECT_EQ(0, sb.f_fsid.__val[1]);
   EXPECT_EQ(255, static_cast<int>(sb.f_namelen));
 
+  // Linux 6.7 requires that all filesystems have a non-zero fsid.
+  if (sb.f_fsid.__val[0] != 0U) {
+    // fs/libfs.c reuses the filesystem's device number.
+    struct stat proc_sb;
+    ASSERT_EQ(0, stat("/proc", &proc_sb));
+    EXPECT_EQ(static_cast<int>(proc_sb.st_dev), sb.f_fsid.__val[0]);
+    EXPECT_EQ(0, sb.f_fsid.__val[1]);
+  } else {
+    // Prior to that, the fsid for /proc was just 0.
+    EXPECT_EQ(0, sb.f_fsid.__val[0]);
+    EXPECT_EQ(0, sb.f_fsid.__val[1]);
+  }
+
   // The kernel sets a private bit to indicate that f_flags is valid.
   // This flag is not supposed to be exposed to libc clients.
   static const uint32_t ST_VALID = 0x0020;
diff --git a/tests/time_test.cpp b/tests/time_test.cpp
index f0ad937..0dcbcd2 100644
--- a/tests/time_test.cpp
+++ b/tests/time_test.cpp
@@ -167,7 +167,9 @@
 #endif
 }
 
-TEST(time, mktime_EOVERFLOW) {
+TEST(time, DISABLED_mktime_EOVERFLOW) {
+  setenv("TZ", "UTC", 1);
+
   struct tm t;
   memset(&t, 0, sizeof(tm));
 
diff --git a/tests/uchar_test.cpp b/tests/uchar_test.cpp
index 4dc6314..703f558 100644
--- a/tests/uchar_test.cpp
+++ b/tests/uchar_test.cpp
@@ -112,7 +112,7 @@
   ASSERT_EQ(0U, mbrtoc16(nullptr, nullptr, 0, nullptr));
 }
 
-TEST(uchar, mbrtoc16_zero_len) {
+TEST(uchar, DISABLED_mbrtoc16_zero_len) {
   char16_t out;
 
   out = L'x';
@@ -125,7 +125,7 @@
   ASSERT_EQ(L'h', out);
 }
 
-TEST(uchar, mbrtoc16) {
+TEST(uchar, DISABLED_mbrtoc16) {
   char16_t out;
 
   ASSERT_STREQ("C.UTF-8", setlocale(LC_CTYPE, "C.UTF-8"));
@@ -196,7 +196,7 @@
   ASSERT_EQ(EILSEQ, errno);
 }
 
-TEST(uchar, mbrtoc16_incomplete) {
+TEST(uchar, DISABLED_mbrtoc16_incomplete) {
   mbstate_t ps;
   memset(&ps, 0, sizeof(ps));
 
@@ -271,7 +271,7 @@
   ASSERT_EQ(EILSEQ, errno);
 }
 
-TEST(uchar, mbrtoc32) {
+TEST(uchar, DISABLED_mbrtoc32) {
   char32_t out[8];
 
   out[0] = L'x';
diff --git a/tests/wchar_test.cpp b/tests/wchar_test.cpp
index 8716810..07eef1b 100644
--- a/tests/wchar_test.cpp
+++ b/tests/wchar_test.cpp
@@ -34,7 +34,7 @@
   EXPECT_EQ(4U, sizeof(wint_t));
 }
 
-TEST(wchar, mbrlen) {
+TEST(wchar, DISABLED_mbrlen) {
   char bytes[] = { 'h', 'e', 'l', 'l', 'o', '\0' };
   EXPECT_EQ(0U, mbrlen(&bytes[0], 0, nullptr));
   EXPECT_EQ(1U, mbrlen(&bytes[0], 1, nullptr));
@@ -252,7 +252,7 @@
   ASSERT_TRUE(wcsstr(L"romrom", L"rom") != nullptr);
 }
 
-TEST(wchar, mbtowc) {
+TEST(wchar, DISABLED_mbtowc) {
   wchar_t out[8];
 
   out[0] = 'x';
@@ -271,7 +271,7 @@
   ASSERT_EQ(0, mbtowc(nullptr, nullptr, 0));
 }
 
-TEST(wchar, mbrtowc) {
+TEST(wchar, DISABLED_mbrtowc) {
   wchar_t out[8];
 
   out[0] = 'x';