[cfe-dev] Platform header test

Douglas Gregor dgregor at apple.com
Fri Nov 20 11:47:08 PST 2009


On Nov 20, 2009, at 11:45 AM, Douglas Gregor wrote:

>
> On Nov 20, 2009, at 11:31 AM, John Thompson wrote:
>
>> Are there any plans for testing compilations of the headers on the
>> various platforms?
>>
>> I would like to look into getting Visual Studio and Windows headers
>> to compile, and the first step would be to see where we are.
>>
>> I'm thinking that if we had some tests that just include individual
>> headers and just syntax check them, that would both give us this
>> information, as well as become a regression test.
>>
>> What I've done locally is to create an "Includes" directory under
>> "test", and put in simple tests of the form:
>>
>> // RUN: clang -fsyntax-only %s
>> #include <stdio.h>
>>
>> I'm using the clang driver because of the -fms-extension issue.
>>
>> Since headers might act differently between C and C++, perhaps each
>> test should have two compile commands, one for C and one for C++.
>> (I haven't figured out the right options to do that yet with the
>> clang driver.)
>>
>> Since stdio.h might include other files, I test those separately.
>> Since these might be platform-specific, I'd use conditionals:
>>
>> // This test is for Windows only.
>> // RUN: clang -fsyntax-only %s
>> #if defined(__WIN32__) || defined(__WIN64__)
>> #include <crtdefs.h>
>> #endif
>>
>> Platform and complier-specific files probably should be in separate
>> directories, perhaps under Includes, i.e.:
>>
>> test
>>    Includes
>>        VisualStudio
>>        Windows
>>        GNU
>>
>> I separated VisualStudio and Windows with respect to the files under
>> Visual Studio and those under the Platform SDK also being separated,
>> but they could be combined.
>>
>> Anyway, let me know what you think.
>
> We definitely want to do this kind of testing. lit actually has some
> support already for "try to syntax-check all of the headers in a given
> directory". Check out, for example, clang/utils/C++Tests/stdc++-
> Syntax, which checks the GCC 4.2.1 C++ headers. Run it from the clang
> source directory with, e.g.,
>
> 	lit -sv utils/C++Tests/stdc++-Syntax

Oh, and of course... I think it would be great to have utils/ 
WindowsSDK and such. We don't automatically run all of the tests in  
utils, so it's okay to have platform-specific stuff in there.

	- Doug



More information about the cfe-dev mailing list