bug-gnulib
[Top][All Lists]
Advanced

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

Re: test-poll vs ioctl


From: Bruno Haible
Subject: Re: test-poll vs ioctl
Date: Tue, 21 Oct 2008 04:21:08 +0200
User-agent: KMail/1.5.4

Simon Josefsson wrote:
> The current situation breaks simple test-cases like this:
> 
> rm -rf m;gnulib-tool --create-testdir --with-tests --dir m poll; cd m; 
> ./configure --host=i586-mingw32msvc --build=i686-pc-linux-gnu; make check; cd 
> ..
> 
> Regardless of the solution, I think the above command should work.

The above command does work. The case that does not work is when you're
using --import, not --create-testdir. This is because with --import,
source files that are needed only for the tests are stored in tests/
even if in gnulib they are in lib/. This was implemented on 2007-12-10,
in order to clearly separate library code and tests code (for licensing
reasons).

--create-testdir does not do this, because it has two different configure
files. IIRC I tried to make the same change there but it got too complicated.

> The problem is caused by:
> 
> 1) One gnulib module (e.g., shutdown) pulls in one file (winsock.c) in
>    the gl/ directory
> 
> 2) A test module (e.g., poll-tests) depends on a module (e.g., ioctl)
>    that change how winsock.c behaves (i.e., causes it to #include
>    additional headers such as sys/ioctl.h)
> 
> I guess this happens whenever you re-use the same *.c file for more than
> one module

Correct. The aforementioned move of files from lib/ to tests/ assumes that
every source file is compiled only for one module.

I think what gnulib-tool does is basically right, and it's not worth the
effort to make gnulib-tool understand which files may be compilation units
in which modules. Rather, I see two solutions, that both introduce separate
compilation units for each sockets module:

  a) Rename winsock.c to w32sock.h.
     Create a file connect.c containing

       #define GNULIB_CONNECT 1
       #include "w32sock.h"

     and similarly for the other modules that make up winsock.c.

     Remove the gl_MODULE_INDICATOR([$1]) line from the definition of
     gl_SYS_SOCKET_MODULE_INDICATOR.

  b) Split winsock.c into accept.c, connect.c, etc. - like we are doing
     in gnulib for most other functionalities. The inline functions
     (FD_TO_SOCKET, SOCKET_TO_FD, set_winsock_errno) can go to a private
     header file, let's say, w32sock.h or socket-internal.h.

I would prefer b), because it's leads to a more understandable code structure.

Bruno





reply via email to

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