Bug 41222 - Simplify generation of test data
Summary: Simplify generation of test data
Status: RESOLVED FIXED
Alias: None
Product: dbus
Classification: Unclassified
Component: core (show other bugs)
Version: 1.5
Hardware: Other All
: medium enhancement
Assignee: Simon McVittie
QA Contact: John (J5) Palmieri
URL:
Whiteboard:
Keywords: patch
Depends on:
Blocks: dbus-1.5
  Show dependency treegraph
 
Reported: 2011-09-26 04:36 UTC by Simon McVittie
Modified: 2011-09-28 11:50 UTC (History)
5 users (show)

See Also:
i915 platform:
i915 features:


Attachments
[1/5] Simplify generation of bus configuration files (8.17 KB, patch)
2011-09-26 09:56 UTC, Simon McVittie
Details | Splinter Review
[2/5] Simplify substitution of test executables to use fewer variables (20.96 KB, patch)
2011-09-26 09:57 UTC, Simon McVittie
Details | Splinter Review
[3/5] cmake: remove unused TEST_SERVICE_DIR variable (867 bytes, patch)
2011-09-26 09:57 UTC, Simon McVittie
Details | Splinter Review
[4/5] Merge tests' cmake and autotools bus configuration (15.29 KB, patch)
2011-09-26 09:58 UTC, Simon McVittie
Details | Splinter Review
[5/5] sysdeps: remove misleading comments (1.81 KB, patch)
2011-09-26 09:59 UTC, Simon McVittie
Details | Splinter Review
[6] Remove EXT variable from CMake, just use Automake-compatible EXEEXT (1.55 KB, patch)
2011-09-27 02:53 UTC, Simon McVittie
Details | Splinter Review

Description Simon McVittie 2011-09-26 04:36:45 UTC
configure.ac and CMakeLists.txt substitute several variables for test data (TEST_VALID_SERVICE_DIR, TEST_VALID_SERVICE_SYSTEM_DIR, etc.) and one for each test executable (TEST_SERVICE_BINARY, TEST_EXIT_BINARY etc.).

I think they'd be clearer (and have less duplication between autotools and cmake) if they just substituted two directory names, DBUS_TEST_DATA and DBUS_TEST_EXEC, plus EXEEXT (which is a standard Autoconf feature - D-Bus' CMake build system calls it EXT, but I added EXEEXT as a synonym there). An additional motivation for this is that in a later branch, I want to make more tests installable, and allow the hard-coded paths to be overridden via environment variables $DBUS_TEST_DATA (which already exists) and $DBUS_TEST_EXEC (which will be new).

