Merge "Add CtsBionicAppTestCases to postsubmit" into main
diff --git a/libc/Android.bp b/libc/Android.bp
index 7e5e972..7098ab1 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -820,8 +820,6 @@
         "bionic/dup.cpp",
         "bionic/environ.cpp",
         "bionic/error.cpp",
-        "bionic/ether_aton.c",
-        "bionic/ether_ntoa.c",
         "bionic/eventfd.cpp",
         "bionic/exec.cpp",
         "bionic/execinfo.cpp",
@@ -881,8 +879,9 @@
         "bionic/mknod.cpp",
         "bionic/mntent.cpp",
         "bionic/mremap.cpp",
-        "bionic/net_if.cpp",
         "bionic/netdb.cpp",
+        "bionic/net_if.cpp",
+        "bionic/netinet_ether.cpp",
         "bionic/netinet_in.cpp",
         "bionic/nl_types.cpp",
         "bionic/open.cpp",
diff --git a/libc/bionic/__bionic_get_shell_path.cpp b/libc/bionic/__bionic_get_shell_path.cpp
index b78aede..5d22e00 100644
--- a/libc/bionic/__bionic_get_shell_path.cpp
+++ b/libc/bionic/__bionic_get_shell_path.cpp
@@ -28,29 +28,11 @@
 
 #include "private/__bionic_get_shell_path.h"
 
-#include <errno.h>
-#include <string.h>
-#include <sys/cdefs.h>
-#include <unistd.h>
-
-#define VENDOR_PREFIX "/vendor/"
-
-static const char* init_sh_path() {
+const char* __bionic_get_shell_path() {
 #if !defined(__ANDROID__)
   // For the host Bionic, use the standard /bin/sh
   return "/bin/sh";
 #else
-  // Look for /system or /vendor prefix.
-  char exe_path[strlen(VENDOR_PREFIX)];
-  ssize_t len = readlink("/proc/self/exe", exe_path, sizeof(exe_path));
-  if (len != -1 && !strncmp(exe_path, VENDOR_PREFIX, strlen(VENDOR_PREFIX))) {
-    return "/vendor/bin/sh";
-  }
   return "/system/bin/sh";
 #endif  // if !defined(__ANDROID__)
 }
-
-const char* __bionic_get_shell_path() {
-  static const char* sh_path = init_sh_path();
-  return sh_path;
-}
diff --git a/libc/bionic/ether_aton.c b/libc/bionic/ether_aton.c
deleted file mode 100644
index edd6b11..0000000
--- a/libc/bionic/ether_aton.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <net/ethernet.h>
-
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-static inline int
-xdigit (char c) {
-    unsigned d;
-    d = (unsigned)(c-'0');
-    if (d < 10) return (int)d;
-    d = (unsigned)(c-'a');
-    if (d < 6) return (int)(10+d);
-    d = (unsigned)(c-'A');
-    if (d < 6) return (int)(10+d);
-    return -1;
-}
-
-/*
- * Convert Ethernet address in the standard hex-digits-and-colons to binary
- * representation.
- * Re-entrant version (GNU extensions)
- */
-struct ether_addr *
-ether_aton_r (const char *asc, struct ether_addr * addr)
-{
-    int i, val0, val1;
-    for (i = 0; i < ETHER_ADDR_LEN; ++i) {
-        val0 = xdigit(*asc);
-        asc++;
-        if (val0 < 0)
-            return NULL;
-
-        val1 = xdigit(*asc);
-        asc++;
-        if (val1 < 0)
-            return NULL;
-
-        addr->ether_addr_octet[i] = (u_int8_t)((val0 << 4) + val1);
-
-        if (i < ETHER_ADDR_LEN - 1) {
-            if (*asc != ':')
-                return NULL;
-            asc++;
-        }
-    }
-    if (*asc != '\0')
-        return NULL;
-    return addr;
-}
-
-/*
- * Convert Ethernet address in the standard hex-digits-and-colons to binary
- * representation.
- */
-struct ether_addr *
-ether_aton (const char *asc)
-{
-    static struct ether_addr addr;
-    return ether_aton_r(asc, &addr);
-}
diff --git a/libc/bionic/ether_ntoa.c b/libc/bionic/ether_ntoa.c
deleted file mode 100644
index 7c31af3..0000000
--- a/libc/bionic/ether_ntoa.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <net/ethernet.h>
-
-/*
- * Convert Ethernet address to standard hex-digits-and-colons printable form.
- * Re-entrant version (GNU extensions).
- */
-char *
-ether_ntoa_r (const struct ether_addr *addr, char * buf)
-{
-    snprintf(buf, 18, "%02x:%02x:%02x:%02x:%02x:%02x",
-            addr->ether_addr_octet[0], addr->ether_addr_octet[1],
-            addr->ether_addr_octet[2], addr->ether_addr_octet[3],
-            addr->ether_addr_octet[4], addr->ether_addr_octet[5]);
-    return buf;
-}
-
-/*
- * Convert Ethernet address to standard hex-digits-and-colons printable form.
- */
-char *
-ether_ntoa (const struct ether_addr *addr)
-{
-    static char buf[18];
-    return ether_ntoa_r(addr, buf);
-}
diff --git a/libc/bionic/netinet_ether.cpp b/libc/bionic/netinet_ether.cpp
new file mode 100644
index 0000000..7ebceac
--- /dev/null
+++ b/libc/bionic/netinet_ether.cpp
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <netinet/ether.h>
+
+#include <stdio.h>
+
+ether_addr* ether_aton_r(const char* asc, ether_addr* addr) {
+  int bytes[ETHER_ADDR_LEN], end;
+  int n = sscanf(asc, "%x:%x:%x:%x:%x:%x%n",
+                 &bytes[0], &bytes[1], &bytes[2],
+                 &bytes[3], &bytes[4], &bytes[5], &end);
+  if (n != ETHER_ADDR_LEN || asc[end] != '\0') return NULL;
+  for (int i = 0; i < ETHER_ADDR_LEN; i++) {
+    if (bytes[i] > 0xff) return NULL;
+    addr->ether_addr_octet[i] = bytes[i];
+  }
+  return addr;
+}
+
+struct ether_addr* ether_aton(const char* asc) {
+  static ether_addr addr;
+  return ether_aton_r(asc, &addr);
+}
+
+char* ether_ntoa_r(const ether_addr* addr, char* buf) {
+  snprintf(buf, 18, "%02x:%02x:%02x:%02x:%02x:%02x",
+           addr->ether_addr_octet[0], addr->ether_addr_octet[1],
+           addr->ether_addr_octet[2], addr->ether_addr_octet[3],
+           addr->ether_addr_octet[4], addr->ether_addr_octet[5]);
+  return buf;
+}
+
+char* ether_ntoa(const ether_addr* addr) {
+  static char buf[18];
+  return ether_ntoa_r(addr, buf);
+}
diff --git a/libc/bionic/pathconf.cpp b/libc/bionic/pathconf.cpp
index 9724f44..9bbecc3 100644
--- a/libc/bionic/pathconf.cpp
+++ b/libc/bionic/pathconf.cpp
@@ -107,14 +107,6 @@
     case _PC_REC_MIN_XFER_SIZE:
       return s.f_bsize;
 
-#if 0
-    case _PC_REC_INCR_XFER_SIZE:
-    case _PC_REC_MAX_XFER_SIZE:
-#endif
-
-    case _PC_SYMLINK_MAX:
-      return -1; /* no limit */
-
     case _PC_CHOWN_RESTRICTED:
       return _POSIX_CHOWN_RESTRICTED;
 
@@ -125,12 +117,15 @@
       return _POSIX_VDISABLE;
 
     case _PC_ASYNC_IO:
-      return -1;
-
     case _PC_PRIO_IO:
-      return -1;
-
+    case _PC_REC_INCR_XFER_SIZE:
+    case _PC_REC_MAX_XFER_SIZE:
+    case _PC_SYMLINK_MAX:
     case _PC_SYNC_IO:
+      // No API to answer these: the caller will have to "try it and see".
+      // This differs from the next case in not setting errno to EINVAL,
+      // since we did understand the question --- we just don't have a
+      // good answer.
       return -1;
 
     default:
diff --git a/libc/bionic/sysconf.cpp b/libc/bionic/sysconf.cpp
index ff72b93..9ffb58e 100644
--- a/libc/bionic/sysconf.cpp
+++ b/libc/bionic/sysconf.cpp
@@ -41,16 +41,6 @@
 #include "platform/bionic/page.h"
 #include "private/bionic_tls.h"
 
-static long __sysconf_fread_long(const char* path) {
-  long result = 0;
-  FILE* fp = fopen(path, "re");
-  if (fp != nullptr) {
-    fscanf(fp, "%ld", &result);
-    fclose(fp);
-  }
-  return result;
-}
-
 struct sysconf_cache {
   long size, assoc, linesize;
 
@@ -100,6 +90,16 @@
 
 #else
 
+static long __sysconf_fread_long(const char* path) {
+  long result = 0;
+  FILE* fp = fopen(path, "re");
+  if (fp != nullptr) {
+    fscanf(fp, "%ld", &result);
+    fclose(fp);
+  }
+  return result;
+}
+
 static sysconf_caches* __sysconf_caches() {
   static sysconf_caches cached = []{
     sysconf_caches info = {};
@@ -182,8 +182,8 @@
 
     case _SC_AVPHYS_PAGES:      return get_avphys_pages();
     case _SC_CHILD_MAX:         return __sysconf_rlimit(RLIMIT_NPROC);
-    case _SC_CLK_TCK:           return static_cast<long>(getauxval(AT_CLKTCK));
-    case _SC_NGROUPS_MAX:       return __sysconf_fread_long("/proc/sys/kernel/ngroups_max");
+    case _SC_CLK_TCK:
+      return static_cast<long>(getauxval(AT_CLKTCK));
     case _SC_NPROCESSORS_CONF:  return get_nprocs_conf();
     case _SC_NPROCESSORS_ONLN:  return get_nprocs();
     case _SC_OPEN_MAX:          return __sysconf_rlimit(RLIMIT_NOFILE);
@@ -205,6 +205,11 @@
     case _SC_COLL_WEIGHTS_MAX:  return _POSIX2_COLL_WEIGHTS_MAX;  // Minimum requirement.
     case _SC_EXPR_NEST_MAX:     return _POSIX2_EXPR_NEST_MAX;     // Minimum requirement.
     case _SC_LINE_MAX:          return _POSIX2_LINE_MAX;          // Minimum requirement.
+    case _SC_NGROUPS_MAX:
+      // Only root can read /proc/sys/kernel/ngroups_max on Android, and groups
+      // are vestigial anyway, so the "maximum maximum" of NGROUPS_MAX is a good
+      // enough answer for _SC_NGROUPS_MAX...
+      return NGROUPS_MAX;
     case _SC_PASS_MAX:          return PASS_MAX;
     case _SC_2_C_BIND:          return _POSIX2_C_BIND;
     case _SC_2_C_DEV:           return _POSIX2_C_DEV;
diff --git a/libc/include/netinet/ether.h b/libc/include/netinet/ether.h
index d570c18..4af7eda 100644
--- a/libc/include/netinet/ether.h
+++ b/libc/include/netinet/ether.h
@@ -40,7 +40,7 @@
 
 /**
  * [ether_ntoa(3)](http://man7.org/linux/man-pages/man3/ether_ntoa.3.html) returns a string
- * representation of the given Ethernet address.
+ * representation of the given Ethernet (MAC) address.
  *
  * Returns a pointer to a static buffer.
  */
@@ -48,7 +48,7 @@
 
 /**
  * [ether_ntoa_r(3)](http://man7.org/linux/man-pages/man3/ether_ntoa_r.3.html) returns a string
- * representation of the given Ethernet address.
+ * representation of the given Ethernet (MAC) address.
  *
  * Returns a pointer to the given buffer.
  */
@@ -56,7 +56,7 @@
 
 /**
  * [ether_aton(3)](http://man7.org/linux/man-pages/man3/ether_aton.3.html) returns an `ether_addr`
- * corresponding to the given Ethernet address string.
+ * corresponding to the given Ethernet (MAC) address string.
  *
  * Returns a pointer to a static buffer, or NULL if the given string isn't a valid MAC address.
  */
@@ -64,7 +64,7 @@
 
 /**
  * [ether_aton_r(3)](http://man7.org/linux/man-pages/man3/ether_aton_r.3.html) returns an
- * `ether_addr` corresponding to the given Ethernet address string.
+ * `ether_addr` corresponding to the given Ethernet (MAC) address string.
  *
  * Returns a pointer to the given buffer, or NULL if the given string isn't a valid MAC address.
  */
diff --git a/tests/NOTICE b/tests/NOTICE
index cc99d20..de95698 100644
--- a/tests/NOTICE
+++ b/tests/NOTICE
@@ -454,3 +454,31 @@
 
 -------------------------------------------------------------------
 
+Copyright (C) 2024 The Android Open Source Project
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+ * Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in
+   the documentation and/or other materials provided with the
+   distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
diff --git a/tests/grp_pwd_test.cpp b/tests/grp_pwd_test.cpp
index 16b8d5a..ddc0fc1 100644
--- a/tests/grp_pwd_test.cpp
+++ b/tests/grp_pwd_test.cpp
@@ -444,16 +444,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/libs/dlopen_testlib_depends_on_simple.cpp b/tests/libs/dlopen_testlib_depends_on_simple.cpp
index 9e130d4..3652be8 100644
--- a/tests/libs/dlopen_testlib_depends_on_simple.cpp
+++ b/tests/libs/dlopen_testlib_depends_on_simple.cpp
@@ -1,17 +1,29 @@
 /*
  * Copyright (C) 2024 The Android Open Source Project
+ * All rights reserved.
  *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  */
 
 #include <stdint.h>
diff --git a/tests/libs/testbinary_is_stack_mte.cpp b/tests/libs/testbinary_is_stack_mte.cpp
index 8dde83c..d8074d5 100644
--- a/tests/libs/testbinary_is_stack_mte.cpp
+++ b/tests/libs/testbinary_is_stack_mte.cpp
@@ -1,17 +1,29 @@
 /*
  * Copyright (C) 2024 The Android Open Source Project
+ * All rights reserved.
  *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  */
 
 #include <stdint.h>
diff --git a/tests/libs/testbinary_is_stack_mte_after_dlopen.cpp b/tests/libs/testbinary_is_stack_mte_after_dlopen.cpp
index c5e6868..937ac4c 100644
--- a/tests/libs/testbinary_is_stack_mte_after_dlopen.cpp
+++ b/tests/libs/testbinary_is_stack_mte_after_dlopen.cpp
@@ -1,17 +1,29 @@
 /*
  * Copyright (C) 2024 The Android Open Source Project
+ * All rights reserved.
  *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  */
 
 #include <stdint.h>
diff --git a/tests/mte_utils.h b/tests/mte_utils.h
index 0f18442..6e8385c 100644
--- a/tests/mte_utils.h
+++ b/tests/mte_utils.h
@@ -1,17 +1,29 @@
 /*
  * Copyright (C) 2024 The Android Open Source Project
+ * All rights reserved.
  *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  */
 
 #pragma once
diff --git a/tests/netinet_ether_test.cpp b/tests/netinet_ether_test.cpp
index af020ec..d7b81eb 100644
--- a/tests/netinet_ether_test.cpp
+++ b/tests/netinet_ether_test.cpp
@@ -56,4 +56,5 @@
   ASSERT_TRUE(ether_aton_r("12:34:56:78:9a:bc ", &addr) == nullptr);
   ASSERT_TRUE(ether_aton_r("g2:34:56:78:9a:bc ", &addr) == nullptr);
   ASSERT_TRUE(ether_aton_r("1G:34:56:78:9a:bc ", &addr) == nullptr);
+  ASSERT_TRUE(ether_aton_r("123:34:56:78:9a:bc ", &addr) == nullptr);
 }
diff --git a/tests/unistd_test.cpp b/tests/unistd_test.cpp
index 88f5851..6c08972 100644
--- a/tests/unistd_test.cpp
+++ b/tests/unistd_test.cpp
@@ -753,22 +753,36 @@
 
 TEST(UNISTD_TEST, pathconf_fpathconf) {
   TemporaryFile tf;
-  long rc = 0L;
+  long l;
+
   // As a file system's block size is always power of 2, the configure values
   // for ALLOC and XFER should be power of 2 as well.
-  rc = pathconf(tf.path, _PC_ALLOC_SIZE_MIN);
-  ASSERT_TRUE(rc > 0 && powerof2(rc));
-  rc = pathconf(tf.path, _PC_REC_MIN_XFER_SIZE);
-  ASSERT_TRUE(rc > 0 && powerof2(rc));
-  rc = pathconf(tf.path, _PC_REC_XFER_ALIGN);
-  ASSERT_TRUE(rc > 0 && powerof2(rc));
+  l = pathconf(tf.path, _PC_ALLOC_SIZE_MIN);
+  ASSERT_TRUE(l > 0 && powerof2(l));
+  l = pathconf(tf.path, _PC_REC_MIN_XFER_SIZE);
+  ASSERT_TRUE(l > 0 && powerof2(l));
+  l = pathconf(tf.path, _PC_REC_XFER_ALIGN);
+  ASSERT_TRUE(l > 0 && powerof2(l));
 
-  rc = fpathconf(tf.fd, _PC_ALLOC_SIZE_MIN);
-  ASSERT_TRUE(rc > 0 && powerof2(rc));
-  rc = fpathconf(tf.fd, _PC_REC_MIN_XFER_SIZE);
-  ASSERT_TRUE(rc > 0 && powerof2(rc));
-  rc = fpathconf(tf.fd, _PC_REC_XFER_ALIGN);
-  ASSERT_TRUE(rc > 0 && powerof2(rc));
+  l = fpathconf(tf.fd, _PC_ALLOC_SIZE_MIN);
+  ASSERT_TRUE(l > 0 && powerof2(l));
+  l = fpathconf(tf.fd, _PC_REC_MIN_XFER_SIZE);
+  ASSERT_TRUE(l > 0 && powerof2(l));
+  l = fpathconf(tf.fd, _PC_REC_XFER_ALIGN);
+  ASSERT_TRUE(l > 0 && powerof2(l));
+
+  // Check that the "I can't answer that, you'll have to try it and see"
+  // cases don't set errno.
+  int names[] = {
+      _PC_ASYNC_IO, _PC_PRIO_IO, _PC_REC_INCR_XFER_SIZE, _PC_REC_MAX_XFER_SIZE, _PC_SYMLINK_MAX,
+      _PC_SYNC_IO,  -1};
+  for (size_t i = 0; names[i] != -1; i++) {
+    errno = 0;
+    ASSERT_EQ(-1, pathconf(tf.path, names[i])) << names[i];
+    ASSERT_ERRNO(0) << names[i];
+    ASSERT_EQ(-1, fpathconf(tf.fd, names[i])) << names[i];
+    ASSERT_ERRNO(0) << names[i];
+  }
 }
 
 TEST(UNISTD_TEST, _POSIX_constants) {
diff --git a/tools/update_notice.sh b/tools/update_notice.sh
index c45311a..69e090c 100755
--- a/tools/update_notice.sh
+++ b/tools/update_notice.sh
@@ -11,4 +11,4 @@
 python3 ./libc/tools/generate_notice.py linker > linker/NOTICE
 python3 ./libc/tools/generate_notice.py tests > tests/NOTICE
 python3 ./libc/tools/generate_notice.py tools > tools/NOTICE
-git diff --exit-code HEAD libc/NOTICE
+git diff --exit-code HEAD */NOTICE