blob: 2e17117a2a292c20eea5391c15aa5d20758969af [file] [log] [blame]
Douglas Gregor69a6b6d2009-04-26 03:52:11 +00001#!/usr/bin/perl -w
2
3# This tiny little script, which should be run from the clang
4# directory (with clang-cc in your patch), tries to take each
5# compilable Clang test and build a PCH file from that test, then read
6# and dump the contents of the PCH file just created.
7use POSIX;
8
9$exitcode = 0;
Douglas Gregor69a6b6d2009-04-26 03:52:11 +000010sub testfiles($$) {
11 my $suffix = shift;
12 my $language = shift;
Douglas Gregor405bad02009-04-26 22:20:50 +000013 my $passed = 0;
14 my $failed = 0;
15 my $skipped = 0;
Douglas Gregor69a6b6d2009-04-26 03:52:11 +000016
17 @files = `ls test/*/*.$suffix`;
18 foreach $file (@files) {
19 chomp($file);
Douglas Gregor69a6b6d2009-04-26 03:52:11 +000020 my $code = system("clang-cc -fsyntax-only -x $language $file > /dev/null 2>&1");
21 if ($code == 0) {
Douglas Gregor405bad02009-04-26 22:20:50 +000022 print(".");
Douglas Gregor69a6b6d2009-04-26 03:52:11 +000023 $code = system("clang-cc -emit-pch -x $language -o $file.pch $file > /dev/null 2>&1");
24 if ($code == 0) {
Douglas Gregor4fe0c8e2009-05-30 00:08:05 +000025 $code = system("clang-cc -include-pch $file.pch -x $language -ast-dump /dev/null > /dev/null 2>&1");
Douglas Gregor69a6b6d2009-04-26 03:52:11 +000026 if ($code == 0) {
Douglas Gregor405bad02009-04-26 22:20:50 +000027 $passed++;
Douglas Gregor69a6b6d2009-04-26 03:52:11 +000028 } elsif (($code & 0xFF) == SIGINT) {
29 exit($exitcode);
30 } else {
31 print("\n---Failed to dump AST file for \"$file\"---\n");
32 $exitcode = 1;
Douglas Gregor405bad02009-04-26 22:20:50 +000033 $failed++;
Douglas Gregor69a6b6d2009-04-26 03:52:11 +000034 }
35 unlink "$file.pch";
36 } elsif (($code & 0xFF) == SIGINT) {
37 exit($exitcode);
38 } else {
39 print("\n---Failed to build PCH file for \"$file\"---\n");
40 $exitcode = 1;
Douglas Gregor405bad02009-04-26 22:20:50 +000041 $failed++;
Douglas Gregor69a6b6d2009-04-26 03:52:11 +000042 }
43 } elsif (($code & 0xFF) == SIGINT) {
44 exit($exitcode);
Douglas Gregor405bad02009-04-26 22:20:50 +000045 } else {
46 print("x");
47 $skipped++;
Douglas Gregor69a6b6d2009-04-26 03:52:11 +000048 }
49 }
Douglas Gregor405bad02009-04-26 22:20:50 +000050
51 print("\n\n$passed tests passed\n");
52 print("$failed tests failed\n");
53 print("$skipped tests skipped ('x')\n")
Douglas Gregor69a6b6d2009-04-26 03:52:11 +000054}
55
56printf("-----Testing precompiled headers for C-----\n");
57testfiles("c", "c");
58printf("\n-----Testing precompiled headers for Objective-C-----\n");
59testfiles("m", "objective-c");
60print("\n");
61exit($exitcode);