Skip to content

Commit

Permalink
account for Windows behviour changes
Browse files Browse the repository at this point in the history
  • Loading branch information
stooke committed Oct 9, 2024
1 parent 6715569 commit e1b2c53
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 2 deletions.
8 changes: 6 additions & 2 deletions test/hotspot/gtest/runtime/test_os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,13 @@ TEST_VM(os, realpath) {
/* test a non-existant path, but provide an adequate buffer */
errno = 0;
returnedBuffer = os::realpath(nosuchpath, buffer, sizeof(nosuchpath) + 3);
/* Returns ENOENT on Linux, 0 on Windows */
/* Returns ENOENT on Linux, 0 on SOME versions of Windows */
#if defined(_WINDOWS)
EXPECT_TRUE(returnedBuffer == buffer);
if (returnedBuffer != nullptr) {
EXPECT_TRUE(returnedBuffer == buffer);
} else {
EXPECT_TRUE(errno != 0);
}
#else
EXPECT_TRUE(returnedBuffer == nullptr);
EXPECT_TRUE(errno == ENOENT);
Expand Down
59 changes: 59 additions & 0 deletions test/hotspot/jtreg/serviceability/dcmd/vm/SystemMapZGCTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2024, Red Hat, Inc. and/or its affiliates.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

import org.testng.annotations.Test;
import jdk.test.lib.dcmd.CommandExecutor;
import jdk.test.lib.dcmd.JMXExecutor;
import jdk.test.lib.process.OutputAnalyzer;

/*
* @test
* @summary Test of diagnostic command System.map
* @library /test/lib
* @requires (os.family == "linux" | os.family == "windows")
* @modules java.base/jdk.internal.misc
* java.compiler
* java.management
* jdk.internal.jvmstat/sun.jvmstat.monitor
* @run testng/othervm -XX:+UseZGC -XX:+UsePerfData SystemMapTest
*/
public class SystemMapZGCTest extends SystemMapTestBase {
public void run(CommandExecutor executor) {
OutputAnalyzer output = executor.execute("System.map");
boolean NMTOff = output.contains("NMT is disabled");
for (String s: shouldMatchUnconditionally()) {
output.shouldMatch(s);
}
if (!NMTOff) { // expect VM annotations if NMT is on
for (String s: shouldMatchIfNMTIsEnabled()) {
output.shouldMatch(s);
}
}
}

@Test
public void jmx() {
run(new JMXExecutor());
}
}

0 comments on commit e1b2c53

Please sign in to comment.