]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/utils/pch-test.pl
Import the Cavium Simple Executive from the Cavium Octeon SDK. The Simple
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / utils / pch-test.pl
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;
10 sub testfiles($$) {
11   my $suffix = shift;
12   my $language = shift;
13   my $passed = 0;
14   my $failed = 0;
15   my $skipped = 0;
16
17   @files = `ls test/*/*.$suffix`;
18   foreach $file (@files) {
19     chomp($file);
20     my $code = system("clang-cc -fsyntax-only -x $language $file > /dev/null 2>&1");
21     if ($code == 0) {
22       print(".");
23       $code = system("clang-cc -emit-pch -x $language -o $file.pch $file > /dev/null 2>&1");
24       if ($code == 0) {
25         $code = system("clang-cc -include-pch $file.pch -x $language -ast-dump /dev/null > /dev/null 2>&1");
26         if ($code == 0) {
27           $passed++;
28         } elsif (($code & 0xFF) == SIGINT) {
29           exit($exitcode);
30         } else {
31           print("\n---Failed to dump AST file for \"$file\"---\n");
32           $exitcode = 1;
33           $failed++;
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;
41           $failed++;
42       }
43     } elsif (($code & 0xFF) == SIGINT) {
44       exit($exitcode);
45     } else {
46       print("x");
47       $skipped++;
48     }
49   }
50
51   print("\n\n$passed tests passed\n");
52   print("$failed tests failed\n");
53   print("$skipped tests skipped ('x')\n")
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);