On Mon, 24 Mar 2025 10:13:34 GMT, Kevin Walls <[email protected]> wrote:
> These tests have always silently permitted a -1 return value from
> OperatingSystemMXBean CPU time methods.
>
> They need to be stricter, but occasionally Windows 2019 returns a -1 for the
> first few calls of these methods. This seems to be a Windows 2019 bug or
> peculiarity. Other Windows versions are not affected.
>
> GetProcessCpuLoad.java and GetSystemCpuLoad.java need to fail only if the CPU
> time calls continually return -1. They should permit -1 values, as long as
> subsequently a value in the valid range is read.
>
> The GetProcessCpuTime test also needs to retry enough times to expect no -1
> values, and not just skip. While updating this test: it has a maximum
> expected value of Long.MAX_VALUE, which it may as well reduce to something
> that does not look like a binary "all ones except for the high bit" value
> (without creating an ongoing game where we keep increasing the value to avoid
> failures in slow runs).
test/jdk/com/sun/management/OperatingSystemMXBean/GetProcessCpuLoad.java line
43:
> 41: double load;
> 42:
> 43: for(int i = 0; i < 10; i++) {
Suggestion:
for (int i = 0; i < 10; i++) {
test/jdk/com/sun/management/OperatingSystemMXBean/GetSystemCpuLoad.java line 43:
> 41: double load;
> 42:
> 43: for(int i = 0; i < 10; i++) {
Suggestion:
for (int i = 0; i < 10; i++) {
test/jdk/com/sun/management/OperatingSystemMXBean/GetSystemCpuLoad.java line 49:
> 47: // Remember a -1 in case it never gets better.
> 48: ex = new RuntimeException("getSystemCpuLoad() returns " +
> load
> 49: + " which is not in the [0.0,1.0] interval");
Suggestion:
+ " which is not in the [0.0,1.0] interval");
test/jdk/com/sun/management/OperatingSystemMXBean/GetSystemCpuLoad.java line 53:
> 51: } else if (load < 0.0 || load > 1.0) {
> 52: throw new RuntimeException("getSystemCpuLoad() returns "
> + load
> 53: + " which is not in the [0.0,1.0] interval");
Suggestion:
+ " which is not in the [0.0,1.0] interval");
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24186#discussion_r2010344429
PR Review Comment: https://git.openjdk.org/jdk/pull/24186#discussion_r2010344971
PR Review Comment: https://git.openjdk.org/jdk/pull/24186#discussion_r2010345618
PR Review Comment: https://git.openjdk.org/jdk/pull/24186#discussion_r2010346257