From c19f427ce152cc8bb806baa6877457380813a82b Mon Sep 17 00:00:00 2001
From: Oz Linden <oz@lindenlab.com>
Date: Wed, 10 Jul 2013 14:35:25 -0700
Subject: [PATCH] update tester for new gpu_table.txt format

---
 scripts/gpu_table_tester | 67 +++++++++++++++++++++++++++-------------
 1 file changed, 46 insertions(+), 21 deletions(-)

diff --git a/scripts/gpu_table_tester b/scripts/gpu_table_tester
index 9bc958636d..339823246c 100755
--- a/scripts/gpu_table_tester
+++ b/scripts/gpu_table_tester
@@ -46,8 +46,8 @@ my $mini_HELP = "
   $MyName {--gpu-table|-g} <gpu_table.txt> {--diff|-d} <old_results> [ <gpu-strings-file> ...]
 
     With the --diff option, the report compares the current results to <old-results>,
-    which should be the output from a previous run without --diff.  The report shows each
-    input value with the old result and the new result if it is different.
+    which should be the output from a previous run without --diff.  The report shows 
+    each input value with the old result and the new result if they are different. 
 ";
 
 &GetOptions("help"               => \$Help
@@ -81,11 +81,15 @@ my %Recognizer;     # name -> recognizer
 my %Class;          # recognizer -> class
 my %Supported;      # recognizer -> supported
 my @InOrder;        # lowercased recognizers in file order - these are the ones really used to match
+my %StatsBased;
+my %ExpectedOpenGL;
 
 $Name{$NoMatch}      = $NoMatch;
 $NameLine{$NoMatch}  = '(hard-coded)'; # use this for error messages in table parsing
 $Class{$NoMatch}     = '';
 $Supported{$NoMatch} = '';
+$StatsBased{$NoMatch} = '';
+$ExpectedOpenGL{$NoMatch} = '';
 
 while (<GPUS>)
 {
@@ -93,7 +97,7 @@ while (<GPUS>)
     next if m|^\s*$|;  # skip blank lines
 
     chomp;
-    my ($name, $regex, $class, $supported, $extra) = split('\t+');
+    my ($name, $regex, $class, $supported, $stats_based, $expected_opengl, $extra) = split('\t+');
     my $errsOnLine = $ErrorsSeen;
     if (!$name)
     {
@@ -119,7 +123,7 @@ while (<GPUS>)
         print STDERR "     $INPUT_LINE_NUMBER: name '$name'  " . ($supported ? "supported" : "unsupported") .  "  class $class - ignored\n";
         $ErrorsSeen++;
     }
-    if ($class !~ m/[0123]/)
+    if ($class !~ m/[012345]/)
     {
         print STDERR "Invalid class value '$class' on $GpuTable line $INPUT_LINE_NUMBER\n";
         $ErrorsSeen++;
@@ -129,6 +133,16 @@ while (<GPUS>)
         print STDERR "Invalid supported value '$supported' on $GpuTable line $INPUT_LINE_NUMBER\n";
         $ErrorsSeen++;
     }
+    if ($stats_based !~ m/[01]/)
+    {
+        print STDERR "Invalid stats_based value '$stats_based' on $GpuTable line $INPUT_LINE_NUMBER\n";
+        $ErrorsSeen++;
+    }
+    if ($expected_opengl !~ m/\d+(\.\d+)?/)
+    {
+        print STDERR "Invalid expected_opengl value '$expected_opengl' on $GpuTable line $INPUT_LINE_NUMBER\n";
+        $ErrorsSeen++;
+    }
     if ($extra)
     {
         print STDERR "Extra data '$extra' on $GpuTable line $INPUT_LINE_NUMBER\n";
@@ -144,6 +158,8 @@ while (<GPUS>)
         $Recognizer{$name} = $regex;
         $Class{$regex} = $class;
         $Supported{$regex} = $supported ? "supported" : "unsupported";
+        $StatsBased{$regex} = $stats_based;
+        $ExpectedOpenGL{$regex} = $expected_opengl;
     }
 }
 
@@ -174,27 +190,27 @@ while (<>)
 }
 
 format STDOUT_TOP =
-GPU String                                                                                               Supported?  Class  Recognizer
-------------------------------------------------------------------------------------------------------   ----------- -----  ------------------------------------
+GPU String                                                                                               Supported?  Class  Stats  OpenGL  Recognizer
+------------------------------------------------------------------------------------------------------   ----------- -----  -----  ------  ------------------------------------
 .
 format STDOUT =
-@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<...   @<<<<<<<<<<   @>   @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<...
-$_, $Supported{$RecognizedBy{$_}},$Class{$RecognizedBy{$_}},$Name{$RecognizedBy{$_}}
+@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<...   @<<<<<<<<<<   @>    @>     @<<<<  @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<...
+$_, $Supported{$RecognizedBy{$_}},$Class{$RecognizedBy{$_}},$StatsBased{$RecognizedBy{$_}},$ExpectedOpenGL{$RecognizedBy{$_}},$Name{$RecognizedBy{$_}}
 .
 
-my $ReportLineTemplate = "A102xxxA12xxxAA*"; # MUST match the format STDOUT above
+my $ReportLineTemplate = "A102xxxA12xxxA2xxxxA2xxxxA5A*"; # MUST match the format STDOUT above
 
 format DIFF_TOP =
-                                                                                                         ------ OLD ------   ------ NEW ------
-GPU String                                                                                               Supported?  Class   Supported?  Class
-------------------------------------------------------------------------------------------------------   ----------- -----   ----------- -----
+                                                                                                         ------------- OLD -------------  ----------- NEW ---------------
+GPU String                                                                                               Supported?  Class Stats OpenGL   Supported?  Class Stats OpenGL
+------------------------------------------------------------------------------------------------------   ----------- ----- ----- ------   ----------- ----- ----- ------
 .                                                                                                                                             
 
 my ( $oldSupported, $oldClass, $newSupported, $newClass );
 
 format DIFF =                                                                                                                                 
-@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<...   @<<<<<<<<<<   @>    @<<<<<<<<<<   @> 
-$_,                                                                                                $oldSupported, $oldClass, $newSupported, $newClass
+@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<...   @<<<<<<<<<<   @>    @>  @<<<<    @<<<<<<<<<<    @>   @>  @<<<<  
+$_,                                                    $oldSupported, $oldClass, $oldStatsBased, $oldExpectedOpenGL, $newSupported, $newClass, $newStatsBased, $newExpectedOpenGL
 .
 
 if ( ! $Diff )
@@ -215,12 +231,14 @@ else
     my $discard = 2;
     while ( <OLD> )
     {
-        if ( $discard > 0 )
+        if ( $discard <= 0 )
         {
-            my ( $gpu, $supported, $class ) = unpack $ReportLineTemplate;
+            my ( $gpu, $supported, $class, $stats, $opengl ) = unpack $ReportLineTemplate;
             $gpu =~ s/\s*$//;
             ( $OldSupported{$gpu} = $supported ) =~ s/\s*$//;
             ( $OldClass{$gpu} = $class ) =~ s/\s*$//;
+            ( $OldStatsBased{$gpu} = $stats ) =~ s/\s*$//;
+            ( $OldExpectedOpenGL{$gpu} = $opengl ) =~ s/\s*$//;
         }
         else
         {
@@ -235,26 +253,33 @@ else
     {
         $newSupported = $Supported{$RecognizedBy{$_}} || $NoMatch;
         $newClass     = $Class{$RecognizedBy{$_}};
+        $newStatsBased     = $StatsBased{$RecognizedBy{$_}};
+        $newExpectedOpenGL = $ExpectedOpenGL{$RecognizedBy{$_}};
 
         if ( ! defined $OldSupported{$_} )
         {
             $oldSupported = 'NEW';
             $oldClass = '-';
+            $oldStatsBased = '-';
+            $oldExpectedOpenGL = '-';
+            write;
         }
         else
         {
             $oldSupported = $OldSupported{$_} || $NoMatch;
             $oldClass     = $OldClass{$_};
+            $oldStatsBased     = $OldStatsBased{$_};
+            $oldExpectedOpenGL = $OldExpectedOpenGL{$_};
 
-            if (   ( $oldSupported eq $newSupported )
-                && ( $oldClass     eq $newClass )
+            if (   ( $oldSupported ne $newSupported )
+                || ( $oldClass  ne $newClass )
+                || ( $oldStatsBased ne $newStatsBased )
+                || ( $oldExpectedOpenGL ne $newExpectedOpenGL )
                 )
             {
-                $newSupported = '';
-                $newClass = '';
+                write;
             }
         }
-        write;
         $-++; # suppresses pagination
     }
 }
-- 
GitLab