1*f4a2713aSLionel Sambuc#!/usr/bin/perl -w 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuc# This tiny little script, which should be run from the clang 4*f4a2713aSLionel Sambuc# directory (with clang in your patch), tries to take each 5*f4a2713aSLionel Sambuc# compilable Clang test and build a PCH file from that test, then read 6*f4a2713aSLionel Sambuc# and dump the contents of the PCH file just created. 7*f4a2713aSLionel Sambucuse POSIX; 8*f4a2713aSLionel Sambuc 9*f4a2713aSLionel Sambuc$exitcode = 0; 10*f4a2713aSLionel Sambucsub testfiles($$) { 11*f4a2713aSLionel Sambuc my $suffix = shift; 12*f4a2713aSLionel Sambuc my $language = shift; 13*f4a2713aSLionel Sambuc my $passed = 0; 14*f4a2713aSLionel Sambuc my $failed = 0; 15*f4a2713aSLionel Sambuc my $skipped = 0; 16*f4a2713aSLionel Sambuc 17*f4a2713aSLionel Sambuc @files = `ls test/*/*.$suffix`; 18*f4a2713aSLionel Sambuc foreach $file (@files) { 19*f4a2713aSLionel Sambuc chomp($file); 20*f4a2713aSLionel Sambuc my $code = system("clang -fsyntax-only -x $language $file > /dev/null 2>&1"); 21*f4a2713aSLionel Sambuc if ($code == 0) { 22*f4a2713aSLionel Sambuc print("."); 23*f4a2713aSLionel Sambuc $code = system("clang -cc1 -emit-pch -x $language -o $file.pch $file > /dev/null 2>&1"); 24*f4a2713aSLionel Sambuc if ($code == 0) { 25*f4a2713aSLionel Sambuc $code = system("clang -cc1 -include-pch $file.pch -x $language -ast-dump /dev/null > /dev/null 2>&1"); 26*f4a2713aSLionel Sambuc if ($code == 0) { 27*f4a2713aSLionel Sambuc $passed++; 28*f4a2713aSLionel Sambuc } elsif (($code & 0xFF) == SIGINT) { 29*f4a2713aSLionel Sambuc exit($exitcode); 30*f4a2713aSLionel Sambuc } else { 31*f4a2713aSLionel Sambuc print("\n---Failed to dump AST file for \"$file\"---\n"); 32*f4a2713aSLionel Sambuc $exitcode = 1; 33*f4a2713aSLionel Sambuc $failed++; 34*f4a2713aSLionel Sambuc } 35*f4a2713aSLionel Sambuc unlink "$file.pch"; 36*f4a2713aSLionel Sambuc } elsif (($code & 0xFF) == SIGINT) { 37*f4a2713aSLionel Sambuc exit($exitcode); 38*f4a2713aSLionel Sambuc } else { 39*f4a2713aSLionel Sambuc print("\n---Failed to build PCH file for \"$file\"---\n"); 40*f4a2713aSLionel Sambuc $exitcode = 1; 41*f4a2713aSLionel Sambuc $failed++; 42*f4a2713aSLionel Sambuc } 43*f4a2713aSLionel Sambuc } elsif (($code & 0xFF) == SIGINT) { 44*f4a2713aSLionel Sambuc exit($exitcode); 45*f4a2713aSLionel Sambuc } else { 46*f4a2713aSLionel Sambuc print("x"); 47*f4a2713aSLionel Sambuc $skipped++; 48*f4a2713aSLionel Sambuc } 49*f4a2713aSLionel Sambuc } 50*f4a2713aSLionel Sambuc 51*f4a2713aSLionel Sambuc print("\n\n$passed tests passed\n"); 52*f4a2713aSLionel Sambuc print("$failed tests failed\n"); 53*f4a2713aSLionel Sambuc print("$skipped tests skipped ('x')\n") 54*f4a2713aSLionel Sambuc} 55*f4a2713aSLionel Sambuc 56*f4a2713aSLionel Sambucprintf("-----Testing precompiled headers for C-----\n"); 57*f4a2713aSLionel Sambuctestfiles("c", "c"); 58*f4a2713aSLionel Sambucprintf("\n-----Testing precompiled headers for Objective-C-----\n"); 59*f4a2713aSLionel Sambuctestfiles("m", "objective-c"); 60*f4a2713aSLionel Sambucprint("\n"); 61*f4a2713aSLionel Sambucexit($exitcode); 62