1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
use strict;
BEGIN {
eval "use Test::More";
return unless $@;
print "1..0 # Skip: Test requires Test::More module\n";
exit 0;
}
use Win32;
my $tests = 14;
$tests += 2 if Win32::IsWinNT();
plan tests => $tests;
# test Win32::DomainName()
if (Win32::IsWinNT()) {
my $domain = eval { Win32::DomainName() };
SKIP: {
skip('The Workstation service has not been started', 2) if (Win32::GetLastError() == 2138);
is( $@, '', "Win32::DomainName()" );
like( $domain, '/^[a-zA-Z0-9!@#$%^&()_\'{}.~-]+$/', " - checking returned domain" );
}
}
# test Win32::GetArchName()
my $archname = eval { Win32::GetArchName() };
is( $@, '', "Win32::GetArchName()" );
cmp_ok( length($archname), '>=', 3, " - checking returned architecture name" );
# test Win32::GetChipName()
my $chipname = eval { Win32::GetChipName() };
is( $@, '', "Win32::GetChipName()" );
cmp_ok( length($chipname), '>=', 3, " - checking returned chip name" );
# test Win32::GetOSName()
# - scalar context
my $osname = eval { Win32::GetOSName() };
is( $@, '', "Win32::GetOSName() in scalar context" );
cmp_ok( length($osname), '>', 3, " - checking returned OS name" );
# - list context
my ($osname2, $desc) = eval { Win32::GetOSName() };
is( $@, '', "Win32::GetOSName() in list context" );
cmp_ok( length($osname2), '>', 3, " - checking returned OS name" );
ok( defined($desc), " - checking returned description" );
is( $osname2, $osname, " - checking that OS name is the same in both calls" );
# test Win32::LoginName()
my $login = eval { Win32::LoginName() };
is( $@, '', "Win32::LoginName()" );
cmp_ok( length($login), '>', 1, " - checking returned login name" );
# test Win32::NodeName()
my $nodename = eval { Win32::NodeName() };
is( $@, '', "Win32::NodeName()" );
cmp_ok( length($nodename), '>', 1, " - checking returned node name" );
|