Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DEBUG] Add test for C++ exception error #234

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions recipe/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,9 @@ if [[ ("$target_platform" != "linux-ppc64le") && \
# https://forum.hdfgroup.org/t/hdf5-1-10-long-double-conversions-tests-failed-in-ppc64le/4077
make check RUNPARALLEL="mpiexec -n 2"
fi

# test for hdf5 C++ exceptions
if [[ "${CONDA_BUILD_CROSS_COMPILATION:-}" != "1" || "${CROSSCOMPILING_EMULATOR}" != "" ]]; then
${CXX} ${CXXFLAGS} ${LDFLAGS} $RECIPE_DIR/testhdf5exc.cpp -o testhdf5exc -lhdf5_cpp -lhdf5 -I$PREFIX/include
./testhdf5exc
fi
30 changes: 30 additions & 0 deletions recipe/testhdf5exc.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

#include <iostream>
#include <H5Cpp.h>

int main()
{
H5::Exception::dontPrint();

H5::H5File *H5File = new H5::H5File("/tmp/test.hd5", H5F_ACC_TRUNC, H5::FileCreatPropList::DEFAULT);
H5File->createGroup("/HEADER");

H5::DataSet ds;
try
{
// should fail
ds = H5File->openDataSet("/HEADER/NUMBANDS");
std::cout << "Was able to open dataset\n";
return -1;
}
catch (const H5::Exception &e)
{
std::cout << "Failed to open dataset (expected)\n";
return 0;
}

return 0;
}



Loading