summaryrefslogtreecommitdiffstats
path: root/test/h5test.h
diff options
context:
space:
mode:
Diffstat (limited to 'test/h5test.h')
-rw-r--r--test/h5test.h291
1 files changed, 194 insertions, 97 deletions
diff --git a/test/h5test.h b/test/h5test.h
index dd38546..ea7ab4d 100644
--- a/test/h5test.h
+++ b/test/h5test.h
@@ -1,29 +1,31 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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. *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * Programmer: Robb Matzke <matzke@llnl.gov>
+ * Programmer: Robb Matzke
* Friday, November 20, 1998
*
* Purpose: Test support stuff.
*/
-#ifndef _H5TEST_H
-#define _H5TEST_H
+#ifndef H5TEST_H
+#define H5TEST_H
+/*
+ * Include required headers. This file tests internal library functions,
+ * so we include the private headers here.
+ */
#include "hdf5.h"
#include "H5private.h"
+#include "H5Eprivate.h"
/*
* Predefined test verbosity levels.
@@ -46,11 +48,11 @@
* 8
* 9 High: Highest level. All information.
*/
-#define VERBO_NONE 0 /* None */
-#define VERBO_DEF 3 /* Default */
-#define VERBO_LO 5 /* Low */
-#define VERBO_MED 7 /* Medium */
-#define VERBO_HI 9 /* High */
+#define VERBO_NONE 0 /* None */
+#define VERBO_DEF 3 /* Default */
+#define VERBO_LO 5 /* Low */
+#define VERBO_MED 7 /* Medium */
+#define VERBO_HI 9 /* High */
/*
* Verbose queries
@@ -61,33 +63,35 @@
/* Should be used internally by the libtest.a only. */
#define HDGetTestVerbosity() (TestVerbosity)
-#define VERBOSE_NONE (HDGetTestVerbosity()==VERBO_NONE)
-#define VERBOSE_DEF (HDGetTestVerbosity()>=VERBO_DEF)
-#define VERBOSE_LO (HDGetTestVerbosity()>=VERBO_LO)
-#define VERBOSE_MED (HDGetTestVerbosity()>=VERBO_MED)
-#define VERBOSE_HI (HDGetTestVerbosity()>=VERBO_HI)
+#define VERBOSE_NONE (HDGetTestVerbosity() == VERBO_NONE)
+#define VERBOSE_DEF (HDGetTestVerbosity() >= VERBO_DEF)
+#define VERBOSE_LO (HDGetTestVerbosity() >= VERBO_LO)
+#define VERBOSE_MED (HDGetTestVerbosity() >= VERBO_MED)
+#define VERBOSE_HI (HDGetTestVerbosity() >= VERBO_HI)
/*
* Test controls definitions.
*/
-#define SKIPTEST 1 /* Skip this test */
-#define ONLYTEST 2 /* Do only this test */
-#define BEGINTEST 3 /* Skip all tests before this test */
+#define SKIPTEST 1 /* Skip this test */
+#define ONLYTEST 2 /* Do only this test */
+#define BEGINTEST 3 /* Skip all tests before this test */
/*
- * This contains the filename prefix specificied as command line option for
+ * This contains the filename prefix specified as command line option for
* the parallel test files.
*/
H5TEST_DLLVAR char *paraprefix;
#ifdef H5_HAVE_PARALLEL
-H5TEST_DLLVAR MPI_Info h5_io_info_g; /* MPI INFO object for IO */
+H5TEST_DLLVAR MPI_Info h5_io_info_g; /* MPI INFO object for IO */
#endif
/*
* Print the current location on the standard output stream.
*/
-#define AT() printf (" at %s:%d in %s()...\n", \
- __FILE__, __LINE__, FUNC);
+#define AT() \
+ do { \
+ HDprintf(" at %s:%d in %s()...\n", __FILE__, __LINE__, __func__); \
+ } while (0)
/*
* The name of the test is printed by saying TESTING("something") which will
@@ -98,101 +102,194 @@ H5TEST_DLLVAR MPI_Info h5_io_info_g; /* MPI INFO object for IO */
* spaces. If the h5_errors() is used for automatic error handling then
* the H5_FAILED() macro is invoked automatically when an API function fails.
*/
-#define TESTING(WHAT) {printf("Testing %-62s",WHAT); fflush(stdout);}
-#define TESTING_2(WHAT) {printf(" Testing %-62s",WHAT); fflush(stdout);}
-#define PASSED() {puts(" PASSED");fflush(stdout);}
-#define H5_FAILED() {puts("*FAILED*");fflush(stdout);}
-#define H5_WARNING() {puts("*WARNING*");fflush(stdout);}
-#define SKIPPED() {puts(" -SKIP-");fflush(stdout);}
-#define TEST_ERROR {H5_FAILED(); AT(); goto error;}
-#define STACK_ERROR {H5Eprint2(H5E_DEFAULT, stdout); goto error;}
-#define FAIL_STACK_ERROR {H5_FAILED(); AT(); H5Eprint2(H5E_DEFAULT, stdout); \
- goto error;}
-#define FAIL_PUTS_ERROR(s) {H5_FAILED(); AT(); puts(s); goto error;}
+#define TESTING(WHAT) \
+ do { \
+ HDprintf("Testing %-62s", WHAT); \
+ HDfflush(stdout); \
+ } while (0)
+#define TESTING_2(WHAT) \
+ do { \
+ HDprintf(" Testing %-60s", WHAT); \
+ HDfflush(stdout); \
+ } while (0)
+#define PASSED() \
+ do { \
+ HDputs(" PASSED"); \
+ HDfflush(stdout); \
+ } while (0)
+#define H5_FAILED() \
+ do { \
+ HDputs("*FAILED*"); \
+ HDfflush(stdout); \
+ } while (0)
+#define H5_WARNING() \
+ do { \
+ HDputs("*WARNING*"); \
+ HDfflush(stdout); \
+ } while (0)
+#define SKIPPED() \
+ do { \
+ HDputs(" -SKIP-"); \
+ HDfflush(stdout); \
+ } while (0)
+#define PUTS_ERROR(s) \
+ do { \
+ HDputs(s); \
+ AT(); \
+ goto error; \
+ } while (0)
+#define TEST_ERROR \
+ do { \
+ H5_FAILED(); \
+ AT(); \
+ goto error; \
+ } while (0)
+#define STACK_ERROR \
+ do { \
+ H5Eprint2(H5E_DEFAULT, stdout); \
+ goto error; \
+ } while (0)
+#define FAIL_STACK_ERROR \
+ do { \
+ H5_FAILED(); \
+ AT(); \
+ H5Eprint2(H5E_DEFAULT, stdout); \
+ goto error; \
+ } while (0)
+#define FAIL_PUTS_ERROR(s) \
+ do { \
+ H5_FAILED(); \
+ AT(); \
+ HDputs(s); \
+ goto error; \
+ } while (0)
-/*
- * Alarm definitions to wait up (terminate) a test that runs too long.
- */
-#define H5_ALARM_SEC 1200 /* default is 20 minutes */
-#define ALARM_ON TestAlarmOn()
-#define ALARM_OFF HDalarm(0)
+/* Number of seconds to wait before killing a test (requires alarm(2)) */
+#define H5_ALARM_SEC 1200 /* default is 20 minutes */
-/*
- * The methods to compare the equality of floating-point values:
- * 1. XXX_ABS_EQUAL - check if the difference is smaller than the
- * Epsilon value. The Epsilon values, FLT_EPSILON, DBL_EPSILON,
- * and LDBL_EPSILON, are defined by compiler in float.h.
- * 2. XXX_REL_EQUAL - check if the relative difference is smaller than a
- * predefined value M. See if two values are relatively equal.
- * It's the test's responsibility not to pass in the value 0, which
- * may cause the equation to fail.
- */
-#define FLT_ABS_EQUAL(X,Y) ((float)fabs(X-Y)<FLT_EPSILON)
-#define DBL_ABS_EQUAL(X,Y) (fabs(X-Y)<DBL_EPSILON)
-#define LDBL_ABS_EQUAL(X,Y) (fabsl(X-Y)<LDBL_EPSILON)
+/* Flags for h5_fileaccess_flags() */
+#define H5_FILEACCESS_LIBVER 0x01
+
+/* Flags for h5_driver_uses_multiple_files() */
+#define H5_EXCLUDE_MULTIPART_DRIVERS 0x01
+#define H5_EXCLUDE_NON_MULTIPART_DRIVERS 0x02
-#define FLT_REL_EQUAL(X,Y,M) (fabsf((Y-X)/X<M)
-#define DBL_REL_EQUAL(X,Y,M) (fabs((Y-X)/X)<M)
-#define LDBL_REL_EQUAL(X,Y,M) (fabsl((Y-X)/X)<M)
+/* Fill an array on the heap with an increasing count value. BUF
+ * is expected to point to a `struct { TYPE arr[...][...]; }`.
+ */
+#define H5TEST_FILL_2D_HEAP_ARRAY(BUF, TYPE) \
+ do { \
+ /* Prefix with h5tfa to avoid shadow warnings */ \
+ size_t h5tfa_i = 0; \
+ size_t h5tfa_j = 0; \
+ TYPE h5tfa_count = 0; \
+ \
+ for (h5tfa_i = 0; h5tfa_i < NELMTS((BUF)->arr); h5tfa_i++) \
+ for (h5tfa_j = 0; h5tfa_j < NELMTS((BUF)->arr[0]); h5tfa_j++) { \
+ (BUF)->arr[h5tfa_i][h5tfa_j] = h5tfa_count; \
+ h5tfa_count++; \
+ } \
+ } while (0)
#ifdef __cplusplus
extern "C" {
#endif
+/*
+ * Ugly hack to cast away const for freeing const-qualified pointers.
+ * Should only be used sparingly, where the alternative (like keeping
+ * an equivalent non-const pointer around) is far messier.
+ */
+#ifndef h5_free_const
+#define h5_free_const(mem) HDfree((void *)(uintptr_t)mem)
+#endif
+
/* Generally useful testing routines */
-H5TEST_DLL int h5_cleanup(const char *base_name[], hid_t fapl);
-H5TEST_DLL char *h5_fixname(const char *base_name, hid_t fapl, char *fullname,
- size_t size);
-H5TEST_DLL hid_t h5_fileaccess(void);
-H5TEST_DLL void h5_no_hwconv(void);
+H5TEST_DLL void h5_clean_files(const char *base_name[], hid_t fapl);
+H5TEST_DLL int h5_cleanup(const char *base_name[], hid_t fapl);
+H5TEST_DLL char *h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size);
+H5TEST_DLL char *h5_fixname_superblock(const char *base_name, hid_t fapl, char *fullname, size_t size);
+H5TEST_DLL char *h5_fixname_no_suffix(const char *base_name, hid_t fapl, char *fullname, size_t size);
+H5TEST_DLL char *h5_fixname_printf(const char *base_name, hid_t fapl, char *fullname, size_t size);
+H5TEST_DLL hid_t h5_fileaccess(void);
+H5TEST_DLL hid_t h5_fileaccess_flags(unsigned flags);
+H5TEST_DLL void h5_no_hwconv(void);
H5TEST_DLL const char *h5_rmprefix(const char *filename);
-H5TEST_DLL void h5_reset(void);
-H5TEST_DLL void h5_show_hostname(void);
+H5TEST_DLL void h5_reset(void);
+H5TEST_DLL void h5_restore_err(void);
+H5TEST_DLL void h5_show_hostname(void);
H5TEST_DLL h5_stat_size_t h5_get_file_size(const char *filename, hid_t fapl);
-H5TEST_DLL int print_func(const char *format, ...);
-H5TEST_DLL int h5_make_local_copy(const char *origfilename, const char *local_copy_name);
-H5TEST_DLL herr_t h5_verify_cached_stabs(const char *base_name[], hid_t fapl);
+H5TEST_DLL int print_func(const char *format, ...) H5_ATTR_FORMAT(printf, 1, 2);
+H5TEST_DLL int h5_make_local_copy(const char *origfilename, const char *local_copy_name);
+H5TEST_DLL herr_t h5_verify_cached_stabs(const char *base_name[], hid_t fapl);
+H5TEST_DLL H5FD_class_t *h5_get_dummy_vfd_class(void);
+H5TEST_DLL H5VL_class_t *h5_get_dummy_vol_class(void);
+H5TEST_DLL const char *h5_get_version_string(H5F_libver_t libver);
+H5TEST_DLL int h5_compare_file_bytes(char *fname1, char *fname2);
+H5TEST_DLL int h5_duplicate_file_by_bytes(const char *orig, const char *dest);
+H5TEST_DLL herr_t h5_check_if_file_locking_enabled(hbool_t *are_enabled);
+H5TEST_DLL hbool_t h5_using_default_driver(const char *drv_name);
+H5TEST_DLL herr_t h5_using_parallel_driver(hid_t fapl_id, hbool_t *driver_is_parallel);
+H5TEST_DLL herr_t h5_driver_is_default_vfd_compatible(hid_t fapl_id, hbool_t *default_vfd_compatible);
+H5TEST_DLL hbool_t h5_driver_uses_multiple_files(const char *drv_name, unsigned flags);
+
+/* Functions that will replace components of a FAPL */
+H5TEST_DLL herr_t h5_get_libver_fapl(hid_t fapl_id);
+
+/* h5_clean_files() replacements */
+H5TEST_DLL void h5_delete_test_file(const char *base_name, hid_t fapl);
+H5TEST_DLL void h5_delete_all_test_files(const char *base_name[], hid_t fapl);
+
+/* h5_reset() replacement */
+H5TEST_DLL void h5_test_init(void);
+
+/* h5_cleanup() replacement */
+H5TEST_DLL void h5_test_shutdown(void);
/* Routines for operating on the list of tests (for the "all in one" tests) */
-H5TEST_DLL void TestUsage(void);
-H5TEST_DLL void AddTest(const char *TheName, void (*TheCall) (void),
- void (*Cleanup) (void), const char *TheDescr,
- const void *Parameters);
-H5TEST_DLL void TestInfo(const char *ProgName);
-H5TEST_DLL void TestParseCmdLine(int argc, char *argv[]);
-H5TEST_DLL void PerformTests(void);
-H5TEST_DLL void TestSummary(void);
-H5TEST_DLL void TestCleanup(void);
-H5TEST_DLL void TestInit(const char *ProgName, void (*private_usage)(void), int (*private_parser)(int ac, char *av[]));
-H5TEST_DLL int GetTestVerbosity(void);
-H5TEST_DLL int SetTestVerbosity(int newval);
-H5TEST_DLL int GetTestSummary(void);
-H5TEST_DLL int GetTestCleanup(void);
-H5TEST_DLL int SetTestNoCleanup(void);
-H5TEST_DLL int GetTestExpress(void);
-H5TEST_DLL int SetTestExpress(int newval);
-H5TEST_DLL void ParseTestVerbosity(char *argv);
-H5TEST_DLL int GetTestNumErrs(void);
-H5TEST_DLL void IncTestNumErrs(void);
+H5TEST_DLL void TestUsage(void);
+H5TEST_DLL void AddTest(const char *TheName, void (*TheCall)(void), void (*Cleanup)(void),
+ const char *TheDescr, const void *Parameters);
+H5TEST_DLL void TestInfo(const char *ProgName);
+H5TEST_DLL void TestParseCmdLine(int argc, char *argv[]);
+H5TEST_DLL void PerformTests(void);
+H5TEST_DLL void TestSummary(void);
+H5TEST_DLL void TestCleanup(void);
+H5TEST_DLL void TestShutdown(void);
+H5TEST_DLL void TestInit(const char *ProgName, void (*private_usage)(void),
+ int (*private_parser)(int ac, char *av[]));
+H5TEST_DLL int GetTestVerbosity(void);
+H5TEST_DLL int SetTestVerbosity(int newval);
+H5TEST_DLL int GetTestSummary(void);
+H5TEST_DLL int GetTestCleanup(void);
+H5TEST_DLL int SetTestNoCleanup(void);
+H5TEST_DLL int GetTestExpress(void);
+H5TEST_DLL int SetTestExpress(int newval);
+H5TEST_DLL void ParseTestVerbosity(char *argv);
+H5TEST_DLL int GetTestNumErrs(void);
+H5TEST_DLL void IncTestNumErrs(void);
H5TEST_DLL const void *GetTestParameters(void);
-H5TEST_DLL int TestErrPrintf(const char *format, ...);
-H5TEST_DLL void SetTest(const char *testname, int action);
-H5TEST_DLL void TestAlarmOn(void);
-H5TEST_DLL void TestAlarmOff(void);
+H5TEST_DLL int TestErrPrintf(const char *format, ...) H5_ATTR_FORMAT(printf, 1, 2);
+H5TEST_DLL void SetTest(const char *testname, int action);
+H5TEST_DLL void TestAlarmOn(void);
+H5TEST_DLL void TestAlarmOff(void);
#ifdef H5_HAVE_FILTER_SZIP
H5TEST_DLL int h5_szip_can_encode(void);
#endif /* H5_HAVE_FILTER_SZIP */
#ifdef H5_HAVE_PARALLEL
-H5TEST_DLL int h5_set_info_object(void);
-H5TEST_DLL void h5_dump_info_object(MPI_Info info);
-H5TEST_DLL char* getenv_all(MPI_Comm comm, int root, const char* name);
+H5TEST_DLL int h5_set_info_object(void);
+H5TEST_DLL void h5_dump_info_object(MPI_Info info);
+H5TEST_DLL char *getenv_all(MPI_Comm comm, int root, const char *name);
#endif
/* Extern global variables */
H5TEST_DLLVAR int TestVerbosity;
+H5TEST_DLL void h5_send_message(const char *file, const char *arg1, const char *arg2);
+H5TEST_DLL herr_t h5_wait_message(const char *file);
+
#ifdef __cplusplus
}
#endif