File 0195-fix-10366-reading-out-os-version-for-windows-manifes.patch of Package erlang
From 83c66689f3d936e756350b99fd6ede43513e34c8 Mon Sep 17 00:00:00 2001
From: Dmytro Lytovchenko <dima.lytovchenko@ericsson.com>
Date: Wed, 14 Jan 2026 15:09:21 +0100
Subject: [PATCH] fix #10366 reading out os:version() for windows -
manifest.xml Update comment to include 'Windows 11, Windows Server 2016,
Windows Server 2019 and Windows Server 2022' Add license Add test for
os:version on Windows
---
erts/etc/win32/manifest.xml | 36 ++++++++++++++++++++++++++++++++
lib/kernel/test/os_SUITE.erl | 40 ++++++++++++++++++++++++++++++++++--
2 files changed, 74 insertions(+), 2 deletions(-)
diff --git a/erts/etc/win32/manifest.xml b/erts/etc/win32/manifest.xml
index eea364c9e9..4a7ad9cedb 100644
--- a/erts/etc/win32/manifest.xml
+++ b/erts/etc/win32/manifest.xml
@@ -1,3 +1,25 @@
+<!--
+%%
+%% %CopyrightBegin%
+%%
+%% SPDX-License-Identifier: Apache-2.0
+%%
+%% Copyright Ericsson AB 2026. All Rights Reserved.
+%%
+%% Licensed under the Apache License, Version 2.0 (the "License");
+%% you may not use this file except in compliance with the License.
+%% You may obtain a copy of the License at
+%%
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS,
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%% See the License for the specific language governing permissions and
+%% limitations under the License.
+%%
+%% %CopyrightEnd%
+-->
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<dependency>
<dependentAssembly>
@@ -7,6 +29,20 @@
</assemblyIdentity>
</dependentAssembly>
</dependency>
+ <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
+ <application>
+ <!-- Windows 8.1 -->
+ <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
+ <!-- Windows Vista -->
+ <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
+ <!-- Windows 7 -->
+ <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
+ <!-- Windows 8 -->
+ <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
+ <!-- Windows 10, Windows 11, Windows Server 2016, Windows Server 2019 and Windows Server 2022 -->
+ <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
+ </application>
+ </compatibility>
<ms_asmv2:trustInfo xmlns:ms_asmv2="urn:schemas-microsoft-com:asm.v2">
<ms_asmv2:security>
<ms_asmv2:requestedPrivileges>
diff --git a/lib/kernel/test/os_SUITE.erl b/lib/kernel/test/os_SUITE.erl
index 17ec610774..f6f19fe766 100644
--- a/lib/kernel/test/os_SUITE.erl
+++ b/lib/kernel/test/os_SUITE.erl
@@ -31,7 +31,8 @@
large_output_command/1, background_command/0, background_command/1,
message_leak/1, close_stdin/0, close_stdin/1, max_size_command/1,
cmd_exception/1, os_cmd_shell/1, os_cmd_shell_peer/1,
- perf_counter_api/1, error_info/1]).
+ perf_counter_api/1, error_info/1,
+ os_version/1]).
-include_lib("common_test/include/ct.hrl").
-include_lib("stdlib/include/assert.hrl").
@@ -48,7 +49,8 @@ all() ->
large_output_command, background_command, message_leak,
close_stdin, max_size_command, perf_counter_api,
error_info, os_cmd_shell, os_cmd_shell_peer,
- cmd_exception].
+ cmd_exception,
+ os_version].
groups() ->
[].
@@ -564,3 +566,37 @@ receive_all() ->
X -> [X|receive_all()]
after 0 -> []
end.
+
+
+get_windows_version_from_cmd() ->
+ VerOutput = os:cmd("ver"),
+ %% Expected format: "Microsoft Windows [Version 10.0.19045.1234]" or similar
+ case re:run(VerOutput, "(\\d+)\\.(\\d+)\\.(\\d+)",
+ [{capture, all_but_first, list}]) of
+ {match, [Major, Minor, Build]} ->
+ {list_to_integer(Major), list_to_integer(Minor), list_to_integer(Build)};
+ nomatch ->
+ {0, 0, 0}
+ end.
+
+%% On Windows, make sure that appropriate Windows version is returned
+%% Example versions:
+%% {5,0,_}=Windows 2000, {6,0,_}=Vista, {6,1,_}=Windows 7, {6,2,_}=Windows 8 and Server 2012,
+%% {10,0,_}=Windows 10 and 11, Server 2016, 2019, 2022
+os_version_win32() ->
+ V = os:version(),
+ CmdV = get_windows_version_from_cmd(),
+
+ %% Verify that command line version matches os:version()
+ ct:log("os:version() returned: ~p~n", [V]),
+ ct:log("Command line version: ~p~n", [CmdV]),
+
+ %% This test will fail if Windows manifest.xml does not include the Windows OS where the test is run.
+ %% If a new version has been released, please update erts/etc/win32/manifest.xml
+ ?assertEqual(V, CmdV, "Windows versions from os:version and from 'ver' command are expected to match").
+
+os_version(_Config) ->
+ case os:type() of
+ {win32, nt} -> os_version_win32();
+ _ -> ok
+ end.
--
2.51.0