1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-15 01:04:37 +02:00

Rename TEST_SYSTEM*() to HRN_SYSTEM*().

These calls are not tests, rather they setup data for tests.
This commit is contained in:
David Steele
2021-05-22 14:22:51 -04:00
parent 73885f8c2e
commit bd40156c22
7 changed files with 26 additions and 26 deletions

View File

@ -250,9 +250,9 @@ Macros to compare results of common data types
TEST_RESULT_UINT_INT_PARAM(statement, expected, harnessTestResultOperationEq, comment) TEST_RESULT_UINT_INT_PARAM(statement, expected, harnessTestResultOperationEq, comment)
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Test system calls System call harness
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
#define TEST_SYSTEM(command) \ #define HRN_SYSTEM(command) \
do \ do \
{ \ { \
int TEST_SYSTEM_FMT_result = system(command); \ int TEST_SYSTEM_FMT_result = system(command); \
@ -265,7 +265,7 @@ Test system calls
} \ } \
} while (0) } while (0)
#define TEST_SYSTEM_FMT(...) \ #define HRN_SYSTEM_FMT(...) \
do \ do \
{ \ { \
char TEST_SYSTEM_FMT_buffer[8192]; \ char TEST_SYSTEM_FMT_buffer[8192]; \
@ -273,7 +273,7 @@ Test system calls
if (snprintf(TEST_SYSTEM_FMT_buffer, sizeof(TEST_SYSTEM_FMT_buffer), __VA_ARGS__) >= (int)sizeof(TEST_SYSTEM_FMT_buffer)) \ if (snprintf(TEST_SYSTEM_FMT_buffer, sizeof(TEST_SYSTEM_FMT_buffer), __VA_ARGS__) >= (int)sizeof(TEST_SYSTEM_FMT_buffer)) \
THROW_FMT(AssertError, "command needs more than the %zu characters available", sizeof(TEST_SYSTEM_FMT_buffer)); \ THROW_FMT(AssertError, "command needs more than the %zu characters available", sizeof(TEST_SYSTEM_FMT_buffer)); \
\ \
TEST_SYSTEM(TEST_SYSTEM_FMT_buffer); \ HRN_SYSTEM(TEST_SYSTEM_FMT_buffer); \
} while (0) } while (0)
/*********************************************************************************************************************************** /***********************************************************************************************************************************

View File

@ -1977,7 +1977,7 @@ testRun(void)
FileOpenError, "unable to create symlink"); FileOpenError, "unable to create symlink");
// Special files should not be in the repo // Special files should not be in the repo
TEST_SYSTEM_FMT( HRN_SYSTEM_FMT(
"mkfifo -m 666 %s", "mkfifo -m 666 %s",
strZ(storagePathP(storageRepo(), strNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/pipe", strZ(resumeLabel))))); strZ(storagePathP(storageRepo(), strNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/pipe", strZ(resumeLabel)))));
@ -2255,8 +2255,8 @@ testRun(void)
// Move pg1-path and put a link in its place. This tests that backup works when pg1-path is a symlink yet should be // Move pg1-path and put a link in its place. This tests that backup works when pg1-path is a symlink yet should be
// completely invisible in the manifest and logging. // completely invisible in the manifest and logging.
TEST_SYSTEM_FMT("mv %s %s-data", strZ(pg1Path), strZ(pg1Path)); HRN_SYSTEM_FMT("mv %s %s-data", strZ(pg1Path), strZ(pg1Path));
TEST_SYSTEM_FMT("ln -s %s-data %s ", strZ(pg1Path), strZ(pg1Path)); HRN_SYSTEM_FMT("ln -s %s-data %s ", strZ(pg1Path), strZ(pg1Path));
// Zeroed file which passes page checksums // Zeroed file which passes page checksums
Buffer *relation = bufNew(PG_PAGE_SIZE_DEFAULT); Buffer *relation = bufNew(PG_PAGE_SIZE_DEFAULT);

View File

@ -852,8 +852,8 @@ testRun(void)
TEST_TITLE("expire via backup command"); TEST_TITLE("expire via backup command");
// Copy the repo to another repo // Copy the repo to another repo
TEST_SYSTEM("mkdir " TEST_PATH "/repo2"); HRN_SYSTEM("mkdir " TEST_PATH "/repo2");
TEST_SYSTEM("cp -r " TEST_PATH "/repo/* " TEST_PATH "/repo2/"); HRN_SYSTEM("cp -r " TEST_PATH "/repo/* " TEST_PATH "/repo2/");
// Configure multi-repo and set the repo option to expire the second repo (non-default) files // Configure multi-repo and set the repo option to expire the second repo (non-default) files
argList = strLstDup(argListBase); argList = strLstDup(argListBase);

View File

@ -969,7 +969,7 @@ testRun(void)
manifestPathAdd(manifest, &path); manifestPathAdd(manifest, &path);
manifestFileAdd(manifest, &file); manifestFileAdd(manifest, &file);
TEST_SYSTEM_FMT("sudo chown 77777:77777 %s", strZ(pgPath)); HRN_SYSTEM_FMT("sudo chown 77777:77777 %s", strZ(pgPath));
userLocalData.userName = STRDEF("root"); userLocalData.userName = STRDEF("root");
userLocalData.groupName = STRDEF("root"); userLocalData.groupName = STRDEF("root");
@ -1101,7 +1101,7 @@ testRun(void)
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("succeed when all directories empty and ignore recovery.conf"); TEST_TITLE("succeed when all directories empty and ignore recovery.conf");
TEST_SYSTEM_FMT("rm -rf %s/*", strZ(pgPath)); HRN_SYSTEM_FMT("rm -rf %s/*", strZ(pgPath));
argList = strLstNew(); argList = strLstNew();
strLstAddZ(argList, "--stanza=test1"); strLstAddZ(argList, "--stanza=test1");
@ -1117,7 +1117,7 @@ testRun(void)
"P00 DETAIL: check '" TEST_PATH "/conf' exists\n" "P00 DETAIL: check '" TEST_PATH "/conf' exists\n"
"P00 DETAIL: create symlink '" TEST_PATH "/pg/pg_hba.conf' to '../conf/pg_hba.conf'"); "P00 DETAIL: create symlink '" TEST_PATH "/pg/pg_hba.conf' to '../conf/pg_hba.conf'");
TEST_SYSTEM_FMT("rm -rf %s/*", strZ(pgPath)); HRN_SYSTEM_FMT("rm -rf %s/*", strZ(pgPath));
storagePutP(storageNewWriteP(storagePgWrite(), PG_FILE_RECOVERYCONF_STR), NULL); storagePutP(storageNewWriteP(storagePgWrite(), PG_FILE_RECOVERYCONF_STR), NULL);
TEST_RESULT_VOID(restoreCleanBuild(manifest), "normal restore ignore recovery.conf"); TEST_RESULT_VOID(restoreCleanBuild(manifest), "normal restore ignore recovery.conf");
@ -1130,7 +1130,7 @@ testRun(void)
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("succeed when all directories empty and PG12 and preserve but no recovery files"); TEST_TITLE("succeed when all directories empty and PG12 and preserve but no recovery files");
TEST_SYSTEM_FMT("rm -rf %s/*", strZ(pgPath)); HRN_SYSTEM_FMT("rm -rf %s/*", strZ(pgPath));
manifest->pub.data.pgVersion = PG_VERSION_12; manifest->pub.data.pgVersion = PG_VERSION_12;
@ -1144,7 +1144,7 @@ testRun(void)
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("succeed when all directories empty and ignore PG12 recovery files"); TEST_TITLE("succeed when all directories empty and ignore PG12 recovery files");
TEST_SYSTEM_FMT("rm -rf %s/*", strZ(pgPath)); HRN_SYSTEM_FMT("rm -rf %s/*", strZ(pgPath));
manifestFileAdd(manifest, &(ManifestFile){.name = STRDEF(MANIFEST_TARGET_PGDATA "/" PG_FILE_POSTGRESQLAUTOCONF)}); manifestFileAdd(manifest, &(ManifestFile){.name = STRDEF(MANIFEST_TARGET_PGDATA "/" PG_FILE_POSTGRESQLAUTOCONF)});
@ -1163,7 +1163,7 @@ testRun(void)
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("succeed when all directories empty and PG12"); TEST_TITLE("succeed when all directories empty and PG12");
TEST_SYSTEM_FMT("rm -rf %s/*", strZ(pgPath)); HRN_SYSTEM_FMT("rm -rf %s/*", strZ(pgPath));
argList = strLstNew(); argList = strLstNew();
strLstAddZ(argList, "--stanza=test1"); strLstAddZ(argList, "--stanza=test1");
@ -1734,7 +1734,7 @@ testRun(void)
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("PG12 restore type none"); TEST_TITLE("PG12 restore type none");
TEST_SYSTEM_FMT("rm -rf %s/*", strZ(pgPath)); HRN_SYSTEM_FMT("rm -rf %s/*", strZ(pgPath));
storagePutP( storagePutP(
storageNewWriteP(storagePgWrite(), PG_FILE_POSTGRESQLAUTOCONF_STR), storageNewWriteP(storagePgWrite(), PG_FILE_POSTGRESQLAUTOCONF_STR),
@ -1757,7 +1757,7 @@ testRun(void)
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("PG12 restore type standby and remove existing recovery settings"); TEST_TITLE("PG12 restore type standby and remove existing recovery settings");
TEST_SYSTEM_FMT("rm -rf %s/*", strZ(pgPath)); HRN_SYSTEM_FMT("rm -rf %s/*", strZ(pgPath));
storagePutP( storagePutP(
storageNewWriteP(storagePgWrite(), PG_FILE_POSTGRESQLAUTOCONF_STR), storageNewWriteP(storagePgWrite(), PG_FILE_POSTGRESQLAUTOCONF_STR),
@ -1795,7 +1795,7 @@ testRun(void)
Manifest *manifest = testManifestMinimal(STRDEF("20161219-212741F"), PG_VERSION_12, STRDEF("/pg")); Manifest *manifest = testManifestMinimal(STRDEF("20161219-212741F"), PG_VERSION_12, STRDEF("/pg"));
TEST_SYSTEM_FMT("rm -rf %s/*", strZ(pgPath)); HRN_SYSTEM_FMT("rm -rf %s/*", strZ(pgPath));
storagePutP(storageNewWriteP(storagePgWrite(), PG_FILE_POSTGRESQLAUTOCONF_STR), BUFSTRDEF("# DO NOT MODIFY\n")); storagePutP(storageNewWriteP(storagePgWrite(), PG_FILE_POSTGRESQLAUTOCONF_STR), BUFSTRDEF("# DO NOT MODIFY\n"));
storagePutP(storageNewWriteP(storagePgWrite(), PG_FILE_STANDBYSIGNAL_STR), NULL); storagePutP(storageNewWriteP(storagePgWrite(), PG_FILE_STANDBYSIGNAL_STR), NULL);
@ -1818,7 +1818,7 @@ testRun(void)
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("PG12 restore type default"); TEST_TITLE("PG12 restore type default");
TEST_SYSTEM_FMT("rm -rf %s/*", strZ(pgPath)); HRN_SYSTEM_FMT("rm -rf %s/*", strZ(pgPath));
storagePutP( storagePutP(
storageNewWriteP(storagePgWrite(), PG_FILE_POSTGRESQLAUTOCONF_STR), storageNewWriteP(storagePgWrite(), PG_FILE_POSTGRESQLAUTOCONF_STR),
@ -2062,7 +2062,7 @@ testRun(void)
storagePutP(storageNewWriteP(storagePgWrite(), STRDEF("bogus-file")), NULL); storagePutP(storageNewWriteP(storagePgWrite(), STRDEF("bogus-file")), NULL);
// Add a special file that will be removed // Add a special file that will be removed
TEST_SYSTEM_FMT("mkfifo %s/pipe", strZ(pgPath)); HRN_SYSTEM_FMT("mkfifo %s/pipe", strZ(pgPath));
// Overwrite PG_VERSION with bogus content that will not be detected by delta force because the time and size are the same // Overwrite PG_VERSION with bogus content that will not be detected by delta force because the time and size are the same
storagePutP( storagePutP(
@ -2603,8 +2603,8 @@ testRun(void)
// Move pg1-path and put a link in its place. This tests that restore works when pg1-path is a symlink yet should be // Move pg1-path and put a link in its place. This tests that restore works when pg1-path is a symlink yet should be
// completely invisible in the manifest and logging. // completely invisible in the manifest and logging.
TEST_SYSTEM_FMT("mv %s %s-data", strZ(pgPath), strZ(pgPath)); HRN_SYSTEM_FMT("mv %s %s-data", strZ(pgPath), strZ(pgPath));
TEST_SYSTEM_FMT("ln -s %s-data %s ", strZ(pgPath), strZ(pgPath)); HRN_SYSTEM_FMT("ln -s %s-data %s ", strZ(pgPath), strZ(pgPath));
// Create the stanza archive pool path to check that it gets removed // Create the stanza archive pool path to check that it gets removed
HRN_STORAGE_PUT_EMPTY(storageSpoolWrite(), STORAGE_SPOOL_ARCHIVE "/empty.txt"); HRN_STORAGE_PUT_EMPTY(storageSpoolWrite(), STORAGE_SPOOL_ARCHIVE "/empty.txt");

View File

@ -98,7 +98,7 @@ testSuite(CompressType type, const char *decompressCmd)
TEST_TITLE("compressed output can be decompressed with command-line tool"); TEST_TITLE("compressed output can be decompressed with command-line tool");
storagePutP(storageNewWriteP(storageTest, STRDEF("test.cmp")), compressed); storagePutP(storageNewWriteP(storageTest, STRDEF("test.cmp")), compressed);
TEST_SYSTEM_FMT("%s " TEST_PATH "/test.cmp > " TEST_PATH "/test.out", decompressCmd); HRN_SYSTEM_FMT("%s " TEST_PATH "/test.cmp > " TEST_PATH "/test.out", decompressCmd);
TEST_RESULT_BOOL(bufEq(decompressed, storageGetP(storageNewReadP(storageTest, STRDEF("test.out")))), true, "check output"); TEST_RESULT_BOOL(bufEq(decompressed, storageGetP(storageNewReadP(storageTest, STRDEF("test.out")))), true, "check output");
TEST_RESULT_BOOL( TEST_RESULT_BOOL(

View File

@ -138,7 +138,7 @@ testRun(void)
const String *fileExists = STRDEF(TEST_PATH "/exists"); const String *fileExists = STRDEF(TEST_PATH "/exists");
const String *pathExists = STRDEF(TEST_PATH "/pathExists"); const String *pathExists = STRDEF(TEST_PATH "/pathExists");
TEST_RESULT_INT(system(strZ(strNewFmt("touch %s", strZ(fileExists)))), 0, "create exists file"); TEST_RESULT_INT(system(strZ(strNewFmt("touch %s", strZ(fileExists)))), 0, "create exists file");
TEST_SYSTEM_FMT("mkdir %s", strZ(pathExists)); HRN_SYSTEM_FMT("mkdir %s", strZ(pathExists));
TEST_RESULT_BOOL(storageExistsP(storageTest, fileExists), true, "file exists"); TEST_RESULT_BOOL(storageExistsP(storageTest, fileExists), true, "file exists");
TEST_RESULT_BOOL(storageExistsP(storageTest, pathExists), false, "not a file"); TEST_RESULT_BOOL(storageExistsP(storageTest, pathExists), false, "not a file");

View File

@ -147,7 +147,7 @@ testRun(void)
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("special info"); TEST_TITLE("special info");
TEST_SYSTEM_FMT("mkfifo -m 666 %s", strZ(storagePathP(storageTest, STRDEF("repo/fifo")))); HRN_SYSTEM_FMT("mkfifo -m 666 %s", strZ(storagePathP(storageTest, STRDEF("repo/fifo"))));
TEST_ASSIGN(info, storageInfoP(storageRemote, STRDEF("fifo")), "valid fifo"); TEST_ASSIGN(info, storageInfoP(storageRemote, STRDEF("fifo")), "valid fifo");
TEST_RESULT_STR(info.name, NULL, " name is not set"); TEST_RESULT_STR(info.name, NULL, " name is not set");
@ -164,7 +164,7 @@ testRun(void)
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("link info"); TEST_TITLE("link info");
TEST_SYSTEM_FMT("ln -s ../repo/test %s", strZ(storagePathP(storageTest, STRDEF("repo/link")))); HRN_SYSTEM_FMT("ln -s ../repo/test %s", strZ(storagePathP(storageTest, STRDEF("repo/link"))));
TEST_ASSIGN(info, storageInfoP(storageRemote, STRDEF("link")), "valid link"); TEST_ASSIGN(info, storageInfoP(storageRemote, STRDEF("link")), "valid link");
TEST_RESULT_STR(info.name, NULL, " name is not set"); TEST_RESULT_STR(info.name, NULL, " name is not set");