Skip to content

Commit 951e541

Browse files
authored
Support for AARCH64 architecture on Linux (#279)
Fixes #278
1 parent 20b3321 commit 951e541

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

src/main/java/io/specto/hoverfly/junit/core/SystemConfigFactory.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ SystemConfig createSystemConfig() {
3636
}
3737

3838
if (systemInfo.is64BitSystem()) {
39-
archType = ArchType.ARCH_AMD64;
39+
if (systemInfo.isOsLinux() && systemInfo.isArmArchitecture()) {
40+
archType = ArchType.ARCH_ARM64;
41+
} else {
42+
archType = ArchType.ARCH_AMD64;
43+
}
4044
} else {
4145
archType = ArchType.ARCH_386;
4246
}
@@ -66,6 +70,7 @@ String getName() {
6670

6771
enum ArchType {
6872
ARCH_AMD64("amd64"),
73+
ARCH_ARM64("arm64"),
6974
ARCH_386("386");
7075

7176
private final String name;

src/main/java/io/specto/hoverfly/junit/core/SystemInfo.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class SystemInfo {
1111
private final boolean isOsMac = SystemUtils.IS_OS_MAC;
1212
private final boolean isOsLinux = SystemUtils.IS_OS_LINUX;
1313
private final boolean is64BitSystem = SystemUtils.OS_ARCH.contains("64");
14+
private final boolean isArmArchitecture = SystemUtils.OS_ARCH.contains("aarch");
1415
private final String osName = SystemUtils.OS_NAME;
1516

1617
boolean isOsWindows() {
@@ -29,6 +30,10 @@ boolean is64BitSystem() {
2930
return is64BitSystem;
3031
}
3132

33+
boolean isArmArchitecture() {
34+
return isArmArchitecture;
35+
}
36+
3237
String getOsName() {
3338
return osName;
3439
}

src/test/java/io/specto/hoverfly/junit/core/SystemConfigFactoryTest.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
import org.junit.Test;
77
import org.powermock.reflect.Whitebox;
88

9-
import static io.specto.hoverfly.junit.core.SystemConfigFactory.ArchType.ARCH_386;
10-
import static io.specto.hoverfly.junit.core.SystemConfigFactory.ArchType.ARCH_AMD64;
9+
import static io.specto.hoverfly.junit.core.SystemConfigFactory.ArchType.*;
1110
import static io.specto.hoverfly.junit.core.SystemConfigFactory.OsName.*;
1211
import static org.assertj.core.api.Assertions.assertThat;
1312
import static org.assertj.core.api.Assertions.catchThrowable;
@@ -46,6 +45,18 @@ public void shouldCreateSystemConfigForLinux() {
4645
assertThat(systemConfig.getOsName()).isEqualTo(LINUX);
4746
}
4847

48+
@Test
49+
public void shouldCreateSystemConfigWithArm64BitArchType() {
50+
51+
when(systemInfo.isOsLinux()).thenReturn(true);
52+
when(systemInfo.is64BitSystem()).thenReturn(true);
53+
when(systemInfo.isArmArchitecture()).thenReturn(true);
54+
55+
SystemConfig systemConfig = factory.createSystemConfig();
56+
57+
assertThat(systemConfig.getArchType()).isEqualTo(ARCH_ARM64);
58+
}
59+
4960
@Test
5061
public void shouldCreateSystemConfigForMac() {
5162

0 commit comments

Comments
 (0)