From d88f901b2a50539e276aa409b5d7ce1eb3e1bfc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Shipil=C3=ABv?= Date: Thu, 6 Jul 2023 15:26:27 +0200 Subject: [PATCH] 7903504: JMH: Fix new Sonar warnings --- .../org/openjdk/jmh/validation/AffinitySupport.java | 4 +++- .../jmh/it/profilers/LinuxPerfNormProfilerTest.java | 10 +++++----- .../jmh/it/profilers/LinuxPerfProfilerTest.java | 4 ++-- .../jmh/it/profilers/SafepointsProfilerTest.java | 10 +++++----- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/AffinitySupport.java b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/AffinitySupport.java index 775d844b0..4b77c46e1 100644 --- a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/AffinitySupport.java +++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/AffinitySupport.java @@ -87,7 +87,9 @@ public static List prepare() { // Need to rename the file to the proper name, otherwise JNA would not discover it File proper = new File(bootLibraryPath + '/' + System.mapLibraryName("jnidispatch")); - file.renameTo(proper); + if (!file.renameTo(proper)) { + throw new IllegalStateException("Failed to rename " + file + " to " + proper); + } return Arrays.asList( "-Djna.nounpack=true", // Should not unpack itself, but use predefined path diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfNormProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfNormProfilerTest.java index a1fc91552..7780c028f 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfNormProfilerTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfNormProfilerTest.java @@ -77,9 +77,9 @@ public void test() throws RunnerException { double cycles = ProfilerTestUtils.checkedGet(sr, "cycles", "cycles:u").getScore(); double branches = ProfilerTestUtils.checkedGet(sr, "branches", "branches:u").getScore(); - Assert.assertNotEquals(0, instructions); - Assert.assertNotEquals(0, cycles); - Assert.assertNotEquals(0, branches); + Assert.assertNotEquals(0D, instructions, 0D); + Assert.assertNotEquals(0D, cycles, 0D); + Assert.assertNotEquals(0D, branches, 0D); if (branches > instructions) { throw new IllegalStateException(String.format("Branches (%.2f) larger than instructions (%.3f)", branches, instructions)); @@ -88,8 +88,8 @@ public void test() throws RunnerException { double ipc = ProfilerTestUtils.checkedGet(sr, "IPC").getScore(); double cpi = ProfilerTestUtils.checkedGet(sr, "CPI").getScore(); - Assert.assertNotEquals(0, ipc); - Assert.assertNotEquals(0, cpi); + Assert.assertNotEquals(0D, ipc, 0D); + Assert.assertNotEquals(0D, cpi, 0D); } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfProfilerTest.java index e713bc52e..41ad2c4be 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfProfilerTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfProfilerTest.java @@ -79,8 +79,8 @@ public void test() throws RunnerException { if (sr.containsKey("·ipc")) { double ipc = ProfilerTestUtils.checkedGet(sr, "·ipc").getScore(); double cpi = ProfilerTestUtils.checkedGet(sr, "·cpi").getScore(); - Assert.assertNotEquals(0, ipc); - Assert.assertNotEquals(0, cpi); + Assert.assertNotEquals(0D, ipc, 0D); + Assert.assertNotEquals(0D, cpi, 0D); } Assert.assertTrue(msg.contains("cycles")); diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/SafepointsProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/SafepointsProfilerTest.java index 9b0868725..e9e474e30 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/SafepointsProfilerTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/SafepointsProfilerTest.java @@ -68,12 +68,12 @@ public void test() throws RunnerException { double pauseCount = ProfilerTestUtils.checkedGet(sr, "·safepoints.pause.count").getScore(); double ttspCount = ProfilerTestUtils.checkedGet(sr, "·safepoints.ttsp.count").getScore(); - Assert.assertNotEquals(pauseTotal, 0); - Assert.assertNotEquals(ttspTotal, 0); + Assert.assertNotEquals(0D, pauseTotal, 0D); + Assert.assertNotEquals(0D, ttspTotal, 0D); - Assert.assertNotEquals(pauseCount, 0); - Assert.assertNotEquals(ttspCount, 0); - Assert.assertEquals(ttspCount, pauseCount, 0); + Assert.assertNotEquals(0D, pauseCount, 0D); + Assert.assertNotEquals(0D, ttspCount, 0D); + Assert.assertEquals(ttspCount, pauseCount, 0D); if (interval < 3000) { throw new IllegalStateException("Interval time is too low. " +