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