Debian Codegraph @

testsuite/bin/install_test_perl

raw
1 #!/usr/bin/env perl
2 #
3 # INSTALL_TEST_PERL, perl test script for install non-reg suite
4 # Copyright (C) 2017-2021 Xavier Delaruelle
5 #
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19 ##########################################################################
20
21 use strict;
22 use warnings;
23
24 if ($#ARGV != 1) {
25 # print usage message
26 print STDERR "Usage: $0 initfile command[:command]\n";
27 exit 1;
28 }
29
30 my ($initfile, $cmdlist) = @ARGV;
31 my @cmdlist = split(':', $cmdlist);
32 # empty command list, means one empty command
33 if (@cmdlist == 0) {
34 push @cmdlist, "";
35 }
36
37 if (! -r $initfile) {
38 print STDERR "Cannot read $initfile\n";
39 exit 1
40 }
41
42 # source module init file
43 require $initfile;
44
45 # execute command list
46 my $code = 0;
47 my $runml = 0;
48 foreach my $cmd (@cmdlist) {
49 my $ret;
50 # call ml procedure instead of module
51 if ($cmd eq 'ml') {
52 $runml = 1;
53 $ret = 1;
54 # if command equals to NOARG string, means call with no arg passed
55 } elsif ($cmd eq 'NOARG') {
56 if ($runml == 0) {
57 $ret = &module();
58 } else {
59 $ret = &ml();
60 }
61 } else {
62 my @arglist = split(/,/, $cmd, -1);
63 # empty arg list, means one empty arg
64 if (@arglist == 0) {
65 push @arglist, "";
66 }
67 if ($runml == 0) {
68 $ret = &module(@arglist);
69 } else {
70 $ret = &ml(@arglist);
71 }
72 }
73 if (!($ret & ~$ret) && length($ret) > 0 && $ret == 0) {
74 $code = 1;
75 } elsif ($ret & ~$ret) {
76 print "$ret\n";
77 }
78 }
79
80 exit $code;
81
82 # vim:set tabstop=3 shiftwidth=3 expandtab autoindent: