]> Savannah Git Hosting - gnulib.git/commitdiff
getlogin_r tests: Remove xalloc dependency.
authorBruno Haible <bruno@clisp.org>
Fri, 18 Apr 2025 13:05:10 +0000 (15:05 +0200)
committerBruno Haible <bruno@clisp.org>
Fri, 18 Apr 2025 13:05:10 +0000 (15:05 +0200)
* tests/test-getlogin.c (main): Don't assume the putenv argument is
unmodified.
* tests/test-getlogin_r.c: Do not include xalloc.h.
(main): Use a static rather than heap storage.
* modules/getlogin_r-tests (Depends-on): Remove xalloc.
(test_getlogin_LDADD): Remove @LIBINTL@.

ChangeLog
modules/getlogin_r-tests
tests/test-getlogin.c
tests/test-getlogin_r.c

index 6df7b09a1e61d38681ac46ff0bd07b88bdd3304d..2489838c208a8f68848ef917db3e7743c36e5ad0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2025-04-18  Bruno Haible  <bruno@clisp.org>
+
+       getlogin_r tests: Remove xalloc dependency.
+       * tests/test-getlogin.c (main): Don't assume the putenv argument is
+       unmodified.
+       * tests/test-getlogin_r.c: Do not include xalloc.h.
+       (main): Use a static rather than heap storage.
+       * modules/getlogin_r-tests (Depends-on): Remove xalloc.
+       (test_getlogin_LDADD): Remove @LIBINTL@.
+
 2025-04-17  Paul Eggert  <eggert@cs.ucla.edu>
 
        memset_explicit-tests: pacify -Wuse-after-free
index 3cddb655846131477893e4062e4ec949b6eee21d..8fefa059bc71f679d91dde1328f83ba8a701face 100644 (file)
@@ -6,11 +6,10 @@ tests/macros.h
 
 Depends-on:
 bool
-xalloc
 
 configure.ac:
 
 Makefile.am:
 TESTS += test-getlogin_r
 check_PROGRAMS += test-getlogin_r
-test_getlogin_r_LDADD = $(LDADD) @LIBINTL@ $(GETLOGIN_LIB)
+test_getlogin_r_LDADD = $(LDADD) $(GETLOGIN_LIB)
index 35ca3e0980a0962e8548adde072b75339fd74ba9..d2e006d5e1841e686a7b836e98ce4e405a5623cd 100644 (file)
@@ -43,11 +43,13 @@ main (void)
   test_getlogin_result (buf, err);
 
   /* Check that getlogin() does not merely return getenv ("LOGNAME").  */
-  static char set_LOGNAME[] = "LOGNAME=ygvfibmslhkmvoetbrcegzwydorcke";
-  putenv (set_LOGNAME);
-  buf = getlogin ();
-  ASSERT (!(buf != NULL
-            && strcmp (buf, set_LOGNAME + sizeof "LOGNAME") == 0));
+  {
+    static char set_LOGNAME[] = "LOGNAME=ygvfibmslhkmvoetbrcegzwydorcke";
+    putenv (set_LOGNAME);
+    buf = getlogin ();
+    ASSERT (!(buf != NULL
+              && strcmp (buf, "ygvfibmslhkmvoetbrcegzwydorcke") == 0));
+  }
 
   return test_exit_status;
 }
index e27e23da2349b6cc9a5b259a4693309e8fffec95..e8a438bf10a10efcfb6e315c345d446859c9d148 100644 (file)
@@ -26,8 +26,6 @@
 SIGNATURE_CHECK (getlogin_r, int, (char *, size_t));
 #endif
 
-#include "xalloc.h"
-
 #include "test-getlogin.h"
 
 int
@@ -72,9 +70,12 @@ main (void)
   }
 
   /* Check that getlogin_r() does not merely return getenv ("LOGNAME").  */
-  putenv (xstrdup ("LOGNAME=ygvfibmslhkmvoetbrcegzwydorcke"));
-  err = getlogin_r (buf, sizeof buf);
-  ASSERT (!(err == 0 && strcmp (buf, "ygvfibmslhkmvoetbrcegzwydorcke") == 0));
+  {
+    static char set_LOGNAME[] = "LOGNAME=ygvfibmslhkmvoetbrcegzwydorcke";
+    putenv (set_LOGNAME);
+    err = getlogin_r (buf, sizeof buf);
+    ASSERT (!(err == 0 && strcmp (buf, "ygvfibmslhkmvoetbrcegzwydorcke") == 0));
+  }
 
   return test_exit_status;
 }