unit_tests/run_tests.pl
changeset 876 e005b1f38952
parent 750 238675cfa788
child 885 29b6d4c4a7a2
equal deleted inserted replaced
875:dc28354d576e 876:e005b1f38952
     1 #!/usr/bin/perl -w
     1 #!/usr/bin/perl -w
     2 
     2 
     3 use warnings;
     3 use warnings;
     4 use strict;
     4 use strict;
     5 use Digest::SHA1;
     5 use Digest::SHA1;
       
     6 use Cwd;
     6 
     7 
     7 use FindBin qw($Bin);
     8 use FindBin qw($Bin);
     8 my $testdir = $Bin;
     9 my $testdir = $Bin;
     9 undef $Bin;
    10 undef $Bin;
    10 #print("testdir is $testdir\n");
    11 #print("testdir is $testdir\n");
    11 
    12 my $binpath = getcwd();
       
    13 #print("binpath is $binpath\n");
    12 
    14 
    13 my $GPrintCmds = 0;
    15 my $GPrintCmds = 0;
    14 
    16 
    15 my @modules = qw( preprocessor assembler compiler parser );
    17 my @modules = qw( preprocessor assembler compiler parser );
    16 
    18 
    56     my $cmd = undef;
    58     my $cmd = undef;
    57     my $endlines = 1;
    59     my $endlines = 1;
    58 
    60 
    59     # !!! FIXME: this should go elsewhere.
    61     # !!! FIXME: this should go elsewhere.
    60     if ($module eq 'preprocessor') {
    62     if ($module eq 'preprocessor') {
    61         $cmd = "./mojoshader-compiler -P '$fname' -o '$output'";
    63         $cmd = "$binpath/mojoshader-compiler -P '$fname' -o '$output'";
    62     } else {
    64     } else {
    63         return (0, "Don't know how to do this module type");
    65         return (0, "Don't know how to do this module type");
    64     }
    66     }
    65     $cmd .= ' 2>/dev/null 1>/dev/null';
    67     $cmd .= ' 2>/dev/null 1>/dev/null';
    66 
    68 
    86 my $pass = 0;
    88 my $pass = 0;
    87 my $fail = 0;
    89 my $fail = 0;
    88 my $skip = 0;
    90 my $skip = 0;
    89 
    91 
    90 my $result = '';
    92 my $result = '';
       
    93 chdir($testdir) or die("Failed to chdir('$testdir'): $!\n");
    91 foreach (@modules) {
    94 foreach (@modules) {
    92     my $module = $_;
    95     my $module = $_;
    93     foreach (keys %tests) {
    96     foreach (keys %tests) {
    94         my $testtype = $_;
    97         my $testtype = $_;
    95         my $fn = $tests{$_};
    98         my $fn = $tests{$_};
    96         my $d = "$testdir/$module/$testtype";
    99         my $d = "$module/$testtype";
    97         next if (not -d $d);  # no tests at the moment.
   100         next if (not -d $d);  # no tests at the moment.
    98         opendir(TESTDIR, $d) || die("Failed to open dir '$d': $!\n");
   101         opendir(TESTDIR, $d) || die("Failed to open dir '$d': $!\n");
    99         print(" ... $module / $testtype ...\n");
   102         print(" ... $module / $testtype ...\n");
   100         my $fname = readdir(TESTDIR);
   103         my $fname = readdir(TESTDIR);
   101         while (defined $fname) {
   104         while (defined $fname) {