From 3f0b41eb9c1137b0b19138d22d2c26009d477602 Mon Sep 17 00:00:00 2001 From: David Steele Date: Mon, 20 Jul 2020 09:59:16 -0400 Subject: [PATCH] Add support for testing on 64-bit big-endian architectures. In particular add support for s390x but we hope this will work for other 64-bit big-endian architectures. Run basic unit tests on Travis CI for 390x. --- .travis.yml | 7 +++++++ test/src/common/harnessTest.h | 5 +++++ test/src/module/command/archivePushTest.c | 3 ++- test/src/module/command/backupTest.c | 4 +++- test/src/module/postgres/interfaceTest.c | 4 ++-- 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 01fe39da4..46bc23a37 100644 --- a/.travis.yml +++ b/.travis.yml @@ -60,6 +60,13 @@ jobs: - PGB_CI="test --vm=none --param=no-coverage --param=module=command --param=module=storage" services: + # Basic unit tests only. Coverage testing is also disabled to save time. + - arch: s390x + dist: bionic + env: + - PGB_CI="test --vm=none --param=no-coverage --param=module=command --param=module=storage" + services: + install: - umask 0022 && cd ~ && pwd && whoami && umask && groups - df -Th && top -bn1 diff --git a/test/src/common/harnessTest.h b/test/src/common/harnessTest.h index ebd1c71bc..d9d3c966c 100644 --- a/test/src/common/harnessTest.h +++ b/test/src/common/harnessTest.h @@ -376,4 +376,9 @@ Is this a 64-bit system? If not then it is 32-bit since 16-bit systems are not #define TEST_64BIT() \ (sizeof(size_t) == 8) +/*********************************************************************************************************************************** +Is this a big-endian system? +***********************************************************************************************************************************/ +#define TEST_BIG_ENDIAN() (!*(unsigned char *)&(uint16_t){1}) + #endif diff --git a/test/src/module/command/archivePushTest.c b/test/src/module/command/archivePushTest.c index 6888315a3..6bccb7c5c 100644 --- a/test/src/module/command/archivePushTest.c +++ b/test/src/module/command/archivePushTest.c @@ -264,7 +264,8 @@ testRun(void) // Check sha1 checksum against fixed values once to make sure they are not getting munged. After this we'll calculate them // directly from the buffers to reduce the cost of maintaining checksums. const char *walBuffer1Sha1 = TEST_64BIT() ? - "aae7591a1dbc58f21d0d004886075094f622e6dd" : "28a13fd8cf6fcd9f9a8108aed4c8bcc58040863a"; + (TEST_BIG_ENDIAN() ? "1c5f963d720bb199d7935dbd315447ea2ec3feb2" : "aae7591a1dbc58f21d0d004886075094f622e6dd") : + "28a13fd8cf6fcd9f9a8108aed4c8bcc58040863a"; storagePutP(storageNewWriteP(storagePgWrite(), strNew("pg_wal/000000010000000100000001")), walBuffer1); diff --git a/test/src/module/command/backupTest.c b/test/src/module/command/backupTest.c index e743ad9ef..56a5a8cd2 100644 --- a/test/src/module/command/backupTest.c +++ b/test/src/module/command/backupTest.c @@ -1487,7 +1487,9 @@ testRun(void) "P01 INFO: backup file {[path]}/pg1/postgresql.conf (11B, 100%%) checksum e3db315c260e79211b7b52587123b7aa060f30ab\n" "P00 INFO: full backup size = 8KB\n" "P00 INFO: new backup label = [FULL-1]", - TEST_64BIT() ? "21e2ddc99cdf4cfca272eee4f38891146092e358" : "8bb70506d988a8698d9e8cf90736ada23634571b"); + TEST_64BIT() ? + (TEST_BIG_ENDIAN() ? "749acedef8f8d5fe35fc20c0375657f876ccc38e" : "21e2ddc99cdf4cfca272eee4f38891146092e358") : + "8bb70506d988a8698d9e8cf90736ada23634571b"); // Make pg no longer appear to be running storageRemoveP(storagePgWrite(), PG_FILE_POSTMASTERPID_STR, .errorOnMissing = true); diff --git a/test/src/module/postgres/interfaceTest.c b/test/src/module/postgres/interfaceTest.c index 3a1f69d02..b98578dbf 100644 --- a/test/src/module/postgres/interfaceTest.c +++ b/test/src/module/postgres/interfaceTest.c @@ -190,8 +190,8 @@ testRun(void) unsigned char page[PG_PAGE_SIZE_DEFAULT]; memset(page, 0xFF, PG_PAGE_SIZE_DEFAULT); - TEST_RESULT_UINT(pgPageChecksum(page, 0), 0x0E1C, "check 0xFF filled page, block 0"); - TEST_RESULT_UINT(pgPageChecksum(page, 999), 0x0EC3, "check 0xFF filled page, block 999"); + TEST_RESULT_UINT(pgPageChecksum(page, 0), TEST_BIG_ENDIAN() ? 0xF55E : 0x0E1C, "check 0xFF filled page, block 0"); + TEST_RESULT_UINT(pgPageChecksum(page, 999), TEST_BIG_ENDIAN() ? 0xF1B9 : 0x0EC3, "check 0xFF filled page, block 999"); } // *****************************************************************************************************************************