run_tests.pl 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #! /usr/bin/env perl
  2. # Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
  3. #
  4. # Licensed under the OpenSSL license (the "License"). You may not use
  5. # this file except in compliance with the License. You can obtain a copy
  6. # in the file LICENSE in the source distribution or at
  7. # https://www.openssl.org/source/license.html
  8. use strict;
  9. use warnings;
  10. # Recognise VERBOSE and V which is common on other projects.
  11. BEGIN {
  12. $ENV{HARNESS_VERBOSE} = "yes" if $ENV{VERBOSE} || $ENV{V};
  13. }
  14. use File::Spec::Functions qw/catdir catfile curdir abs2rel rel2abs/;
  15. use File::Basename;
  16. use Test::Harness qw/runtests $switches/;
  17. my $srctop = $ENV{SRCTOP} || $ENV{TOP};
  18. my $bldtop = $ENV{BLDTOP} || $ENV{TOP};
  19. my $recipesdir = catdir($srctop, "test", "recipes");
  20. my $testlib = catdir($srctop, "test", "testlib");
  21. my $utillib = catdir($srctop, "util");
  22. # It seems that $switches is getting interpreted with 'eval' or something
  23. # like that, and that we need to take care of backslashes or they will
  24. # disappear along the way.
  25. $testlib =~ s|\\|\\\\|g if $^O eq "MSWin32";
  26. $utillib =~ s|\\|\\\\|g if $^O eq "MSWin32";
  27. # Test::Harness provides the variable $switches to give it
  28. # switches to be used when it calls our recipes.
  29. $switches = "-w \"-I$testlib\" \"-I$utillib\"";
  30. my @tests = ( "alltests" );
  31. if (@ARGV) {
  32. @tests = @ARGV;
  33. }
  34. my $list_mode = scalar(grep /^list$/, @tests) != 0;
  35. if (grep /^(alltests|list)$/, @tests) {
  36. @tests = grep {
  37. basename($_) =~ /^[0-9][0-9]-[^\.]*\.t$/
  38. } glob(catfile($recipesdir,"*.t"));
  39. } else {
  40. my @t = ();
  41. foreach (@tests) {
  42. push @t, grep {
  43. basename($_) =~ /^[0-9][0-9]-[^\.]*\.t$/
  44. } glob(catfile($recipesdir,"*-$_.t"));
  45. }
  46. @tests = @t;
  47. }
  48. if ($list_mode) {
  49. @tests = map { $_ = basename($_); $_ =~ s/^[0-9][0-9]-//; $_ =~ s/\.t$//;
  50. $_ } @tests;
  51. print join("\n", @tests), "\n";
  52. } else {
  53. @tests = map { abs2rel($_, rel2abs(curdir())); } @tests;
  54. runtests(sort @tests);
  55. }