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