(Ralf: is EXT a special CMake name with other side-effects, or something you made up for D-Bus? If it's something you made up, we could just rename it to EXEEXT and throw away EXT entirely.)

Meanwhile, as mentioned on Bug #41033, the Autoconf and CMake build systems currently have parallel source files for some things. They shouldn't: they should share a source file, and perform the same substitutions (perhaps with different values - but in fact it makes more sense to vary the values for Windows vs Unix, not for CMake vs Autoconf). This branch fixes this for all the test data.

Patches to follow later today (I'm tidying them up a bit).
Comment 1 Simon McVittie 2011-09-26 09:56:42 UTC
Created attachment 51632 [details] [review]
[1/5] Simplify generation of bus configuration files

All we really need is one substituted variable, DBUS_TEST_DATA, rather than things like TEST_VALID_SERVICE_DIR.

In theory we could even go further and use @abs_top_builddir@, but that'd break if we want the possibility to install more of the regression tests (to be used to test installed/packaged binaries), which is something I'm working on.
Comment 2 Simon McVittie 2011-09-26 09:57:06 UTC
Created attachment 51633 [details] [review]
[2/5] Simplify substitution of test executables to use fewer variables

Also use EXEEXT in all the service files, even in the automake build
system.
Comment 3 Simon McVittie 2011-09-26 09:57:38 UTC
Created attachment 51634 [details] [review]
[3/5] cmake: remove unused TEST_SERVICE_DIR variable

`git grep TEST_SERVICE_DIR` says we don't need it.
Comment 4 Simon McVittie 2011-09-26 09:58:27 UTC
Created attachment 51636 [details] [review]
[4/5] Merge tests' cmake and autotools bus configuration

In Unix, the tests listened on both debug-pipe (which is a socketpair,
or a TCP emulation of socketpair on Windows) and a Unix socket.
 
In the Windows port, the tests were hard-coded to listen on a particular
port, which allowed the dispatch test to connect to that port, as long
as no two tests ran simultaneously (which I don't think was ever guaranteed -
make -j can violate this). That's valid out-of-process, and also
fully-specified, so they only needed one <listen> directive, so the
CMake input only had one.
        
To make the tests work under CMake on Unix, there was a hack: the string
substituted for the content of the <listen> directive contained
</listen><listen> to get the other address in, which is pretty nasty.

Instead of doing that, I've made both build systems, on both Unix and
Windows, use both debug-pipe and a more normal transport (Unix or TCP).
debug-pipe has a Windows implementation and it's used in
dbus-spawn-win.c, so it'd better work. The use of debug-pipe is now
hard-coded rather than being a configure parameter (there's no reason
to vary it in different builds), and I used TEST_LISTEN as the name of the
Unix/TCP address, because it's a "vague" address (no specific Unix path, no
TCP port), that you can listen on but not connect to.

This in turn means that we can merge the Autoconf .in and CMake .cmake
files, similar to Bug #41033.

You might wonder why I've kept debug-pipe. I did try to get rid of it, but
it turns out that the tests in dispatch.c rely on
dbus_connection_open_private() not blocking, and normal socket
connections block on connect(). Until we fix that by adding an async
version of dbus_connection_open_private(), it won't be safe to have a
test like dispatch.c that "talks to itself", unless it uses a transport
as trivial as debug-pipe in which neither end has to block on the other.
Comment 5 Simon McVittie 2011-09-26 09:59:17 UTC
Created attachment 51637 [details] [review]
[5/5] sysdeps: remove misleading comments

The comment claims that _dbus_full_duplex_pipe() is only used for
the debug-pipe server, but in fact the process-spawning code uses it now
(on both Unix and Windows platforms).

---

This one is trivial and can be applied before the others if desired.
Comment 6 Simon McVittie 2011-09-26 10:00:12 UTC
The branch is against dbus-1.4, but perhaps this'd make more sense in master only.
Comment 7 Ralf Habacker 2011-09-26 11:05:45 UTC
(In reply to comment #0)
> 
> (Ralf: is EXT a special CMake name with other side-effects 
no 
> or something you made up for D-Bus? If it's something you made up, we could just rename it to EXEEXT and throw away EXT entirely.)

feel free to throw away EXT

I'm going to apply and compile this stuff on windows to see if there still problems.
Comment 8 Simon McVittie 2011-09-27 02:53:33 UTC
Created attachment 51655 [details] [review]
[6] Remove EXT variable from CMake, just use Automake-compatible EXEEXT

According to Ralf, there's no standard name for this in CMake, so we
might as well use the standard Automake name.
Comment 9 Ralf Habacker 2011-09-28 10:21:37 UTC
(In reply to comment #7)
> (In reply to comment #0)
> > 
> > (Ralf: is EXT a special CMake name with other side-effects 
> no 
> > or something you made up for D-Bus? If it's something you made up, we could just rename it to EXEEXT and throw away EXT entirely.)
> 
> feel free to throw away EXT
> 
> I'm going to apply and compile this stuff on windows to see if there still
> problems.

no problems found on windows and patches are looking good.
Comment 10 Simon McVittie 2011-09-28 11:50:49 UTC
(In reply to comment #9)
> no problems found on windows and patches are looking good.

Thanks, fixed in git for 1.5.10. On a second look, this wasn't suitable for dbus-1.4 (it's rearrangement/cleaning rather than strict bugfixing).


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.