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