test-xalloc-die: avoid spurious failure due to libtool argv difference
authorJim Meyering <meyering@redhat.com>
Fri, 27 Nov 2009 09:19:32 +0000 (10:19 +0100)
committerJim Meyering <meyering@redhat.com>
Fri, 27 Nov 2009 09:19:32 +0000 (10:19 +0100)
In a libtool-enabled project, this test would fail due to a difference
in the emitted program name, e.g.,
-test-xalloc-die: memory exhausted
+/tmp/.../tests/.libs/lt-test-xalloc-die: memory exhausted
Use program to avoid that.
* modules/xalloc-die-tests (Depends-on): Add progname.
* tests/test-xalloc-die.c: Include progname.h".
(program_name): Remove decl.
(main): Call set_program_name.
* tests/test-xalloc-die.sh (compare): Remove unnecessary ${EXE}.

ChangeLog
modules/xalloc-die-tests
tests/test-xalloc-die.c
tests/test-xalloc-die.sh

index 25e8b59..27a6abc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2009-11-27  Jim Meyering  <meyering@redhat.com>
+
+       test-xalloc-die: avoid spurious failure due to libtool argv difference
+       In a libtool-enabled project, this test would fail due to a difference
+       in the emitted program name, e.g.,
+       -test-xalloc-die: memory exhausted
+       +/tmp/.../tests/.libs/lt-test-xalloc-die: memory exhausted
+       Use program to avoid that.
+       * modules/xalloc-die-tests (Depends-on): Add progname.
+       * tests/test-xalloc-die.c: Include progname.h".
+       (program_name): Remove decl.
+       (main): Call set_program_name.
+       * tests/test-xalloc-die.sh (compare): Remove unnecessary ${EXE}.
+
 2009-11-26  Richard Jones  <rjones@redhat.com>
 
        w32sock: leave win32 error in place.
index 9b430cb..d28c95f 100644 (file)
@@ -3,6 +3,7 @@ tests/test-xalloc-die.c
 tests/test-xalloc-die.sh
 
 Depends-on:
+progname
 
 Makefile.am:
 TESTS += test-xalloc-die.sh
index 88461e8..4a03a0b 100644 (file)
 #include <config.h>
 
 #include "xalloc.h"
-
-char *program_name = "test-xalloc-die";
+#include "progname.h"
 
 int
-main (void)
+main (int argc, char **argv)
 {
+  set_program_name (argv[0]);
   xalloc_die ();
   return 0;
 }
index 4b0d2c2..8a30022 100755 (executable)
@@ -34,7 +34,7 @@ tmpfiles="$tmpout $tmperr ${tmperr}2"
 
 PATH=".:$PATH"
 export PATH
-test-xalloc-die${EXEEXT} 2> ${tmperr} > ${tmpout}
+test-xalloc-die 2> ${tmperr} > ${tmpout}
 case $? in
   1) ;;
   *) (exit 1); exit 1 ;;