Skip to content

Commit

Permalink
Support Arm64: Java tests
Browse files Browse the repository at this point in the history
  • Loading branch information
VladRassokhin committed Oct 11, 2022
1 parent 70da0cc commit 2d228f9
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/test/java/org/jvnet/winp/PlatformSpecificProcessTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,13 @@ public PlatformSpecificProcessTest(ExecutablePlatform p) {
public void verifyTargetPlatform() {

// Run 64bit tests only if the platform supports it
if (executablePlatform == ExecutablePlatform.X64) {
if (executablePlatform == ExecutablePlatform.X64 || executablePlatform == ExecutablePlatform.ARM64) {
TestHelper.assumeIs64BitHost();
}

if (executablePlatform == ExecutablePlatform.ARM64) {
TestHelper.assumeIsArm64Host();
}

File exec = getTestAppExecutable(executablePlatform);
System.out.println("Target executable: " + exec.getAbsolutePath());
Assert.assertTrue("Cannot locate the required executable: " + exec.getAbsolutePath(), exec.exists());
Expand Down Expand Up @@ -193,6 +196,6 @@ private String getExpectedPEBName(boolean processIsRunning) {

@Parameters
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][] { {ExecutablePlatform.X64}, {ExecutablePlatform.X86}});
return Arrays.asList(new Object[][] { {ExecutablePlatform.ARM64}, {ExecutablePlatform.X64}, {ExecutablePlatform.X86}});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* The MIT License
*
* Copyright 2017 CloudBees, Inc.; 2022 JetBrains s.r.o.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.jvnet.winp.profiling;

import java.io.File;
import org.junit.Before;
import org.junit.Test;
import org.jvnet.winp.WinProcess;
import org.jvnet.winp.util.ExecutablePlatform;
import org.jvnet.winp.util.ProcessSpawningTest;
import org.jvnet.winp.util.TestHelper;

/**
* Runs profiling for a single ARM64 application.
*/
public class ProfileSingleEnvVars_ARM64 extends ProcessSpawningTest {

@Before
public void assumeArm64() {
TestHelper.assumeIsArm64Host();
}

@Test
public void doProfile() throws Exception {
File executable = getTestAppExecutable(ExecutablePlatform.ARM64);
Process proc = spawnProcess(false, false, executable.getAbsolutePath());
WinProcess wp = new WinProcess(proc);
wp.getEnvironmentVariables();
killSpawnedProcess();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* Runs profiling for a single 64bit application.
* @author Oleg Nenashev
*/
public class ProfileSingleEnvVars_64bit extends ProcessSpawningTest {
public class ProfileSingleEnvVars_X64 extends ProcessSpawningTest {

@Before
public void assumeIs64Bit() {
Expand Down
1 change: 1 addition & 0 deletions src/test/java/org/jvnet/winp/util/ExecutablePlatform.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* @author Oleg Nenashev
*/
public enum ExecutablePlatform {
ARM64,
X64,
X86
//TODO: Add support of ARM?
Expand Down
3 changes: 3 additions & 0 deletions src/test/java/org/jvnet/winp/util/ProcessSpawningTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ public Process spawnProcess(boolean delayAfterCreate, boolean spotcheckProcess,
protected static File getTestAppExecutable(ExecutablePlatform executablePlatform) {
final String executable;
switch (executablePlatform) {
case ARM64:
executable = "native/Arm64/Release/testapp.arm64.exe";
break;
case X64:
executable = "native/x64/Release/testapp.x64.exe";
break;
Expand Down
11 changes: 10 additions & 1 deletion src/test/java/org/jvnet/winp/util/TestHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

package org.jvnet.winp.util;

import static org.hamcrest.CoreMatchers.anyOf;
import static org.hamcrest.CoreMatchers.equalTo;
import org.hamcrest.core.StringContains;
import org.junit.Assume;
Expand All @@ -49,7 +50,15 @@ public static void assumeIs64BitHost() {
Assume.assumeThat("This test can run ony on 64-bit platforms.",
System.getProperty("sun.arch.data.model"), equalTo("64"));
}


/**
* Checks if current system may run ARM64 binaries and skips the test otherwise.
*/
public static void assumeIsArm64Host() {
Assume.assumeThat("This test can run ony on ARM64-compatible platforms.",
System.getProperty("os.arch"), anyOf(equalTo("aarch64"), equalTo("arm64")));
}

public static boolean is64BitJVM() {
return "64".equals(System.getProperty("sun.arch.data.model"));
}
Expand Down

0 comments on commit 2d228f9

Please sign in to comment.