grp_pwd_test: Hack around "trunk stable".

The 2024Q builds don't have their own branches like QPR builds used to,
and there's no API bump until V proper, so the same CTS build needs to
cope with both last year's Android release _and_ the one that doesn't
have an API level yet. So poke holes in the uid test to support these
mismatches.

This runs the risk of allowing accidental misuse in U of the very uids
that will definitely be used in V, so check that _if_ the uids do exist,
they have the names we're expecting them to have. That should make
accidents easier to spot?

Bug: http://b/322256445
Test: treehugger
Change-Id: I3b24b8fafe20012df70c73589b40dba5a10e50e9
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