blib/lib/IxNetwork/checkDependencies.pm untested

filter: Statementstmt 0.0% 0 / 71 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 24 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 127 CC 10 SCAR 39.8
CC
10
Cov
0%
checkDeps
110.0
BEGIN
2.0
BEGIN
2.0
CRAP 53.4
1 #!/usr/bin/perl
2 #
3 # Copyright 1997 - 2018 by IXIA Keysight
4 #
5 # Permission is hereby granted, free of charge, to any person obtaining a copy
6 # of this software and associated documentation files (the "Software"),
7 # to deal in the Software without restriction, including without limitation
8 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 # and/or sell copies of the Software, and to permit persons to whom the
10 # Software is furnished to do so, subject to the following conditions:
11 #
12 # The above copyright notice and this permission notice shall be included in
13 # all copies or substantial portions of the Software.
14 #
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 # THE SOFTWARE.
22
23 use File::Spec;
24 my $dependenciespath;
25 BEGIN {
26 my ($volume, $directory, $file) = File::Spec->splitpath(__FILE__);
27 $directory = File::Spec->catdir( (File::Spec->rel2abs($directory), 'dependencies') );
28 $dependenciespath = $directory;
29 }
30 use lib $dependenciespath;
31
32 package checkDependencies;
33
34 sub checkDeps {
35 my @missingDependencies = ();
36 my $ret = eval {
37 require IO::Socket::SSL;
38 IO::Socket::SSL->import();
39 1;
40 };
41 if (!$ret and $@) {
42 push(@missingDependencies, "IO::Socket::SSL");
43 }
44 my $ret = eval {
45 require LWP::UserAgent;
46 LWP::UserAgent->import();
47 1;
48 };
49 if (!$ret and $@) {
50 push(@missingDependencies, "LWP::UserAgent");
51 }
52 my $ret = eval {
53 require Protocol::WebSocket::Client;
54 Protocol::WebSocket::Client->import();
55 1;
56 };
57 if (!$ret and $@) {
58 push(@missingDependencies, "Protocol::WebSocket::Client");
59 }
60 my $ret = eval {
61 require JSON::PP;
62 JSON::PP->import();
63 1;
64 };
65 if (!$ret and $@) {
66 push(@missingDependencies, "JSON::PP");
67 }
68 my $ret = eval {
69 require URI::Escape;
70 URI::Escape->import();
71 1;
72 };
73 if (!$ret and $@) {
74 push(@missingDependencies, "URI::Escape");
75 }
76 my $ret = eval {
77 require Net::SSLeay;
78 Net::SSLeay->import();
79 1;
80 };
81 if (!$ret and $@) {
82 push(@missingDependencies, "Net::SSLeay");
83 }
84 my $ret = eval {
85 require LWP::Protocol::https;
86 LWP::Protocol::https->import();
87 1;
88 };
89 if (!$ret and $@) {
90 push(@missingDependencies, "LWP::Protocol::https");
91 }
92 my $ret = eval {
93 require Time::Seconds;
94 Time::Seconds->import();
95 1;
96 };
97 if (!$ret and $@) {
98 push(@missingDependencies, "Time::Seconds");
99 }
100
101 if (scalar(@missingDependencies) > 0) {
102 my $enumeratedDependencies = join(', ', @missingDependencies);
103 die 'Cannot load required dependencies: '.$enumeratedDependencies.". \nPlease consult documentation for installing required dependencies.\n";
104 }
105
106 }
107
108 1;
109
110
111