Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
gpu_table_tester 6.42 KiB
#!/usr/bin/perl
## Checks entries in the indra/newview/gpu_table.txt file against sample data
##
## Copyright (c) 2011, Linden Research, Inc.
##
## Permission is hereby granted, free of charge, to any person obtaining a copy
## of this software and associated documentation files (the "Software"), to deal
## in the Software without restriction, including without limitation the rights
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
## copies of the Software, and to permit persons to whom the Software is
## furnished to do so, subject to the following conditions:
##
## The above copyright notice and this permission notice shall be included in
## all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
## THE SOFTWARE.

use English;
use Getopt::Long;

( $MyName = $0 ) =~ s|.*/||;
my $mini_HELP = "
  $MyName --gpu-table <gpu_table.txt> 
          [ --unrecognized-only ]
          [ --table-only ]
          [ <gpu-strings-file> ...]
  
  Checks for duplicates and invalid lines in the gpu_table.txt file.

  Unless the '--table-only' option is specified, it also tests the recognition of 
  values in the gpu-strings-files (or standard input if no files are given).  

  If the --unrecognized-only option is specified, then no output is produced for
  values that are matched, otherwise a line is output for each input line that
  describes the results of attempting to match the value on that line.
";

&GetOptions("help"              => \$Help,
            "gpu-table=s"       => \$GpuTable,
            "unrecognized-only" => \$UnrecognizedOnly,
            "table-only"        => \$TableOnly
    )
    || die "$mini_HELP";

if ($Help)
{
    print $mini_HELP;
    exit 0;
}

$ErrorsSeen = 0;

die "Must specify a --gpu-table <gpu_table.txt> value"
    unless $GpuTable;

open(GPUS, "<$GpuTable")
    || die "Failed to open gpu table '$GpuTable':\n\t$!\n";

# Parse the GPU table into these table, indexed by the name
my %NameLine;       # name -> line number on which a given name was found (catches duplicate names)
my %RecognizerLine; # name -> line number on which a given name was found (catches duplicate names)
my %Name;           # recognizer -> name
my %Recognizer;     # name -> recognizer
my %Class;          # recognizer -> class