1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-12 10:04:14 +02:00

Replace system() in tests with HRN_SYSTEM*().

This commit is contained in:
David Steele 2021-05-22 15:07:18 -04:00
parent bd40156c22
commit e5e0b21196
10 changed files with 91 additions and 108 deletions

View File

@ -87,10 +87,10 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_VOID(storageRemoveP(hrnStorage, STRDEF("lockpath/all" STOP_FILE_EXT)), "remove stop file");
TEST_RESULT_INT(system(strZ(strNewFmt("chmod 444 %s", strZ(lockPath)))), 0, "change perms");
HRN_SYSTEM_FMT("chmod 444 %s", strZ(lockPath));
TEST_ERROR_FMT(
cmdStop(), FileOpenError, "unable to get info for path/file '%s/all.stop': [13] Permission denied", strZ(lockPath));
TEST_RESULT_INT(system(strZ(strNewFmt("chmod 700 %s", strZ(lockPath)))), 0, "change perms");
HRN_SYSTEM_FMT("chmod 700 %s", strZ(lockPath));
TEST_RESULT_VOID(
storagePathRemoveP(hrnStorage, lockPath, .recurse = true, .errorOnMissing = true), " remove the lock path");

View File

@ -363,18 +363,18 @@ testRun(void)
//--------------------------------------------------------------------------------------------------------------------------
String *archiveDb1_1 = strNewFmt("%s/9.4-1/0000000100000000", strZ(archiveStanza1Path));
TEST_RESULT_VOID(storagePathCreateP(storageLocalWrite(), archiveDb1_1), "create db1 archive WAL1 directory");
TEST_RESULT_INT(system(
strZ(strNewFmt("touch %s", strZ(strNewFmt("%s/000000010000000000000002-ac61b8f1ec7b1e6c3eaee9345214595eb7daa9a1.gz",
strZ(archiveDb1_1)))))), 0, "touch WAL1 file");
TEST_RESULT_INT(system(
strZ(strNewFmt("touch %s", strZ(strNewFmt("%s/000000010000000000000003-37dff2b7552a9d66e4bae1a762488a6885e7082c.gz",
strZ(archiveDb1_1)))))), 0, "touch WAL1 file");
HRN_SYSTEM_FMT(
"touch %s",
strZ(strNewFmt("%s/000000010000000000000002-ac61b8f1ec7b1e6c3eaee9345214595eb7daa9a1.gz", strZ(archiveDb1_1))));
HRN_SYSTEM_FMT(
"touch %s",
strZ(strNewFmt("%s/000000010000000000000003-37dff2b7552a9d66e4bae1a762488a6885e7082c.gz", strZ(archiveDb1_1))));
String *archiveDb1_2 = strNewFmt("%s/9.4-1/0000000200000000", strZ(archiveStanza1Path));
TEST_RESULT_VOID(storagePathCreateP(storageLocalWrite(), archiveDb1_2), "create db1 archive WAL2 directory");
TEST_RESULT_INT(system(
strZ(strNewFmt("touch %s", strZ(strNewFmt("%s/000000020000000000000003-37dff2b7552a9d66e4bae1a762488a6885e7082c.gz",
strZ(archiveDb1_2)))))), 0, "touch WAL2 file");
HRN_SYSTEM_FMT(
"touch %s",
strZ(strNewFmt("%s/000000020000000000000003-37dff2b7552a9d66e4bae1a762488a6885e7082c.gz", strZ(archiveDb1_2))));
String *archiveDb1_3 = strNewFmt("%s/9.4-1/0000000300000000", strZ(archiveStanza1Path));
TEST_RESULT_VOID(storagePathCreateP(storageLocalWrite(), archiveDb1_3), "create db1 archive WAL3 directory");
@ -384,9 +384,9 @@ testRun(void)
storagePutP(storageNewWriteP(storageLocalWrite(), archiveDb3Wal), bufNew(0)), "create db3 archive WAL3 file");
// Create a WAL file in 9.3-2 so that a prior will show
TEST_RESULT_INT(system(
strZ(strNewFmt("touch %s", strZ(strNewFmt("%s/000000010000000000000001-ac61b8f1ec7b1e6c3eaee9345214595eb7daa9a1.gz",
strZ(archiveDb2_1)))))), 0, "touch WAL1 file in prior");
HRN_SYSTEM_FMT(
"touch %s",
strZ(strNewFmt("%s/000000010000000000000001-ac61b8f1ec7b1e6c3eaee9345214595eb7daa9a1.gz", strZ(archiveDb2_1))));
harnessCfgLoad(cfgCmdInfo, argList);
content = STRDEF
@ -934,27 +934,27 @@ testRun(void)
// Add WAL on repo1 and encrypted repo2 for stanza1
String *archive1Db1_1 = strNewFmt("%s/9.5-2/0000000100000000", strZ(archiveStanza1Path));
TEST_RESULT_VOID(storagePathCreateP(storageLocalWrite(), archive1Db1_1), "create db1 archive WAL directory, repo1");
TEST_RESULT_INT(system(
strZ(strNewFmt("touch %s", strZ(strNewFmt("%s/000000010000000000000002-ac61b8f1ec7b1e6c3eaee9345214595eb7daa9a1.gz",
strZ(archive1Db1_1)))))), 0, "touch WAL file, repo1");
TEST_RESULT_INT(system(
strZ(strNewFmt("touch %s", strZ(strNewFmt("%s/000000010000000000000003-37dff2b7552a9d66e4bae1a762488a6885e7082c.gz",
strZ(archive1Db1_1)))))), 0, "touch WAL file, repo1");
TEST_RESULT_INT(system(
strZ(strNewFmt("touch %s", strZ(strNewFmt("%s/000000010000000000000004-ee61b8f1ec7b1e6c3eaee9345214595eb7daa9a1.gz",
strZ(archive1Db1_1)))))), 0, "touch WAL file, repo1");
TEST_RESULT_INT(system(
strZ(strNewFmt("touch %s", strZ(strNewFmt("%s/000000010000000000000005-abc123f1ec7b1e6c3eaee9345214595eb7daa9a1.gz",
strZ(archive1Db1_1)))))), 0, "touch WAL file, repo1");
HRN_SYSTEM_FMT(
"touch %s",
strZ(strNewFmt("%s/000000010000000000000002-ac61b8f1ec7b1e6c3eaee9345214595eb7daa9a1.gz", strZ(archive1Db1_1))));
HRN_SYSTEM_FMT(
"touch %s",
strZ(strNewFmt("%s/000000010000000000000003-37dff2b7552a9d66e4bae1a762488a6885e7082c.gz", strZ(archive1Db1_1))));
HRN_SYSTEM_FMT(
"touch %s",
strZ(strNewFmt("%s/000000010000000000000004-ee61b8f1ec7b1e6c3eaee9345214595eb7daa9a1.gz", strZ(archive1Db1_1))));
HRN_SYSTEM_FMT(
"touch %s",
strZ(strNewFmt("%s/000000010000000000000005-abc123f1ec7b1e6c3eaee9345214595eb7daa9a1.gz", strZ(archive1Db1_1))));
String *archive2Db1_1 = strNewFmt("%s/stanza1/9.5-1/0000000100000000", strZ(repo2archivePath));
TEST_RESULT_VOID(storagePathCreateP(storageLocalWrite(), archive2Db1_1), "create db1 archive WAL directory, repo2");
TEST_RESULT_INT(system(
strZ(strNewFmt("touch %s", strZ(strNewFmt("%s/000000010000000000000003-37dff2b7552a9d66e4bae1a762488a6885e7082c.gz",
strZ(archive2Db1_1)))))), 0, "touch WAL file, repo2");
TEST_RESULT_INT(system(
strZ(strNewFmt("touch %s", strZ(strNewFmt("%s/000000010000000000000004-ff61b8f1ec7b1e6c3eaee9345214595eb7daa9a1.gz",
strZ(archive2Db1_1)))))), 0, "touch WAL file, repo2");
HRN_SYSTEM_FMT(
"touch %s",
strZ(strNewFmt("%s/000000010000000000000003-37dff2b7552a9d66e4bae1a762488a6885e7082c.gz", strZ(archive2Db1_1))));
HRN_SYSTEM_FMT(
"touch %s",
strZ(strNewFmt("%s/000000010000000000000004-ff61b8f1ec7b1e6c3eaee9345214595eb7daa9a1.gz", strZ(archive2Db1_1))));
// Add a manifest on the encrypted repo2
#define TEST_MANIFEST_HEADER2 \
@ -1067,12 +1067,12 @@ testRun(void)
archive2Db1_1 = strNewFmt("%s/stanza3/9.4-1/0000000100000000", strZ(repo2archivePath));
TEST_RESULT_VOID(storagePathCreateP(storageLocalWrite(), archive2Db1_1), "create db1 archive WAL directory, repo2");
TEST_RESULT_INT(system(
strZ(strNewFmt("touch %s", strZ(strNewFmt("%s/000000010000000000000001-11dff2b7552a9d66e4bae1a762488a6885e7082c.gz",
strZ(archive2Db1_1)))))), 0, "touch WAL file, repo2");
TEST_RESULT_INT(system(
strZ(strNewFmt("touch %s", strZ(strNewFmt("%s/000000010000000000000002-2261b8f1ec7b1e6c3eaee9345214595eb7daa9a1.gz",
strZ(archive2Db1_1)))))), 0, "touch WAL file, repo2");
HRN_SYSTEM_FMT(
"touch %s",
strZ(strNewFmt("%s/000000010000000000000001-11dff2b7552a9d66e4bae1a762488a6885e7082c.gz", strZ(archive2Db1_1))));
HRN_SYSTEM_FMT(
"touch %s",
strZ(strNewFmt("%s/000000010000000000000002-2261b8f1ec7b1e6c3eaee9345214595eb7daa9a1.gz", strZ(archive2Db1_1))));
// Set up the configuration
StringList *argListMultiRepo = strLstNew();
@ -2543,12 +2543,12 @@ testRun(void)
String *walPath = strNewFmt("%s/9.4-1/0000000100000000", strZ(archiveStanza1Path));
TEST_RESULT_VOID(storagePathCreateP(storageLocalWrite(), walPath), "create stanza1, repo1, archive directory");
TEST_RESULT_INT(system(
strZ(strNewFmt("touch %s", strZ(strNewFmt("%s/000000010000000000000002-22dff2b7552a9d66e4bae1a762488a6885e7082c.gz",
strZ(walPath)))))), 0, "touch WAL file, stanza1, repo1");
TEST_RESULT_INT(system(
strZ(strNewFmt("touch %s", strZ(strNewFmt("%s/000000010000000000000003-37dff2b7552a9d66e4bae1a762488a6885e7082c.gz",
strZ(walPath)))))), 0, "touch WAL file, stanza1, repo1");
HRN_SYSTEM_FMT(
"touch %s",
strZ(strNewFmt("%s/000000010000000000000002-22dff2b7552a9d66e4bae1a762488a6885e7082c.gz", strZ(walPath))));
HRN_SYSTEM_FMT(
"touch %s",
strZ(strNewFmt("%s/000000010000000000000003-37dff2b7552a9d66e4bae1a762488a6885e7082c.gz", strZ(walPath))));
content = STRDEF
(
@ -2599,12 +2599,12 @@ testRun(void)
walPath = strNewFmt("%s/stanza1/9.5-1/0000000100000000", strZ(archivePath2));
TEST_RESULT_VOID(storagePathCreateP(storageLocalWrite(), walPath), "create stanza1, repo2, archive directory");
TEST_RESULT_INT(system(
strZ(strNewFmt("touch %s", strZ(strNewFmt("%s/000000010000000000000001-11dff2b7552a9d66e4bae1a762488a6885e7082c.gz",
strZ(walPath)))))), 0, "touch WAL file, stanza1, repo2");
TEST_RESULT_INT(system(
strZ(strNewFmt("touch %s", strZ(strNewFmt("%s/000000010000000000000002-222ff2b7552a9d66e4bae1a762488a6885e7082c.gz",
strZ(walPath)))))), 0, "touch WAL file, stanza1, repo2");
HRN_SYSTEM_FMT(
"touch %s",
strZ(strNewFmt("%s/000000010000000000000001-11dff2b7552a9d66e4bae1a762488a6885e7082c.gz", strZ(walPath))));
HRN_SYSTEM_FMT(
"touch %s",
strZ(strNewFmt("%s/000000010000000000000002-222ff2b7552a9d66e4bae1a762488a6885e7082c.gz", strZ(walPath))));
StringList *argList2 = strLstNew();
hrnCfgArgRawZ(argList2, cfgOptRepoPath, TEST_PATH_REPO);

View File

@ -105,8 +105,8 @@ testRun(void)
storagePutP(storageNewWriteP(storageTest, STRDEF("repo/aaa"), .timeModified = 1578671569), BUFSTRDEF("TESTDATA"));
storagePutP(storageNewWriteP(storageTest, STRDEF("repo/bbb/ccc")), BUFSTRDEF("TESTDATA2"));
ASSERT(system("ln -s ../bbb " TEST_PATH "/repo/link") == 0);
ASSERT(system("mkfifo " TEST_PATH "/repo/pipe") == 0);
HRN_SYSTEM("ln -s ../bbb " TEST_PATH "/repo/link");
HRN_SYSTEM("mkfifo " TEST_PATH "/repo/pipe");
output = bufNew(0);
cfgOptionSet(cfgOptOutput, cfgSourceParam, VARSTRDEF("text"));

View File

@ -241,12 +241,9 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
// Add test hosts
#ifdef TEST_CONTAINER_REQUIRED
if (system( // {uncoverable_branch}
"echo \"127.0.0.1 test.pgbackrest.org host.test2.pgbackrest.org test3.pgbackrest.org\" |"
" sudo tee -a /etc/hosts > /dev/null") != 0)
{
THROW(AssertError, "unable to add test hosts to /etc/hosts"); // {uncovered+}
}
HRN_SYSTEM(
"echo \"127.0.0.1 test.pgbackrest.org host.test2.pgbackrest.org test3.pgbackrest.org\" | sudo tee -a /etc/hosts >"
" /dev/null");
HARNESS_FORK_BEGIN()
{

View File

@ -23,7 +23,7 @@ testRun(void)
const String *archiveLock = STRDEF(TEST_PATH "/main-archive" LOCK_FILE_EXT);
int lockFdTest = -1;
TEST_RESULT_INT(system(strZ(strNewFmt("touch %s", strZ(archiveLock)))), 0, "touch lock file");
HRN_SYSTEM_FMT("touch %s", strZ(archiveLock));
TEST_ASSIGN(lockFdTest, lockAcquireFile(archiveLock, STRDEF("1-test"), 0, true), "get lock");
TEST_RESULT_BOOL(lockFdTest != -1, true, "lock succeeds");
TEST_RESULT_BOOL(storageExistsP(storageTest, archiveLock), true, "lock file was created");
@ -42,7 +42,7 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("fail file lock on the same exec-id when lock file is empty");
TEST_RESULT_INT(system(strZ(strNewFmt("echo '' > %s", strZ(archiveLock)))), 0, "overwrite lock file");
HRN_SYSTEM_FMT("echo '' > %s", strZ(archiveLock));
TEST_ERROR(lockAcquireFile(archiveLock, STRDEF("2-test"), 0, true), LockAcquireError,
strZ(
@ -69,7 +69,7 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
const String *dirLock = STRDEF(TEST_PATH "/dir" LOCK_FILE_EXT);
TEST_RESULT_INT(system(strZ(strNewFmt("mkdir -p 750 %s", strZ(dirLock)))), 0, "create dirtest.lock dir");
HRN_SYSTEM_FMT("mkdir -p 750 %s", strZ(dirLock));
TEST_ERROR(
lockAcquireFile(dirLock, STRDEF("1-test"), 0, true), LockAcquireError,
@ -77,8 +77,8 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
const String *noPermLock = STRDEF(TEST_PATH "/noperm/noperm");
TEST_RESULT_INT(system(strZ(strNewFmt("mkdir -p 750 %s", strZ(strPath(noPermLock))))), 0, "create noperm dir");
TEST_RESULT_INT(system(strZ(strNewFmt("chmod 000 %s", strZ(strPath(noPermLock))))), 0, "chmod noperm dir");
HRN_SYSTEM_FMT("mkdir -p 750 %s", strZ(strPath(noPermLock)));
HRN_SYSTEM_FMT("chmod 000 %s", strZ(strPath(noPermLock)));
TEST_ERROR(
lockAcquireFile(noPermLock, STRDEF("1-test"), 100, true), LockAcquireError,

View File

@ -474,9 +474,7 @@ testRun(void)
// Copy the configFile to pgbackrest.conf (default is /etc/pgbackrest/pgbackrest.conf and new value is testPath so copy the
// config file (that was not read in the previous test) to pgbackrest.conf so it will be read by the override
TEST_RESULT_INT(
system(strZ(strNewFmt("cp %s " TEST_PATH "/pgbackrest.conf", strZ(configFile)))), 0,
"copy configFile to pgbackrest.conf");
HRN_SYSTEM_FMT("cp %s " TEST_PATH "/pgbackrest.conf", strZ(configFile));
parseOptionList[cfgOptConfig].indexList[0].found = false;
parseOptionList[cfgOptConfig].indexList[0].source = cfgSourceDefault;
@ -509,7 +507,7 @@ testRun(void)
// config default and config-include-path passed - but no config files in the include path - only in the default path
// rm command is split below because code counter is confused by what looks like a comment.
//--------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_INT(system(strZ(strNewFmt("rm -rf %s/" "*", strZ(configIncludePath)))), 0, "remove all include files");
HRN_SYSTEM_FMT("rm -rf %s/" "*", strZ(configIncludePath));
value = strLstNew();
strLstAdd(value, configIncludePath);
@ -529,9 +527,7 @@ testRun(void)
// config default and config-include-path passed - only empty file in the include path and nothing in either config defaults
//--------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_INT(
system(strZ(strNewFmt("touch %s", strZ(strNewFmt("%s/empty.conf", strZ(configIncludePath)))))), 0,
"add empty conf file to include directory");
HRN_SYSTEM_FMT("touch %s/empty.conf", strZ(configIncludePath));
value = strLstNew();
strLstAdd(value, configIncludePath);

View File

@ -196,7 +196,7 @@ testRun(void)
// Create special file
const String *const specialFile = STRDEF(TEST_PATH "/pg/testpipe");
TEST_RESULT_INT(system(strZ(strNewFmt("mkfifo -m 666 %s", strZ(specialFile)))), 0, "create pipe");
HRN_SYSTEM_FMT("mkfifo -m 666 %s", strZ(specialFile));
// Files that will always be ignored
storagePutP(

View File

@ -29,14 +29,9 @@ testRun(void)
// Create and start the test database
// -------------------------------------------------------------------------------------------------------------------------
#ifdef HARNESS_PQ_REAL
if (system("sudo pg_createcluster 11 test") != 0)
THROW(AssertError, "unable to create cluster");
if (system("sudo pg_ctlcluster 11 test start") != 0)
THROW(AssertError, "unable to start cluster");
if (system("sudo -u postgres psql -c 'create user " TEST_USER " superuser'") != 0)
THROW(AssertError, "unable to create superuser");
HRN_SYSTEM("sudo pg_createcluster 11 test");
HRN_SYSTEM("sudo pg_ctlcluster 11 test start");
HRN_SYSTEM("sudo -u postgres psql -c 'create user " TEST_USER " superuser'");
#endif
// Test connection error

View File

@ -30,11 +30,8 @@ storageTestPathExpression(const String *expression, const String *path)
Macro to create a path and file that cannot be accessed
***********************************************************************************************************************************/
#define TEST_CREATE_NOPERM() \
TEST_RESULT_INT( \
system( \
strZ(strNewFmt("sudo mkdir -m 700 %s && sudo touch %s && sudo chmod 600 %s", strZ(pathNoPerm), strZ(fileNoPerm), \
strZ(fileNoPerm)))), \
0, "create no perm path/file");
HRN_SYSTEM_FMT( \
"sudo mkdir -m 700 %s && sudo touch %s && sudo chmod 600 %s", strZ(pathNoPerm), strZ(fileNoPerm), strZ(fileNoPerm))
/***********************************************************************************************************************************
Test Run
@ -137,13 +134,13 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
const String *fileExists = STRDEF(TEST_PATH "/exists");
const String *pathExists = STRDEF(TEST_PATH "/pathExists");
TEST_RESULT_INT(system(strZ(strNewFmt("touch %s", strZ(fileExists)))), 0, "create exists file");
HRN_SYSTEM_FMT("touch %s", strZ(fileExists));
HRN_SYSTEM_FMT("mkdir %s", strZ(pathExists));
TEST_RESULT_BOOL(storageExistsP(storageTest, fileExists), true, "file exists");
TEST_RESULT_BOOL(storageExistsP(storageTest, pathExists), false, "not a file");
TEST_RESULT_BOOL(storagePathExistsP(storageTest, fileExists), false, "not a path");
TEST_RESULT_INT(system(strZ(strNewFmt("rm %s", strZ(fileExists)))), 0, "remove exists file");
HRN_SYSTEM_FMT("rm %s", strZ(fileExists));
// -------------------------------------------------------------------------------------------------------------------------
HARNESS_FORK_BEGIN()
@ -151,7 +148,7 @@ testRun(void)
HARNESS_FORK_CHILD_BEGIN(0, false)
{
sleepMSec(250);
TEST_RESULT_INT(system(strZ(strNewFmt("touch %s", strZ(fileExists)))), 0, "create exists file");
HRN_SYSTEM_FMT("touch %s", strZ(fileExists));
}
HARNESS_FORK_CHILD_END();
@ -163,7 +160,7 @@ testRun(void)
}
HARNESS_FORK_END();
TEST_RESULT_INT(system(strZ(strNewFmt("rm %s", strZ(fileExists)))), 0, "remove exists file");
HRN_SYSTEM_FMT("rm %s", strZ(fileExists));
}
// *****************************************************************************************************************************
@ -226,7 +223,7 @@ testRun(void)
HRN_STORAGE_TIME(storageTest, strZ(fileName), 1555155555);
#ifdef TEST_CONTAINER_REQUIRED
TEST_RESULT_INT(system(strZ(strNewFmt("sudo chown 99999:99999 %s", strZ(fileName)))), 0, "set invalid user/group");
HRN_SYSTEM_FMT("sudo chown 99999:99999 %s", strZ(fileName));
#endif // TEST_CONTAINER_REQUIRED
TEST_ASSIGN(info, storageInfoP(storageTest, fileName), "get file info");
@ -246,7 +243,7 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
const String *linkName = STRDEF(TEST_PATH "/testlink");
TEST_RESULT_INT(system(strZ(strNewFmt("ln -s /tmp %s", strZ(linkName)))), 0, "create link");
HRN_SYSTEM_FMT("ln -s /tmp %s", strZ(linkName));
TEST_ASSIGN(info, storageInfoP(storageTest, linkName), "get link info");
TEST_RESULT_STR(info.name, NULL, " name is not set");
@ -272,7 +269,7 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
const String *pipeName = STRDEF(TEST_PATH "/testpipe");
TEST_RESULT_INT(system(strZ(strNewFmt("mkfifo -m 666 %s", strZ(pipeName)))), 0, "create pipe");
HRN_SYSTEM_FMT("mkfifo -m 666 %s", strZ(pipeName));
TEST_ASSIGN(info, storageInfoP(storageTest, pipeName), "get info from pipe (special file)");
TEST_RESULT_STR(info.name, NULL, " name is not set");
@ -339,13 +336,13 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
#ifdef TEST_CONTAINER_REQUIRED
storagePathCreateP(storageTest, STRDEF("pg/.include"), .mode = 0755);
ASSERT(system(strZ(strNewFmt("sudo chown 77777:77777 %s/pg/.include", TEST_PATH))) == 0);
HRN_SYSTEM("sudo chown 77777:77777 " TEST_PATH "/pg/.include");
#endif // TEST_CONTAINER_REQUIRED
storagePutP(storageNewWriteP(storageTest, STRDEF("pg/file"), .modeFile = 0660), BUFSTRDEF("TESTDATA"));
ASSERT(system(strZ(strNewFmt("ln -s ../file %s/pg/link", TEST_PATH))) == 0);
ASSERT(system(strZ(strNewFmt("mkfifo -m 777 %s/pg/pipe", TEST_PATH))) == 0);
HRN_SYSTEM("ln -s ../file " TEST_PATH "/pg/link");
HRN_SYSTEM("mkfifo -m 777 " TEST_PATH "/pg/pipe");
callbackData = (HarnessStorageInfoListCallbackData)
{
@ -373,7 +370,7 @@ testRun(void)
" check content");
#ifdef TEST_CONTAINER_REQUIRED
ASSERT(system(strZ(strNewFmt("sudo rmdir %s/pg/.include", TEST_PATH))) == 0);
HRN_SYSTEM("sudo rmdir " TEST_PATH "/pg/.include");
#endif // TEST_CONTAINER_REQUIRED
// -------------------------------------------------------------------------------------------------------------------------
@ -645,7 +642,7 @@ testRun(void)
"unable to create path '" TEST_PATH "/sub3/sub4': [2] No such file or directory");
TEST_RESULT_VOID(storagePathCreateP(storageTest, STRDEF("sub3/sub4")), "create sub3/sub4");
TEST_RESULT_INT(system(strZ(strNewFmt("rm -rf %s/sub*", TEST_PATH))), 0, "remove sub paths");
HRN_SYSTEM("rm -rf " TEST_PATH "/sub*");
}
// *****************************************************************************************************************************
@ -664,7 +661,7 @@ testRun(void)
#ifdef TEST_CONTAINER_REQUIRED
TEST_RESULT_INT(system(strZ(strNewFmt("sudo mkdir -p -m 700 %s", strZ(pathRemove2)))), 0, "create noperm paths");
HRN_SYSTEM_FMT("sudo mkdir -p -m 700 %s", strZ(pathRemove2));
TEST_ERROR_FMT(
storagePathRemoveP(storageTest, pathRemove2), PathRemoveError, STORAGE_ERROR_PATH_REMOVE ": [13] Permission denied",
@ -674,7 +671,7 @@ testRun(void)
STORAGE_ERROR_LIST_INFO ": [13] Permission denied", strZ(pathRemove2));
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_INT(system(strZ(strNewFmt("sudo chmod 777 %s", strZ(pathRemove1)))), 0, "top path can be removed");
HRN_SYSTEM_FMT("sudo chmod 777 %s", strZ(pathRemove1));
TEST_ERROR_FMT(
storagePathRemoveP(storageTest, pathRemove2, .recurse = true), PathOpenError,
@ -683,17 +680,15 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
String *fileRemove = strNewFmt("%s/remove.txt", strZ(pathRemove2));
TEST_RESULT_INT(
system(strZ(strNewFmt(
"sudo chmod 755 %s && sudo touch %s && sudo chmod 777 %s", strZ(pathRemove2), strZ(fileRemove), strZ(fileRemove)))),
0, "add no perm file");
HRN_SYSTEM_FMT(
"sudo chmod 755 %s && sudo touch %s && sudo chmod 777 %s", strZ(pathRemove2), strZ(fileRemove), strZ(fileRemove));
TEST_ERROR_FMT(
storagePathRemoveP(storageTest, pathRemove1, .recurse = true), PathRemoveError,
STORAGE_ERROR_PATH_REMOVE_FILE ": [13] Permission denied", strZ(fileRemove));
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_INT(system(strZ(strNewFmt("sudo chmod 777 %s", strZ(pathRemove2)))), 0, "bottom path can be removed");
HRN_SYSTEM_FMT("sudo chmod 777 %s", strZ(pathRemove2));
TEST_RESULT_VOID(
storagePathRemoveP(storageTest, pathRemove1, .recurse = true), "remove path");
@ -702,7 +697,7 @@ testRun(void)
#endif // TEST_CONTAINER_REQUIRED
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_INT(system(strZ(strNewFmt("mkdir -p %s", strZ(pathRemove2)))), 0, "create subpaths");
HRN_SYSTEM_FMT("mkdir -p %s", strZ(pathRemove2));
TEST_RESULT_VOID(
storagePathRemoveP(storageTest, pathRemove1, .recurse = true), "remove path");
@ -747,7 +742,7 @@ testRun(void)
TEST_ERROR_FMT(ioReadOpen(storageReadIo(file)), FileMissingError, STORAGE_ERROR_READ_MISSING, strZ(fileName));
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_INT(system(strZ(strNewFmt("touch %s", strZ(fileName)))), 0, "create read file");
HRN_SYSTEM_FMT("touch %s", strZ(fileName));
TEST_RESULT_BOOL(ioReadOpen(storageReadIo(file)), true, " open file");
TEST_RESULT_INT(ioReadFd(storageReadIo(file)), ((StorageReadPosix *)file->driver)->fd, "check read fd");
@ -884,7 +879,7 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
const String *fileExists = STRDEF(TEST_PATH "/exists");
TEST_RESULT_INT(system(strZ(strNewFmt("touch %s", strZ(fileExists)))), 0, "create exists file");
HRN_SYSTEM_FMT("touch %s", strZ(fileExists));
TEST_RESULT_VOID(storageRemoveP(storageTest, fileExists), "remove exists file");

View File

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