Skip to content

Commit

Permalink
Run each failing test 1000x to see if we can reproduce consistently
Browse files Browse the repository at this point in the history
  • Loading branch information
mkitti committed Jun 2, 2024
1 parent fb52906 commit 245c535
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 0 deletions.
113 changes: 113 additions & 0 deletions test/failing_tests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
using HDF5, Test

@testset "h5a_iterate failing" begin
for i in 1:1000
filename = tempname()
f = h5open(filename, "w")

write_attribute(f, "a", 1)
write_attribute(f, "b", 2)

# iterate over attributes
names = String[]
@test HDF5.API.h5a_iterate(
f, HDF5.API.H5_INDEX_NAME, HDF5.API.H5_ITER_INC
) do loc, name, info
push!(names, unsafe_string(name))
return false
end == 2
@test names == ["a", "b"]

# iterate over attributes in reverse
names = String[]
@test HDF5.API.h5a_iterate(
f, HDF5.API.H5_INDEX_NAME, HDF5.API.H5_ITER_DEC
) do loc, name, info
push!(names, unsafe_string(name))
return false
end == 2
@test names == ["b", "a"]

# only iterate once
names = String[]
@test HDF5.API.h5a_iterate(
f, HDF5.API.H5_INDEX_NAME, HDF5.API.H5_ITER_INC
) do loc, name, info
push!(names, unsafe_string(name))
return true
end == 1
@test names == ["a"]

@test_throws AssertionError HDF5.API.h5a_iterate(
f, HDF5.API.H5_INDEX_NAME, HDF5.API.H5_ITER_INC
) do loc, name, info
@assert false
end

# HDF5 error
@test_throws HDF5.API.H5Error HDF5.API.h5a_iterate(
f, HDF5.API.H5_INDEX_NAME, HDF5.API.H5_ITER_INC
) do loc, name, info
return -1
end

close(f)
end
end

@testset "h5l_iterate failing" begin
for i in 1:1000
filename = tempname()
f = h5open(filename, "w")

create_group(f, "a")
create_group(f, "b")

# iterate over groups
names = String[]
@test HDF5.API.h5l_iterate(
f, HDF5.API.H5_INDEX_NAME, HDF5.API.H5_ITER_INC
) do loc, name, info
push!(names, unsafe_string(name))
return false
end == 2
@test names == ["a", "b"]

# iterate over attributes in reverse
names = String[]
@test HDF5.API.h5l_iterate(
f, HDF5.API.H5_INDEX_NAME, HDF5.API.H5_ITER_DEC
) do loc, name, info
push!(names, unsafe_string(name))
return false
end == 2
@test names == ["b", "a"]

# only iterate once
names = String[]
@test HDF5.API.h5l_iterate(
f, HDF5.API.H5_INDEX_NAME, HDF5.API.H5_ITER_INC
) do loc, name, info
push!(names, unsafe_string(name))
return true
end == 1
@test names == ["a"]

# HDF5 error
@test_throws HDF5.API.H5Error HDF5.API.h5l_iterate(
f, HDF5.API.H5_INDEX_NAME, HDF5.API.H5_ITER_INC
) do loc, name, info
return -1
end

# Julia error
@test_throws AssertionError HDF5.API.h5l_iterate(
f, HDF5.API.H5_INDEX_NAME, HDF5.API.H5_ITER_INC
) do loc, name, info
@assert false
end

close(f)
end
end

2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ end
include("ros3.jl")
end

include("failing_tests.jl")

# Clean up after all resources
HDF5.API.h5_close()
end

0 comments on commit 245c535

Please sign in to comment.