2021-02-25 18:31:42 +08:00
|
|
|
#!/usr/bin/env perl
|
2009-04-26 11:52:11 +08:00
|
|
|
|
|
|
|
# This tiny little script, which should be run from the clang
|
2009-12-12 07:04:35 +08:00
|
|
|
# directory (with clang in your patch), tries to take each
|
2009-04-26 11:52:11 +08:00
|
|
|
# compilable Clang test and build a PCH file from that test, then read
|
|
|
|
# and dump the contents of the PCH file just created.
|
|
|
|
use POSIX;
|
2021-02-25 18:31:42 +08:00
|
|
|
use warnings;
|
2009-04-26 11:52:11 +08:00
|
|
|
|
|
|
|
$exitcode = 0;
|
|
|
|
sub testfiles($$) {
|
|
|
|
my $suffix = shift;
|
|
|
|
my $language = shift;
|
2009-04-27 06:20:50 +08:00
|
|
|
my $passed = 0;
|
|
|
|
my $failed = 0;
|
|
|
|
my $skipped = 0;
|
2009-04-26 11:52:11 +08:00
|
|
|
|
|
|
|
@files = `ls test/*/*.$suffix`;
|
|
|
|
foreach $file (@files) {
|
|
|
|
chomp($file);
|
2010-07-14 08:09:17 +08:00
|
|
|
my $code = system("clang -fsyntax-only -x $language $file > /dev/null 2>&1");
|
2009-04-26 11:52:11 +08:00
|
|
|
if ($code == 0) {
|
2009-04-27 06:20:50 +08:00
|
|
|
print(".");
|
2009-12-12 07:04:35 +08:00
|
|
|
$code = system("clang -cc1 -emit-pch -x $language -o $file.pch $file > /dev/null 2>&1");
|
2009-04-26 11:52:11 +08:00
|
|
|
if ($code == 0) {
|
2009-12-12 07:04:35 +08:00
|
|
|
$code = system("clang -cc1 -include-pch $file.pch -x $language -ast-dump /dev/null > /dev/null 2>&1");
|
2009-04-26 11:52:11 +08:00
|
|
|
if ($code == 0) {
|
2009-04-27 06:20:50 +08:00
|
|
|
$passed++;
|
2009-04-26 11:52:11 +08:00
|
|
|
} elsif (($code & 0xFF) == SIGINT) {
|
|
|
|
exit($exitcode);
|
|
|
|
} else {
|
|
|
|
print("\n---Failed to dump AST file for \"$file\"---\n");
|
|
|
|
$exitcode = 1;
|
2009-04-27 06:20:50 +08:00
|
|
|
$failed++;
|
2009-04-26 11:52:11 +08:00
|
|
|
}
|
|
|
|
unlink "$file.pch";
|
|
|
|
} elsif (($code & 0xFF) == SIGINT) {
|
|
|
|
exit($exitcode);
|
|
|
|
} else {
|
|
|
|
print("\n---Failed to build PCH file for \"$file\"---\n");
|
|
|
|
$exitcode = 1;
|
2009-04-27 06:20:50 +08:00
|
|
|
$failed++;
|
2009-04-26 11:52:11 +08:00
|
|
|
}
|
|
|
|
} elsif (($code & 0xFF) == SIGINT) {
|
|
|
|
exit($exitcode);
|
2009-04-27 06:20:50 +08:00
|
|
|
} else {
|
|
|
|
print("x");
|
|
|
|
$skipped++;
|
2009-04-26 11:52:11 +08:00
|
|
|
}
|
|
|
|
}
|
2009-04-27 06:20:50 +08:00
|
|
|
|
|
|
|
print("\n\n$passed tests passed\n");
|
|
|
|
print("$failed tests failed\n");
|
|
|
|
print("$skipped tests skipped ('x')\n")
|
2009-04-26 11:52:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
printf("-----Testing precompiled headers for C-----\n");
|
|
|
|
testfiles("c", "c");
|
|
|
|
printf("\n-----Testing precompiled headers for Objective-C-----\n");
|
|
|
|
testfiles("m", "objective-c");
|
|
|
|
print("\n");
|
|
|
|
exit($exitcode);
|