From ad5f958dc6f892d3f59934352a6244e90e418a8d Mon Sep 17 00:00:00 2001 From: Tobias Knopp Date: Fri, 7 Sep 2018 15:09:01 +0200 Subject: [PATCH] Add missing import for Mmap (#515) * import Mmap * add Mmap to _Project.toml * add test for readmmap --- _Project.toml | 1 + src/HDF5.jl | 1 + test/mmap.jl | 23 +++++++++++++++++++++++ test/runtests.jl | 3 +++ 4 files changed, 28 insertions(+) create mode 100644 test/mmap.jl diff --git a/_Project.toml b/_Project.toml index 36b034cd0..1d30d66f0 100644 --- a/_Project.toml +++ b/_Project.toml @@ -8,6 +8,7 @@ BinDeps = "9e28174c-4ba2-5203-b857-d8d62c4213ee" Blosc = "a74b3585-a348-5f62-a45c-50e91977d574" Homebrew = "d9be37ee-ecc9-5288-90f1-b9ca67657a75" Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb" +Mmap = "a63ad114-7e13-5084-954f-fe012c677804" WinRPM = "c17dfb99-b4f7-5aad-8812-456da1ad7187" [extras] diff --git a/src/HDF5.jl b/src/HDF5.jl index 590f4a638..0e1f5a293 100644 --- a/src/HDF5.jl +++ b/src/HDF5.jl @@ -8,6 +8,7 @@ import Base: setindex!, show, size, sizeof, write, isopen, iterate import Libdl +import Mmap export # types diff --git a/test/mmap.jl b/test/mmap.jl new file mode 100644 index 000000000..f68e2372f --- /dev/null +++ b/test/mmap.jl @@ -0,0 +1,23 @@ +using HDF5 +using Test + +@testset "mmap" begin + +# Create a new file +fn = tempname() +f = h5open(fn, "w") +@test isopen(f) + +# Write HDF5 file +hdf5_A = d_create(f,"A",datatype(Int64),dataspace(3,3)); +A = rand(Int64,3,3) +hdf5_A[:,:] = A +flush(f); +close(f); +# Read HDF5 file & MMAP +f = h5open(fn,"r"); +A_mmaped = readmmap(f["A"]); + +@test all(A .== A_mmaped) + +end diff --git a/test/runtests.jl b/test/runtests.jl index b6521ec65..16239776b 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -10,6 +10,9 @@ include("extend_test.jl") include("gc.jl") include("external.jl") include("swmr.jl") +if !Sys.iswindows() # Mmap needs to be fixed on windows + include("mmap.jl") +end if get(Pkg.installed(), "MPI", nothing) !== nothing # basic MPI tests, for actual parallel tests we need to run in MPI mode include("mpio.jl")