From 9bf3dee2424bd8ccbc7ef0175c6e7165ff5cf1c6 Mon Sep 17 00:00:00 2001 From: Mikhailo Seledtsov Date: Thu, 7 Sep 2023 17:12:46 +0000 Subject: [PATCH] 8314831: NMT tests ignore vm flags Reviewed-by: lmesnik, stuefe, gziemski --- test/hotspot/jtreg/runtime/NMT/CommandLineDetail.java | 4 ++-- .../jtreg/runtime/NMT/CommandLineEmptyArgument.java | 3 ++- .../jtreg/runtime/NMT/CommandLineInvalidArgument.java | 3 ++- test/hotspot/jtreg/runtime/NMT/CommandLineSummary.java | 4 ++-- test/hotspot/jtreg/runtime/NMT/CommandLineTurnOffNMT.java | 3 ++- test/hotspot/jtreg/runtime/NMT/JcmdWithNMTDisabled.java | 3 ++- test/hotspot/jtreg/runtime/NMT/MallocLimitTest.java | 8 +++++++- test/hotspot/jtreg/runtime/NMT/NMTInitializationTest.java | 4 ++-- test/hotspot/jtreg/runtime/NMT/NMTWithCDS.java | 6 +++--- test/hotspot/jtreg/runtime/NMT/PrintNMTStatistics.java | 6 +++--- .../runtime/NMT/PrintNMTStatisticsWithNMTDisabled.java | 3 ++- 11 files changed, 29 insertions(+), 18 deletions(-) diff --git a/test/hotspot/jtreg/runtime/NMT/CommandLineDetail.java b/test/hotspot/jtreg/runtime/NMT/CommandLineDetail.java index 94bd1de830a..074a9b194eb 100644 --- a/test/hotspot/jtreg/runtime/NMT/CommandLineDetail.java +++ b/test/hotspot/jtreg/runtime/NMT/CommandLineDetail.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ public class CommandLineDetail { public static void main(String args[]) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createTestJvm( "-XX:NativeMemoryTracking=detail", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/runtime/NMT/CommandLineEmptyArgument.java b/test/hotspot/jtreg/runtime/NMT/CommandLineEmptyArgument.java index e2d627ffded..3d2ac8baf29 100644 --- a/test/hotspot/jtreg/runtime/NMT/CommandLineEmptyArgument.java +++ b/test/hotspot/jtreg/runtime/NMT/CommandLineEmptyArgument.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ /* * @test * @summary Empty argument to NMT should result in an informative error message + * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/runtime/NMT/CommandLineInvalidArgument.java b/test/hotspot/jtreg/runtime/NMT/CommandLineInvalidArgument.java index 78eeb29222c..d82df08b8cc 100644 --- a/test/hotspot/jtreg/runtime/NMT/CommandLineInvalidArgument.java +++ b/test/hotspot/jtreg/runtime/NMT/CommandLineInvalidArgument.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ /* * @test * @summary Invalid argument to NMT should result in an informative error message + * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/runtime/NMT/CommandLineSummary.java b/test/hotspot/jtreg/runtime/NMT/CommandLineSummary.java index 1efe805b457..c44be999d5f 100644 --- a/test/hotspot/jtreg/runtime/NMT/CommandLineSummary.java +++ b/test/hotspot/jtreg/runtime/NMT/CommandLineSummary.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ public class CommandLineSummary { public static void main(String args[]) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createTestJvm( "-XX:NativeMemoryTracking=summary", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/runtime/NMT/CommandLineTurnOffNMT.java b/test/hotspot/jtreg/runtime/NMT/CommandLineTurnOffNMT.java index c2b784e383e..710902a53cb 100644 --- a/test/hotspot/jtreg/runtime/NMT/CommandLineTurnOffNMT.java +++ b/test/hotspot/jtreg/runtime/NMT/CommandLineTurnOffNMT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ /* * @test * @summary Turning off NMT should not result in an error + * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/runtime/NMT/JcmdWithNMTDisabled.java b/test/hotspot/jtreg/runtime/NMT/JcmdWithNMTDisabled.java index da1dd497975..079d8d99052 100644 --- a/test/hotspot/jtreg/runtime/NMT/JcmdWithNMTDisabled.java +++ b/test/hotspot/jtreg/runtime/NMT/JcmdWithNMTDisabled.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ /* * @test * @summary Verify that jcmd correctly reports that NMT is not enabled + * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/runtime/NMT/MallocLimitTest.java b/test/hotspot/jtreg/runtime/NMT/MallocLimitTest.java index c321f91b719..ba53d4d06a1 100644 --- a/test/hotspot/jtreg/runtime/NMT/MallocLimitTest.java +++ b/test/hotspot/jtreg/runtime/NMT/MallocLimitTest.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2022 SAP SE. All rights reserved. - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ /* * @test id=global-limit-fatal * @summary Verify -XX:MallocLimit with a global limit + * @requires vm.flagless * @modules java.base/jdk.internal.misc * @library /test/lib * @run driver MallocLimitTest global-limit-fatal @@ -34,6 +35,7 @@ /* * @test id=global-limit-oom * @summary Verify -XX:MallocLimit with a global limit + * @requires vm.flagless * @modules java.base/jdk.internal.misc * @library /test/lib * @run driver MallocLimitTest global-limit-oom @@ -42,6 +44,7 @@ /* * @test id=compiler-limit-fatal * @summary Verify -XX:MallocLimit with a compiler-specific limit (for "mtCompiler" category) + * @requires vm.flagless * @modules java.base/jdk.internal.misc * @library /test/lib * @run driver MallocLimitTest compiler-limit-fatal @@ -50,6 +53,7 @@ /* * @test id=compiler-limit-oom * @summary Verify -XX:MallocLimit with a compiler-specific limit (for "mtCompiler" category) + * @requires vm.flagless * @modules java.base/jdk.internal.misc * @library /test/lib * @run driver MallocLimitTest compiler-limit-oom @@ -58,6 +62,7 @@ /* * @test id=multi-limit * @summary Verify -XX:MallocLimit with multiple limits + * @requires vm.flagless * @modules java.base/jdk.internal.misc * @library /test/lib * @run driver MallocLimitTest multi-limit @@ -66,6 +71,7 @@ /* * @test id=limit-without-nmt * @summary Verify that the VM warns if -XX:MallocLimit is given but NMT is disabled + * @requires vm.flagless * @modules java.base/jdk.internal.misc * @library /test/lib * @run driver MallocLimitTest limit-without-nmt diff --git a/test/hotspot/jtreg/runtime/NMT/NMTInitializationTest.java b/test/hotspot/jtreg/runtime/NMT/NMTInitializationTest.java index b0e543dfe43..ef1e5cd8346 100644 --- a/test/hotspot/jtreg/runtime/NMT/NMTInitializationTest.java +++ b/test/hotspot/jtreg/runtime/NMT/NMTInitializationTest.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2021 SAP SE. All rights reserved. - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -156,7 +156,7 @@ public class NMTInitializationTest { } vmArgs.add("-version"); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(vmArgs); + ProcessBuilder pb = ProcessTools.createTestJvm(vmArgs); OutputAnalyzer output = new OutputAnalyzer(pb.start()); if (debug) { output.reportDiagnosticSummary(); diff --git a/test/hotspot/jtreg/runtime/NMT/NMTWithCDS.java b/test/hotspot/jtreg/runtime/NMT/NMTWithCDS.java index 777b08ce9ff..994705e1e77 100644 --- a/test/hotspot/jtreg/runtime/NMT/NMTWithCDS.java +++ b/test/hotspot/jtreg/runtime/NMT/NMTWithCDS.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,14 +38,14 @@ public class NMTWithCDS { public static void main(String[] args) throws Exception { ProcessBuilder pb; - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createTestJvm( "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./NMTWithCDS.jsa", "-Xshare:dump", "-Xlog:cds"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); try { output.shouldContain("Loading classes to share"); output.shouldHaveExitValue(0); - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createTestJvm( "-XX:+UnlockDiagnosticVMOptions", "-XX:NativeMemoryTracking=detail", "-XX:SharedArchiveFile=./NMTWithCDS.jsa", "-Xshare:on", "-version"); output = new OutputAnalyzer(pb.start()); output.shouldContain("sharing"); diff --git a/test/hotspot/jtreg/runtime/NMT/PrintNMTStatistics.java b/test/hotspot/jtreg/runtime/NMT/PrintNMTStatistics.java index c59ce0315e8..3263cc40233 100644 --- a/test/hotspot/jtreg/runtime/NMT/PrintNMTStatistics.java +++ b/test/hotspot/jtreg/runtime/NMT/PrintNMTStatistics.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ public class PrintNMTStatistics { public static void main(String args[]) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createTestJvm( "-XX:+UnlockDiagnosticVMOptions", "-XX:+PrintNMTStatistics", "-XX:NativeMemoryTracking=detail", @@ -55,7 +55,7 @@ public class PrintNMTStatistics { // Make sure memory reserved for Module processing is recorded. output_detail.shouldContain(" Module (reserved="); - ProcessBuilder pb1 = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb1 = ProcessTools.createTestJvm( "-XX:+UnlockDiagnosticVMOptions", "-XX:+PrintNMTStatistics", "-XX:NativeMemoryTracking=summary", diff --git a/test/hotspot/jtreg/runtime/NMT/PrintNMTStatisticsWithNMTDisabled.java b/test/hotspot/jtreg/runtime/NMT/PrintNMTStatisticsWithNMTDisabled.java index 31ab2537fe1..70222701b06 100644 --- a/test/hotspot/jtreg/runtime/NMT/PrintNMTStatisticsWithNMTDisabled.java +++ b/test/hotspot/jtreg/runtime/NMT/PrintNMTStatisticsWithNMTDisabled.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ /* * @test * @summary Trying to enable PrintNMTStatistics should result in a warning + * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.misc * java.management