mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-01-18 15:15:56 +08:00
[svn-r445] Added individually named cleanup_xxx routine to each test module file
to cleanup temporary files used by that particular module. Added a cleanup() routine to testhdf5 that calls all the other cleanup_xxx() routines to do cleanup. Cleanup action can be disabled either by -c (no cleanup) option or HDF5_NOCLEANUP environment variable.
This commit is contained in:
parent
b8237b2977
commit
b81abe336d
21
test/tattr.c
21
test/tattr.c
@ -1231,3 +1231,24 @@ test_attr(void)
|
||||
test_attr_delete(); /* Test H5A code for deleting attributes */
|
||||
} /* test_attr() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: cleanup_attr
|
||||
*
|
||||
* Purpose: Cleanup temporary test files
|
||||
*
|
||||
* Return: none
|
||||
*
|
||||
* Programmer: Albert Cheng
|
||||
* July 2, 1998
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
cleanup_attr(void)
|
||||
{
|
||||
remove(FILE);
|
||||
}
|
||||
|
||||
|
@ -132,6 +132,37 @@ print_func(const char *format,...)
|
||||
return (ret_value);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: cleanup
|
||||
*
|
||||
* Purpose: Cleanup temporary test files
|
||||
*
|
||||
* Return: none
|
||||
*
|
||||
* Programmer: Albert Cheng
|
||||
* July 2, 1998
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static void
|
||||
cleanup(void)
|
||||
{
|
||||
if (!getenv ("HDF5_NOCLEANUP")) {
|
||||
MESSAGE(2, ("\nCleaning Up temp files...\n\n"));
|
||||
/* call individual cleanup routines in each source module */
|
||||
cleanup_metadata();
|
||||
cleanup_file();
|
||||
cleanup_heap();
|
||||
cleanup_ohdr();
|
||||
cleanup_stab();
|
||||
cleanup_h5s();
|
||||
cleanup_attr();
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
@ -282,15 +313,8 @@ main(int argc, char *argv[])
|
||||
} /* end for */
|
||||
print_func("\n\n");
|
||||
} /* end if */
|
||||
if (CleanUp) {
|
||||
MESSAGE(2, ("\nCleaning Up...\n\n"));
|
||||
#if !(defined DOS386 | defined WIN386)
|
||||
system("rm -f *.h5 *.tmp");
|
||||
#else /* OLD_WAY */
|
||||
remove("*.h5");
|
||||
remove("*.tmp");
|
||||
#endif /* OLD_WAY */
|
||||
} /* end if */
|
||||
if (CleanUp)
|
||||
cleanup();
|
||||
exit(0);
|
||||
return (0);
|
||||
} /* end main() */
|
||||
|
@ -139,4 +139,13 @@ void test_h5s(void);
|
||||
void test_h5d(void);
|
||||
void test_attr(void);
|
||||
|
||||
#endif /* HDF5TEST_H */
|
||||
/* Prototypes for the cleanup routines */
|
||||
void cleanup_metadata(void);
|
||||
void cleanup_file(void);
|
||||
void cleanup_heap(void);
|
||||
void cleanup_ohdr(void);
|
||||
void cleanup_stab(void);
|
||||
void cleanup_h5s(void);
|
||||
void cleanup_attr(void);
|
||||
|
||||
#endif /* HDF5cleanup_H */
|
||||
|
24
test/tfile.c
24
test/tfile.c
@ -301,3 +301,27 @@ test_file(void)
|
||||
test_file_create(); /* Test file creation (also creation templates) */
|
||||
test_file_open(); /* Test file opening */
|
||||
} /* test_file() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: cleanup_file
|
||||
*
|
||||
* Purpose: Cleanup temporary test files
|
||||
*
|
||||
* Return: none
|
||||
*
|
||||
* Programmer: Albert Cheng
|
||||
* July 2, 1998
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
cleanup_file(void)
|
||||
{
|
||||
remove(FILE1);
|
||||
remove(FILE2);
|
||||
remove(FILE3);
|
||||
}
|
||||
|
||||
|
22
test/th5s.c
22
test/th5s.c
@ -424,3 +424,25 @@ test_h5s(void)
|
||||
test_h5s_compound_scalar_write(); /* Test compound datatype scalar H5S writing code */
|
||||
test_h5s_compound_scalar_read(); /* Test compound datatype scalar H5S reading code */
|
||||
} /* test_h5s() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: cleanup_h5s
|
||||
*
|
||||
* Purpose: Cleanup temporary test files
|
||||
*
|
||||
* Return: none
|
||||
*
|
||||
* Programmer: Albert Cheng
|
||||
* July 2, 1998
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
cleanup_h5s(void)
|
||||
{
|
||||
remove(FILE);
|
||||
}
|
||||
|
||||
|
25
test/theap.c
25
test/theap.c
@ -23,6 +23,7 @@
|
||||
#include <H5Fprivate.h>
|
||||
#include <H5HLprivate.h>
|
||||
|
||||
#define FILE "theap.h5"
|
||||
#define NOBJS 40
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
@ -55,7 +56,7 @@ test_heap(void)
|
||||
MESSAGE(5, ("Testing Heaps\n"));
|
||||
|
||||
/* Create the file */
|
||||
fid = H5Fcreate("theap.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
|
||||
fid = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
|
||||
CHECK(fid, FAIL, "H5Fcreate");
|
||||
f = H5I_object(fid);
|
||||
CHECK(f, NULL, "H5I_object");
|
||||
@ -88,3 +89,25 @@ test_heap(void)
|
||||
/* Close the file */
|
||||
H5Fclose(fid);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: cleanup_heap
|
||||
*
|
||||
* Purpose: Cleanup temporary test files
|
||||
*
|
||||
* Return: none
|
||||
*
|
||||
* Programmer: Albert Cheng
|
||||
* July 2, 1998
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
cleanup_heap(void)
|
||||
{
|
||||
remove(FILE);
|
||||
}
|
||||
|
||||
|
22
test/tmeta.c
22
test/tmeta.c
@ -122,3 +122,25 @@ test_metadata(void)
|
||||
num_errs++;
|
||||
} /* end if */
|
||||
} /* test_metadata() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: cleanup_metadata
|
||||
*
|
||||
* Purpose: Cleanup temporary test files
|
||||
*
|
||||
* Return: none
|
||||
*
|
||||
* Programmer: Albert Cheng
|
||||
* July 2, 1998
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
cleanup_metadata(void)
|
||||
{
|
||||
/* no file to clean */
|
||||
}
|
||||
|
||||
|
27
test/tohdr.c
27
test/tohdr.c
@ -14,6 +14,7 @@
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include <testhdf5.h>
|
||||
|
||||
#include <H5private.h>
|
||||
@ -24,6 +25,8 @@
|
||||
#include <H5Gprivate.h>
|
||||
#include <H5Oprivate.h>
|
||||
|
||||
#define TEST_FILE "tohdr.h5"
|
||||
|
||||
/*
|
||||
* This file needs to access private datatypes from the H5G package.
|
||||
*/
|
||||
@ -59,7 +62,7 @@ test_ohdr(void)
|
||||
MESSAGE(5, ("Testing Object Headers\n"));
|
||||
|
||||
/* create the file */
|
||||
fid = H5Fcreate("tohdr.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
|
||||
fid = H5Fcreate(TEST_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
|
||||
CHECK(fid, FAIL, "H5Fcreate");
|
||||
f = H5I_object(fid);
|
||||
CHECK(f, NULL, "H5I_object");
|
||||
@ -170,3 +173,25 @@ test_ohdr(void)
|
||||
H5O_close(&oh_ent);
|
||||
H5Fclose(fid);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: cleanup_ohdr
|
||||
*
|
||||
* Purpose: Cleanup temporary test files
|
||||
*
|
||||
* Return: none
|
||||
*
|
||||
* Programmer: Albert Cheng
|
||||
* July 2, 1998
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
cleanup_ohdr(void)
|
||||
{
|
||||
remove(TEST_FILE);
|
||||
}
|
||||
|
||||
|
26
test/tstab.c
26
test/tstab.c
@ -24,6 +24,8 @@
|
||||
#include <H5Gprivate.h>
|
||||
#include <H5Oprivate.h>
|
||||
|
||||
#define TEST_FILE "tstab2.h5"
|
||||
|
||||
/*
|
||||
* This file needs to access private datatypes from the H5G package.
|
||||
*/
|
||||
@ -92,7 +94,7 @@ test_2(void)
|
||||
#endif
|
||||
|
||||
/* create the file */
|
||||
fid = H5Fcreate("tstab2.h5", H5F_ACC_TRUNC, create_plist, access_plist);
|
||||
fid = H5Fcreate(TEST_FILE, H5F_ACC_TRUNC, create_plist, access_plist);
|
||||
CHECK(fid, FAIL, "H5Fcreate");
|
||||
f = H5I_object(fid);
|
||||
CHECK(f, NULL, "H5I_object");
|
||||
@ -149,3 +151,25 @@ test_stab(void)
|
||||
{
|
||||
test_2();
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: cleanup_stab
|
||||
*
|
||||
* Purpose: Cleanup temporary test files
|
||||
*
|
||||
* Return: none
|
||||
*
|
||||
* Programmer: Albert Cheng
|
||||
* July 2, 1998
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
cleanup_stab(void)
|
||||
{
|
||||
remove(TEST_FILE);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user