Skip to content

Commit

Permalink
Remove duplicate MESSAGE macro (HDFGroup#5200)
Browse files Browse the repository at this point in the history
* Removes duplicate macro from C++ code
* Hides global variables behind accessor functions
  • Loading branch information
derobins authored Jan 2, 2025
1 parent be3f299 commit 00adfce
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
5 changes: 0 additions & 5 deletions c++/test/h5cpputil.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ using namespace H5;
using std::cerr;
using std::endl;

#define MESSAGE(V, A) \
do { \
if (GetTestVerbosity() > (V)) \
printf A; \
} while (0)
#define SUBTEST(TEST) \
do { \
printf(" Subtest: %-52s", TEST); \
Expand Down
9 changes: 9 additions & 0 deletions test/testframe.c
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,15 @@ TestShutdown(void)
return SUCCEED;
}

/*
* Retrieve the MPI rank for this process.
*/
H5_ATTR_PURE int
GetTestFrameworkProcessID(void)
{
return TestFrameworkProcessID_g;
}

/*
* Retrieve the verbosity level for the testing framework
*/
Expand Down
29 changes: 20 additions & 9 deletions test/testframe.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,16 @@
* Verbose queries
* Only None needs an exact match. The rest are at least as much.
*/
#define VERBOSE_NONE (TestVerbosity_g == VERBO_NONE)
#define VERBOSE_DEF (TestVerbosity_g >= VERBO_DEF)
#define VERBOSE_LO (TestVerbosity_g >= VERBO_LO)
#define VERBOSE_MED (TestVerbosity_g >= VERBO_MED)
#define VERBOSE_HI (TestVerbosity_g >= VERBO_HI)
#define VERBOSE_NONE (GetTestVerbosity() == VERBO_NONE)
#define VERBOSE_DEF (GetTestVerbosity() >= VERBO_DEF)
#define VERBOSE_LO (GetTestVerbosity() >= VERBO_LO)
#define VERBOSE_MED (GetTestVerbosity() >= VERBO_MED)
#define VERBOSE_HI (GetTestVerbosity() >= VERBO_HI)

/* Used to document process through a test */
#define MESSAGE(V, A) \
do { \
if (TestFrameworkProcessID_g == 0 && TestVerbosity_g > (V)) \
if (GetTestFrameworkProcessID() == 0 && GetTestVerbosity() > (V)) \
printf A; \
} while (0)

Expand All @@ -112,9 +112,6 @@
/* Variables */
/*************/

H5TEST_DLLVAR int TestFrameworkProcessID_g;
H5TEST_DLLVAR int TestVerbosity_g;

/**************/
/* Prototypes */
/**************/
Expand Down Expand Up @@ -422,6 +419,20 @@ H5TEST_DLL herr_t PerformTests(void);
*/
H5TEST_DLL void TestSummary(FILE *stream);

/**
* --------------------------------------------------------------------------
* \ingroup H5TEST
*
* \brief Returns the MPI rank for this process
*
* \return The MPI rank of this process
*
* \details GetTestFrameworkProcessID() returns the MPI rank for this process.
* Always returns rank 0 in serial HDF5.
*
*/
H5TEST_DLL int GetTestFrameworkProcessID(void);

/**
* --------------------------------------------------------------------------
* \ingroup H5TEST
Expand Down

0 comments on commit 00adfce

Please sign in to comment.