HDF5.Pinvoke nunit tests error C#


#1

Hi
We are building a C# .NET library based on hdf.pinvoke We written nunit tests for it. They are passing successfully each time when run from VS but fail at random times when run in cmd using nunit3-console.exe.

It’s the same test A that fails all the times and the error points to the H5G.create method. If I remove test A then a test B will fail, also using H5G.create . Test B was always successful if test A was run. And so on, if test B is also removed, another one will start to fail even though it was successful previously.

It looks like the cotainer ID is negative (invalid) though the file was created successfully and I can see it on the disk.
The error that I could from the hdf5.pinvoke library is:
custom_print_cb1: 0, D:\build\HDF5\1.8.18\CMake-hdf5-1.8.18\hdf5-1.8.18\src\H5Gloc.c, 173, invalid file ID, H5G_loc
custom_print_cb1: 1, D:\build\HDF5\1.8.18\CMake-hdf5-1.8.18\hdf5-1.8.18\src\H5G.c, 287, not a location, H5Gcreate2

I also took the lines from the test and run it as a normal Console exe and it never gives errors.

Any idea what can cause this instable behavior? Or how to find out more info about what fails?


#2

Is the name a random string? Are you passing a string or a byte[] for the name parameter? If string is it CharSet.Ansi? If byte[] and non-ASCII, are you specifying UTF-8 as the string encoding in the link creation property list?

G.


#3

In this case the name is the name of the method (human readable, usual chars). There’s a test for unusual characters and that passes.

internal static Hdf5Id CreateGroup([NotNull] Hdf5Id containerId, [NotNull] string name)

{
var nameBytes = name.ToUtf8Bytes();
var gid = H5G.create(containerId, nameBytes);