From 88da0f9413afecf5b78552987085bc946b39c2a5 Mon Sep 17 00:00:00 2001 From: Sam Gillingham Date: Tue, 22 Oct 2024 08:20:37 +1000 Subject: [PATCH 1/6] add test for C++ exception error --- recipe/build.sh | 6 ++++++ recipe/testhdf5exc.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 recipe/testhdf5exc.cpp diff --git a/recipe/build.sh b/recipe/build.sh index ce00550d..716482d7 100755 --- a/recipe/build.sh +++ b/recipe/build.sh @@ -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 +$CXX testhdf5exc.cpp -o testhdf5exc -L$CONDA_PREFIX/lib -lhdf5_cpp -lhdf5 -I$CONDA_PREFIX/include +LD_LIBRARY_PATH=$CONDA_PREFIX/lib DYLD_LIBRARY_PATH=$CONDA_PREFIX/lib ./testhdf5exc + + diff --git a/recipe/testhdf5exc.cpp b/recipe/testhdf5exc.cpp new file mode 100644 index 00000000..21b01b15 --- /dev/null +++ b/recipe/testhdf5exc.cpp @@ -0,0 +1,28 @@ + +#include +#include + +int main() +{ + H5::Exception::dontPrint(); + + H5::H5File *keaImgH5File = new H5::H5File("/tmp/test.hd5", H5F_ACC_TRUNC, H5::FileCreatPropList::DEFAULT); + keaImgH5File->createGroup("/HEADER"); + + H5::DataSet ds; + try + { + // should fail + ds = keaImgH5File->openDataSet("/HEADER/NUMBANDS"); + std::cout << "Was able to open dataset\n"; + } + catch (const H5::Exception &e) + { + std::cout << "Failed to open dataset (expected)\n"; + } + + return 0; +} + + + From 1735827ec8f3fabae802c07030ffd21d588f025b Mon Sep 17 00:00:00 2001 From: Sam Gillingham Date: Tue, 22 Oct 2024 08:44:13 +1000 Subject: [PATCH 2/6] fix path --- recipe/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipe/build.sh b/recipe/build.sh index 716482d7..a554c6e3 100755 --- a/recipe/build.sh +++ b/recipe/build.sh @@ -160,7 +160,7 @@ if [[ ("$target_platform" != "linux-ppc64le") && \ fi # test for hdf5 C++ exceptions -$CXX testhdf5exc.cpp -o testhdf5exc -L$CONDA_PREFIX/lib -lhdf5_cpp -lhdf5 -I$CONDA_PREFIX/include +$CXX $RECIPE_DIR/testhdf5exc.cpp -o testhdf5exc -L$CONDA_PREFIX/lib -lhdf5_cpp -lhdf5 -I$CONDA_PREFIX/include LD_LIBRARY_PATH=$CONDA_PREFIX/lib DYLD_LIBRARY_PATH=$CONDA_PREFIX/lib ./testhdf5exc From b3b974df2b0a355663be745947af4f7688b190a3 Mon Sep 17 00:00:00 2001 From: Sam Gillingham Date: Tue, 22 Oct 2024 09:28:31 +1000 Subject: [PATCH 3/6] use PREFIX rather than CONDA_PREFIX. xylar's changes --- recipe/build.sh | 4 ++-- recipe/testhdf5exc.cpp | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/recipe/build.sh b/recipe/build.sh index a554c6e3..c2b4b8db 100755 --- a/recipe/build.sh +++ b/recipe/build.sh @@ -160,7 +160,7 @@ if [[ ("$target_platform" != "linux-ppc64le") && \ fi # test for hdf5 C++ exceptions -$CXX $RECIPE_DIR/testhdf5exc.cpp -o testhdf5exc -L$CONDA_PREFIX/lib -lhdf5_cpp -lhdf5 -I$CONDA_PREFIX/include -LD_LIBRARY_PATH=$CONDA_PREFIX/lib DYLD_LIBRARY_PATH=$CONDA_PREFIX/lib ./testhdf5exc +$CXX $RECIPE_DIR/testhdf5exc.cpp -o testhdf5exc -L$PREFIX/lib -lhdf5_cpp -lhdf5 -I$PREFIX/include +LD_LIBRARY_PATH=$PREFIX/lib DYLD_LIBRARY_PATH=$PREFIX/lib ./testhdf5exc diff --git a/recipe/testhdf5exc.cpp b/recipe/testhdf5exc.cpp index 21b01b15..eb58a522 100644 --- a/recipe/testhdf5exc.cpp +++ b/recipe/testhdf5exc.cpp @@ -6,19 +6,21 @@ int main() { H5::Exception::dontPrint(); - H5::H5File *keaImgH5File = new H5::H5File("/tmp/test.hd5", H5F_ACC_TRUNC, H5::FileCreatPropList::DEFAULT); - keaImgH5File->createGroup("/HEADER"); + 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 = keaImgH5File->openDataSet("/HEADER/NUMBANDS"); + 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; From b6ca9cdbff4b8aa803ee5600c1a7d0df68450d50 Mon Sep 17 00:00:00 2001 From: Sam Gillingham Date: Tue, 22 Oct 2024 10:35:09 +1000 Subject: [PATCH 4/6] @hmaarrfk's suggestion --- recipe/build.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/recipe/build.sh b/recipe/build.sh index c2b4b8db..f74aecfa 100755 --- a/recipe/build.sh +++ b/recipe/build.sh @@ -160,7 +160,7 @@ if [[ ("$target_platform" != "linux-ppc64le") && \ fi # test for hdf5 C++ exceptions -$CXX $RECIPE_DIR/testhdf5exc.cpp -o testhdf5exc -L$PREFIX/lib -lhdf5_cpp -lhdf5 -I$PREFIX/include -LD_LIBRARY_PATH=$PREFIX/lib DYLD_LIBRARY_PATH=$PREFIX/lib ./testhdf5exc - - +if [[ "${CONDA_BUILD_CROSS_COMPILATION:-}" != "1" || "${CROSSCOMPILING_EMULATOR}" != "" ]]; then + $CXX $RECIPE_DIR/testhdf5exc.cpp -o testhdf5exc -L$PREFIX/lib -lhdf5_cpp -lhdf5 -I$PREFIX/include + ./testhdf5exc +fi From 5bd4da6fa815a9ba28266f54d34752fa46c71d03 Mon Sep 17 00:00:00 2001 From: Xylar Asay-Davis Date: Tue, 22 Oct 2024 05:01:18 +0200 Subject: [PATCH 5/6] Add CXXFLAGS --- recipe/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipe/build.sh b/recipe/build.sh index f74aecfa..0385f0f0 100755 --- a/recipe/build.sh +++ b/recipe/build.sh @@ -161,6 +161,6 @@ fi # test for hdf5 C++ exceptions if [[ "${CONDA_BUILD_CROSS_COMPILATION:-}" != "1" || "${CROSSCOMPILING_EMULATOR}" != "" ]]; then - $CXX $RECIPE_DIR/testhdf5exc.cpp -o testhdf5exc -L$PREFIX/lib -lhdf5_cpp -lhdf5 -I$PREFIX/include + $CXX ${CXXFLAGS} $RECIPE_DIR/testhdf5exc.cpp -o testhdf5exc -L$PREFIX/lib -lhdf5_cpp -lhdf5 -I$PREFIX/include ./testhdf5exc fi From f04aeb2b33d01b12cdc3d8bd66c6e396ee2eaccb Mon Sep 17 00:00:00 2001 From: Xylar Asay-Davis Date: Tue, 22 Oct 2024 07:49:46 -0600 Subject: [PATCH 6/6] Fix test build Co-authored-by: Mark Harfouche --- recipe/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipe/build.sh b/recipe/build.sh index 0385f0f0..8b694b8e 100755 --- a/recipe/build.sh +++ b/recipe/build.sh @@ -161,6 +161,6 @@ fi # test for hdf5 C++ exceptions if [[ "${CONDA_BUILD_CROSS_COMPILATION:-}" != "1" || "${CROSSCOMPILING_EMULATOR}" != "" ]]; then - $CXX ${CXXFLAGS} $RECIPE_DIR/testhdf5exc.cpp -o testhdf5exc -L$PREFIX/lib -lhdf5_cpp -lhdf5 -I$PREFIX/include + ${CXX} ${CXXFLAGS} ${LDFLAGS} $RECIPE_DIR/testhdf5exc.cpp -o testhdf5exc -lhdf5_cpp -lhdf5 -I$PREFIX/include ./testhdf5exc fi