hdf5/tools/h5stat/h5stat_gentest.c
Quincey Koziol 63eb5b9ebb [svn-r14104] Description:
Pursue calls to H5Gcreate() relentlessly and ruthlessly exterminate
them, leaving only a few tame specimens in text files and comments.  ;-)

Tested on:
	Mac OS X/32 10.4.10 (amazon)
	FreeBSD/32 6.2 (duty)
	FreeBSD/64 6.2 (liberty)
	Linux/32 2.6 (kagiso)
	Linux/64 2.6 (smirom)
	Solaris/32 5.10 (linew)
2007-08-23 15:25:25 -05:00

86 lines
2.9 KiB
C

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the files COPYING and Copyright.html. COPYING can be found at the root *
* of the source code distribution tree; Copyright.html can be found at the *
* root level of an installed copy of the electronic HDF5 document set and *
* is linked from the top-level documents page. It can also be found at *
* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Generate the binary hdf5 files for the h5stat tests.
* Usage: just execute the program without any arguments will
* generate all the binary hdf5 files in the ./testfiles directory.
*
* If you regenerate the test files (e.g., changing some code,
* trying it on a new platform, ...), you need to verify the correctness
* of the expected output and update the corresponding *.ddl files.
*/
#include "hdf5.h"
#define FILE "h5stat_newgrat.h5"
#define DATASET_NAME "DATASET_NAME"
#define GROUP_NAME "GROUP"
#define ATTR_NAME "ATTR"
#define NUM_GRPS 350
#define NUM_ATTRS 100
/*
* Generate 1.8 HDF5 file
* with NUM_GRPS groups
* with NUM_ATTRS attributes on the dataset
*/
static void gen_file(void)
{
int ret, i;
hid_t fapl, gid;
hid_t file, type_id, space_id, attr_id, dset_id;
char name[30];
char attrname[30];
fapl = H5Pcreate(H5P_FILE_ACCESS);
ret = H5Pset_latest_format(fapl, 1);
/* Create dataset */
file = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
for(i = 1; i <= NUM_GRPS; i++) {
sprintf(name, "%s%d", GROUP_NAME,i);
gid = H5Gcreate2(file, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
H5Gclose(gid);
}
/* Create a datatype to commit and use */
type_id = H5Tcopy(H5T_NATIVE_INT);
/* Create dataspace for dataset */
space_id = H5Screate(H5S_SCALAR);
/* Create dataset */
dset_id = H5Dcreate(file, DATASET_NAME, type_id, space_id, H5P_DEFAULT);
for(i = 1; i <= NUM_ATTRS; i++) {
sprintf(attrname, "%s%d", ATTR_NAME,i);
attr_id = H5Acreate(dset_id, attrname, type_id, space_id, H5P_DEFAULT);
ret = H5Aclose(attr_id);
}
ret = H5Dclose(dset_id);
ret = H5Sclose(space_id);
ret = H5Tclose(type_id);
ret = H5Fclose(file);
}
int main(void)
{
gen_file();
return 0;
}