Debian Codegraph @

t/external_cluster_command

raw ◀ ▶
1 Debian patch touch this file
•1 #!/usr/bin/perl
2 #
3 # test script for proving external command for fetching tags works
4 #
5 use strict;
6 use warnings;
7 use Getopt::Std;
8
9 my $opt = {};
10 getopts( 'Lqx', $opt );
11
12 my %tag_lookup = (
13 tag100 => [qw/ host100 /],
14 tag200 => [qw/ host200 host210 host205 /],
15 tag300 => [qw/ host300 host350 host325 /],
16 tag400 => [qw/ tag100 tag200 tag300 host400 host401 /],
17 );
18
19 # if we get '-q' option, force an error
20 if ( $opt->{q} ) {
21 my $fail;
22 $fail->cause_death();
23 }
24
25 # if we get '-x' option, die with non-0 return code
26 if ( $opt->{x} ) {
27 warn 'Forced non-0 exit', $/;
28 exit 5;
29 }
30
31 # '-L' means list out available tags
32 if ( $opt->{L} ) {
33 print join( ' ', sort keys %tag_lookup ), $/;
34 exit 0;
35 }
36
37 my @lookup = @ARGV;
38
39 for (@lookup) {
40 if ( $tag_lookup{$_} ) {
41 push( @lookup, @{ $tag_lookup{$_} } );
42 $_ = '';
43 }
44 }
45
46 @lookup = grep { $_ !~ m/^$/ } sort @lookup;
47
48 if (@lookup) {
49 print "@lookup", $/;
50 }