Re: [MERGE] Remove old .h file tests from unit-testing

From: Amos Jeffries <squid3@dont-contact.us>
Date: Tue, 11 Mar 2008 11:52:02 +1300

Alex Rousskov wrote:
> On Mon, 2008-03-10 at 18:59 +1300, Amos Jeffries wrote:
>> Alex Rousskov wrote:
>>> IMO, at the end of the cleanup, "squid.h" should be the file that all
>>> sources are guaranteed to include first simply because it is called
>>> squid.h. Config.h has, by name, a much narrower scope.
>>>
>>> I realize that this is subjective and that very few people care about
>>> things like that in Squid so if, for whatever reason, Amos wants to
>>> remove squid.h from most files and leave config.h instead, I am not
>>> going to object since I am not the person doing the cleanup leg work,
>>> and since the functional effect will be the same.
>>>
>>> The little tweaks that are not global in nature should be moved out to
>>> specific headers and wrappers, of course. The
>>> guaranteed-to-be-included-first.h file should eventually be almost
>>> empty. Its primary value is the guarantee itself, which becomes a useful
>>> tool for [usually temporary] hacks.
>> With the testheaders.sh every .h now has
>> guaranteed-to-be-included-at-earliest-actual-need.
>
> Yes, that is great(*), but to-be-included-first guarantee is a little
> different (and much easier to support/test).
>
>> The hacks should be localized to the object(s) they are hacking anyway
>> and not affect the entire Squid + sub-programs + linked-programs +
>> helpers + unit-tests + tools.
>>
>> If they do you would be:
>> - hacking a system include
>> (which requires config.h for the wrapping!)
>> - hacking an objects behaviour
>> (which gets linked/included everywhere its used anyway!)
>
> The guaranteed-to-be-included-first.h file is needed for exceptional
> hacks that defy "normal" rules. For example, it is 3:00 in the morning
> and you must make Squid to compile on some remote box, but some internal
> system header is broken and needs a special _BSD_API #define to compile.
> Many system headers include that header conditionally so you cannot just
> quickly wrap a system include file to #define that constant. If only you
> could define it before any system header is included!
>
> Such hacks are usually temporary.

Those hacks would go in config.h around #include "autoconf.h". Which in
squid is guaranteed-before-system-headers.

The few places where the sys headers are not wrapped need fixing.

>
> Again, I am just sharing my experience here. No significant pressure to
> implement guaranteed-to-be-included-first.h file idea...
>
> Thank you,
>
> Alex.
> P.S. Can a script reliably test an included-at-earliest-actual-need
> guarantee? I think I can write a header that compiles fine without
> config.h but still needs it to enable an optional API. How would a
> script detect such a need?

Thats the tricky bit. It can test the guarantee for included files and
custom types. Which covers most of the cases, where the optional API is
represented by a class or uses new branch-specific fields of objects.

What can't be tested this way is the inverse case of code which does not
add object fields anywhere, reference branch-specific fields, or use a
branch-specific class API. That case can only really be tested by hand.

Amos

-- 
Please use Squid 2.6STABLE17+ or 3.0STABLE1+
There are serious security advisories out on all earlier releases.
Received on Mon Mar 10 2008 - 16:51:26 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Apr 01 2008 - 13:00:10 MDT