1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-01-30 05:39:12 +02:00

Use static checksums in mock/all integration tests.

Using static values serves as a better cross-check against the page checksum code. The downside is that these checksums may not work with some big endian systems but in that case neither will the unit tests.

We can also remove the page checksum interface from LibC which brings us one step closer to eliminating it.
This commit is contained in:
David Steele 2020-03-05 13:56:20 -05:00
parent 77853d3c13
commit eb4347f20b
6 changed files with 19 additions and 55 deletions

View File

@ -76,11 +76,6 @@ sub libcAutoExportTag
{
return
{
checksum =>
[
'pgPageChecksum',
],
config =>
[
'CFGOPTVAL_INFO_OUTPUT_TEXT',

View File

@ -55,7 +55,6 @@ These includes are from the src directory. There is no Perl-specific code in th
#include "config/define.h"
#include "config/load.h"
#include "config/parse.h"
#include "postgres/pageChecksum.h"
#include "storage/posix/storage.h"
/***********************************************************************************************************************************
@ -99,7 +98,6 @@ INCLUDE: xs/config/configTest.xs
INCLUDE: xs/config/define.xs
INCLUDE: xs/crypto/hash.xs
INCLUDE: xs/postgres/client.xs
INCLUDE: xs/postgres/pageChecksum.xs
INCLUDE: xs/storage/storage.xs
INCLUDE: xs/storage/storageRead.xs
INCLUDE: xs/storage/storageWrite.xs

View File

@ -99,7 +99,6 @@ my @stryCFile =
'protocol/parallelJob.c',
'protocol/server.c',
'postgres/client.c',
'postgres/pageChecksum.c',
'storage/posix/read.c',
'storage/posix/storage.c',
'storage/posix/write.c',

View File

@ -71,13 +71,6 @@ sub buildPutDiffers
####################################################################################################################################
my $rhExport =
{
'checksum' =>
{
&BLD_EXPORTTYPE_SUB => [qw(
pgPageChecksum
)],
},
'config' =>
{
&BLD_EXPORTTYPE_SUB => [qw(

View File

@ -1,20 +0,0 @@
# ----------------------------------------------------------------------------------------------------------------------------------
# Page Checksum Perl Exports
# ----------------------------------------------------------------------------------------------------------------------------------
MODULE = pgBackRest::LibC PACKAGE = pgBackRest::LibC
U16
pgPageChecksum(page, blockNo)
unsigned char *page
U32 blockNo
CODE:
RETVAL = 0;
ERROR_XS_BEGIN()
{
RETVAL = pgPageChecksum(page, blockNo);
}
ERROR_XS_END();
OUTPUT:
RETVAL

View File

@ -23,7 +23,6 @@ use pgBackRest::Common::Log;
use pgBackRest::Common::Wait;
use pgBackRest::Config::Config;
use pgBackRest::InfoCommon;
use pgBackRest::LibC qw(:checksum);
use pgBackRest::Manifest;
use pgBackRest::Protocol::Storage::Helper;
use pgBackRest::Storage::Helper;
@ -45,13 +44,13 @@ sub pageBuild
{
my $tPageSource = shift;
my $iBlockNo = shift;
my $iChecksum = shift;
my $iWalId = shift;
my $iWalOffset = shift;
my $tPage = defined($iWalId) ? pack('I', $iWalId) . pack('I', $iWalOffset) . substr($tPageSource, 8) : $tPageSource;
my $iChecksum = pgPageChecksum($tPage, $iBlockNo);
return substr($tPage, 0, 8) . pack('S', $iChecksum) . substr($tPage, 10);
return
(defined($iWalId) ? pack('I', $iWalId) . pack('I', $iWalOffset) : substr($tPageSource, 0, 8)) . pack('S', $iChecksum) .
substr($tPageSource, 10);
}
####################################################################################################################################
@ -184,10 +183,10 @@ sub run
$oHostDbMaster->manifestPathCreate(\%oManifest, MANIFEST_TARGET_PGDATA, 'base/32768');
my $tPageValid =
pageBuild($tBasePage, 0) .
pageBuild($tBasePage, 1) .
pageBuild($tBasePage, 2) .
pageBuild($tBasePage, 0, 0xFFFFFFFF, 0xFFFFFFFF);
pageBuild($tBasePage, 0, 0x1b99) .
pageBuild($tBasePage, 1, 0x1b9a) .
pageBuild($tBasePage, 2, 0x1b97) .
pageBuild($tBasePage, 0, 0x8170, 0xFFFFFFFF, 0xFFFFFFFF);
$oHostDbMaster->manifestFileCreate(
\%oManifest, MANIFEST_TARGET_PGDATA, 'base/32768/33000', $tPageValid, '7a16d165e4775f7c92e8cdf60c0af57313f0bf90',
@ -196,24 +195,24 @@ sub run
my $iBlockOffset = 32767 * 131072;
my $tPageValidSeg32767 =
pageBuild($tBasePage, $iBlockOffset + 0) .
pageBuild($tBasePage, $iBlockOffset + 1) .
pageBuild($tBasePage, $iBlockOffset + 0, 0xf7de) .
pageBuild($tBasePage, $iBlockOffset + 1, 0xf7df) .
("\0" x 8192) .
pageBuild($tBasePage, 0, 0xFFFFFFFF, 0xFFFFFFFF);
pageBuild($tBasePage, 0, 0x8170, 0xFFFFFFFF, 0xFFFFFFFF);
$oHostDbMaster->manifestFileCreate(
\%oManifest, MANIFEST_TARGET_PGDATA, 'base/32768/33000.32767', $tPageValidSeg32767,
'6e99b589e550e68e934fd235ccba59fe5b592a9e', $lTime);
my $tPageInvalid33001 =
pageBuild($tBasePage, 1) .
pageBuild($tBasePage, 1) .
pageBuild($tBasePage, 2) .
pageBuild($tBasePage, 0) .
pageBuild($tBasePage, 0) .
pageBuild($tBasePage, 0) .
pageBuild($tBasePage, 6) .
pageBuild($tBasePage, 0);
pageBuild($tBasePage, 1, 0x1b9a) .
pageBuild($tBasePage, 1, 0x1b9a) .
pageBuild($tBasePage, 2, 0x1b97) .
pageBuild($tBasePage, 0, 0x1b99) .
pageBuild($tBasePage, 0, 0x1b99) .
pageBuild($tBasePage, 0, 0x1b99) .
pageBuild($tBasePage, 6, 0x1b9b) .
pageBuild($tBasePage, 0, 0x1b99);
$oHostDbMaster->manifestFileCreate(
\%oManifest, MANIFEST_TARGET_PGDATA, 'base/32768/33001', $tPageInvalid33001,