Skip to content

Commit ee8033a

Browse files
committed
Convert t/GetOSName.t to Unix line endings
like the rest of the repo.
1 parent df366e5 commit ee8033a

File tree

1 file changed

+169
-169
lines changed

1 file changed

+169
-169
lines changed

t/GetOSName.t

Lines changed: 169 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -1,169 +1,169 @@
1-
use strict;
2-
use Test::More;
3-
use Win32;
4-
5-
# The "description" value is extracted from the $pretty field:
6-
#
7-
# "2000 [Server]" => "Server"
8-
# "{Home Server}" => "Windows Home Server" (prefixed with "Windows ")
9-
# "Anything R2" => "R2 Anything" (R2 moved to front)
10-
#
11-
# The "display name" value is the same as the $pretty field,
12-
# prefixed by "Windows ", with all "[]{}" characters removed.
13-
14-
# $pretty, $os $id, $major, $minor, $sm, $pt, $metric
15-
16-
my @intel_tests = (
17-
["Win32s", "Win32s", 0 ],
18-
19-
["95", "95", 1, 4, 0 ],
20-
["98", "98", 1, 4, 10 ],
21-
["Me", "Me", 1, 4, 90 ],
22-
23-
["NT 3.51", "NT3.51", 2, 3, 51 ],
24-
["NT 4", "NT4", 2, 4, 0 ],
25-
26-
["2000 [Professional]", "2000", 2, 5, 0, 0x0000, 1, 0],
27-
["2000 [Server]", "2000", 2, 5, 0, 0x0000, 2, 0],
28-
["[Small Business Server] 2000", "2000", 2, 5, 0, 0x0020, 2, 0],
29-
["2000 [Advanced Server]", "2000", 2, 5, 0, 0x0002, 2, 0],
30-
["2000 [Datacenter Server]", "2000", 2, 5, 0, 0x0080, 2, 0],
31-
32-
["XP [Home Edition]", "XP/.Net", 2, 5, 1, 0x0200, 1, 0],
33-
["XP [Professional]", "XP/.Net", 2, 5, 1, 0x0000, 1, 0],
34-
["XP [Tablet PC Edition]", "XP/.Net", 2, 5, 1, 0x0000, 1, 86],
35-
["XP [Media Center Edition]", "XP/.Net", 2, 5, 1, 0x0000, 1, 87],
36-
["XP [Starter Edition]", "XP/.Net", 2, 5, 1, 0x0000, 1, 88],
37-
38-
["2003 [Standard Edition]", "2003", 2, 5, 2, 0x0000, 2, 0],
39-
["[Small Business Server] 2003", "2003", 2, 5, 2, 0x0020, 2, 0],
40-
["{Storage Server} 2003", "2003", 2, 5, 2, 0x2000, 2, 0],
41-
["{Home Server}", "2003", 2, 5, 2, 0x8000, 2, 0],
42-
43-
["{Compute Cluster Server} 2003", "2003", 2, 5, 2, 0x4000, 2, 0],
44-
["2003 [Datacenter Edition]", "2003", 2, 5, 2, 0x0080, 2, 0],
45-
["2003 [Enterprise Edition]", "2003", 2, 5, 2, 0x0002, 2, 0],
46-
["2003 [Web Edition]", "2003", 2, 5, 2, 0x0400, 2, 0],
47-
48-
["2003 [R2 Standard Edition]", "2003", 2, 5, 2, 0x0000, 2, 89],
49-
["[Small Business Server] 2003 R2", "2003", 2, 5, 2, 0x0020, 2, 89],
50-
["{Storage Server} 2003 R2", "2003", 2, 5, 2, 0x2000, 2, 89],
51-
# ??? test for more R2 versions?
52-
);
53-
54-
my @amd64_tests = (
55-
["{XP Professional x64 Edition}", "2003", 2, 5, 2, 0x0000, 1, 0],
56-
["2003 [Datacenter x64 Edition]", "2003", 2, 5, 2, 0x0080, 2, 0],
57-
["2003 [Enterprise x64 Edition]", "2003", 2, 5, 2, 0x0002, 2, 0],
58-
["2003 [Standard x64 Edition]", "2003", 2, 5, 2, 0x0000, 2, 0],
59-
);
60-
61-
my @dual_tests = (
62-
["Vista", "Vista", 2, 6, 0 ],
63-
64-
["Vista [Starter]", "Vista", 2, 6, 0, 0x0b ],
65-
["Vista [Home Basic]", "Vista", 2, 6, 0, 0x02 ],
66-
["Vista [Home Premium]", "Vista", 2, 6, 0, 0x03 ],
67-
["Vista [Business]", "Vista", 2, 6, 0, 0x06 ],
68-
["Vista [Enterprise]", "Vista", 2, 6, 0, 0x04 ],
69-
["Vista [Ultimate]", "Vista", 2, 6, 0, 0x01 ],
70-
71-
#["Vista Business for Embedded Systems", "Vista", 2, 6, 0 ],
72-
#["Vista Ultimate for Embedded Systems", "Vista", 2, 6, 0 ],
73-
74-
["2008 [Standard]", "2008", 2, 6, 0, 0x07, 2 ],
75-
["2008 [Enterprise]", "2008", 2, 6, 0, 0x04, 2 ],
76-
["[HPC Server] 2008", "2008", 2, 6, 0, 0x12, 2 ],
77-
["[Web Server] 2008", "2008", 2, 6, 0, 0x11, 2 ],
78-
#["[Storage Server] 2008", "2008", 2, 6, 0, ????, 2 ],
79-
["[Small Business Server] 2008", "2008", 2, 6, 0, 0x09, 2, 0 ],
80-
81-
# * Windows Server 2008 Standard (x86 and x86-64)
82-
# * Windows Server 2008 Enterprise (x86 and x86-64)
83-
# * Windows HPC Server 2008 (replacing Windows Compute Cluster Server 2003)
84-
# * Windows Web Server 2008 (x86 and x86-64)
85-
# * Windows Storage Server 2008 (x86 and x86-64)
86-
# * Windows Small Business Server 2008 (Codenamed "Cougar") (x86-64) for small businesses
87-
# * Windows Essential Business Server 2008 (Codenamed "Centro") (x86-64) for medium-sized businesses [25]
88-
# * Windows Server 2008 for Itanium-based Systems
89-
# * Windows Server 2008 Foundation
90-
#
91-
# Server Core is available in the Web, Standard, Enterprise and Datacenter editions.
92-
93-
["7", "7", 2, 6, 1 ],
94-
["7 [Starter]", "7", 2, 6, 1, 0x0b ],
95-
["7 [Home Basic]", "7", 2, 6, 1, 0x02 ],
96-
["7 [Home Premium]", "7", 2, 6, 1, 0x03 ],
97-
["7 [Professional]", "7", 2, 6, 1, 0x06 ],
98-
["7 [Professional]", "7", 2, 6, 1, 0x30 ],
99-
["7 [Enterprise]", "7", 2, 6, 1, 0x04 ],
100-
["7 [Ultimate]", "7", 2, 6, 1, 0x01 ],
101-
102-
["8", "8", 2, 6, 2 ],
103-
["2008 [R2]", "2008", 2, 6, 1, 0x00, 2, 89 ],
104-
["2012", "2012", 2, 6, 2, 0x00, 2, 89 ],
105-
["[Small Business Server] 2008 R2", "2008", 2, 6, 1, 0x09, 2, 89 ],
106-
107-
);
108-
109-
my @ia64_tests = (
110-
["2003 [Datacenter Edition for Itanium-based Systems]", "2003", 2, 5, 2, 0x0080, 2, 0],
111-
["2003 [Enterprise Edition for Itanium-based Systems]", "2003", 2, 5, 2, 0x0002, 2, 0],
112-
);
113-
114-
plan tests => 6 * (@intel_tests + @amd64_tests + 2*@dual_tests + @ia64_tests);
115-
116-
# Test internal implementation function
117-
sub check {
118-
my($test, $arch) = @_;
119-
my($pretty, $expect, $id, $major, $minor, $sm, $pt, $metrics) = @$test;
120-
$metrics = [$metrics] if defined($metrics) && not ref $metrics;
121-
122-
my $tag = "";
123-
($pretty, $tag) = ("$1$2$3", "$2") if $pretty =~ /^(.*)\[(.*)\](.*)$/;
124-
($pretty, $tag) = ("$1$2$3", "Windows $2") if $pretty =~ /^(.*)\{(.*)\}(.*)$/;
125-
$tag = "R2 $tag" if $tag !~ /R2/ && $pretty =~ /R2$/;
126-
127-
# All display names start with "Windows";
128-
# and 2003/2008 start with "Windows Server"
129-
unless ($pretty eq "Win32s") {
130-
my $prefix = "Windows";
131-
$prefix .= " Server" if $pretty =~ /^20(03|08|12)/;
132-
$pretty = "$prefix $pretty";
133-
}
134-
135-
# @dual_tests: Vista and later all come in both 32-bit and 64-bit versions
136-
if ($id == 2 && $major >= 6) {
137-
my $suffix = "";
138-
$suffix = " (32-bit)" if $arch == Win32::PROCESSOR_ARCHITECTURE_INTEL;
139-
$suffix = " (64-bit)" if $arch == Win32::PROCESSOR_ARCHITECTURE_AMD64;
140-
$_ .= $suffix for $pretty, $tag;
141-
$tag =~ s/^\s*//;
142-
}
143-
144-
# We pass the same value for $suitemask and $productinfo. The former is
145-
# used for Windows up to 2003, the latter is used for Vista and later.
146-
my($os, $desc) = Win32::_GetOSName("", $major||0, $minor||0, 0,
147-
$id, $sm||0, $pt||1, $sm||0, $arch, $metrics);
148-
my $display = Win32::GetOSDisplayName($os, $desc);
149-
150-
note($pretty);
151-
is($display, $pretty);
152-
is($os, "Win$expect", "os: $os");
153-
is($desc, $tag, "desc: $desc");
154-
155-
my $sp = "Service Pack 42";
156-
($os, $desc) = Win32::_GetOSName($sp, $major||0, $minor||0, 0,
157-
$id, $sm||0, $pt||1, $sm||0, $arch, $metrics);
158-
$display = Win32::GetOSDisplayName($os, $desc);
159-
160-
is($display, "$pretty $sp", "display: $display");
161-
is($os, "Win$expect", "os: $os");
162-
$expect = length($tag) ? "$tag $sp" : $sp;
163-
is($desc, $expect, "desc: $desc");
164-
}
165-
166-
check($_, Win32::PROCESSOR_ARCHITECTURE_INTEL) for @intel_tests, @dual_tests;
167-
check($_, Win32::PROCESSOR_ARCHITECTURE_AMD64) for @amd64_tests, @dual_tests;
168-
check($_, Win32::PROCESSOR_ARCHITECTURE_IA64) for @ia64_tests;
169-
1+
use strict;
2+
use Test::More;
3+
use Win32;
4+
5+
# The "description" value is extracted from the $pretty field:
6+
#
7+
# "2000 [Server]" => "Server"
8+
# "{Home Server}" => "Windows Home Server" (prefixed with "Windows ")
9+
# "Anything R2" => "R2 Anything" (R2 moved to front)
10+
#
11+
# The "display name" value is the same as the $pretty field,
12+
# prefixed by "Windows ", with all "[]{}" characters removed.
13+
14+
# $pretty, $os $id, $major, $minor, $sm, $pt, $metric
15+
16+
my @intel_tests = (
17+
["Win32s", "Win32s", 0 ],
18+
19+
["95", "95", 1, 4, 0 ],
20+
["98", "98", 1, 4, 10 ],
21+
["Me", "Me", 1, 4, 90 ],
22+
23+
["NT 3.51", "NT3.51", 2, 3, 51 ],
24+
["NT 4", "NT4", 2, 4, 0 ],
25+
26+
["2000 [Professional]", "2000", 2, 5, 0, 0x0000, 1, 0],
27+
["2000 [Server]", "2000", 2, 5, 0, 0x0000, 2, 0],
28+
["[Small Business Server] 2000", "2000", 2, 5, 0, 0x0020, 2, 0],
29+
["2000 [Advanced Server]", "2000", 2, 5, 0, 0x0002, 2, 0],
30+
["2000 [Datacenter Server]", "2000", 2, 5, 0, 0x0080, 2, 0],
31+
32+
["XP [Home Edition]", "XP/.Net", 2, 5, 1, 0x0200, 1, 0],
33+
["XP [Professional]", "XP/.Net", 2, 5, 1, 0x0000, 1, 0],
34+
["XP [Tablet PC Edition]", "XP/.Net", 2, 5, 1, 0x0000, 1, 86],
35+
["XP [Media Center Edition]", "XP/.Net", 2, 5, 1, 0x0000, 1, 87],
36+
["XP [Starter Edition]", "XP/.Net", 2, 5, 1, 0x0000, 1, 88],
37+
38+
["2003 [Standard Edition]", "2003", 2, 5, 2, 0x0000, 2, 0],
39+
["[Small Business Server] 2003", "2003", 2, 5, 2, 0x0020, 2, 0],
40+
["{Storage Server} 2003", "2003", 2, 5, 2, 0x2000, 2, 0],
41+
["{Home Server}", "2003", 2, 5, 2, 0x8000, 2, 0],
42+
43+
["{Compute Cluster Server} 2003", "2003", 2, 5, 2, 0x4000, 2, 0],
44+
["2003 [Datacenter Edition]", "2003", 2, 5, 2, 0x0080, 2, 0],
45+
["2003 [Enterprise Edition]", "2003", 2, 5, 2, 0x0002, 2, 0],
46+
["2003 [Web Edition]", "2003", 2, 5, 2, 0x0400, 2, 0],
47+
48+
["2003 [R2 Standard Edition]", "2003", 2, 5, 2, 0x0000, 2, 89],
49+
["[Small Business Server] 2003 R2", "2003", 2, 5, 2, 0x0020, 2, 89],
50+
["{Storage Server} 2003 R2", "2003", 2, 5, 2, 0x2000, 2, 89],
51+
# ??? test for more R2 versions?
52+
);
53+
54+
my @amd64_tests = (
55+
["{XP Professional x64 Edition}", "2003", 2, 5, 2, 0x0000, 1, 0],
56+
["2003 [Datacenter x64 Edition]", "2003", 2, 5, 2, 0x0080, 2, 0],
57+
["2003 [Enterprise x64 Edition]", "2003", 2, 5, 2, 0x0002, 2, 0],
58+
["2003 [Standard x64 Edition]", "2003", 2, 5, 2, 0x0000, 2, 0],
59+
);
60+
61+
my @dual_tests = (
62+
["Vista", "Vista", 2, 6, 0 ],
63+
64+
["Vista [Starter]", "Vista", 2, 6, 0, 0x0b ],
65+
["Vista [Home Basic]", "Vista", 2, 6, 0, 0x02 ],
66+
["Vista [Home Premium]", "Vista", 2, 6, 0, 0x03 ],
67+
["Vista [Business]", "Vista", 2, 6, 0, 0x06 ],
68+
["Vista [Enterprise]", "Vista", 2, 6, 0, 0x04 ],
69+
["Vista [Ultimate]", "Vista", 2, 6, 0, 0x01 ],
70+
71+
#["Vista Business for Embedded Systems", "Vista", 2, 6, 0 ],
72+
#["Vista Ultimate for Embedded Systems", "Vista", 2, 6, 0 ],
73+
74+
["2008 [Standard]", "2008", 2, 6, 0, 0x07, 2 ],
75+
["2008 [Enterprise]", "2008", 2, 6, 0, 0x04, 2 ],
76+
["[HPC Server] 2008", "2008", 2, 6, 0, 0x12, 2 ],
77+
["[Web Server] 2008", "2008", 2, 6, 0, 0x11, 2 ],
78+
#["[Storage Server] 2008", "2008", 2, 6, 0, ????, 2 ],
79+
["[Small Business Server] 2008", "2008", 2, 6, 0, 0x09, 2, 0 ],
80+
81+
# * Windows Server 2008 Standard (x86 and x86-64)
82+
# * Windows Server 2008 Enterprise (x86 and x86-64)
83+
# * Windows HPC Server 2008 (replacing Windows Compute Cluster Server 2003)
84+
# * Windows Web Server 2008 (x86 and x86-64)
85+
# * Windows Storage Server 2008 (x86 and x86-64)
86+
# * Windows Small Business Server 2008 (Codenamed "Cougar") (x86-64) for small businesses
87+
# * Windows Essential Business Server 2008 (Codenamed "Centro") (x86-64) for medium-sized businesses [25]
88+
# * Windows Server 2008 for Itanium-based Systems
89+
# * Windows Server 2008 Foundation
90+
#
91+
# Server Core is available in the Web, Standard, Enterprise and Datacenter editions.
92+
93+
["7", "7", 2, 6, 1 ],
94+
["7 [Starter]", "7", 2, 6, 1, 0x0b ],
95+
["7 [Home Basic]", "7", 2, 6, 1, 0x02 ],
96+
["7 [Home Premium]", "7", 2, 6, 1, 0x03 ],
97+
["7 [Professional]", "7", 2, 6, 1, 0x06 ],
98+
["7 [Professional]", "7", 2, 6, 1, 0x30 ],
99+
["7 [Enterprise]", "7", 2, 6, 1, 0x04 ],
100+
["7 [Ultimate]", "7", 2, 6, 1, 0x01 ],
101+
102+
["8", "8", 2, 6, 2 ],
103+
["2008 [R2]", "2008", 2, 6, 1, 0x00, 2, 89 ],
104+
["2012", "2012", 2, 6, 2, 0x00, 2, 89 ],
105+
["[Small Business Server] 2008 R2", "2008", 2, 6, 1, 0x09, 2, 89 ],
106+
107+
);
108+
109+
my @ia64_tests = (
110+
["2003 [Datacenter Edition for Itanium-based Systems]", "2003", 2, 5, 2, 0x0080, 2, 0],
111+
["2003 [Enterprise Edition for Itanium-based Systems]", "2003", 2, 5, 2, 0x0002, 2, 0],
112+
);
113+
114+
plan tests => 6 * (@intel_tests + @amd64_tests + 2*@dual_tests + @ia64_tests);
115+
116+
# Test internal implementation function
117+
sub check {
118+
my($test, $arch) = @_;
119+
my($pretty, $expect, $id, $major, $minor, $sm, $pt, $metrics) = @$test;
120+
$metrics = [$metrics] if defined($metrics) && not ref $metrics;
121+
122+
my $tag = "";
123+
($pretty, $tag) = ("$1$2$3", "$2") if $pretty =~ /^(.*)\[(.*)\](.*)$/;
124+
($pretty, $tag) = ("$1$2$3", "Windows $2") if $pretty =~ /^(.*)\{(.*)\}(.*)$/;
125+
$tag = "R2 $tag" if $tag !~ /R2/ && $pretty =~ /R2$/;
126+
127+
# All display names start with "Windows";
128+
# and 2003/2008 start with "Windows Server"
129+
unless ($pretty eq "Win32s") {
130+
my $prefix = "Windows";
131+
$prefix .= " Server" if $pretty =~ /^20(03|08|12)/;
132+
$pretty = "$prefix $pretty";
133+
}
134+
135+
# @dual_tests: Vista and later all come in both 32-bit and 64-bit versions
136+
if ($id == 2 && $major >= 6) {
137+
my $suffix = "";
138+
$suffix = " (32-bit)" if $arch == Win32::PROCESSOR_ARCHITECTURE_INTEL;
139+
$suffix = " (64-bit)" if $arch == Win32::PROCESSOR_ARCHITECTURE_AMD64;
140+
$_ .= $suffix for $pretty, $tag;
141+
$tag =~ s/^\s*//;
142+
}
143+
144+
# We pass the same value for $suitemask and $productinfo. The former is
145+
# used for Windows up to 2003, the latter is used for Vista and later.
146+
my($os, $desc) = Win32::_GetOSName("", $major||0, $minor||0, 0,
147+
$id, $sm||0, $pt||1, $sm||0, $arch, $metrics);
148+
my $display = Win32::GetOSDisplayName($os, $desc);
149+
150+
note($pretty);
151+
is($display, $pretty);
152+
is($os, "Win$expect", "os: $os");
153+
is($desc, $tag, "desc: $desc");
154+
155+
my $sp = "Service Pack 42";
156+
($os, $desc) = Win32::_GetOSName($sp, $major||0, $minor||0, 0,
157+
$id, $sm||0, $pt||1, $sm||0, $arch, $metrics);
158+
$display = Win32::GetOSDisplayName($os, $desc);
159+
160+
is($display, "$pretty $sp", "display: $display");
161+
is($os, "Win$expect", "os: $os");
162+
$expect = length($tag) ? "$tag $sp" : $sp;
163+
is($desc, $expect, "desc: $desc");
164+
}
165+
166+
check($_, Win32::PROCESSOR_ARCHITECTURE_INTEL) for @intel_tests, @dual_tests;
167+
check($_, Win32::PROCESSOR_ARCHITECTURE_AMD64) for @amd64_tests, @dual_tests;
168+
check($_, Win32::PROCESSOR_ARCHITECTURE_IA64) for @ia64_tests;
169+

0 commit comments

Comments
 (0)