diff options
author | Robb Matzke <matzke@llnl.gov> | 1998-04-14 16:44:46 (GMT) |
---|---|---|
committer | Robb Matzke <matzke@llnl.gov> | 1998-04-14 16:44:46 (GMT) |
commit | b6fc6ede10fee24e9ef0a21df81cc181f6d7fec0 (patch) | |
tree | 66321165e4bd58a9fe3722a1a3baee2f835d0544 /test | |
parent | 3f571b6b4499e09aa6db29cb389e1121624a081d (diff) | |
download | hdf5-b6fc6ede10fee24e9ef0a21df81cc181f6d7fec0.zip hdf5-b6fc6ede10fee24e9ef0a21df81cc181f6d7fec0.tar.gz hdf5-b6fc6ede10fee24e9ef0a21df81cc181f6d7fec0.tar.bz2 |
[svn-r346] Changes since 19980410
----------------------
./html/H5.format.html
./src/H5E.c
./src/H5Epublic.h
./src/H5F.c
./src/H5G.c
./src/H5Gent.c
./src/H5Gnode.c
./src/H5Gprivate.h
./src/h5ls.c
./test/Makefile.in
Symbolic links are now supported. The ./test/links program
will create a `links.h5' file that demonstrates hard links,
soft links, dangling links, and recursive links. A symbolic
link is a symbol table entity and doesn't have an object
header. It's format is described in H5.format.hml.
./src/H5G.c
./src/H5Gpublic.h
./src/h5ls.c
Implemented H5Gstat() and H5Gget_linkval() as documented by
Quincey. The `H5G_type_t type' field of `H5G_stat_t' was
changed to `int type' because H5G_type_t was already used and
the `type' data type should be open-ended.
./src/H5Ffamily.c
Removed an incorrect diagnostic message.
./test/big.c
Added read/write calls to test partial I/O to big contiguous
datasets. With no arguments it writes to a dataset and prints
the list of points written which should be redirected to a
file. With an argument (the name of a file containing the
stdout of a run with no arguments) values are read from the
dataset. One would typically say `big >x && big x'.
Diffstat (limited to 'test')
-rw-r--r-- | test/.distdep | 38 | ||||
-rw-r--r-- | test/Makefile.in | 14 | ||||
-rw-r--r-- | test/big.c | 160 | ||||
-rw-r--r-- | test/links.c | 63 |
4 files changed, 252 insertions, 23 deletions
diff --git a/test/.distdep b/test/.distdep index 409acbb..cbe325d 100644 --- a/test/.distdep +++ b/test/.distdep @@ -3,7 +3,9 @@ testhdf5.o: \ testhdf5.h \ ../src/H5private.h \ ../src/H5public.h \ - ../src/H5config.h + ../src/H5config.h \ + ../src/H5Eprivate.h \ + ../src/H5Epublic.h tfile.o: \ tfile.c \ testhdf5.h \ @@ -147,14 +149,13 @@ dtypes.o: \ ../src/H5Iprivate.h \ ../src/H5private.h \ ../src/H5Tprivate.h \ - ../src/H5Gprivate.h + ../src/H5Gprivate.h \ + ../src/H5Bprivate.h hyperslab.o: \ hyperslab.c \ ../src/H5private.h \ ../src/H5public.h \ - ../src/H5config.h \ - ../src/H5MMprivate.h \ - ../src/H5MMpublic.h + ../src/H5config.h istore.o: \ istore.c \ ../src/H5private.h \ @@ -179,7 +180,8 @@ istore.o: \ ../src/H5HGpublic.h \ ../src/H5Tprivate.h \ ../src/H5Tpublic.h \ - ../src/H5Sprivate.h + ../src/H5Sprivate.h \ + ../src/H5Spublic.h dsets.o: \ dsets.c \ ../src/hdf5.h \ @@ -218,8 +220,7 @@ cmpd_dset.o: \ ../src/H5MMpublic.h \ ../src/H5Opublic.h \ ../src/H5Ppublic.h \ - ../src/H5Spublic.h \ - ../src/H5Tpublic.h + ../src/H5Spublic.h extend.o: \ extend.c \ ../src/hdf5.h \ @@ -332,4 +333,23 @@ big.o: \ ../src/H5MMpublic.h \ ../src/H5Opublic.h \ ../src/H5Ppublic.h \ - ../src/H5Spublic.h + ../src/H5Spublic.h \ + ../src/H5Tpublic.h +links.o: \ + links.c \ + ../src/hdf5.h \ + ../src/H5public.h \ + ../src/H5config.h \ + ../src/H5ACpublic.h \ + ../src/H5Bpublic.h \ + ../src/H5Dpublic.h \ + ../src/H5Ipublic.h \ + ../src/H5Epublic.h \ + ../src/H5Fpublic.h \ + ../src/H5Gpublic.h \ + ../src/H5HGpublic.h \ + ../src/H5HLpublic.h \ + ../src/H5MFpublic.h \ + ../src/H5MMpublic.h \ + ../src/H5Opublic.h \ + ../src/H5Ppublic.h diff --git a/test/Makefile.in b/test/Makefile.in index 6ee08ad..55da8cd 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -12,9 +12,9 @@ CPPFLAGS=-I. -I../src @CPPFLAGS@ # These are our main targets. They should be listed in the order to be # executed, generally most specific tests to least specific tests. PROGS=testhdf5 gheap hyperslab istore dtypes dsets cmpd_dset extend external \ - shtype iopipe big + shtype iopipe big links TESTS=testhdf5 gheap hyperslab istore dtypes dsets cmpd_dset extend external \ - shtype + shtype links TIMINGS=iopipe # Temporary files @@ -24,7 +24,7 @@ MOSTLYCLEAN=cmpd_dset.h5 dataset.h5 extend.h5 istore.h5 tfile1.h5 tfile2.h5 \ extern_2.raw extern_2b.raw extern_3.raw extern_3b.raw \ extern_4.raw extern_4b.raw iopipe.raw iopipe.h5 gheap0.h5 \ gheap1.h5 gheap2.h5 gheap3.h5 gheap4.h5 shtype0.h5 shtype1.h5 \ - shtype2a.h5 shtype2b.h5 shtype3.h5 + shtype2a.h5 shtype2b.h5 shtype3.h5 links.h5 # Source and object files for programs... The PROG_SRC list contains all the # source files and is used for things like dependencies, archiving, etc. The @@ -32,7 +32,7 @@ MOSTLYCLEAN=cmpd_dset.h5 dataset.h5 extend.h5 istore.h5 tfile1.h5 tfile2.h5 \ # overlap with other tests. PROG_SRC=testhdf5.c tfile.c theap.c tmeta.c tohdr.c tstab.c th5s.c dtypes.c \ hyperslab.c istore.c dsets.c cmpd_dset.c extend.c external.c \ - iopipe.c gheap.c shtype.c big.c + iopipe.c gheap.c shtype.c big.c links.c PROG_OBJ=$(PROG_SRC:.c=.o) TESTHDF5_SRC=testhdf5.c tfile.c theap.c tmeta.c tohdr.c tstab.c th5s.c @@ -74,6 +74,9 @@ IOPIPE_OBJ=$(IOPIPE_SRC:.c=.o) BIG_SRC=big.c BIG_OBJ=$(BIG_SRC:.c=.o) +LINKS_SRC=links.c +LINKS_OBJ=$(LINKS_SRC:.c=.o) + # Private header files (not to be installed)... PRIVATE_HDR=testhdf5.h @@ -127,4 +130,7 @@ grptime: $(GRPTIME_OBJ) ../src/libhdf5.a big: $(BIG_OBJ) ../src/libhdf5.a $(CC) $(CFLAGS) -o $@ $(BIG_OBJ) ../src/libhdf5.a $(LIBS) +links: $(LINKS_OBJ) ../src/libhdf5.a + $(CC) $(CFLAGS) -o $@ $(LINKS_OBJ) ../src/libhdf5.a $(LIBS) + @CONCLUDE@ @@ -6,7 +6,26 @@ * Wednesday, April 8, 1998 */ #include <assert.h> +#include <ctype.h> #include <hdf5.h> +#include <math.h> +#include <stdlib.h> + +#include <H5private.h> /*needed for HDfprintf() */ + +#define FNAME "big%05d.h5" +#define WRT_N 50 +#define WRT_SIZE 4*1024 + +static hsize_t +randll (hsize_t limit) +{ + hsize_t acc = rand (); + acc *= rand (); + + return acc % limit; +} + /*------------------------------------------------------------------------- @@ -25,12 +44,16 @@ * *------------------------------------------------------------------------- */ -int -main (void) +static void +writer (int wrt_n) { hsize_t size1[4] = {8, 1024, 1024, 1024}; hsize_t size2[1] = {8589934592LL}; - hid_t plist, file, space1, space2, dset; + hssize_t hs_start[1]; + hsize_t hs_size[1]; + hid_t plist, file, space1, space2, mem_space, d1, d2; + int *buf = malloc (sizeof(int) * WRT_SIZE); + int i, j; /* * Make sure that `hsize_t' is large enough to represent the entire data @@ -44,20 +67,137 @@ main (void) */ plist = H5Pcreate (H5P_FILE_ACCESS); H5Pset_family (plist, 30, H5P_DEFAULT); - file = H5Fcreate ("big%05d.h5", H5F_ACC_TRUNC, H5P_DEFAULT, plist); + file = H5Fcreate (FNAME, H5F_ACC_TRUNC, H5P_DEFAULT, plist); /* Create simple data spaces according to the size specified above. */ space1 = H5Screate_simple (4, size1, size1); space2 = H5Screate_simple (1, size2, size2); /* Create the datasets */ - dset = H5Dcreate (file, "d1", H5T_NATIVE_INT, space1, H5P_DEFAULT); - H5Dclose (dset); - dset = H5Dcreate (file, "d2", H5T_NATIVE_INT, space2, H5P_DEFAULT); - H5Dclose (dset); - + d1 = H5Dcreate (file, "d1", H5T_NATIVE_INT, space1, H5P_DEFAULT); + d2 = H5Dcreate (file, "d2", H5T_NATIVE_INT, space2, H5P_DEFAULT); + + /* Write some things to them randomly */ + hs_size[0] = WRT_SIZE; + mem_space = H5Screate_simple (1, hs_size, hs_size); + for (i=0; i<wrt_n; i++) { + hs_start[0] = randll (size2[0]); + HDfprintf (stdout, "#%03d 0x%016Hx\n", i, hs_start[0]); + H5Sset_hyperslab (space2, hs_start, hs_size, NULL); + for (j=0; j<WRT_SIZE; j++) { + buf[j] = i+1; + } + H5Dwrite (d2, H5T_NATIVE_INT, mem_space, space2, H5P_DEFAULT, buf); + } + + H5Dclose (d1); + H5Dclose (d2); + H5Sclose (mem_space); H5Sclose (space1); H5Sclose (space2); H5Fclose (file); - exit (0); + free (buf); +} + + +/*------------------------------------------------------------------------- + * Function: reader + * + * Purpose: Reads some data from random locations in the dataset. + * + * Return: void + * + * Programmer: Robb Matzke + * Friday, April 10, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void +reader (const char *script_name) +{ + FILE *script; + hid_t plist, file, mspace, fspace, d2; + char ln[64], *s; + hssize_t hs_offset[1]; + hsize_t hs_size[1] = {WRT_SIZE}; + int *buf = malloc (sizeof(int) * WRT_SIZE); + int i, j, zero, wrong; + + /* Open script file */ + script = fopen (script_name, "r"); + + /* Open HDF5 file */ + plist = H5Pcreate (H5P_FILE_ACCESS); + H5Pset_family (plist, 30, H5P_DEFAULT); + file = H5Fopen (FNAME, H5F_ACC_RDONLY, plist); + + /* Open the dataset */ + d2 = H5Dopen (file, "d2"); + fspace = H5Dget_space (d2); + + /* Describe `buf' */ + mspace = H5Screate_simple (1, hs_size, hs_size); + + /* Read each region */ + while (fgets (ln, sizeof(ln), script)) { + if ('#'!=ln[0]) break; + i = strtol (ln+1, &s, 10); + hs_offset[0] = HDstrtoll (s, NULL, 0); + HDfprintf (stdout, "#%03d 0x%016Hx", i, hs_offset[0]); + fflush (stdout); + + H5Sset_hyperslab (fspace, hs_offset, hs_size, NULL); + H5Dread (d2, H5T_NATIVE_INT, mspace, fspace, H5P_DEFAULT, buf); + + /* Check */ + for (j=zero=wrong=0; j<WRT_SIZE; j++) { + if (0==buf[j]) zero++; + else if (buf[j]!=i+1) wrong++; + } + if (zero) { + printf (" *FAILED* (%d zeros)\n", zero); + } else if (wrong) { + printf (" *SKIPPED* (possible overlap with another region)\n"); + } else { + printf (" PASSED\n"); + } + } + + H5Dclose (d2); + H5Sclose (mspace); + H5Sclose (fspace); + H5Fclose (file); + fclose (script); +} + + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: + * + * Return: Success: + * + * Failure: + * + * Programmer: Robb Matzke + * Friday, April 10, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +int +main (int argc, char *argv[]) +{ + if (1==argc) { + writer (WRT_N); + } else if (isdigit (argv[1][0])) { + writer (strtol (argv[1], NULL, 0)); + } else { + reader (argv[1]); + } + return 0; } diff --git a/test/links.c b/test/links.c new file mode 100644 index 0000000..ac4a3e1 --- /dev/null +++ b/test/links.c @@ -0,0 +1,63 @@ +/* + * Copyright (C) 1998 NCSA + * All rights reserved. + * + * Programmer: Robb Matzke <matzke@llnl.gov> + * Friday, April 10, 1998 + * + * Purpose: Tests hard and soft (symbolic) links. + */ +#include <hdf5.h> + + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: Tests links. + * + * Return: Success: 0 + * + * Failure: non-zero + * + * Programmer: Robb Matzke + * Friday, April 10, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +int +main (void) +{ + hid_t file, scalar, grp, d1; + hsize_t size[1] = {1}; + + /* Create a file */ + file = H5Fcreate ("links.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + scalar = H5Screate_simple (1, size, size); + + /* Create a group */ + grp = H5Gcreate (file, "grp1", 0); + H5Gclose (grp); + + /* Create a dataset */ + d1 = H5Dcreate (file, "d1", H5T_NATIVE_INT, scalar, H5P_DEFAULT); + H5Dclose (d1); + + /* Create a hard link */ + H5Glink (file, H5G_LINK_HARD, "d1", "grp1/hard"); + + /* Create a symbolic link */ + H5Glink (file, H5G_LINK_SOFT, "/d1", "grp1/soft"); + + /* Create a symbolic link to something that doesn't exist */ + H5Glink (file, H5G_LINK_SOFT, "foobar", "grp1/dangle"); + + /* Create a recursive symbolic link */ + H5Glink (file, H5G_LINK_SOFT, "/grp1/recursive", "/grp1/recursive"); + + /* Close */ + H5Sclose (scalar); + H5Fclose (file); + return 0; +} |