line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Sys::Info::Driver; |
2
|
|
|
|
|
|
|
$Test::Sys::Info::Driver::VERSION = '0.23'; |
3
|
1
|
|
|
1
|
|
575
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
32
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use Test::More; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
7
|
1
|
|
|
1
|
|
245
|
use Carp qw( croak ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
66
|
|
8
|
1
|
|
|
|
|
872
|
use constant DRIVER_MODULES => ( |
9
|
|
|
|
|
|
|
'Sys::Info::OS', |
10
|
|
|
|
|
|
|
'Sys::Info::Device', |
11
|
|
|
|
|
|
|
'Sys::Info::Constants', |
12
|
|
|
|
|
|
|
'Sys::Info::Driver::%s', |
13
|
|
|
|
|
|
|
'Sys::Info::Driver::%s::OS', |
14
|
|
|
|
|
|
|
'Sys::Info::Driver::%s::Device', |
15
|
|
|
|
|
|
|
'Sys::Info::Driver::%s::Device::CPU', |
16
|
1
|
|
|
1
|
|
7
|
); |
|
1
|
|
|
|
|
2
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub new { |
19
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
20
|
0
|
|
0
|
|
|
|
my $id = shift || croak 'Driver ID is missing'; |
21
|
|
|
|
|
|
|
my @suite = map { |
22
|
0
|
|
|
|
|
|
my $name = $_; |
|
0
|
|
|
|
|
|
|
23
|
0
|
0
|
|
|
|
|
$name =~ m{ \%s }xms ? sprintf( $name, $id ) : $name; |
24
|
|
|
|
|
|
|
} DRIVER_MODULES; |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
foreach my $module ( @suite ) { |
27
|
0
|
|
|
|
|
|
require_ok( $module ); |
28
|
0
|
|
0
|
|
|
|
ok( $module->import || 1, "$module imported" ); |
29
|
|
|
|
|
|
|
} |
30
|
0
|
|
|
|
|
|
my $self = { |
31
|
|
|
|
|
|
|
_id => $id, |
32
|
|
|
|
|
|
|
_cpu => Sys::Info::Device->new('CPU'), |
33
|
|
|
|
|
|
|
_os => Sys::Info::OS->new, |
34
|
|
|
|
|
|
|
}; |
35
|
0
|
|
|
|
|
|
bless $self, $class; |
36
|
0
|
|
|
|
|
|
return $self; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub run { |
40
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
41
|
0
|
|
|
|
|
|
my @tests = grep { m{ \A test_ }xms } sort keys %Test::Sys::Info::Driver::; |
|
0
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
foreach my $test ( @tests ) { |
43
|
0
|
|
|
|
|
|
$self->$test(); |
44
|
|
|
|
|
|
|
} |
45
|
0
|
|
|
|
|
|
return 1; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub test_os { |
49
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
50
|
0
|
|
|
|
|
|
my $os = $self->os; |
51
|
0
|
|
|
|
|
|
my @methods; |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
ok( defined $os->name , 'OS name is defined'); |
54
|
0
|
|
|
|
|
|
ok( defined $os->name(qw(long 1 ) ) , 'OS long name is defined'); |
55
|
0
|
|
|
|
|
|
ok( defined $os->name(qw(long 1 edition 1)), 'OS long name with edition is defined'); |
56
|
0
|
|
|
|
|
|
ok( defined $os->version , 'OS Version is defined'); |
57
|
0
|
|
|
|
|
|
ok( defined $os->build , 'OS build is defined'); |
58
|
0
|
|
|
|
|
|
ok( defined $os->uptime , 'Uptime is defined'); |
59
|
|
|
|
|
|
|
#ok( defined $os->login_name , 'Login name is defined'); |
60
|
|
|
|
|
|
|
#ok( defined $os->login_name( real => 1 ) , 'Real login name is defined'); |
61
|
0
|
|
|
|
|
|
ok( defined $os->tick_count , 'Tick count is defined'); |
62
|
|
|
|
|
|
|
#ok( defined $os->ip , 'IP is defined'); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
#these seem to fail on some environments disable defined test for now |
65
|
0
|
|
|
|
|
|
push @methods, qw( ip login_name ); |
66
|
0
|
|
0
|
|
|
|
ok( $os->login_name( real => 1 ) || 1, 'Able to call login_name( real => 1 )' ); |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
push @methods, qw( |
69
|
|
|
|
|
|
|
edition |
70
|
|
|
|
|
|
|
bitness |
71
|
|
|
|
|
|
|
node_name host_name |
72
|
|
|
|
|
|
|
domain_name workgroup |
73
|
|
|
|
|
|
|
is_windows is_win32 is_win is_winnt is_win95 is_win9x |
74
|
|
|
|
|
|
|
is_linux is_lin |
75
|
|
|
|
|
|
|
is_bsd |
76
|
|
|
|
|
|
|
is_unknown |
77
|
|
|
|
|
|
|
is_admin is_admin_user is_adminuser |
78
|
|
|
|
|
|
|
is_root is_root_user is_rootuser |
79
|
|
|
|
|
|
|
is_su is_superuser is_super_user |
80
|
|
|
|
|
|
|
logon_server |
81
|
|
|
|
|
|
|
time_zone |
82
|
|
|
|
|
|
|
tz |
83
|
|
|
|
|
|
|
cdkey |
84
|
|
|
|
|
|
|
product_type |
85
|
|
|
|
|
|
|
); |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
$self->just_test_successful_call( $os, @methods ); |
88
|
0
|
|
0
|
|
|
|
ok( $os->cdkey( office => 1 ) || 1, 'cdkey() with office parameter called successfully'); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# TODO: test the keys |
91
|
0
|
|
|
|
|
|
ok( my %fs = $os->fs , 'FS is defined'); |
92
|
0
|
|
|
|
|
|
ok( my %meta = $os->meta, 'Meta is defined'); |
93
|
0
|
|
|
|
|
|
return; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub test_device_cpu { |
97
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
98
|
0
|
|
|
|
|
|
my $cpu = $self->cpu; |
99
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
my @methods = qw( |
101
|
|
|
|
|
|
|
ht |
102
|
|
|
|
|
|
|
hyper_threading |
103
|
|
|
|
|
|
|
bitness |
104
|
|
|
|
|
|
|
load |
105
|
|
|
|
|
|
|
speed |
106
|
|
|
|
|
|
|
count |
107
|
|
|
|
|
|
|
); |
108
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
$self->just_test_successful_call( $cpu, @methods ); |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
# TODO: more detailed tests |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
0
|
|
|
|
ok( $cpu->identify || 1, 'CPU identified' ); |
114
|
0
|
|
0
|
|
|
|
ok( my @cpu = $cpu->identify or (), 'CPU identified in list context' ); |
115
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
|
my $load_00 = $cpu->load( ); |
117
|
0
|
|
|
|
|
|
my $load_01 = $cpu->load(Sys::Info::Constants->DCPU_LOAD_LAST_01); |
118
|
0
|
|
|
|
|
|
my $load_05 = $cpu->load(Sys::Info::Constants->DCPU_LOAD_LAST_05); |
119
|
0
|
|
|
|
|
|
my $load_10 = $cpu->load(Sys::Info::Constants->DCPU_LOAD_LAST_10); |
120
|
0
|
|
|
|
|
|
return; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub just_test_successful_call { |
124
|
0
|
|
|
0
|
1
|
|
my($self, $obj, @methods) = @_; |
125
|
0
|
|
|
|
|
|
foreach my $method ( @methods ) { |
126
|
0
|
|
0
|
|
|
|
ok( $obj->$method() || 1, "$method() called successfully"); |
127
|
|
|
|
|
|
|
} |
128
|
0
|
|
|
|
|
|
return; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
0
|
|
|
0
|
1
|
|
sub cpu { return shift->{_cpu} } |
132
|
0
|
|
|
0
|
1
|
|
sub os { return shift->{_os} } |
133
|
0
|
|
|
0
|
1
|
|
sub id { return shift->{_id} } |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
1; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
__END__ |