16k: Fix sysconf_SC_ARG_MAX test to support 16k page sizes

The sysconf_SC_ARG_MAX test was failing because it didn't
handle the case for 16k. After fixing the test case, it will
handle 4k/16k page sizes and fail when there is another page
size.

Bug: 315174209
Test: atest -c bionic-unit-tests-static
Change-Id: Ie24a79be9d6790a1243be48d39f67acda485c37d
diff --git a/tests/unistd_test.cpp b/tests/unistd_test.cpp
index 6a94507..e9a3080 100644
--- a/tests/unistd_test.cpp
+++ b/tests/unistd_test.cpp
@@ -1127,8 +1127,8 @@
 
 TEST(UNISTD_TEST, sysconf_SC_ARG_MAX) {
   // Since Linux 2.6.23, ARG_MAX isn't a constant and depends on RLIMIT_STACK.
-  // See prepare_arg_pages() in the kernel for the gory details:
-  // https://elixir.bootlin.com/linux/v5.3.11/source/fs/exec.c#L451
+  // See setup_arg_pages() in the kernel for the gory details:
+  // https://elixir.bootlin.com/linux/v6.6.4/source/fs/exec.c#L749
 
   // Get our current limit, and set things up so we restore the limit.
   rlimit rl;
@@ -1145,19 +1145,24 @@
   // _SC_ARG_MAX should be 1/4 the stack size.
   EXPECT_EQ(static_cast<long>(rl.rlim_cur / 4), sysconf(_SC_ARG_MAX));
 
-  // If you have a really small stack, the kernel still guarantees "32 pages" (see fs/exec.c).
+  // If you have a really small stack, the kernel still guarantees a stack
+  // expansion of 128KiB (see setup_arg_pages() in fs/exec.c).
   rl.rlim_cur = 1024;
   rl.rlim_max = RLIM_INFINITY;
   ASSERT_EQ(0, setrlimit(RLIMIT_STACK, &rl));
 
-  EXPECT_EQ(static_cast<long>(32 * sysconf(_SC_PAGE_SIZE)), sysconf(_SC_ARG_MAX));
+  // The stack expansion number is defined in fs/exec.c.
+  // https://elixir.bootlin.com/linux/v6.6.4/source/fs/exec.c#L845
+  constexpr long kernel_stack_expansion = 131072;
+  EXPECT_EQ(kernel_stack_expansion, sysconf(_SC_ARG_MAX));
 
-  // With a 128-page stack limit, we know exactly what _SC_ARG_MAX should be...
-  rl.rlim_cur = 128 * sysconf(_SC_PAGE_SIZE);
+  // If you have a large stack, the kernel will keep the stack
+  // expansion to 128KiB (see setup_arg_pages() in fs/exec.c).
+  rl.rlim_cur = 524288;
   rl.rlim_max = RLIM_INFINITY;
   ASSERT_EQ(0, setrlimit(RLIMIT_STACK, &rl));
 
-  EXPECT_EQ(static_cast<long>((128 * sysconf(_SC_PAGE_SIZE)) / 4), sysconf(_SC_ARG_MAX));
+  EXPECT_EQ(kernel_stack_expansion, sysconf(_SC_ARG_MAX));
 }
 
 TEST(UNISTD_TEST, sysconf_unknown) {