+ Allow -DDEBUG_UNIT to be suppressed to test how debug macros behave.
+
diff --git a/test/lib/pgBackRestTest/Common/DefineTest.pm b/test/lib/pgBackRestTest/Common/DefineTest.pm
index 5473214ca..939158705 100644
--- a/test/lib/pgBackRestTest/Common/DefineTest.pm
+++ b/test/lib/pgBackRestTest/Common/DefineTest.pm
@@ -46,6 +46,9 @@ use constant TESTDEF_C => 'c';
# #defines for C testing
use constant TESTDEF_CDEF => 'cdef';
push @EXPORT, qw(TESTDEF_CDEF);
+# Don't define DEBUG_UNIT for unit tests -- this is used to test unit test debugging macros
+use constant TESTDEF_DEBUG_UNIT_SUPPRESS => 'debug-unit-supress';
+ push @EXPORT, qw(TESTDEF_DEBUG_UNIT_SUPPRESS);
# Determines if each run in a test will be run in a new container
use constant TESTDEF_INDIVIDUAL => 'individual';
push @EXPORT, qw(TESTDEF_INDIVIDUAL);
@@ -139,6 +142,7 @@ my $oTestDef =
&TESTDEF_TOTAL => 2,
&TESTDEF_C => true,
&TESTDEF_CDEF => '-DNDEBUG -DNO_LOG',
+ &TESTDEF_DEBUG_UNIT_SUPPRESS => true,
&TESTDEF_COVERAGE =>
{
@@ -182,6 +186,7 @@ my $oTestDef =
&TESTDEF_TOTAL => 2,
&TESTDEF_C => true,
&TESTDEF_CDEF => '-DNDEBUG -DNO_LOG',
+ &TESTDEF_DEBUG_UNIT_SUPPRESS => true,
&TESTDEF_COVERAGE =>
{
@@ -962,8 +967,8 @@ foreach my $hModule (@{$oTestDef->{&TESTDEF_MODULE}})
# Resolve variables that can be set in the module or the test
foreach my $strVar (
- TESTDEF_C, TESTDEF_CDEF, TESTDEF_CONTAINER, TESTDEF_EXPECT, TESTDEF_DB, TESTDEF_INDIVIDUAL, TESTDEF_PERL_REQ,
- TESTDEF_VM)
+ TESTDEF_C, TESTDEF_CDEF, TESTDEF_CONTAINER, TESTDEF_DEBUG_UNIT_SUPPRESS, TESTDEF_EXPECT, TESTDEF_DB, TESTDEF_INDIVIDUAL,
+ TESTDEF_PERL_REQ, TESTDEF_VM)
{
$hTestDefHash->{$strModule}{$strTest}{$strVar} = coalesce(
$hModuleTest->{$strVar}, $hModule->{$strVar}, $strVar eq TESTDEF_VM ? undef : false);
diff --git a/test/lib/pgBackRestTest/Common/JobTest.pm b/test/lib/pgBackRestTest/Common/JobTest.pm
index 62bdea91d..7bad9bac9 100644
--- a/test/lib/pgBackRestTest/Common/JobTest.pm
+++ b/test/lib/pgBackRestTest/Common/JobTest.pm
@@ -351,7 +351,8 @@ sub run
" `perl -MExtUtils::Embed -e ccopts`\n" .
"LDFLAGS=-lcrypto" . (vmCoverage($self->{oTest}->{&TEST_VM}) ? " -lgcov" : '') .
" `perl -MExtUtils::Embed -e ldopts`\n" .
- 'TESTFLAGS=-DDEBUG_UNIT' . ($self->{oTest}->{&TEST_CDEF} ? " $self->{oTest}->{&TEST_CDEF}" : '') .
+ 'TESTFLAGS=' . ($self->{oTest}->{&TEST_DEBUG_UNIT_SUPPRESS} ? '' : "-DDEBUG_UNIT ") .
+ ($self->{oTest}->{&TEST_CDEF} ? "$self->{oTest}->{&TEST_CDEF}" : '') .
"\n" .
"\nSRCS=" . join(' ', @stryCFile) . "\n" .
"OBJS=\$(SRCS:.c=.o)\n" .
diff --git a/test/lib/pgBackRestTest/Common/ListTest.pm b/test/lib/pgBackRestTest/Common/ListTest.pm
index 26404520e..a5d52f25e 100644
--- a/test/lib/pgBackRestTest/Common/ListTest.pm
+++ b/test/lib/pgBackRestTest/Common/ListTest.pm
@@ -30,6 +30,8 @@ use constant TEST_CDEF => 'cdef';
push @EXPORT, qw(TEST_CDEF);
use constant TEST_CONTAINER => 'container';
push @EXPORT, qw(TEST_CONTAINER);
+use constant TEST_DEBUG_UNIT_SUPPRESS => TESTDEF_DEBUG_UNIT_SUPPRESS;
+ push @EXPORT, qw(TEST_DEBUG_UNIT_SUPPRESS);
use constant TEST_MODULE => 'module';
push @EXPORT, qw(TEST_MODULE);
use constant TEST_NAME => 'test';
@@ -147,6 +149,7 @@ sub testListGet
&TEST_VM => $strTestOS,
&TEST_C => coalesce($hTest->{&TESTDEF_C}, $hModule->{&TESTDEF_C}, false),
&TEST_CDEF => $hTest->{&TESTDEF_CDEF},
+ &TEST_DEBUG_UNIT_SUPPRESS => $hTest->{&TEST_DEBUG_UNIT_SUPPRESS},
&TEST_CONTAINER => defined($hTest->{&TESTDEF_CONTAINER}) ?
$hTest->{&TESTDEF_CONTAINER} : $hModule->{&TESTDEF_CONTAINER},
&TEST_PGSQL_BIN => $strPgSqlBin,
diff --git a/test/src/common/harnessTest.h b/test/src/common/harnessTest.h
index 38c751b2b..77d31cb3b 100644
--- a/test/src/common/harnessTest.h
+++ b/test/src/common/harnessTest.h
@@ -19,6 +19,14 @@ void testComplete();
const char *testPath();
void testPathSet(const char *testPathParam);
+/***********************************************************************************************************************************
+Convert a macro to a string -- handy for testing debug macros
+***********************************************************************************************************************************/
+#define MACRO_TO_STR_INNER(macro) \
+ #macro
+#define MACRO_TO_STR(macro) \
+ MACRO_TO_STR_INNER(macro)
+
/***********************************************************************************************************************************
Maximum size of a formatted result in the TEST_RESULT macro. Strings don't count as they are output directly, so this only applies
to the formatting of bools, ints, floats, etc. This should be plenty of room for any of those types.
diff --git a/test/src/module/common/debugOffTest.c b/test/src/module/common/debugOffTest.c
index 1a7d82d64..b657a5c3d 100644
--- a/test/src/module/common/debugOffTest.c
+++ b/test/src/module/common/debugOffTest.c
@@ -23,7 +23,7 @@ testRun()
// -----------------------------------------------------------------------------------------------------------------------------
if (testBegin("DEBUG_UNIT_EXTERN"))
{
- const char *debugUnitExtern = "" DEBUG_UNIT_EXTERN "";
- TEST_RESULT_STR(debugUnitExtern, "", "DEBUG_UNIT_EXTERN is static");
+ const char *debugUnitExtern = MACRO_TO_STR(DEBUG_UNIT_EXTERN);
+ TEST_RESULT_STR(debugUnitExtern, "static", "DEBUG_UNIT_EXTERN is static");
}
}
diff --git a/test/src/module/common/debugOnTest.c b/test/src/module/common/debugOnTest.c
index 6580f8e68..2ea4408af 100644
--- a/test/src/module/common/debugOnTest.c
+++ b/test/src/module/common/debugOnTest.c
@@ -23,7 +23,7 @@ testRun()
// -----------------------------------------------------------------------------------------------------------------------------
if (testBegin("DEBUG_UNIT_EXTERN"))
{
- const char *debugUnitExtern = "" DEBUG_UNIT_EXTERN "";
+ const char *debugUnitExtern = MACRO_TO_STR(DEBUG_UNIT_EXTERN);
TEST_RESULT_STR(debugUnitExtern, "", "DEBUG_UNIT_EXTERN is blank (extern)");
}
}