Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Apache: Dev

Adding unit tests to httpd?

 

 

Apache dev RSS feed   Index | Next | Previous | View Threaded


sf at sfritsch

May 4, 2012, 2:27 PM

Post #1 of 6 (222 views)
Permalink
Adding unit tests to httpd?

Hi,

there are some parts of httpd where unit tests would allow easier
testing or more complete test coverage than tests written for the perl
framework. Examples include the ap_pcfg_* functions, the varbuf API,
the regex plus API, and new interfaces that are not yet used by any
module.

Therefore, I am thinking about adding unit tests to httpd. For maximum
usefulness, such unit tests should be able to access functions that
are not exported (including static functions). I could think of a few
ways to achive this:

1) Add some preprocessor magic that exports the required functions
when compiled with a special configure option. Then, put the unit
tests into a separate module that executes them during server startup
(and exits instead of allowing the startup to continue).

2) Put the unit tests into a separate executable using source files
that #include the .c file(s) that contains the tested functions. This
is a very hackish approach and has problems with source file
interdependencies. It would likely require special linking magic.

3) Put the unit tests into the same httpd source files that contain
the functions to be tested. They would only be compiled in with a
special configure option. Httpd would then, if some magic -D variable
is defined, execute the tests during server startup and exit instead
of allowing the startup to continue.

I think option 3) is the least hackish approach. Is it problematic if
the unit tests are compiled into the httpd executable and modules,
increasing their size? Of course, one could also compile everything
twice, once for unit testing and once for production use. Newer gcc
versions also have attribute "cold" that can put functions into a
separate section, which would prevent the unit tests from using
significant memory or reducing cache locality during normal operation.

Any comments?

Cheers,
Stefan


i.galic at brainsware

May 4, 2012, 2:35 PM

Post #2 of 6 (217 views)
Permalink
Re: Adding unit tests to httpd? [In reply to]

----- Original Message -----
> Hi,
>
> there are some parts of httpd where unit tests would allow easier
> testing or more complete test coverage than tests written for the
> perl
> framework. Examples include the ap_pcfg_* functions, the varbuf API,
> the regex plus API, and new interfaces that are not yet used by any
> module.
>
> Therefore, I am thinking about adding unit tests to httpd. For
> maximum
> usefulness, such unit tests should be able to access functions that
> are not exported (including static functions). I could think of a few
> ways to achive this:
[snip]
> Any comments?

I know the Subversion project has a very complete unit test suit.
How do they approach this?

> Cheers,
> Stefan

i

--
Igor Galić

Tel: +43 (0) 664 886 22 883
Mail: i.galic [at] brainsware
URL: http://brainsware.org/
GPG: 6880 4155 74BD FD7C B515 2EA5 4B1D 9E08 A097 C9AE


sf at sfritsch

May 6, 2012, 11:36 AM

Post #3 of 6 (207 views)
Permalink
Re: Adding unit tests to httpd? [In reply to]

On Friday 04 May 2012, Igor Galić wrote:
> ----- Original Message -----
>
> > Hi,
> >
> > there are some parts of httpd where unit tests would allow easier
> > testing or more complete test coverage than tests written for the
> > perl
> > framework. Examples include the ap_pcfg_* functions, the varbuf
> > API, the regex plus API, and new interfaces that are not yet
> > used by any module.
> >
> > Therefore, I am thinking about adding unit tests to httpd. For
> > maximum
> > usefulness, such unit tests should be able to access functions
> > that are not exported (including static functions). I could
> > think of a few
>
> > ways to achive this:
> [snip]
>
> > Any comments?
>
> I know the Subversion project has a very complete unit test suit.
> How do they approach this?

I am not sure. It seems they only use the test suite to test exported
interfaces, but some of those interfaces are considered private in
that the header files are not installed on the target system.

Of course it would also be a possibility that we simply mark the
functions to be tested as non-static. Personally, I think that is
ugly, though.


covener at gmail

May 6, 2012, 12:18 PM

Post #4 of 6 (205 views)
Permalink
Re: Adding unit tests to httpd? [In reply to]

> Of course it would also be a possibility that we simply mark the
> functions to be tested as non-static. Personally, I think that is
> ugly, though.


covener at gmail

May 6, 2012, 12:22 PM

Post #5 of 6 (204 views)
Permalink
Re: Adding unit tests to httpd? [In reply to]

On Sun, May 6, 2012 at 3:18 PM, Eric Covener <covener [at] gmail> wrote:
>> Of course it would also be a possibility that we simply mark the
>> functions to be tested as non-static. Personally, I think that is
>> ugly, though.

Sorry, sent draft instead of discarding.

Could they have some AP_XXX macro that resulted in "static" in real
builds and exported symbols when building UT binaries?

--
Eric Covener
covener [at] gmail


i.galic at brainsware

May 6, 2012, 2:02 PM

Post #6 of 6 (206 views)
Permalink
Re: Adding unit tests to httpd? [In reply to]

----- Original Message -----
> On Sun, May 6, 2012 at 3:18 PM, Eric Covener <covener [at] gmail>
> wrote:
> >> Of course it would also be a possibility that we simply mark the
> >> functions to be tested as non-static. Personally, I think that is
> >> ugly, though.
>
> Sorry, sent draft instead of discarding.
>
> Could they have some AP_XXX macro that resulted in "static" in real
> builds and exported symbols when building UT binaries?

I'm wondering how non of the Subversion devs chimes in ;)
Maybe we should CC the thread to dev [at] subversion
to get their attention!

> --
> Eric Covener
> covener [at] gmail

i

--
Igor Galić

Tel: +43 (0) 664 886 22 883
Mail: i.galic [at] brainsware
URL: http://brainsware.org/
GPG: 6880 4155 74BD FD7C B515 2EA5 4B1D 9E08 A097 C9AE

Apache dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.