summaryrefslogtreecommitdiffstats
path: root/tools/misc
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2007-02-14 13:54:11 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2007-02-14 13:54:11 (GMT)
commitbb392083b2a81aa942678e06a537a3c0ab5c08aa (patch)
tree9243c5965897315e4cbeef983f71b224498718c0 /tools/misc
parentdf075c5b9266b3b7a038fb1377d130ed315aa15c (diff)
downloadhdf5-bb392083b2a81aa942678e06a537a3c0ab5c08aa.zip
hdf5-bb392083b2a81aa942678e06a537a3c0ab5c08aa.tar.gz
hdf5-bb392083b2a81aa942678e06a537a3c0ab5c08aa.tar.bz2
[svn-r13297] Description:
Add small 'h5mkgrp' tool to create groups in an HDF5 file from the command line, allowing the group structure for a file to be created in a script. This tool closely follows the 'mkdir' command line tool in UNIX/Linux. Allow tool library applications to pass a FAPL to the h5tool_fopen() call, giving some additional flexibility to tools which are adding objects to an existing HDF5 file (like h5copy & h5mkgrp). Fix missing files in MANIFEST from previous checkin(s). Tested on: Linux/32 2.6 (chicago) Linux/64 2.6 (chicago2)
Diffstat (limited to 'tools/misc')
-rw-r--r--tools/misc/Makefile.am6
-rw-r--r--tools/misc/Makefile.in18
-rw-r--r--tools/misc/h5mkgrp.c330
-rw-r--r--tools/misc/h5stat.c2
-rw-r--r--tools/misc/testh5mkgrp.sh176
5 files changed, 523 insertions, 9 deletions
diff --git a/tools/misc/Makefile.am b/tools/misc/Makefile.am
index 5b746f9..423a28b 100644
--- a/tools/misc/Makefile.am
+++ b/tools/misc/Makefile.am
@@ -25,14 +25,14 @@ INCLUDES=-I$(top_srcdir)/src -I$(top_srcdir)/tools/lib
#test script and program
TEST_PROG=h5repart_gentest
-TEST_SCRIPT=testh5repart.sh testh5stat.sh
+TEST_SCRIPT=testh5repart.sh testh5stat.sh $(srcdir)/testh5mkgrp.sh
check_PROGRAMS=$(TEST_PROG) repart_test
check_SCRIPTS=$(TEST_SCRIPT)
-SCRIPT_DEPEND=h5repart$(EXEEXT) h5stat$(EXEEXT)
+SCRIPT_DEPEND=h5repart$(EXEEXT) h5stat$(EXEEXT) h5mkgrp$(EXEEXT)
# These are our main targets, the tools
-bin_PROGRAMS=h5debug h5repart h5stat
+bin_PROGRAMS=h5debug h5repart h5stat h5mkgrp
bin_SCRIPTS=h5redeploy
# Tell automake to clean h5redeploy script
diff --git a/tools/misc/Makefile.in b/tools/misc/Makefile.in
index 9331bc8..3aec239 100644
--- a/tools/misc/Makefile.in
+++ b/tools/misc/Makefile.in
@@ -59,7 +59,7 @@ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
$(srcdir)/testh5stat.sh.in $(top_srcdir)/config/commence.am \
$(top_srcdir)/config/conclude.am
check_PROGRAMS = $(am__EXEEXT_1) repart_test$(EXEEXT)
-bin_PROGRAMS = h5debug$(EXEEXT) h5repart$(EXEEXT) h5stat$(EXEEXT)
+bin_PROGRAMS = h5debug$(EXEEXT) h5repart$(EXEEXT) h5stat$(EXEEXT) h5mkgrp$(EXEEXT)
subdir = tools/misc
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
@@ -91,6 +91,10 @@ h5stat_SOURCES = h5stat.c
h5stat_OBJECTS = h5stat.$(OBJEXT)
h5stat_LDADD = $(LDADD)
h5stat_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2)
+h5mkgrp_SOURCES = h5mkgrp.c
+h5mkgrp_OBJECTS = h5mkgrp.$(OBJEXT)
+h5mkgrp_LDADD = $(LDADD)
+h5mkgrp_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2)
repart_test_SOURCES = repart_test.c
repart_test_OBJECTS = repart_test.$(OBJEXT)
repart_test_LDADD = $(LDADD)
@@ -108,9 +112,9 @@ LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \
CCLD = $(CC)
LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
-SOURCES = h5debug.c h5repart.c h5repart_gentest.c h5stat.c \
+SOURCES = h5debug.c h5repart.c h5repart_gentest.c h5stat.c h5mkgrp.c \
repart_test.c
-DIST_SOURCES = h5debug.c h5repart.c h5repart_gentest.c h5stat.c \
+DIST_SOURCES = h5debug.c h5repart.c h5repart_gentest.c h5stat.c h5mkgrp.c \
repart_test.c
ETAGS = etags
CTAGS = ctags
@@ -362,9 +366,9 @@ INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/tools/lib
#test script and program
TEST_PROG = h5repart_gentest
-TEST_SCRIPT = testh5repart.sh testh5stat.sh
+TEST_SCRIPT = testh5repart.sh testh5stat.sh $(srcdir)/testh5mkgrp.sh
check_SCRIPTS = $(TEST_SCRIPT)
-SCRIPT_DEPEND = h5repart$(EXEEXT) h5stat$(EXEEXT)
+SCRIPT_DEPEND = h5repart$(EXEEXT) h5stat$(EXEEXT) h5mkgrp$(EXEEXT)
bin_SCRIPTS = h5redeploy
# Tell automake to clean h5redeploy script
@@ -483,6 +487,9 @@ h5repart_gentest$(EXEEXT): $(h5repart_gentest_OBJECTS) $(h5repart_gentest_DEPEND
h5stat$(EXEEXT): $(h5stat_OBJECTS) $(h5stat_DEPENDENCIES)
@rm -f h5stat$(EXEEXT)
$(LINK) $(h5stat_LDFLAGS) $(h5stat_OBJECTS) $(h5stat_LDADD) $(LIBS)
+h5mkgrp$(EXEEXT): $(h5mkgrp_OBJECTS) $(h5mkgrp_DEPENDENCIES)
+ @rm -f h5mkgrp$(EXEEXT)
+ $(LINK) $(h5mkgrp_LDFLAGS) $(h5mkgrp_OBJECTS) $(h5mkgrp_LDADD) $(LIBS)
repart_test$(EXEEXT): $(repart_test_OBJECTS) $(repart_test_DEPENDENCIES)
@rm -f repart_test$(EXEEXT)
$(LINK) $(repart_test_LDFLAGS) $(repart_test_OBJECTS) $(repart_test_LDADD) $(LIBS)
@@ -516,6 +523,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5repart.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5repart_gentest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5stat.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5mkgrp.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/repart_test.Po@am__quote@
.c.o:
diff --git a/tools/misc/h5mkgrp.c b/tools/misc/h5mkgrp.c
new file mode 100644
index 0000000..048523a
--- /dev/null
+++ b/tools/misc/h5mkgrp.c
@@ -0,0 +1,330 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+
+#include "H5private.h"
+#include "h5tools.h"
+#include "h5tools_utils.h"
+#include <string.h>
+#include <stdlib.h>
+
+/* Name of tool */
+const char *progname = "h5mkgrp";
+
+/* Exit status for tools library routines */
+int d_status = EXIT_SUCCESS;
+
+/* command-line options: short and long-named parameters */
+static const char *s_opts = "hlpvV";
+static struct long_options l_opts[] = {
+ { "help", no_arg, 'h' },
+ { "latest", no_arg, 'l' },
+ { "parents", no_arg, 'p' },
+ { "verbose", no_arg, 'v' },
+ { "version", no_arg, 'V' },
+ { NULL, 0, '\0' }
+};
+
+/* Command line parameter settings */
+typedef struct {
+ char *fname; /* File name to operate on */
+ hbool_t latest; /* Whether file should use latest format versions */
+ hbool_t verbose; /* Whether output should be verbose */
+ hbool_t parents; /* Whether to create intermediate groups */
+ size_t ngroups; /* Number of groups to create */
+ char **groups; /* Pointer to array of group names */
+} param_t;
+
+
+/*-------------------------------------------------------------------------
+ * Function: leave
+ *
+ * Purpose: Shutdown MPI and/or HDF5 and call exit()
+ *
+ * Return: Does not return
+ *
+ * Programmer: Quincey Koziol, 2/13/2007
+ *
+ *-------------------------------------------------------------------------
+ */
+static void
+leave(int ret)
+{
+ h5tools_close();
+ exit(ret);
+} /* end leave() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: usage
+ *
+ * Purpose: Prints a usage message on stderr and then returns.
+ *
+ * Return: void
+ *
+ * Programmer: Quincey Koziol, 2/13/2007
+ *
+ *-------------------------------------------------------------------------
+ */
+static void
+usage(void)
+{
+ fprintf(stdout, "\
+usage: h5mkgrp [OPTIONS] FILE GROUP...\n\
+ OPTIONS\n\
+ -h, --help Print a usage message and exit\n\
+ -l, --latest Use latest version of file format to create groups\n\
+ -p, --parents No error if existing, make parent groups as needed\n\
+ -v, --verbose Print information about OBJECTS and OPTIONS\n\
+ -V, --version Print version number and exit\n");
+} /* end usage() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: parse_command_line
+ *
+ * Purpose: Parses command line and sets up global variable to control output
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Quincey Koziol, 2/13/2007
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+parse_command_line(int argc, const char *argv[], param_t *params)
+{
+ int opt; /* Option from command line */
+ size_t curr_group; /* Current group name to copy */
+
+ /* Check for empty command line */
+ if(argc == 1) {
+ usage();
+ leave(EXIT_SUCCESS);
+ } /* end if */
+
+ /* Parse command line options */
+ while((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) {
+ switch((char)opt) {
+ /* Display 'help' */
+ case 'h':
+ usage();
+ leave(EXIT_SUCCESS);
+
+ /* Create objects with the latest version of the format */
+ case 'l':
+ params->latest = TRUE;
+ break;
+
+ /* Create parent groups */
+ case 'p':
+ params->parents = TRUE;
+ break;
+
+ /* Verbose output */
+ case 'v':
+ params->verbose = TRUE;
+ break;
+
+ /* Display version */
+ case 'V':
+ print_version(progname);
+ leave(EXIT_SUCCESS);
+
+ /* Bad command line argument */
+ default:
+ usage();
+ leave(EXIT_FAILURE);
+ } /* end switch */
+ } /* end while */
+
+ /* Check for file name to be processed */
+ if(argc <= opt_ind) {
+ error_msg(progname, "missing file name\n");
+ usage();
+ leave(EXIT_FAILURE);
+ } /* end if */
+
+ /* Retrieve file name */
+ params->fname = HDstrdup(argv[opt_ind]);
+ opt_ind++;
+
+ /* Check for group(s) to be created */
+ if(argc <= opt_ind) {
+ error_msg(progname, "missing group name(s)\n");
+ usage();
+ leave(EXIT_FAILURE);
+ } /* end if */
+
+ /* Allocate space for the group name pointers */
+ params->ngroups = (argc - opt_ind);
+ params->groups = HDmalloc(params->ngroups * sizeof(char *));
+
+ /* Retrieve the group names */
+ curr_group = 0;
+ while(opt_ind < argc) {
+ params->groups[curr_group] = HDstrdup(argv[opt_ind]);
+ curr_group++;
+ opt_ind++;
+ } /* end while */
+
+#ifdef QAK
+HDfprintf(stderr, "params->parents = %t\n", params->parents);
+HDfprintf(stderr, "params->verbose = %t\n", params->verbose);
+HDfprintf(stderr, "params->fname = '%s'\n", params->fname);
+HDfprintf(stderr, "params->ngroups = %Zu\n", params->ngroups);
+for(curr_group = 0; curr_group < params->ngroups; curr_group++)
+ HDfprintf(stderr, "params->group[%Zu] = '%s'\n", curr_group, params->groups[curr_group]);
+#endif /* QAK */
+
+ return(0);
+} /* parse_command_line() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: main
+ *
+ * Purpose: Create group(s) in an HDF5 file
+ *
+ * Programmer: Quincey Koziol, 2/13/2007
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+main(int argc, const char *argv[])
+{
+ param_t params; /* Command line parameter settings */
+ hid_t fid; /* HDF5 file ID */
+ hid_t fapl_id; /* File access property list ID */
+ hid_t lcpl_id; /* Link creation property list ID */
+ size_t curr_group; /* Current group to create */
+
+ /* Disable the HDF5 library's error reporting */
+ H5Eset_auto_stack(H5E_DEFAULT, NULL, NULL);
+
+ /* Initialize h5tools lib */
+ h5tools_init();
+
+ /* Parse command line */
+ HDmemset(&params, 0, sizeof(params));
+ if(parse_command_line(argc, argv, &params) < 0) {
+ error_msg(progname, "unable to parse command line arguments\n");
+ leave(EXIT_FAILURE);
+ } /* end if */
+
+ /* Create file access property list */
+ if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
+ error_msg(progname, "Could not create file access property list\n");
+ leave(EXIT_FAILURE);
+ } /* end if */
+
+ /* Check for creating groups with new format version */
+ if(params.latest) {
+ /* Set the "use the latest version of the format flag */
+ if(H5Pset_latest_format(fapl_id, TRUE) < 0) {
+ error_msg(progname, "Could not set property for using latest version of the format\n");
+ leave(EXIT_FAILURE);
+ } /* end if */
+
+ /* Display some output if requested */
+ if(params.verbose)
+ printf("%s: Creating groups with latest version of the format\n", progname);
+ } /* end if */
+
+ /* Attempt to open an existing HDF5 file first */
+ fid = h5tools_fopen(params.fname, H5F_ACC_RDWR, fapl_id, NULL, NULL, 0);
+
+ /* If we couldn't open an existing file, try creating file */
+ /* (use "EXCL" instead of "TRUNC", so we don't blow away existing non-HDF5 file) */
+ if(fid < 0)
+ fid = H5Fcreate(params.fname, H5F_ACC_EXCL, H5P_DEFAULT, fapl_id);
+
+ /* Test for error in opening file */
+ if(fid < 0) {
+ error_msg(progname, "Could not open output file '%s'\n", params.fname);
+ leave(EXIT_FAILURE);
+ } /* end if */
+
+ /* Create link creation property list */
+ if((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) {
+ error_msg(progname, "Could not create link creation property list\n");
+ leave(EXIT_FAILURE);
+ } /* end if */
+
+ /* Check for creating intermediate groups */
+ if(params.parents) {
+ /* Set the intermediate group creation property */
+ if(H5Pset_create_intermediate_group(lcpl_id, TRUE) < 0) {
+ error_msg(progname, "Could not set property for creating parent groups\n");
+ leave(EXIT_FAILURE);
+ } /* end if */
+
+ /* Display some output if requested */
+ if(params.verbose)
+ printf("%s: Creating parent groups\n", progname);
+ } /* end if */
+
+ /* Loop over creating requested groups */
+ for(curr_group = 0; curr_group < params.ngroups; curr_group++) {
+ hid_t gid; /* Group ID */
+
+ /* Attempt to create a group */
+ if((gid = H5Gcreate_expand(fid, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
+ error_msg(progname, "Could not create group\n");
+ leave(EXIT_FAILURE);
+ } /* end if */
+
+ /* Link new group into group hierarchy */
+ if(H5Llink(fid, params.groups[curr_group], gid, lcpl_id, H5P_DEFAULT) < 0) {
+ error_msg(progname, "Could not create link to group '%s'\n", params.groups[curr_group]);
+ leave(EXIT_FAILURE);
+ } /* end if */
+
+ /* Close the group */
+ if(H5Gclose(gid) < 0) {
+ error_msg(progname, "Could not close group '%s'??\n", params.groups[curr_group]);
+ leave(EXIT_FAILURE);
+ } /* end if */
+
+ /* Display some output if requested */
+ if(params.verbose)
+ printf("%s: created group '%s'\n", progname, params.groups[curr_group]);
+ } /* end for */
+
+ /* Close link creation property list */
+ if(H5Pclose(lcpl_id) < 0) {
+ error_msg(progname, "Could not close link creation property list\n");
+ leave(EXIT_FAILURE);
+ } /* end if */
+
+ /* Close file */
+ if(H5Fclose(fid) < 0) {
+ error_msg(progname, "Could not close output file '%s'??\n", params.fname);
+ leave(EXIT_FAILURE);
+ } /* end if */
+
+ /* Close file access property list */
+ if(H5Pclose(fapl_id) < 0) {
+ error_msg(progname, "Could not close file access property list\n");
+ leave(EXIT_FAILURE);
+ } /* end if */
+
+ /* Shut down h5tools lib */
+ h5tools_close();
+
+ return 0;
+} /* end main() */
+
diff --git a/tools/misc/h5stat.c b/tools/misc/h5stat.c
index 5795b4a..8db92c1 100644
--- a/tools/misc/h5stat.c
+++ b/tools/misc/h5stat.c
@@ -183,7 +183,7 @@ leave(int ret)
}
-static void usage(const char *prog)
+static void usage(const char *prog)
{
fflush(stdout);
fprintf(stdout, "\n");
diff --git a/tools/misc/testh5mkgrp.sh b/tools/misc/testh5mkgrp.sh
new file mode 100644
index 0000000..e4912bb
--- /dev/null
+++ b/tools/misc/testh5mkgrp.sh
@@ -0,0 +1,176 @@
+#! /bin/sh
+#
+# 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.
+#
+# Tests for the h5mkgrp tool
+#
+# Quincey Koziol (koziol@hdfgroup.org)
+# Tuesday, February 13, 2007
+#
+
+H5MKGRP=h5mkgrp # The tool name
+H5MKGRP_BIN=`pwd`/$H5MKGRP # The path of the tool binary
+H5LS=h5ls # The h5ls tool name
+H5LS_ARGS=-vr # Arguments to the h5ls tool
+H5LS_BIN=`pwd`/../h5ls/$H5LS # The path of the h5ls tool binary
+
+nerrors=0
+verbose=yes
+
+CMP='cmp -s'
+DIFF='diff -c'
+
+# The build (current) directory might be different than the source directory.
+if test -z "$srcdir"; then
+ srcdir=.
+fi
+test -d ../testfiles || mkdir ../testfiles
+
+# Print a line-line message left justified in a field of 70 characters
+# beginning with the word "Testing".
+TESTING()
+{
+ SPACES=" "
+ echo "Testing $* $SPACES" |cut -c1-70 |tr -d '\012'
+}
+
+# Print a line-line message left justified in a field of 70 characters
+# beginning with the word "Verifying".
+#
+VERIFY_H5LS()
+{
+ SPACES=" "
+ echo "Verifying h5ls file structure $* $SPACES" | cut -c1-70 | tr -d '\012'
+}
+
+# Run a test and print PASS or *FAIL*. If h5mkgrp can complete
+# with exit status 0, consider it pass. If a test fails then increment
+# the `nerrors' global variable.
+# Assumed arguments:
+# $* arguments for h5mkgrp.
+
+TOOLTEST()
+{
+ TESTING $H5MKGRP $@
+ (
+ echo "#############################"
+ echo " output for '$H5MKGRP $@'"
+ echo "#############################"
+ $RUNSERIAL $H5MKGRP_BIN $@
+ ) > output.out
+ RET=$?
+ if [ $RET != 0 ]; then
+ echo "*FAILED*"
+ echo "failed result is:"
+ cat output.out
+ nerrors="`expr $nerrors + 1`"
+ else
+ echo " PASSED"
+ fi
+}
+
+# Call the h5ls tool to verify the correct output data in the destination file
+#
+H5LSTEST()
+{
+ expect="$srcdir/../testfiles/`basename $1 .h5`.ls"
+ actual="../testfiles/`basename $1 .h5`.out"
+
+ # Stderr is included in stdout so that the diff can detect
+ # any unexpected output from that stream too.
+ VERIFY_H5LS $@
+ (
+ echo "#############################"
+ echo "Expected output for '$H5LS $@'"
+ echo "#############################"
+ $RUNSERIAL $H5LS_BIN $H5LS_ARGS $@
+ ) 2>&1 |sed 's/Modified:.*/Modified: XXXX-XX-XX XX:XX:XX XXX/' >$actual
+
+
+ if [ ! -f $expect ]; then
+ # Create the expect file if it doesn't yet exist.
+ echo " CREATED"
+ cp $actual $expect
+ elif $CMP $expect $actual; then
+ echo " PASSED"
+ else
+ echo "*FAILED*"
+ echo " Expected result (*.ls) differs from actual result (*.out)"
+ nerrors="`expr $nerrors + 1`"
+ test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /'
+ fi
+}
+
+# Single run of tool
+#
+# Assumed arguments:
+# $1 is test file name
+# $2 is h5mkgrp options
+# $* are groups to create
+RUNTEST()
+{
+ FILEOUT=../testfiles/$1
+ shift
+ H5MKGRP_ARGS=$1
+ shift
+
+ # Remove any output file left over from previous test run
+ rm -f $FILEOUT
+
+ # Run test
+ TOOLTEST $H5MKGRP_ARGS $FILEOUT $@
+
+ # Verify that the file created above is correct
+ H5LSTEST $FILEOUT
+
+ # Remove output file created, if the "no cleanup" environment variable is
+ # not defined
+ if [ x$HDF5_NOCLEANUP = "x" ]; then
+ rm -f $FILEOUT
+ fi
+}
+
+##############################################################################
+### T H E T E S T S ###
+##############################################################################
+
+# Check that help & version is displayed properly
+RUNTEST h5mkgrp_help.h5 "-h"
+RUNTEST h5mkgrp_version.h5 "-V"
+
+# Create single group at root level
+RUNTEST h5mkgrp_single.h5 " " single
+RUNTEST h5mkgrp_single.h5 "-v" single
+RUNTEST h5mkgrp_single.h5 "-p" single
+RUNTEST h5mkgrp_single_latest.h5 "-l" latest
+
+# Create several groups at root level
+RUNTEST h5mkgrp_several.h5 " " one two
+RUNTEST h5mkgrp_several.h5 "-v" one two
+RUNTEST h5mkgrp_several.h5 "-p" one two
+RUNTEST h5mkgrp_several_latest.h5 "-l" one two
+
+# Create various nested groups
+RUNTEST h5mkgrp_nested.h5 "-p" /one/two
+RUNTEST h5mkgrp_nested_latest.h5 "-lp" /one/two
+RUNTEST h5mkgrp_nested_mult.h5 "-p" /one/two /three/four
+RUNTEST h5mkgrp_nested_mult_latest.h5 "-lp" /one/two /three/four
+
+
+if test $nerrors -eq 0 ; then
+ echo "All h5mkgrp tests passed."
+fi
+
+exit $nerrors
+