Remove duplicate MESSAGE macro (#5200)

* Removes duplicate macro from C++ code
* Hides global variables behind accessor functions
This commit is contained in:
Dana Robinson 2025-01-02 08:11:17 -08:00 committed by GitHub
parent be3f2995dc
commit 00adfce7a4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 29 additions and 14 deletions

View File

@ -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); \

View File

@ -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
*/

View File

@ -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)
@ -112,9 +112,6 @@
/* Variables */
/*************/
H5TEST_DLLVAR int TestFrameworkProcessID_g;
H5TEST_DLLVAR int TestVerbosity_g;
/**************/
/* Prototypes */
/**************/
@ -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