2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2008 Silicon Graphics, Inc. All Rights Reserved.
5 # Print headers of given tests
6 # Accepted parameter types:
7 # - nothing - list all tests from all subdirectories in tests/*
8 # - tests/DIR - list all tests from DIR
9 # - tests/DIR/123 - show header from single test
22 ['--help|?', "Show this help message.",
24 ['--head|h', "Shows only the head of the QA test",
26 ['--body|b', "Shows only the body of the QA test.",
28 ['--one-line|1', "Output everything on a single line.",
33 GetOptions(map { @{$_}[0] => @{$_}[2] } @oa);
44 map { push @qatests,get_qa_tests("$d/$_") if -d "$d/$_" } readdir(DIR);
49 push @qatests,$_ if -f && /\d{3}$/;
50 push @qatests,get_qa_tests($_) if -d;
54 my @h = get_qa_header($_);
58 } elsif ($opt{'body'}) {
63 if ($opt{'oneline'}) {
64 print map {s/\n/ /; $_} @h;
70 print "--------------------------------------------------\n" unless (@qatests < 2);
76 # local $_ = @{$_}[0];
77 @{$_}[0] =~ s/=(.*)$//;
78 @{$_}[0] =~ s/\|/ \| -/;
80 @{$_}[0] =~ s/$/ \] /;
84 print "Usage: $0\t$sa\n";
87 print "\t$$_[0]\t$$_[1]\n";
91 sub get_qa_header($) {
92 my $f = shift || die "need an argument";
95 open(my $FH, $f) || die "couldn't open '$f': $!";
98 m/^#\!/ and next; # shebang
99 m/^# SPDX/i and next; # SPDX tags
100 m/^# Copyright/i and next; # Copyright tags
101 m/^#\s*\-{10}/ and last; # dashed lines
102 m/^seq/i and last; # test start
113 my $d = shift || $ENV{'PWD'};
115 opendir(my $DIR, $d) || die "can't opendir $d: $!";
116 my @qa = sort grep { m/^\d\d\d$/ && -f "$d/$_" } readdir($DIR);
118 return map { $_ = "$d/$_" } @qa;