diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2005-01-28 17:32:49 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2005-01-28 17:32:49 (GMT) |
commit | 4bf151295a71c87953c509eb0daeb4d1be8b9180 (patch) | |
tree | db792ce8d5d0d23a073bfbaa7cd2c84a8749a590 /test | |
parent | b2d9f7f726426e184e6894b21ff05a0c963e23ac (diff) | |
download | hdf5-4bf151295a71c87953c509eb0daeb4d1be8b9180.zip hdf5-4bf151295a71c87953c509eb0daeb4d1be8b9180.tar.gz hdf5-4bf151295a71c87953c509eb0daeb4d1be8b9180.tar.bz2 |
[svn-r9879] Purpose:
New tests
Description:
Add some tests for H5Fis_hdf5() routine.
Platforms tested:
FreeBSD 4.10 (sleipnir)
Too minor to require h5committest
Diffstat (limited to 'test')
-rw-r--r-- | test/tfile.c | 84 |
1 files changed, 83 insertions, 1 deletions
diff --git a/test/tfile.c b/test/tfile.c index ed691dc..b15cc8b 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -174,7 +174,7 @@ test_file_create(void) /* Create a new file with a non-standard file-creation template */ tmpl1 = H5Pcreate(H5P_FILE_CREATE); - CHECK(tmpl1, FAIL, "H5Pnew"); + CHECK(tmpl1, FAIL, "H5Pcreate"); /* Set the new file-creation parameters */ ret = H5Pset_userblock(tmpl1, F2_USERBLOCK_SIZE); @@ -1222,6 +1222,87 @@ test_file_freespace(void) /**************************************************************** ** +** test_file_ishdf5(): low-level file test routine. +** This test checks whether the H5Fis_hdf5() routine is working +** correctly in variuous situations. +** +*****************************************************************/ +static void +test_file_ishdf5(void) +{ + hid_t file; /* File opened with read-write permission */ + hid_t fcpl; /* File creation property list */ + int fd; /* File Descriptor */ + ssize_t nbytes; /* Number of bytes written */ + unsigned u; /* Local index variable */ + unsigned char buf[1024]; /* Buffer of data to write */ + htri_t status; /* Whether a file is an HDF5 file */ + herr_t ret; + + /* Output message about test being performed */ + MESSAGE(5, ("Testing Detection of HDF5 Files\n")); + + /* Create a file */ + file = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + CHECK(file, FAIL, "H5Fcreate"); + + /* Close file */ + ret = H5Fclose(file); + CHECK(ret, FAIL, "H5Fclose"); + + /* Verify that the file is an HDF5 file */ + status = H5Fis_hdf5(FILE1); + VERIFY(status, TRUE, "H5Fis_hdf5"); + + + /* Create a file creation property list with a non-default user block size */ + fcpl = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl, FAIL, "H5Pcreate"); + + ret = H5Pset_userblock(fcpl, (hsize_t)2048); + CHECK(ret, FAIL, "H5Pset_userblock"); + + /* Create file with non-default user block */ + file = H5Fcreate(FILE1, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT); + CHECK(file, FAIL, "H5Fcreate"); + + /* Release file-creation property list */ + ret = H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Pclose"); + + /* Close file */ + ret = H5Fclose(file); + CHECK(ret, FAIL, "H5Fclose"); + + /* Verify that the file is an HDF5 file */ + status = H5Fis_hdf5(FILE1); + VERIFY(status, TRUE, "H5Fis_hdf5"); + + + /* Create non-HDF5 file and check it */ + fd=HDopen(FILE1, O_RDWR|O_CREAT|O_TRUNC, 0666); + CHECK(ret, FAIL, "HDopen"); + + /* Initialize information to write */ + for(u=0; u<1024; u++) + buf[u]=(unsigned char)u; + + /* Write some information */ + nbytes = HDwrite(fd, buf, 1024); + VERIFY(nbytes, 1024, "HDwrite"); + + /* Close the file */ + ret = HDclose(fd); + CHECK(ret, FAIL, "HDclose"); + + /* Verify that the file is not an HDF5 file */ + status = H5Fis_hdf5(FILE1); + VERIFY(status, FALSE, "H5Fis_hdf5"); + +} /* end test_file_ishdf5() */ + +/**************************************************************** +** ** test_file(): Main low-level file I/O test routine. ** ****************************************************************/ @@ -1239,6 +1320,7 @@ test_file(void) test_get_file_id(); /* Test H5Iget_file_id */ test_file_perm(); /* Test file access permissions */ test_file_freespace(); /* Test file free space information */ + test_file_ishdf5(); /* Test detecting HDF5 files correctly */ } /* test_file() */ |