3 # Copyright (c) 2008 Silicon Graphics, Inc. All Rights Reserved.
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License as
7 # published by the Free Software Foundation.
9 # This program is distributed in the hope that it would be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write the Free Software Foundation,
16 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 ['--help|?', "Show this help message.",
31 ['--head|h', "Shows only the head of the QA test",
33 ['--body|b', "Shows only the body of the QA test.",
35 ['--one-line|1', "Output everything on a single line.",
40 GetOptions(map { @{$_}[0] => @{$_}[2] } @oa);
46 my @qatests = map {sprintf("%03d", $_)} @ARGV;
47 @qatests = get_qa_tests() unless (@qatests);
50 my @h = get_qa_header($_);
54 } elsif ($opt{'body'}) {
59 if ($opt{'oneline'}) {
60 print map {s/\n/ /; $_} @h;
66 print "--------------------------------------------------\n" unless (@qatests < 2);
72 # local $_ = @{$_}[0];
73 @{$_}[0] =~ s/=(.*)$//;
74 @{$_}[0] =~ s/\|/ \| -/;
76 @{$_}[0] =~ s/$/ \] /;
80 print "Usage: $0\t$sa\n";
83 print "\t$$_[0]\t$$_[1]\n";
87 sub get_qa_header($) {
88 my $f = shift || die "need an argument";
91 open(my $FH, $f) || die "couldn't open '$f': $!";
94 m/^#\!/ and next; #shebang
95 m/^#\s*\-{10}/ and last; #dashed lines
96 m/^#\s*copyright/i and last; #copyright lines
107 my $d = shift || $ENV{'PWD'};
109 opendir(my $DIR, $d) || die "can't opendir $d: $!";
110 my @qa = grep {m/^\d\d\d$/ && -f "$d/$_" } readdir($DIR);