pch-test.pl 1.7 KB

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