Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Commit

Permalink
Update platform values
Browse files Browse the repository at this point in the history
  • Loading branch information
ven-k committed Sep 19, 2022
1 parent 4b78c98 commit 960e9e9
Showing 1 changed file with 31 additions and 29 deletions.
60 changes: 31 additions & 29 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ using Test
using Libdl
using Pkg
using SHA
using Pkg.BinaryPlatforms

# The platform we're running on
const platform = platform_key_abi()
Expand All @@ -28,6 +29,7 @@ end

@testset "OutputCollector" begin
cd("output_tests") do
@info pwd()
# Collect the output of `simple.sh``
oc = OutputCollector(`$sh ./simple.sh`)

Expand Down Expand Up @@ -191,8 +193,8 @@ end
end

# Test that we can control libdir() via platform arguments
@test libdir(prefix, Linux(:x86_64)) == joinpath(prefix, "lib")
@test libdir(prefix, Windows(:x86_64)) == joinpath(prefix, "bin")
@test libdir(prefix, Platform("x86_64", "linux")) == joinpath(prefix, "lib")
@test libdir(prefix, Platform("x86_64", "windows")) == joinpath(prefix, "bin")
end
end

Expand Down Expand Up @@ -220,19 +222,19 @@ end
@test satisfied(ef, verbose=true)
@static if !Sys.iswindows()
# Windows doesn't care about executable bit, grumble grumble
@test !satisfied(e, verbose=true, platform=Linux(:x86_64))
@test !satisfied(e, verbose=true, platform=Platform("x86_64", "linux"))
end

# Make it executable and ensure this does satisfy the Executable
chmod(e_path, 0o777)
@test satisfied(e, verbose=true, platform=Linux(:x86_64))
@test satisfied(e, verbose=true, platform=Platform("x86_64", "linux"))

# Remove it and add a `$(path).exe` version to check again, this
# time saying it's a Windows executable
Base.rm(e_path; force=true)
touch("$(e_path).exe")
chmod("$(e_path).exe", 0o777)
@test locate(e, platform=Windows(:x86_64)) == "$(e_path).exe"
@test locate(e, platform=Platform("x86_64", "windows")) == "$(e_path).exe"

# Test that simply creating a library file doesn't satisfy it if we are
# testing something that matches the current platform's dynamic library
Expand All @@ -247,7 +249,7 @@ end
# But if it is from a different platform, simple existence will be
# enough to satisfy a LibraryProduct
@static if Sys.iswindows()
p = Linux(:x86_64)
p = Platform("x86_64", "linux")
mkpath(libdir(prefix, p))
l_path = joinpath(libdir(prefix, p), "libfoo.so")
touch(l_path)
Expand All @@ -259,7 +261,7 @@ end
@test satisfied(ld, verbose=true, platform=p)
@test satisfied(ld, verbose=true, platform=p, isolate=true)
else
p = Windows(:x86_64)
p = Platform("x86_64", "windows")
mkpath(libdir(prefix, p))
l_path = joinpath(libdir(prefix, p), "libfoo.dll")
touch(l_path)
Expand All @@ -275,12 +277,12 @@ end

# Ensure that the test suite thinks that these libraries are foreign
# so that it doesn't try to `dlopen()` them:
foreign_platform = if platform == Linux(:aarch64)
foreign_platform = if platform == Platform("aarch64", "linux")
# Arbitrary architecture that is not dlopen()'able
Linux(:powerpc64le)
Platform("powerpc64le", "linux")
else
# If we're not Linux(:aarch64), then say the libraries are
Linux(:aarch64)
# If we're not Platform("aarch64", "linux")), then say the libraries are
Platform("aarch64", "linux")
end

# Test for valid library name permutations
Expand Down Expand Up @@ -453,8 +455,8 @@ end
end

