From 245c5358ea959fbe59b5629d711e5a88f7e9e517 Mon Sep 17 00:00:00 2001 From: Mark Kittisopikul Date: Sun, 2 Jun 2024 18:18:47 -0400 Subject: [PATCH 1/2] Run each failing test 1000x to see if we can reproduce consistently --- test/failing_tests.jl | 113 ++++++++++++++++++++++++++++++++++++++++++ test/runtests.jl | 2 + 2 files changed, 115 insertions(+) create mode 100644 test/failing_tests.jl diff --git a/test/failing_tests.jl b/test/failing_tests.jl new file mode 100644 index 000000000..7c5e077f5 --- /dev/null +++ b/test/failing_tests.jl @@ -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 + diff --git a/test/runtests.jl b/test/runtests.jl index de9021459..f0635dfbe 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -96,6 +96,8 @@ end include("ros3.jl") end + include("failing_tests.jl") + # Clean up after all resources HDF5.API.h5_close() end From 6bbec5b716eaa267b92ebeeecfa7c8a47dc5ca2a Mon Sep 17 00:00:00 2001 From: Mark Kittisopikul Date: Sun, 2 Jun 2024 18:35:33 -0400 Subject: [PATCH 2/2] Fix formatting --- test/failing_tests.jl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/failing_tests.jl b/test/failing_tests.jl index 7c5e077f5..5780e19fc 100644 --- a/test/failing_tests.jl +++ b/test/failing_tests.jl @@ -62,7 +62,7 @@ end create_group(f, "a") create_group(f, "b") - + # iterate over groups names = String[] @test HDF5.API.h5l_iterate( @@ -110,4 +110,3 @@ end close(f) end end -