From 7075ab7712ea379b7a12c02a3ec5ddbdbad1d5c9 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Fri, 13 May 2011 11:01:37 +0000 Subject: [PATCH] 'h5_attach_test.c' added --- .gitattributes | 1 + test/Makefile.am | 13 ++++++++----- test/h5_attach_test.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 test/h5_attach_test.c diff --git a/.gitattributes b/.gitattributes index 92f7b51..56711ec 100644 --- a/.gitattributes +++ b/.gitattributes @@ -542,6 +542,7 @@ test/H5Part/H5testF.f -text test/H5Part/H5testFpar.f90 -text test/H5Part/Makefile.am -text test/Makefile.am -text +test/h5_attach_test.c -text test/h5b_read.c -text test/h5b_test.c -text test/h5b_write.c -text diff --git a/test/Makefile.am b/test/Makefile.am index 95a7b4b..015b839 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -15,7 +15,7 @@ noinst_PROGRAMS = @BUILD_TESTS@ TESTS_ENVIRONMENT = env LD_LIBRARY_PATH=@HDF5ROOT@/lib:$(LD_LIBRARY_PATH) TESTS = @BUILD_TESTS@ -EXTRA_PROGRAMS = h5u_test h5b_test +EXTRA_PROGRAMS = h5u_test h5b_test h5_attach_test h5u_test_SOURCES = \ h5u_test.c \ @@ -25,10 +25,6 @@ h5u_test_SOURCES = \ testframe.h \ params.h -h5u_test_DEPENDENCIES = \ - ../src/lib/libH5hut.a \ - ../src/lib/libH5hutC.a - h5b_test_SOURCES = \ h5b_test.c \ h5b_write.c \ @@ -41,6 +37,13 @@ h5b_test_DEPENDENCIES = \ ../src/lib/libH5hut.a \ ../src/lib/libH5hutC.a +h5_attach_test_SOURCES = \ + h5_attach_test.c + +h5_attach_test_DEPENDENCIES = \ + ../src/h5core/libH5hut.a \ + ../src/C/libH5hutC.a + clean: clean-am rm -f *.h5 diff --git a/test/h5_attach_test.c b/test/h5_attach_test.c new file mode 100644 index 0000000..ddd59ba --- /dev/null +++ b/test/h5_attach_test.c @@ -0,0 +1,34 @@ +#include +#include +#include +#include + +#define FNAME "h5_attach.h5" +#define ATTACHMENT "h5_attach_test" + + +int +main ( + int argc, + char* argv[] + ) { + H5SetErrorHandler (H5AbortErrorhandler); + H5SetVerbosityLevel (255); + h5_file_t* f = H5OpenFile (FNAME, H5_O_WRONLY, 0); + H5AddAttachment (f, ATTACHMENT); + H5CloseFile (f); + f = H5OpenFile (FNAME, H5_O_RDONLY, 0); + h5_ssize_t num_attachments = H5GetNumAttachments (f); + printf ("Number of attachments: %lld\n", num_attachments); + int i; + char fname[FILENAME_MAX]; + h5_size_t fsize; + for (i=0; i < num_attachments; i++) { + H5GetAttachmentInfoByIdx (f, i, fname, sizeof(fname), &fsize); + printf ("Attachment %d: Name: %s, Size: %llu\n", i, fname, fsize); + H5GetAttachment (f, fname); + H5DeleteAttachment (f, fname); + } + H5CloseFile (f); + return 0; +}