# Get a valid platform tarball name that is not our native platform
other_platform = Linux(:x86_64)
if BinaryProvider.platforms_match(platform, Linux(:x86_64))
other_platform = Platform("x86_64", "linux")
if BinaryProvider.platforms_match(platform, Platform("x86_64", "linux"))
other_platform = MacOS()
end
new_tarball_path = "libfoo.v1.0.0.$(triplet(other_platform)).tar.gz"
Expand Down Expand Up @@ -593,22 +595,22 @@ end
# Use `build_libfoo_tarball.jl` in the BinaryBuilder.jl repository to generate more of these
const bin_prefix = "https://github.com/staticfloat/small_bin/raw/51b13b44feb2a262e2e04690bfa54d03167533f2/libfoo"
const libfoo_downloads = Dict(
Linux(:aarch64; libc=:glibc) => ("$bin_prefix/libfoo.aarch64-linux-gnu.tar.gz", "36886ac25cf5678c01fe20630b413f9354b7a3721c6a2c2043162f7ebd147ff5"),
Linux(:armv7l; libc=:glibc) => ("$bin_prefix/libfoo.arm-linux-gnueabihf.tar.gz", "147ebaeb1a722da43ee08705689aed71ac87c3c2c907af047c6721c0025ba383"),
Linux(:powerpc64le; libc=:glibc) => ("$bin_prefix/libfoo.powerpc64le-linux-gnu.tar.gz", "5c35295ac161272ada9a77d1f6b770e30ea864e521e31853258cbc36ad4c4468"),
Linux(:i686; libc=:glibc) => ("$bin_prefix/libfoo.i686-linux-gnu.tar.gz", "97655b6a218d61284723b6923d7c96e6a256fa68b9419d723c588aa24404b102"),
Linux(:x86_64; libc=:glibc) => ("$bin_prefix/libfoo.x86_64-linux-gnu.tar.gz", "5208c63a9d07e592c78f541fc13caa8cd191b11e7e77b31d407237c2b13ec391"),

Linux(:aarch64; libc=:musl) => ("$bin_prefix/libfoo.aarch64-linux-musl.tar.gz", "81751477c1e3ee6c93e1c28ee7db2b99d1eed0d6ce86dc30d64c2e5dd4dfe88d"),
Linux(:armv7l; libc=:musl) => ("$bin_prefix/libfoo.arm-linux-musleabihf.tar.gz", "bb65aad58f2e6fc39dc9688da1bca5e8103a3a3fa67dc589debbd2e98176f0e1"),
Linux(:i686; libc=:musl) => ("$bin_prefix/libfoo.i686-linux-musl.tar.gz", "5f02fd1fe19f3a565fb128d3673b35c7b3214a101cef9dcbb202c0092438a87b"),
Linux(:x86_64; libc=:musl) => ("$bin_prefix/libfoo.x86_64-linux-musl.tar.gz", "ea630600a12d2c1846bc93bcc8d9638a4991f63329205c534d93e0a3de5f641d"),

FreeBSD(:x86_64) => ("$bin_prefix/libfoo.x86_64-unknown-freebsd11.1.tar.gz", "5f6edd6247b3685fa5c42c98a53d2a3e1eef6242c2bb3cdbb5fe23f538703fe4"),
MacOS(:x86_64) => ("$bin_prefix/libfoo.x86_64-apple-darwin14.tar.gz", "fcc268772d6f21d65b45fcf3854a3142679b78e53c7673dac26c95d6ccc89a24"),

Windows(:i686) => ("$bin_prefix/libfoo.i686-w64-mingw32.tar.gz", "79181cf62ca8e0b2e0851fa0ace52f4ab335d0cad26fb7f9cd4ff356a9a96e70"),
Windows(:x86_64) => ("$bin_prefix/libfoo.x86_64-w64-mingw32.tar.gz", "7f8939e9529835b83810d3ae7e2556f6e002d571f619894e54ece42ea5262b7f"),
Platform("aarch64", "linux"; libc="glibc") => ("$bin_prefix/libfoo.aarch64-linux-gnu.tar.gz", "36886ac25cf5678c01fe20630b413f9354b7a3721c6a2c2043162f7ebd147ff5"),
Platform("armv7l", "linux"; libc="glibc") => ("$bin_prefix/libfoo.arm-linux-gnueabihf.tar.gz", "147ebaeb1a722da43ee08705689aed71ac87c3c2c907af047c6721c0025ba383"),
Platform("powerpc64le", "linux"; libc="glibc") => ("$bin_prefix/libfoo.powerpc64le-linux-gnu.tar.gz", "5c35295ac161272ada9a77d1f6b770e30ea864e521e31853258cbc36ad4c4468"),
Platform("i686", "linux"; libc="glibc") => ("$bin_prefix/libfoo.i686-linux-gnu.tar.gz", "97655b6a218d61284723b6923d7c96e6a256fa68b9419d723c588aa24404b102"),
Platform("x86_64", "linux"; libc="glibc") => ("$bin_prefix/libfoo.x86_64-linux-gnu.tar.gz", "5208c63a9d07e592c78f541fc13caa8cd191b11e7e77b31d407237c2b13ec391"),

Platform("aarch64", "linux"; libc="musl") => ("$bin_prefix/libfoo.aarch64-linux-musl.tar.gz", "81751477c1e3ee6c93e1c28ee7db2b99d1eed0d6ce86dc30d64c2e5dd4dfe88d"),
Platform("armv7l", "linux"; libc="musl") => ("$bin_prefix/libfoo.arm-linux-musleabihf.tar.gz", "bb65aad58f2e6fc39dc9688da1bca5e8103a3a3fa67dc589debbd2e98176f0e1"),
Platform("i686", "linux"; libc="musl") => ("$bin_prefix/libfoo.i686-linux-musl.tar.gz", "5f02fd1fe19f3a565fb128d3673b35c7b3214a101cef9dcbb202c0092438a87b"),
Platform("x86_64", "linux"; libc="musl") => ("$bin_prefix/libfoo.x86_64-linux-musl.tar.gz", "ea630600a12d2c1846bc93bcc8d9638a4991f63329205c534d93e0a3de5f641d"),

Platform("x86_64", "freebsd") => ("$bin_prefix/libfoo.x86_64-unknown-freebsd11.1.tar.gz", "5f6edd6247b3685fa5c42c98a53d2a3e1eef6242c2bb3cdbb5fe23f538703fe4"),
Platform("x86_64", "macos") => ("$bin_prefix/libfoo.x86_64-apple-darwin14.tar.gz", "fcc268772d6f21d65b45fcf3854a3142679b78e53c7673dac26c95d6ccc89a24"),

Platform("i686", "windows") => ("$bin_prefix/libfoo.i686-w64-mingw32.tar.gz", "79181cf62ca8e0b2e0851fa0ace52f4ab335d0cad26fb7f9cd4ff356a9a96e70"),
Platform("x86_64", "windows") => ("$bin_prefix/libfoo.x86_64-w64-mingw32.tar.gz", "7f8939e9529835b83810d3ae7e2556f6e002d571f619894e54ece42ea5262b7f"),
)

# Test manually downloading and using libfoo
Expand Down

0 comments on commit 960e9e9

Please sign in to comment.