You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-06-16 23:47:38 +02:00
Build test harness with the same warnings as code being tested.
The test harness was not being built with warnings which caused some wackiness with an improperly structured switch. Just use the same warnings as the code being tested. Also enable warnings on code that is not directly being tested since other code modules are frequently modified during testing.
This commit is contained in:
@ -113,6 +113,10 @@
|
|||||||
|
|
||||||
<release-test-list>
|
<release-test-list>
|
||||||
<release-development-list>
|
<release-development-list>
|
||||||
|
<release-item>
|
||||||
|
<p>Build test harness with the same warnings as code being tested.</p>
|
||||||
|
</release-item>
|
||||||
|
|
||||||
<release-item>
|
<release-item>
|
||||||
<p>Use <cmd>restore</cmd> command for remote performances tests.</p>
|
<p>Use <cmd>restore</cmd> command for remote performances tests.</p>
|
||||||
</release-item>
|
</release-item>
|
||||||
|
@ -383,6 +383,18 @@ sub run
|
|||||||
$strTestC =~ s/\{\[C\_TEST\_LIST\]\}/$strTestInit/g;
|
$strTestC =~ s/\{\[C\_TEST\_LIST\]\}/$strTestInit/g;
|
||||||
buildPutDiffers($self->{oStorageTest}, "$self->{strGCovPath}/test.c", $strTestC);
|
buildPutDiffers($self->{oStorageTest}, "$self->{strGCovPath}/test.c", $strTestC);
|
||||||
|
|
||||||
|
# Determine which warnings are available
|
||||||
|
my $strWarningFlags =
|
||||||
|
'-Werror -Wfatal-errors -Wall -Wextra -Wwrite-strings -Wswitch-enum -Wconversion -Wformat=2' .
|
||||||
|
' -Wformat-nonliteral -Wstrict-prototypes -Wpointer-arith -Wvla' .
|
||||||
|
($self->{oTest}->{&TEST_VM} eq VM_U16 || $self->{oTest}->{&TEST_VM} eq VM_U18 ?
|
||||||
|
' -Wformat-signedness' : '') .
|
||||||
|
($self->{oTest}->{&TEST_VM} eq VM_U18 ?
|
||||||
|
' -Wduplicated-branches -Wduplicated-cond' : '') .
|
||||||
|
# This warning appears to be broken on U12/CO6 even though the functionality is fine
|
||||||
|
($self->{oTest}->{&TEST_VM} eq VM_U12 || $self->{oTest}->{&TEST_VM} eq VM_CO6 ?
|
||||||
|
' -Wno-missing-field-initializers' : '');
|
||||||
|
|
||||||
# Flags that are common to all builds
|
# Flags that are common to all builds
|
||||||
my $strCommonFlags =
|
my $strCommonFlags =
|
||||||
'-I. -Itest -std=c99 -fPIC -g -Wno-clobbered -D_POSIX_C_SOURCE=200112L' .
|
'-I. -Itest -std=c99 -fPIC -g -Wno-clobbered -D_POSIX_C_SOURCE=200112L' .
|
||||||
@ -395,41 +407,37 @@ sub run
|
|||||||
|
|
||||||
# Flags used to buid harness files
|
# Flags used to buid harness files
|
||||||
my $strHarnessFlags =
|
my $strHarnessFlags =
|
||||||
'-O0' . ($self->{oTest}->{&TEST_VM} ne VM_U12 ? ' -ftree-coalesce-vars' : '') .
|
'-O2' . ($self->{oTest}->{&TEST_VM} ne VM_U12 ? ' -ftree-coalesce-vars' : '') .
|
||||||
($self->{oTest}->{&TEST_CTESTDEF} ? " $self->{oTest}->{&TEST_CTESTDEF}" : '');
|
($self->{oTest}->{&TEST_CTESTDEF} ? " $self->{oTest}->{&TEST_CTESTDEF}" : '');
|
||||||
|
|
||||||
buildPutDiffers($self->{oStorageTest}, "$self->{strGCovPath}/harnessflags", "${strCommonFlags} ${strHarnessFlags}");
|
buildPutDiffers(
|
||||||
|
$self->{oStorageTest}, "$self->{strGCovPath}/harnessflags",
|
||||||
|
"${strCommonFlags} ${strWarningFlags} ${strHarnessFlags}");
|
||||||
|
|
||||||
# Flags used to buid test.c
|
# Flags used to buid test.c
|
||||||
my $strTestFlags =
|
my $strTestFlags =
|
||||||
'-Werror -Wfatal-errors -Wall -Wextra -Wwrite-strings -Wswitch-enum -Wconversion -Wformat=2' .
|
'-O0' . ($self->{oTest}->{&TEST_VM} ne VM_U12 ? ' -ftree-coalesce-vars' : '') .
|
||||||
' -Wformat-nonliteral -Wstrict-prototypes -Wpointer-arith -Wvla' .
|
|
||||||
' -DDEBUG_TEST_TRACE' .
|
|
||||||
($self->{oTest}->{&TEST_VM} eq VM_U16 || $self->{oTest}->{&TEST_VM} eq VM_U18 ?
|
|
||||||
' -Wformat-signedness' : '') .
|
|
||||||
($self->{oTest}->{&TEST_VM} eq VM_U18 ?
|
|
||||||
' -Wduplicated-branches -Wduplicated-cond' : '') .
|
|
||||||
# This warning appears to be broken on U12/CO6 even though the functionality is fine
|
|
||||||
($self->{oTest}->{&TEST_VM} eq VM_U12 || $self->{oTest}->{&TEST_VM} eq VM_CO6 ?
|
|
||||||
' -Wno-missing-field-initializers' : '') .
|
|
||||||
' -O0' . ($self->{oTest}->{&TEST_VM} ne VM_U12 ? ' -ftree-coalesce-vars' : '') .
|
|
||||||
(vmCoverageC($self->{oTest}->{&TEST_VM}) && $self->{bCoverageUnit} ?
|
(vmCoverageC($self->{oTest}->{&TEST_VM}) && $self->{bCoverageUnit} ?
|
||||||
' -fprofile-arcs -ftest-coverage' : '') .
|
' -fprofile-arcs -ftest-coverage' : '') .
|
||||||
($self->{oTest}->{&TEST_CTESTDEF} ? " $self->{oTest}->{&TEST_CTESTDEF}" : '');
|
($self->{oTest}->{&TEST_CTESTDEF} ? " $self->{oTest}->{&TEST_CTESTDEF}" : '');
|
||||||
|
|
||||||
buildPutDiffers(
|
buildPutDiffers(
|
||||||
$self->{oStorageTest}, "$self->{strGCovPath}/testflags", "${strCommonFlags} ${strTestFlags}");
|
$self->{oStorageTest}, "$self->{strGCovPath}/testflags",
|
||||||
|
"${strCommonFlags} ${strWarningFlags} ${strTestFlags}");
|
||||||
|
|
||||||
# Flags used to buid all other files
|
# Flags used to buid all other files
|
||||||
my $strBuildFlags =
|
my $strBuildFlags =
|
||||||
($self->{bOptimize} ? '-O2' : '-O0' . ($self->{oTest}->{&TEST_VM} ne VM_U12 ? ' -ftree-coalesce-vars' : ''));
|
($self->{bOptimize} ? '-O2' : '-O0' . ($self->{oTest}->{&TEST_VM} ne VM_U12 ? ' -ftree-coalesce-vars' : ''));
|
||||||
|
|
||||||
buildPutDiffers($self->{oStorageTest}, "$self->{strGCovPath}/buildflags", "${strCommonFlags} ${strBuildFlags}");
|
buildPutDiffers(
|
||||||
|
$self->{oStorageTest}, "$self->{strGCovPath}/buildflags",
|
||||||
|
"${strCommonFlags} ${strWarningFlags} ${strBuildFlags}");
|
||||||
|
|
||||||
# Build the Makefile
|
# Build the Makefile
|
||||||
my $strMakefile =
|
my $strMakefile =
|
||||||
"CC=gcc\n" .
|
"CC=gcc\n" .
|
||||||
"COMMONFLAGS=${strCommonFlags}\n" .
|
"COMMONFLAGS=${strCommonFlags}\n" .
|
||||||
|
"WARNINGFLAGS=${strWarningFlags}\n" .
|
||||||
"BUILDFLAGS=${strBuildFlags}\n" .
|
"BUILDFLAGS=${strBuildFlags}\n" .
|
||||||
"HARNESSFLAGS=${strHarnessFlags}\n" .
|
"HARNESSFLAGS=${strHarnessFlags}\n" .
|
||||||
"TESTFLAGS=${strTestFlags}\n" .
|
"TESTFLAGS=${strTestFlags}\n" .
|
||||||
@ -445,7 +453,7 @@ sub run
|
|||||||
"\t\$(CC) -o test.bin \$(OBJS) test.o" . ($self->{bProfile} ? " -pg" : '') . " \$(LDFLAGS)\n" .
|
"\t\$(CC) -o test.bin \$(OBJS) test.o" . ($self->{bProfile} ? " -pg" : '') . " \$(LDFLAGS)\n" .
|
||||||
"\n" .
|
"\n" .
|
||||||
"test.o: testflags test.c${strTestDepend}\n" .
|
"test.o: testflags test.c${strTestDepend}\n" .
|
||||||
"\t\$(CC) \$(COMMONFLAGS) \$(TESTFLAGS) -c test.c\n";
|
"\t\$(CC) \$(COMMONFLAGS) \$(WARNINGFLAGS) \$(TESTFLAGS) -c test.c\n";
|
||||||
|
|
||||||
# Build C file dependencies
|
# Build C file dependencies
|
||||||
foreach my $strCFile (@stryCFile)
|
foreach my $strCFile (@stryCFile)
|
||||||
@ -466,7 +474,7 @@ sub run
|
|||||||
|
|
||||||
$strMakefile .=
|
$strMakefile .=
|
||||||
"\n" .
|
"\n" .
|
||||||
"\t\$(CC) \$(COMMONFLAGS)" .
|
"\t\$(CC) \$(COMMONFLAGS) \$(WARNINGFLAGS)" .
|
||||||
($strCFile =~ /^test\// ? " \$(HARNESSFLAGS)" : " \$(BUILDFLAGS)") .
|
($strCFile =~ /^test\// ? " \$(HARNESSFLAGS)" : " \$(BUILDFLAGS)") .
|
||||||
" -c $strCFile -o " . substr($strCFile, 0, length($strCFile) - 2) . ".o\n";
|
" -c $strCFile -o " . substr($strCFile, 0, length($strCFile) - 2) . ".o\n";
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,6 @@ Tls Test Harness
|
|||||||
|
|
||||||
#include "common/harnessTls.h"
|
#include "common/harnessTls.h"
|
||||||
|
|
||||||
static bool hostInit = false;
|
|
||||||
static int testServerSocket = 0;
|
static int testServerSocket = 0;
|
||||||
static SSL_CTX *testServerContext = NULL;
|
static SSL_CTX *testServerContext = NULL;
|
||||||
static int testClientSocket = 0;
|
static int testClientSocket = 0;
|
||||||
|
Reference in New Issue
Block a user