1b39c5158Smillertuse strict; 2898184e3Ssthenuse Test::More; 3b39c5158Smillertuse Win32; 4b39c5158Smillert 5898184e3Ssthen# The "description" value is extracted from the $pretty field: 6898184e3Ssthen# 7898184e3Ssthen# "2000 [Server]" => "Server" 8898184e3Ssthen# "{Home Server}" => "Windows Home Server" (prefixed with "Windows ") 9898184e3Ssthen# "Anything R2" => "R2 Anything" (R2 moved to front) 10898184e3Ssthen# 11898184e3Ssthen# The "display name" value is the same as the $pretty field, 12898184e3Ssthen# prefixed by "Windows ", with all "[]{}" characters removed. 13898184e3Ssthen 14898184e3Ssthen# $pretty, $os $id, $major, $minor, $sm, $pt, $metric 15898184e3Ssthen 16898184e3Ssthenmy @intel_tests = ( 17898184e3Ssthen["Win32s", "Win32s", 0 ], 18898184e3Ssthen 19898184e3Ssthen["95", "95", 1, 4, 0 ], 20898184e3Ssthen["98", "98", 1, 4, 10 ], 21898184e3Ssthen["Me", "Me", 1, 4, 90 ], 22898184e3Ssthen 23898184e3Ssthen["NT 3.51", "NT3.51", 2, 3, 51 ], 24898184e3Ssthen["NT 4", "NT4", 2, 4, 0 ], 25898184e3Ssthen 26898184e3Ssthen["2000 [Professional]", "2000", 2, 5, 0, 0x0000, 1, 0], 27898184e3Ssthen["2000 [Server]", "2000", 2, 5, 0, 0x0000, 2, 0], 28898184e3Ssthen["[Small Business Server] 2000", "2000", 2, 5, 0, 0x0020, 2, 0], 29898184e3Ssthen["2000 [Advanced Server]", "2000", 2, 5, 0, 0x0002, 2, 0], 30898184e3Ssthen["2000 [Datacenter Server]", "2000", 2, 5, 0, 0x0080, 2, 0], 31898184e3Ssthen 32898184e3Ssthen["XP [Home Edition]", "XP/.Net", 2, 5, 1, 0x0200, 1, 0], 33898184e3Ssthen["XP [Professional]", "XP/.Net", 2, 5, 1, 0x0000, 1, 0], 34898184e3Ssthen["XP [Tablet PC Edition]", "XP/.Net", 2, 5, 1, 0x0000, 1, 86], 35898184e3Ssthen["XP [Media Center Edition]", "XP/.Net", 2, 5, 1, 0x0000, 1, 87], 36898184e3Ssthen["XP [Starter Edition]", "XP/.Net", 2, 5, 1, 0x0000, 1, 88], 37898184e3Ssthen 38898184e3Ssthen["2003 [Standard Edition]", "2003", 2, 5, 2, 0x0000, 2, 0], 39898184e3Ssthen["[Small Business Server] 2003", "2003", 2, 5, 2, 0x0020, 2, 0], 40898184e3Ssthen["{Storage Server} 2003", "2003", 2, 5, 2, 0x2000, 2, 0], 41898184e3Ssthen["{Home Server}", "2003", 2, 5, 2, 0x8000, 2, 0], 42898184e3Ssthen 43898184e3Ssthen["{Compute Cluster Server} 2003", "2003", 2, 5, 2, 0x4000, 2, 0], 44898184e3Ssthen["2003 [Datacenter Edition]", "2003", 2, 5, 2, 0x0080, 2, 0], 45898184e3Ssthen["2003 [Enterprise Edition]", "2003", 2, 5, 2, 0x0002, 2, 0], 46898184e3Ssthen["2003 [Web Edition]", "2003", 2, 5, 2, 0x0400, 2, 0], 47898184e3Ssthen 48898184e3Ssthen["2003 [R2 Standard Edition]", "2003", 2, 5, 2, 0x0000, 2, 89], 49898184e3Ssthen["[Small Business Server] 2003 R2", "2003", 2, 5, 2, 0x0020, 2, 89], 50898184e3Ssthen["{Storage Server} 2003 R2", "2003", 2, 5, 2, 0x2000, 2, 89], 51898184e3Ssthen# ??? test for more R2 versions? 52b39c5158Smillert); 53b39c5158Smillert 54898184e3Ssthenmy @amd64_tests = ( 55898184e3Ssthen["{XP Professional x64 Edition}", "2003", 2, 5, 2, 0x0000, 1, 0], 56898184e3Ssthen["2003 [Datacenter x64 Edition]", "2003", 2, 5, 2, 0x0080, 2, 0], 57898184e3Ssthen["2003 [Enterprise x64 Edition]", "2003", 2, 5, 2, 0x0002, 2, 0], 58898184e3Ssthen["2003 [Standard x64 Edition]", "2003", 2, 5, 2, 0x0000, 2, 0], 59898184e3Ssthen); 60898184e3Ssthen 61898184e3Ssthenmy @dual_tests = ( 62898184e3Ssthen["Vista", "Vista", 2, 6, 0 ], 63898184e3Ssthen 64898184e3Ssthen["Vista [Starter]", "Vista", 2, 6, 0, 0x0b ], 65898184e3Ssthen["Vista [Home Basic]", "Vista", 2, 6, 0, 0x02 ], 66898184e3Ssthen["Vista [Home Premium]", "Vista", 2, 6, 0, 0x03 ], 67898184e3Ssthen["Vista [Business]", "Vista", 2, 6, 0, 0x06 ], 68898184e3Ssthen["Vista [Enterprise]", "Vista", 2, 6, 0, 0x04 ], 69898184e3Ssthen["Vista [Ultimate]", "Vista", 2, 6, 0, 0x01 ], 70898184e3Ssthen 71898184e3Ssthen#["Vista Business for Embedded Systems", "Vista", 2, 6, 0 ], 72898184e3Ssthen#["Vista Ultimate for Embedded Systems", "Vista", 2, 6, 0 ], 73898184e3Ssthen 74898184e3Ssthen["2008 [Standard]", "2008", 2, 6, 0, 0x07, 2 ], 75898184e3Ssthen["2008 [Enterprise]", "2008", 2, 6, 0, 0x04, 2 ], 76898184e3Ssthen["[HPC Server] 2008", "2008", 2, 6, 0, 0x12, 2 ], 77898184e3Ssthen["[Web Server] 2008", "2008", 2, 6, 0, 0x11, 2 ], 78898184e3Ssthen#["[Storage Server] 2008", "2008", 2, 6, 0, ????, 2 ], 79898184e3Ssthen["[Small Business Server] 2008", "2008", 2, 6, 0, 0x09, 2, 0 ], 80898184e3Ssthen 81898184e3Ssthen# * Windows Server 2008 Standard (x86 and x86-64) 82898184e3Ssthen# * Windows Server 2008 Enterprise (x86 and x86-64) 83898184e3Ssthen# * Windows HPC Server 2008 (replacing Windows Compute Cluster Server 2003) 84898184e3Ssthen# * Windows Web Server 2008 (x86 and x86-64) 85898184e3Ssthen# * Windows Storage Server 2008 (x86 and x86-64) 86898184e3Ssthen# * Windows Small Business Server 2008 (Codenamed "Cougar") (x86-64) for small businesses 87898184e3Ssthen# * Windows Essential Business Server 2008 (Codenamed "Centro") (x86-64) for medium-sized businesses [25] 88898184e3Ssthen# * Windows Server 2008 for Itanium-based Systems 89898184e3Ssthen# * Windows Server 2008 Foundation 90898184e3Ssthen# 91898184e3Ssthen# Server Core is available in the Web, Standard, Enterprise and Datacenter editions. 92898184e3Ssthen 93898184e3Ssthen["7", "7", 2, 6, 1 ], 94898184e3Ssthen["7 [Starter]", "7", 2, 6, 1, 0x0b ], 95898184e3Ssthen["7 [Home Basic]", "7", 2, 6, 1, 0x02 ], 96898184e3Ssthen["7 [Home Premium]", "7", 2, 6, 1, 0x03 ], 97898184e3Ssthen["7 [Professional]", "7", 2, 6, 1, 0x06 ], 98898184e3Ssthen["7 [Professional]", "7", 2, 6, 1, 0x30 ], 99898184e3Ssthen["7 [Enterprise]", "7", 2, 6, 1, 0x04 ], 100898184e3Ssthen["7 [Ultimate]", "7", 2, 6, 1, 0x01 ], 101898184e3Ssthen 10291f110e0Safresh1["8", "8", 2, 6, 2 ], 103*eac174f2Safresh1["2008 [R2 Standard]", "2008", 2, 6, 1, 0x07, 2, 89 ], 104*eac174f2Safresh1["2012 [Standard]", "2012", 2, 6, 2, 0x07, 2, 89 ], 105898184e3Ssthen["[Small Business Server] 2008 R2", "2008", 2, 6, 1, 0x09, 2, 89 ], 106898184e3Ssthen 107b8851fccSafresh1["8.1", "8.1", 2, 6, 3 ], 108b8851fccSafresh1["2012 [R2]", "2012", 2, 6, 3, 0x00, 2, 89 ], 109*eac174f2Safresh1); 110b8851fccSafresh1 111*eac174f2Safresh1my @win10_tests = ( 112*eac174f2Safresh1["10 [Build 9840]", "10", 2, 10, 0, 0x00, 0, 0, 9840], 113*eac174f2Safresh1 114*eac174f2Safresh1["10 [Version 1507 (Preview Build 9841)]", "10", 2, 10, 0, 0x00, 0, 0, 9841], 115*eac174f2Safresh1["10 [Version 1507 (RTM)]", "10", 2, 10, 0, 0x00, 0, 0, 10240], 116*eac174f2Safresh1 117*eac174f2Safresh1["10 [Version 1511 (November Update) (Preview Build 10525)]", "10", 2, 10, 0, 0x00, 0, 0, 10525], 118*eac174f2Safresh1["10 [Version 1511 (November Update)]", "10", 2, 10, 0, 0x00, 0, 0, 10586], 119*eac174f2Safresh1 120*eac174f2Safresh1["10 [Version 1607 (Anniversary Update) (Preview Build 11082)]", "10", 2, 10, 0, 0x00, 0, 0, 11082], 121*eac174f2Safresh1["10 [Version 1607 (Anniversary Update)]", "10", 2, 10, 0, 0x00, 0, 0, 14393], 122*eac174f2Safresh1 123*eac174f2Safresh1["10 [Version 1703 (Creators Update) (Preview Build 14901)]", "10", 2, 10, 0, 0x00, 0, 0, 14901], 124*eac174f2Safresh1["10 [Version 1703 (Creators Update)]", "10", 2, 10, 0, 0x00, 0, 0, 15063], 125*eac174f2Safresh1 126*eac174f2Safresh1["10 [Version 1709 (Fall Creators Update) (Preview Build 16170)]", "10", 2, 10, 0, 0x00, 0, 0, 16170], 127*eac174f2Safresh1["10 [Version 1709 (Fall Creators Update)]", "10", 2, 10, 0, 0x00, 0, 0, 16299], 128*eac174f2Safresh1 129*eac174f2Safresh1["10 [Version 1803 (April 2018 Update) (Preview Build 16353)]", "10", 2, 10, 0, 0x00, 0, 0, 16353], 130*eac174f2Safresh1["10 [Version 1803 (April 2018 Update)]", "10", 2, 10, 0, 0x00, 0, 0, 17134], 131*eac174f2Safresh1 132*eac174f2Safresh1["10 [Version 1809 (October 2018 Update) (Preview Build 17604)]", "10", 2, 10, 0, 0x00, 0, 0, 17604], 133*eac174f2Safresh1["10 [Version 1809 (October 2018 Update)]", "10", 2, 10, 0, 0x00, 0, 0, 17763], 134*eac174f2Safresh1 135*eac174f2Safresh1["10 [Version 1903 (May 2019 Update) (Preview Build 18204)]", "10", 2, 10, 0, 0x00, 0, 0, 18204], 136*eac174f2Safresh1["10 [Version 1903 (May 2019 Update)]", "10", 2, 10, 0, 0x00, 0, 0, 18362], 137*eac174f2Safresh1 138*eac174f2Safresh1["2016 [Version 1607]", "2016", 2, 10, 0, 0x07, 2, 0, 14393], 139*eac174f2Safresh1["2019 [Version 1809]", "2019", 2, 10, 0, 0x07, 2, 0, 17763], 140*eac174f2Safresh1 141*eac174f2Safresh1["Server [Version 1709]", "Server", 2, 10, 0, 0x07, 2, 0, 16299], 142*eac174f2Safresh1["Server [Version 1803]", "Server", 2, 10, 0, 0x07, 2, 0, 17134], 143*eac174f2Safresh1# The 1809 version from the semi-annual channel will identify as "Windows Server 2019 Version 1809" 144*eac174f2Safresh1#["Server [Version 1809]", "Server", 2, 10, 0, 0x07, 2, 0, 17763], 145*eac174f2Safresh1["Server [Version 1903]", "Server", 2, 10, 0, 0x07, 2, 0, 18362], 146*eac174f2Safresh1["Server [Build 12345]", "Server", 2, 10, 0, 0x07, 2, 0, 12345], 147b8851fccSafresh1 148898184e3Ssthen); 149898184e3Ssthen 150898184e3Ssthenmy @ia64_tests = ( 151898184e3Ssthen["2003 [Datacenter Edition for Itanium-based Systems]", "2003", 2, 5, 2, 0x0080, 2, 0], 152898184e3Ssthen["2003 [Enterprise Edition for Itanium-based Systems]", "2003", 2, 5, 2, 0x0002, 2, 0], 153898184e3Ssthen); 154898184e3Ssthen 155*eac174f2Safresh1plan tests => 6 * (@intel_tests + @amd64_tests + 2*@dual_tests + @ia64_tests) + 3 * @win10_tests; 156b39c5158Smillert 157b39c5158Smillert# Test internal implementation function 158898184e3Ssthensub check { 159898184e3Ssthen my($test, $arch) = @_; 160*eac174f2Safresh1 my($pretty, $expect, $id, $major, $minor, $sm, $pt, $metrics, $build) = @$test; 161898184e3Ssthen $metrics = [$metrics] if defined($metrics) && not ref $metrics; 162898184e3Ssthen 163898184e3Ssthen my $tag = ""; 164898184e3Ssthen ($pretty, $tag) = ("$1$2$3", "$2") if $pretty =~ /^(.*)\[(.*)\](.*)$/; 165898184e3Ssthen ($pretty, $tag) = ("$1$2$3", "Windows $2") if $pretty =~ /^(.*)\{(.*)\}(.*)$/; 166898184e3Ssthen $tag = "R2 $tag" if $tag !~ /R2/ && $pretty =~ /R2$/; 167898184e3Ssthen 168898184e3Ssthen # All display names start with "Windows"; 169898184e3Ssthen # and 2003/2008 start with "Windows Server" 170898184e3Ssthen unless ($pretty eq "Win32s") { 171898184e3Ssthen my $prefix = "Windows"; 172*eac174f2Safresh1 $prefix .= " Server" if $pretty =~ /^20(03|08|12|16|19)/; 173898184e3Ssthen $pretty = "$prefix $pretty"; 174b39c5158Smillert } 175b39c5158Smillert 176898184e3Ssthen # @dual_tests: Vista and later all come in both 32-bit and 64-bit versions 177898184e3Ssthen if ($id == 2 && $major >= 6) { 178898184e3Ssthen my $suffix = ""; 179898184e3Ssthen $suffix = " (32-bit)" if $arch == Win32::PROCESSOR_ARCHITECTURE_INTEL; 180898184e3Ssthen $suffix = " (64-bit)" if $arch == Win32::PROCESSOR_ARCHITECTURE_AMD64; 181898184e3Ssthen $_ .= $suffix for $pretty, $tag; 182898184e3Ssthen $tag =~ s/^\s*//; 183898184e3Ssthen } 184898184e3Ssthen 185898184e3Ssthen # We pass the same value for $suitemask and $productinfo. The former is 186898184e3Ssthen # used for Windows up to 2003, the latter is used for Vista and later. 187*eac174f2Safresh1 my($os, $desc) = Win32::_GetOSName("", $major||0, $minor||0, $build, 188898184e3Ssthen $id, $sm||0, $pt||1, $sm||0, $arch, $metrics); 189898184e3Ssthen my $display = Win32::GetOSDisplayName($os, $desc); 190898184e3Ssthen 1916fb12b70Safresh1 note($pretty) if defined ¬e; 192898184e3Ssthen is($display, $pretty); 193898184e3Ssthen is($os, "Win$expect", "os: $os"); 194898184e3Ssthen is($desc, $tag, "desc: $desc"); 195898184e3Ssthen 196*eac174f2Safresh1 next if $major == 10; 197*eac174f2Safresh1 198898184e3Ssthen my $sp = "Service Pack 42"; 199898184e3Ssthen ($os, $desc) = Win32::_GetOSName($sp, $major||0, $minor||0, 0, 200898184e3Ssthen $id, $sm||0, $pt||1, $sm||0, $arch, $metrics); 201898184e3Ssthen $display = Win32::GetOSDisplayName($os, $desc); 202898184e3Ssthen 203898184e3Ssthen is($display, "$pretty $sp", "display: $display"); 204898184e3Ssthen is($os, "Win$expect", "os: $os"); 205898184e3Ssthen $expect = length($tag) ? "$tag $sp" : $sp; 206898184e3Ssthen is($desc, $expect, "desc: $desc"); 207898184e3Ssthen} 208898184e3Ssthen 209*eac174f2Safresh1check($_, Win32::PROCESSOR_ARCHITECTURE_INTEL) for @intel_tests, @dual_tests, @win10_tests; 210898184e3Ssthencheck($_, Win32::PROCESSOR_ARCHITECTURE_AMD64) for @amd64_tests, @dual_tests; 211898184e3Ssthencheck($_, Win32::PROCESSOR_ARCHITECTURE_IA64) for @ia64_tests; 212898184e3Ssthen 213