Douglas Gregor | 69a6b6d | 2009-04-26 03:52:11 +0000 | [diff] [blame] | 1 | #!/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. |
| 7 | use POSIX; |
| 8 | |
| 9 | $exitcode = 0; |
Douglas Gregor | 69a6b6d | 2009-04-26 03:52:11 +0000 | [diff] [blame] | 10 | sub testfiles($$) { |
| 11 | my $suffix = shift; |
| 12 | my $language = shift; |
Douglas Gregor | 405bad0 | 2009-04-26 22:20:50 +0000 | [diff] [blame] | 13 | my $passed = 0; |
| 14 | my $failed = 0; |
| 15 | my $skipped = 0; |
Douglas Gregor | 69a6b6d | 2009-04-26 03:52:11 +0000 | [diff] [blame] | 16 | |
| 17 | @files = `ls test/*/*.$suffix`; |
| 18 | foreach $file (@files) { |
| 19 | chomp($file); |
Douglas Gregor | 69a6b6d | 2009-04-26 03:52:11 +0000 | [diff] [blame] | 20 | my $code = system("clang-cc -fsyntax-only -x $language $file > /dev/null 2>&1"); |
| 21 | if ($code == 0) { |
Douglas Gregor | 405bad0 | 2009-04-26 22:20:50 +0000 | [diff] [blame] | 22 | print("."); |
Douglas Gregor | 69a6b6d | 2009-04-26 03:52:11 +0000 | [diff] [blame] | 23 | $code = system("clang-cc -emit-pch -x $language -o $file.pch $file > /dev/null 2>&1"); |
| 24 | if ($code == 0) { |
Douglas Gregor | 4fe0c8e | 2009-05-30 00:08:05 +0000 | [diff] [blame] | 25 | $code = system("clang-cc -include-pch $file.pch -x $language -ast-dump /dev/null > /dev/null 2>&1"); |
Douglas Gregor | 69a6b6d | 2009-04-26 03:52:11 +0000 | [diff] [blame] | 26 | if ($code == 0) { |
Douglas Gregor | 405bad0 | 2009-04-26 22:20:50 +0000 | [diff] [blame] | 27 | $passed++; |
Douglas Gregor | 69a6b6d | 2009-04-26 03:52:11 +0000 | [diff] [blame] | 28 | } elsif (($code & 0xFF) == SIGINT) { |
| 29 | exit($exitcode); |
| 30 | } else { |
| 31 | print("\n---Failed to dump AST file for \"$file\"---\n"); |
| 32 | $exitcode = 1; |
Douglas Gregor | 405bad0 | 2009-04-26 22:20:50 +0000 | [diff] [blame] | 33 | $failed++; |
Douglas Gregor | 69a6b6d | 2009-04-26 03:52:11 +0000 | [diff] [blame] | 34 | } |
| 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 Gregor | 405bad0 | 2009-04-26 22:20:50 +0000 | [diff] [blame] | 41 | $failed++; |
Douglas Gregor | 69a6b6d | 2009-04-26 03:52:11 +0000 | [diff] [blame] | 42 | } |
| 43 | } elsif (($code & 0xFF) == SIGINT) { |
| 44 | exit($exitcode); |
Douglas Gregor | 405bad0 | 2009-04-26 22:20:50 +0000 | [diff] [blame] | 45 | } else { |
| 46 | print("x"); |
| 47 | $skipped++; |
Douglas Gregor | 69a6b6d | 2009-04-26 03:52:11 +0000 | [diff] [blame] | 48 | } |
| 49 | } |
Douglas Gregor | 405bad0 | 2009-04-26 22:20:50 +0000 | [diff] [blame] | 50 | |
| 51 | print("\n\n$passed tests passed\n"); |
| 52 | print("$failed tests failed\n"); |
| 53 | print("$skipped tests skipped ('x')\n") |
Douglas Gregor | 69a6b6d | 2009-04-26 03:52:11 +0000 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | printf("-----Testing precompiled headers for C-----\n"); |
| 57 | testfiles("c", "c"); |
| 58 | printf("\n-----Testing precompiled headers for Objective-C-----\n"); |
| 59 | testfiles("m", "objective-c"); |
| 60 | print("\n"); |
| 61 | exit($exitcode); |