bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 4/4] Add a test suite for the sethostname module


From: Bruno Haible
Subject: Re: [PATCH 4/4] Add a test suite for the sethostname module
Date: Sat, 3 Dec 2011 15:57:38 +0100
User-agent: KMail/1.13.6 (Linux/2.6.37.6-0.5-desktop; KDE/4.6.0; x86_64; ; )

Ben Walton wrote:
> +  ASSERT(gethostname (origname, sizeof (origname)) == 0);

On mingw, I'm seeing a warning and link error:

test-sethostname.c: In function `main':
test-sethostname.c:62: warning: implicit declaration of function `gethostname'
...
test-sethostname.o: In function `main':
/home/bruno/multibuild-1547/mingw2009/testdir1/gltests/test-sethostname.c:62: 
undefined reference to `_gethostname'
/home/bruno/multibuild-1547/mingw2009/testdir1/gltests/test-sethostname.c:85: 
undefined reference to `_gethostname'
collect2: ld returned 1 exit status

The trivial change would be to simply require the 'gethostname' module and
link with $(GETHOSTNAME_LIB). But then the test suite would not verify any more
that sethostname can be used without any -l options. The best way to continue
verifying this is through two test programs, one linked without options and one
linked with $(GETHOSTNAME_LIB).


2011-12-03  Bruno Haible  <address@hidden>

        sethostname tests: Fix link error on mingw.
        * tests/test-sethostname1.c: New file, extracted from
        tests/test-sethostname.c.
        * tests/test-sethostname2.c: New file, extracted from
        tests/test-sethostname.c.
        * tests/test-sethostname.c: Remove file.
        * modules/sethostname-tests (Files): Add tests/test-sethostname1.c,
        tests/test-sethostname2.c. Remove tests/test-sethostname.c.
        (Depends-on): Add gethostname.
        (Makefile.am): Compile both test-sethostname1 and test-sethostname2.
        Link the latter with $(GETHOSTNAME_LIB).

--- modules/sethostname-tests.orig      Sat Dec  3 15:52:10 2011
+++ modules/sethostname-tests   Sat Dec  3 15:42:48 2011
@@ -1,13 +1,16 @@
 Files:
-tests/test-sethostname.c
+tests/test-sethostname1.c
+tests/test-sethostname2.c
 tests/signature.h
 tests/macros.h
 
 Depends-on:
+gethostname
 
 configure.ac:
 AC_CHECK_FUNCS_ONCE([geteuid])
 
 Makefile.am:
-TESTS += test-sethostname
-check_PROGRAMS += test-sethostname
+TESTS += test-sethostname1 test-sethostname2
+check_PROGRAMS += test-sethostname1 test-sethostname2
+test_sethostname2_LDADD = $(LDADD) @GETHOSTNAME_LIB@

-- 
In memoriam Rudolf Slánský <http://en.wikipedia.org/wiki/Rudolf_Slánský>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]