Skip to content

Commit

Permalink
If uname returns x86_64 on Mac, use x64 binary #214
Browse files Browse the repository at this point in the history
Even if we were launched by aarch64 Java, see #204 for discussion.
  • Loading branch information
deepy committed Feb 10, 2022
1 parent 460e68d commit ac3f280
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ open class PlatformHelper {
*/
arch == "arm" || arch.startsWith("aarch") -> property("uname")
.mapIf({ it == "armv8l" || it == "aarch64" }) { "arm64" }
.mapIf({ it == "x86_64" }) {"x64"}
arch == "ppc64le" -> "ppc64le"
arch == "s390x" -> "s390x"
arch.contains("64") -> "x64"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,25 @@ class PlatformHelperTest extends Specification {
'ppc64le' | 'ppc64le' | 'ppc64le'
}

@Unroll
def "verify ARM handling Mac OS #archProp (#unameProp)"() {
given:
this.props.setProperty("os.name", "Mac OS X")
this.props.setProperty("os.arch", archProp)
this.props.setProperty("uname", unameProp)

expect:
this.helper.getOsName() == "darwin"
this.helper.getOsArch() == osArch

where:
archProp | unameProp | osArch
'aarch32' | 'arm' | 'arm'
'aarch64' | 'arm64' | 'arm64'
'aarch64' | 'aarch64' | 'arm64'
'aarch64' | 'x86_64' | 'x64' // This shouldn't really happen but according to PR #204 it does
}

def "throw exception if unsupported os"() {
given:
this.props.setProperty("os.name", 'Nonsense')
Expand Down

0 comments on commit ac3f280

Please sign in to comment.