Skip to content

Commit b0ad729

Browse files
committed
add cpu_arch(), os_version()
1 parent b16ba3b commit b0ad729

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

+stdlib/cpu_arch.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
%% CPU_ARCH get the CPU architecture
2+
3+
function arch = cpu_arch()
4+
5+
arch = javaSystemProperty("os.arch");
6+
7+
end

+stdlib/os_version.m

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
%% OS_VERSION Get operating system name and version.
2+
%
3+
% Note: for Windows 11, need new-enough Java version to show Windows 11
4+
% instead of Windows 10.
5+
% Ref: https://bugs.openjdk.org/browse/JDK-8274840
6+
7+
function [os, version] = os_version()
8+
9+
os = javaSystemProperty("os.name");
10+
version = javaSystemProperty("os.version");
11+
12+
end

test/TestJava.m

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,17 @@ function test_java_api(tc)
5050
tc.verifyGreaterThanOrEqual(v, 8, "Java API >= 8 is required for Matlab-stdlib")
5151
end
5252

53+
function test_cpu_arch(tc)
54+
arch = stdlib.cpu_arch();
55+
tc.verifyNotEmpty(arch)
56+
end
57+
58+
function test_os_version(tc)
59+
[os, ver] = stdlib.os_version();
60+
tc.verifyNotEmpty(os)
61+
tc.verifyNotEmpty(ver)
62+
end
63+
5364

5465
function test_hard_link_count(tc)
5566
fn = mfilename("fullpath") + ".m";

0 commit comments

Comments
 (0)