Skip to content

Commit

Permalink
Merge pull request #3890 from pdbain-ibm/attach
Browse files Browse the repository at this point in the history
Select the correct native library suffix
  • Loading branch information
llxia authored Nov 30, 2018
2 parents 3e6530f + e354a2b commit a15b783
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import static org.testng.AssertJUnit.assertTrue;
import static org.openj9.test.util.FileUtilities.deleteRecursive;
import static org.openj9.test.util.PlatformInfo.isWindows;
import static org.openj9.test.util.PlatformInfo.isMacOS;

import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
Expand All @@ -35,6 +35,7 @@
import java.util.List;
import java.util.Properties;

import org.openj9.test.util.PlatformInfo;
import org.openj9.test.util.StringPrintStream;
import org.testng.AssertJUnit;
import org.testng.annotations.AfterMethod;
Expand Down Expand Up @@ -215,15 +216,8 @@ public void test_agntld03() {
String lipPath = System.getProperty("java.library.path");
String[] libDirs = lipPath.split(File.pathSeparator);
char fs = File.separatorChar;
String decoration = "lib";
String suffix = ".so"; // default for Linux, AIX, and z/OS
if (isWindows()) {
/* kludgy test if we are on MS Windows */
decoration = "";
suffix = ".dll";
} else if (isMacOS()) {
suffix = ".dylib";
}
String decoration = isWindows()? "": "lib";
String librarySuffix = PlatformInfo.getLibrarySuffix();
int pIndex = 0;
String outOutput = null;
TargetManager target = launchTarget();
Expand All @@ -241,7 +235,7 @@ public void test_agntld03() {
do {
try {
String libPath = libDirs[pIndex] + fs + decoration + JVMTITST
+ suffix;
+ librarySuffix;
++pIndex;
logger.debug("trying to load " + libPath);
File lib = new File(libPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import java.util.Properties;

import static org.testng.Assert.fail;

import static org.openj9.test.util.PlatformInfo.getLibrarySuffix;
import org.testng.AssertJUnit;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
Expand Down Expand Up @@ -80,7 +82,7 @@ public void testAgentLoading() {
String[] libDirs = lipPath.split(File.pathSeparator);
char fs = File.separatorChar;
String decoration = "lib";
String suffix = ".so";
String librarySuffix = getLibrarySuffix();
String errOutput = "";
String outOutput = "";
TargetManager target = new TargetManager(TestConstants.TARGET_VM_CLASS, null, vmArgs, null);
Expand All @@ -101,7 +103,7 @@ public void testAgentLoading() {
}
for (String libElement: libDirs) {
try {
String libPath = libElement+fs+decoration+TestUtil.JVMTITST+suffix;
String libPath = libElement+fs+decoration+TestUtil.JVMTITST+librarySuffix;
logger.debug("trying to load "+ libPath);
File lib = new File(libPath);
if (!lib.exists()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,13 @@ public static boolean isMacOS() {
return ((null != osName) && osName.startsWith("Mac OS"));
}

public static String getLibrarySuffix() {
String librarySuffix = ".so"; // default for Linux, AIX, and z/OS
if (isWindows()) {
librarySuffix = ".dll";
} else if (isMacOS()) {
librarySuffix = ".dylib";
}
return librarySuffix;
}
}

0 comments on commit a15b783

Please sign in to comment.