1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-17 01:12:23 +02:00

Convert storagePosixNew() to storagePosixNewP().

An upcoming feature requires new parameters for storagePosixNew() and this causes a lot of churn because almost every test creates a Posix storage object. Some refactoring in the tests might reduce this duplication but storagePosixNew() is collecting a lot of parameters so converting to storagePosixNewP() makes sense in any case.

There are relatively few call sites in the core code but they still benefit from better readability after this change.
This commit is contained in:
David Steele
2020-04-30 11:01:38 -04:00
parent baf8cb9068
commit 22ba1f02ce
26 changed files with 67 additions and 87 deletions

View File

@ -132,8 +132,7 @@ storageLocal(void)
MEM_CONTEXT_BEGIN(storageHelper.memContext) MEM_CONTEXT_BEGIN(storageHelper.memContext)
{ {
storageHelper.storageLocal = storagePosixNew( storageHelper.storageLocal = storagePosixNewP(FSLASH_STR);
FSLASH_STR, STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, false, NULL);
} }
MEM_CONTEXT_END(); MEM_CONTEXT_END();
} }
@ -152,8 +151,7 @@ storageLocalWrite(void)
MEM_CONTEXT_BEGIN(storageHelper.memContext) MEM_CONTEXT_BEGIN(storageHelper.memContext)
{ {
storageHelper.storageLocalWrite = storagePosixNew( storageHelper.storageLocalWrite = storagePosixNewP(FSLASH_STR, .write = true);
FSLASH_STR, STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL);
} }
MEM_CONTEXT_END(); MEM_CONTEXT_END();
} }
@ -184,8 +182,7 @@ storagePgGet(unsigned int hostId, bool write)
// Use Posix storage // Use Posix storage
else else
{ {
result = storagePosixNew( result = storagePosixNewP(cfgOptionStr(cfgOptPgPath + hostId - 1), .write = write);
cfgOptionStr(cfgOptPgPath + hostId - 1), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, write, NULL);
} }
FUNCTION_TEST_RETURN(result); FUNCTION_TEST_RETURN(result);
@ -362,8 +359,8 @@ storageRepoGet(const String *type, bool write)
// Use Posix storage // Use Posix storage
else if (strEqZ(type, STORAGE_TYPE_POSIX)) else if (strEqZ(type, STORAGE_TYPE_POSIX))
{ {
result = storagePosixNew( result = storagePosixNewP(
cfgOptionStr(cfgOptRepoPath), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, write, storageRepoPathExpression); cfgOptionStr(cfgOptRepoPath), .write = write, .pathExpressionFunction = storageRepoPathExpression);
} }
// Use S3 storage // Use S3 storage
else if (strEqZ(type, STORAGE_TYPE_S3)) else if (strEqZ(type, STORAGE_TYPE_S3))
@ -488,9 +485,8 @@ storageSpool(void)
MEM_CONTEXT_BEGIN(storageHelper.memContext) MEM_CONTEXT_BEGIN(storageHelper.memContext)
{ {
storageHelper.storageSpool = storagePosixNew( storageHelper.storageSpool = storagePosixNewP(
cfgOptionStr(cfgOptSpoolPath), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, false, cfgOptionStr(cfgOptSpoolPath), .pathExpressionFunction = storageSpoolPathExpression);
storageSpoolPathExpression);
} }
MEM_CONTEXT_END(); MEM_CONTEXT_END();
} }
@ -514,9 +510,8 @@ storageSpoolWrite(void)
MEM_CONTEXT_BEGIN(storageHelper.memContext) MEM_CONTEXT_BEGIN(storageHelper.memContext)
{ {
storageHelper.storageSpoolWrite = storagePosixNew( storageHelper.storageSpoolWrite = storagePosixNewP(
cfgOptionStr(cfgOptSpoolPath), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, cfgOptionStr(cfgOptSpoolPath), .write = true, .pathExpressionFunction = storageSpoolPathExpression);
storageSpoolPathExpression);
} }
MEM_CONTEXT_END(); MEM_CONTEXT_END();
} }

View File

@ -614,17 +614,19 @@ storagePosixNewInternal(
} }
Storage * Storage *
storagePosixNew( storagePosixNew(const String *path, StoragePosixNewParam param)
const String *path, mode_t modeFile, mode_t modePath, bool write, StoragePathExpressionCallback pathExpressionFunction)
{ {
FUNCTION_LOG_BEGIN(logLevelDebug); FUNCTION_LOG_BEGIN(logLevelDebug);
FUNCTION_LOG_PARAM(STRING, path); FUNCTION_LOG_PARAM(STRING, path);
FUNCTION_LOG_PARAM(MODE, modeFile); FUNCTION_LOG_PARAM(MODE, param.modeFile);
FUNCTION_LOG_PARAM(MODE, modePath); FUNCTION_LOG_PARAM(MODE, param.modePath);
FUNCTION_LOG_PARAM(BOOL, write); FUNCTION_LOG_PARAM(BOOL, param.write);
FUNCTION_LOG_PARAM(FUNCTIONP, pathExpressionFunction); FUNCTION_LOG_PARAM(FUNCTIONP, param.pathExpressionFunction);
FUNCTION_LOG_END(); FUNCTION_LOG_END();
FUNCTION_LOG_RETURN( FUNCTION_LOG_RETURN(
STORAGE, storagePosixNewInternal(STORAGE_POSIX_TYPE_STR, path, modeFile, modePath, write, pathExpressionFunction, true)); STORAGE,
storagePosixNewInternal(
STORAGE_POSIX_TYPE_STR, path, param.modeFile == 0 ? STORAGE_MODE_FILE_DEFAULT : param.modeFile,
param.modePath == 0 ? STORAGE_MODE_PATH_DEFAULT : param.modePath, param.write, param.pathExpressionFunction, true));
} }

View File

@ -20,7 +20,18 @@ Storage type
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Constructors Constructors
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
Storage *storagePosixNew( typedef struct StoragePosixNewParam
const String *path, mode_t modeFile, mode_t modePath, bool write, StoragePathExpressionCallback pathExpressionFunction); {
VAR_PARAM_HEADER;
bool write;
mode_t modeFile;
mode_t modePath;
StoragePathExpressionCallback *pathExpressionFunction;
} StoragePosixNewParam;
#define storagePosixNewP(path, ...) \
storagePosixNew(path, (StoragePosixNewParam){VAR_PARAM_INIT, __VA_ARGS__})
Storage *storagePosixNew(const String *path, StoragePosixNewParam param);
#endif #endif

View File

@ -18,8 +18,7 @@ testRun(void)
FUNCTION_HARNESS_VOID(); FUNCTION_HARNESS_VOID();
// Create default storage object for testing // Create default storage object for testing
Storage *storageTest = storagePosixNew( Storage *storageTest = storagePosixNewP(strNew(testPath()), .write = true);
strNew(testPath()), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL);
// ***************************************************************************************************************************** // *****************************************************************************************************************************
if (testBegin("archiveAsyncErrorClear() and archiveAsyncStatus()")) if (testBegin("archiveAsyncErrorClear() and archiveAsyncStatus()"))

View File

@ -20,8 +20,7 @@ testRun(void)
{ {
FUNCTION_HARNESS_VOID(); FUNCTION_HARNESS_VOID();
Storage *storageTest = storagePosixNew( Storage *storageTest = storagePosixNewP(strNew(testPath()), .write = true);
strNew(testPath()), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL);
// Start a protocol server to test the protocol directly // Start a protocol server to test the protocol directly
Buffer *serverWrite = bufNew(8192); Buffer *serverWrite = bufNew(8192);

View File

@ -22,8 +22,7 @@ testRun(void)
FUNCTION_HARNESS_VOID(); FUNCTION_HARNESS_VOID();
// Create default storage object for testing // Create default storage object for testing
Storage *storageTest = storagePosixNew( Storage *storageTest = storagePosixNewP(strNew(testPath()), .write = true);
strNew(testPath()), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL);
// Start a protocol server to test the protocol directly // Start a protocol server to test the protocol directly
Buffer *serverWrite = bufNew(8192); Buffer *serverWrite = bufNew(8192);

View File

@ -456,8 +456,7 @@ testRun(void)
// The tests expect the timezone to be UTC // The tests expect the timezone to be UTC
setenv("TZ", "UTC", true); setenv("TZ", "UTC", true);
Storage *storageTest = storagePosixNew( Storage *storageTest = storagePosixNewP(strNew(testPath()), .write = true);
strNew(testPath()), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL);
// Start a protocol server to test the protocol directly // Start a protocol server to test the protocol directly
Buffer *serverWrite = bufNew(8192); Buffer *serverWrite = bufNew(8192);

View File

@ -24,8 +24,7 @@ testRun(void)
// PQfinish() is strictly checked // PQfinish() is strictly checked
harnessPqScriptStrictSet(true); harnessPqScriptStrictSet(true);
Storage *storageTest = storagePosixNew( Storage *storageTest = storagePosixNewP(strNew(testPath()), .write = true);
strNew(testPath()), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL);
String *pg1 = strNew("pg1"); String *pg1 = strNew("pg1");
String *pg1Path = strNewFmt("%s/%s", testPath(), strPtr(pg1)); String *pg1Path = strNewFmt("%s/%s", testPath(), strPtr(pg1));

View File

@ -16,8 +16,7 @@ testRun(void)
FUNCTION_HARNESS_VOID(); FUNCTION_HARNESS_VOID();
// Create default storage object for testing // Create default storage object for testing
Storage *storageData = storagePosixNew( Storage *storageData = storagePosixNewP(strNew(testDataPath()), .write = true);
strNew(testDataPath()), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL);
// ***************************************************************************************************************************** // *****************************************************************************************************************************
if (testBegin("lockStopFileName()")) if (testBegin("lockStopFileName()"))

View File

@ -71,8 +71,7 @@ testRun(void)
{ {
FUNCTION_HARNESS_VOID(); FUNCTION_HARNESS_VOID();
Storage *storageTest = storagePosixNew( Storage *storageTest = storagePosixNewP(strNew(testPath()), .write = true);
strNew(testPath()), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL);
String *backupStanzaPath = strNew("repo/backup/db"); String *backupStanzaPath = strNew("repo/backup/db");
String *backupInfoFileName = strNewFmt("%s/backup.info", strPtr(backupStanzaPath)); String *backupInfoFileName = strNewFmt("%s/backup.info", strPtr(backupStanzaPath));

View File

@ -413,8 +413,7 @@ testRun(void)
// Restore normal stdout // Restore normal stdout
dup2(stdoutSave, STDOUT_FILENO); dup2(stdoutSave, STDOUT_FILENO);
Storage *storage = storagePosixNew( Storage *storage = storagePosixNewP(strNew(testPath()));
strNew(testPath()), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, false, NULL);
TEST_RESULT_STR_Z(strNewBuf(storageGetP(storageNewReadP(storage, stdoutFile))), generalHelp, " check text"); TEST_RESULT_STR_Z(strNewBuf(storageGetP(storageNewReadP(storage, stdoutFile))), generalHelp, " check text");
} }

View File

@ -1312,8 +1312,7 @@ testRun(void)
// Restore normal stdout // Restore normal stdout
dup2(stdoutSave, STDOUT_FILENO); dup2(stdoutSave, STDOUT_FILENO);
Storage *storage = storagePosixNew( Storage *storage = storagePosixNewP(strNew(testPath()));
strNew(testPath()), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, false, NULL);
TEST_RESULT_STR_Z( TEST_RESULT_STR_Z(
strNewBuf(storageGetP(storageNewReadP(storage, stdoutFile))), "No stanzas exist in the repository.\n", strNewBuf(storageGetP(storageNewReadP(storage, stdoutFile))), "No stanzas exist in the repository.\n",
" check text"); " check text");

View File

@ -19,8 +19,7 @@ testRun(void)
FUNCTION_HARNESS_VOID(); FUNCTION_HARNESS_VOID();
// Create default storage object for testing // Create default storage object for testing
Storage *storageData = storagePosixNew( Storage *storageData = storagePosixNewP(strNew(testDataPath()), .write = true);
strNew(testDataPath()), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL);
// ***************************************************************************************************************************** // *****************************************************************************************************************************
if (testBegin("cmdRemote()")) if (testBegin("cmdRemote()"))
@ -157,9 +156,7 @@ testRun(void)
protocolClientNoOp(client); protocolClientNoOp(client);
TEST_RESULT_BOOL( TEST_RESULT_BOOL(
storageExistsP( storageExistsP(storagePosixNewP(strNew(testDataPath())), STRDEF("lock/test-archive" LOCK_FILE_EXT)),
storagePosixNew(strNew(testDataPath()), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, false, NULL),
STRDEF("lock/test-archive" LOCK_FILE_EXT)),
true, "lock exists"); true, "lock exists");
protocolClientFree(client); protocolClientFree(client);

View File

@ -16,8 +16,7 @@ testRun(void)
FUNCTION_HARNESS_VOID(); FUNCTION_HARNESS_VOID();
// Create default storage object for testing // Create default storage object for testing
Storage *storageTest = storagePosixNew( Storage *storageTest = storagePosixNewP(strNew(testPath()), .write = true);
strNew(testPath()), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL);
// ***************************************************************************************************************************** // *****************************************************************************************************************************
if (testBegin("cmdRepoCreate()")) if (testBegin("cmdRepoCreate()"))

View File

@ -148,8 +148,7 @@ testRun(void)
FUNCTION_HARNESS_VOID(); FUNCTION_HARNESS_VOID();
// Create default storage object for testing // Create default storage object for testing
Storage *storageTest = storagePosixNew( Storage *storageTest = storagePosixNewP(strNew(testPath()), .write = true);
strNew(testPath()), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL);
// ***************************************************************************************************************************** // *****************************************************************************************************************************
if (testBegin("restoreFile()")) if (testBegin("restoreFile()"))

View File

@ -17,8 +17,7 @@ testRun(void)
{ {
FUNCTION_HARNESS_VOID(); FUNCTION_HARNESS_VOID();
Storage *storageTest = storagePosixNew( Storage *storageTest = storagePosixNewP(strNew(testPath()), .write = true);
strNew(testPath()), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL);
String *stanza = strNew("db"); String *stanza = strNew("db");
String *fileName = strNew("test.info"); String *fileName = strNew("test.info");

View File

@ -83,7 +83,7 @@ testSuite(CompressType type, const char *decompressCmd)
varLstAdd(compressParamList, varNewUInt(1)); varLstAdd(compressParamList, varNewUInt(1));
// Create default storage object for testing // Create default storage object for testing
Storage *storageTest = storagePosixNew(strNew(testPath()), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL); Storage *storageTest = storagePosixNewP(strNew(testPath()), .write = true);
TEST_TITLE("simple data"); TEST_TITLE("simple data");

View File

@ -15,8 +15,7 @@ testRun(void)
FUNCTION_HARNESS_VOID(); FUNCTION_HARNESS_VOID();
// Create default storage object for testing // Create default storage object for testing
Storage *storageTest = storagePosixNew( Storage *storageTest = storagePosixNewP(strNew(testPath()), .write = true);
strNew(testPath()), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL);
// ***************************************************************************************************************************** // *****************************************************************************************************************************
if (testBegin("lockAcquireFile() and lockReleaseFile()")) if (testBegin("lockAcquireFile() and lockReleaseFile()"))

View File

@ -16,8 +16,7 @@ void
testRun(void) testRun(void)
{ {
// Create default storage object for testing // Create default storage object for testing
Storage *storageTest = storagePosixNew( Storage *storageTest = storagePosixNewP(strNew(testPath()), .write = true);
strNew(testPath()), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL);
// ***************************************************************************************************************************** // *****************************************************************************************************************************
if (testBegin("InfoArchive")) if (testBegin("InfoArchive"))

View File

@ -16,8 +16,7 @@ void
testRun(void) testRun(void)
{ {
// Create default storage object for testing // Create default storage object for testing
Storage *storageTest = storagePosixNew( Storage *storageTest = storagePosixNewP(strNew(testPath()), .write = true);
strNew(testPath()), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL);
// ***************************************************************************************************************************** // *****************************************************************************************************************************
if (testBegin("InfoBackup")) if (testBegin("InfoBackup"))

View File

@ -21,8 +21,7 @@ Test Run
void void
testRun(void) testRun(void)
{ {
Storage *storageTest = storagePosixNew( Storage *storageTest = storagePosixNewP(strNew(testPath()), .write = true);
strNew(testPath()), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL);
// ***************************************************************************************************************************** // *****************************************************************************************************************************
if (testBegin("struct sizes")) if (testBegin("struct sizes"))
@ -174,10 +173,8 @@ testRun(void)
storagePathCreateP(storageTest, strNew("pg"), .mode = 0700, .noParentCreate = true); storagePathCreateP(storageTest, strNew("pg"), .mode = 0700, .noParentCreate = true);
Storage *storagePg = storagePosixNew( Storage *storagePg = storagePosixNewP(strNewFmt("%s/pg", testPath()));
strNewFmt("%s/pg", testPath()), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, false, NULL); Storage *storagePgWrite = storagePosixNewP(strNewFmt("%s/pg", testPath()), .write = true);
Storage *storagePgWrite = storagePosixNew(
strNewFmt("%s/pg", testPath()), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL);
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("8.3 with custom exclusions and special file"); TEST_TITLE("8.3 with custom exclusions and special file");

View File

@ -277,11 +277,7 @@ testRun(void)
uint64_t rateOut = 100000; uint64_t rateOut = 100000;
// Get the sample pages from disk // Get the sample pages from disk
Buffer *block = storageGetP( Buffer *block = storageGetP(storageNewReadP(storagePosixNewP(STR(testRepoPath())), STRDEF("test/data/filecopy.table.bin")));
storageNewReadP(
storagePosixNew(STR(testRepoPath()), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, false, NULL),
STRDEF("test/data/filecopy.table.bin")));
ASSERT(bufUsed(block) == 1024 * 1024); ASSERT(bufUsed(block) == 1024 * 1024);
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------

View File

@ -11,8 +11,7 @@ testRun(void)
{ {
FUNCTION_HARNESS_VOID(); FUNCTION_HARNESS_VOID();
Storage *storageTest = storagePosixNew( Storage *storageTest = storagePosixNewP(strNew(testPath()), .write = true);
strNew(testPath()), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL);
// ***************************************************************************************************************************** // *****************************************************************************************************************************
if (testBegin("pgVersionFromStr() and pgVersionToStr()")) if (testBegin("pgVersionFromStr() and pgVersionToStr()"))

View File

@ -97,8 +97,7 @@ testRun(void)
{ {
FUNCTION_HARNESS_VOID(); FUNCTION_HARNESS_VOID();
Storage *storageTest = storagePosixNew( Storage *storageTest = storagePosixNewP(strNew(testPath()), .write = true);
strNew(testPath()), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL);
// ***************************************************************************************************************************** // *****************************************************************************************************************************
if (testBegin("protocolStorageTypeEnum() and protocolStorageTypeEnum()")) if (testBegin("protocolStorageTypeEnum() and protocolStorageTypeEnum()"))

View File

@ -48,10 +48,8 @@ testRun(void)
FUNCTION_HARNESS_VOID(); FUNCTION_HARNESS_VOID();
// Create default storage object for testing // Create default storage object for testing
Storage *storageTest = storagePosixNew( Storage *storageTest = storagePosixNewP(strNew(testPath()), .write = true);
strNew(testPath()), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL); Storage *storageTmp = storagePosixNewP(strNew("/tmp"), .write = true);
Storage *storageTmp = storagePosixNew(
strNew("/tmp"), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL);
ioBufferSizeSet(2); ioBufferSizeSet(2);
// Directory and file that cannot be accessed to test permissions errors // Directory and file that cannot be accessed to test permissions errors
@ -86,7 +84,7 @@ testRun(void)
if (testBegin("storageNew() and storageFree()")) if (testBegin("storageNew() and storageFree()"))
{ {
Storage *storageTest = NULL; Storage *storageTest = NULL;
TEST_ASSIGN(storageTest, storagePosixNew(strNew("/"), 0640, 0750, false, NULL), "new storage (defaults)"); TEST_ASSIGN(storageTest, storagePosixNewP(strNew("/")), "new storage (defaults)");
TEST_RESULT_STR_Z(storageTest->path, "/", " check path"); TEST_RESULT_STR_Z(storageTest->path, "/", " check path");
TEST_RESULT_INT(storageTest->modeFile, 0640, " check file mode"); TEST_RESULT_INT(storageTest->modeFile, 0640, " check file mode");
TEST_RESULT_INT(storageTest->modePath, 0750, " check path mode"); TEST_RESULT_INT(storageTest->modePath, 0750, " check path mode");
@ -94,7 +92,10 @@ testRun(void)
TEST_RESULT_BOOL(storageTest->pathExpressionFunction == NULL, true, " check expression function is not set"); TEST_RESULT_BOOL(storageTest->pathExpressionFunction == NULL, true, " check expression function is not set");
TEST_ASSIGN( TEST_ASSIGN(
storageTest, storagePosixNew(strNew("/path/to"), 0600, 0700, true, storageTestPathExpression), storageTest,
storagePosixNewP(
strNew("/path/to"), .modeFile = 0600, .modePath = 0700, .write = true,
.pathExpressionFunction = storageTestPathExpression),
"new storage (non-default)"); "new storage (non-default)");
TEST_RESULT_STR_Z(storageTest->path, "/path/to", " check path"); TEST_RESULT_STR_Z(storageTest->path, "/path/to", " check path");
TEST_RESULT_INT(storageTest->modeFile, 0600, " check file mode"); TEST_RESULT_INT(storageTest->modeFile, 0600, " check file mode");
@ -543,7 +544,7 @@ testRun(void)
{ {
Storage *storageTest = NULL; Storage *storageTest = NULL;
TEST_ASSIGN(storageTest, storagePosixNew(strNew("/"), 0640, 0750, false, NULL), "new storage /"); TEST_ASSIGN(storageTest, storagePosixNewP(strNew("/")), "new storage /");
TEST_RESULT_STR_Z(storagePathP(storageTest, NULL), "/", " root dir"); TEST_RESULT_STR_Z(storagePathP(storageTest, NULL), "/", " root dir");
TEST_RESULT_STR_Z(storagePathP(storageTest, strNew("/")), "/", " same as root dir"); TEST_RESULT_STR_Z(storagePathP(storageTest, strNew("/")), "/", " same as root dir");
TEST_RESULT_STR_Z(storagePathP(storageTest, strNew("subdir")), "/subdir", " simple subdir"); TEST_RESULT_STR_Z(storagePathP(storageTest, strNew("subdir")), "/subdir", " simple subdir");
@ -553,7 +554,7 @@ testRun(void)
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
TEST_ASSIGN( TEST_ASSIGN(
storageTest, storagePosixNew(strNew("/path/to"), 0640, 0750, false, storageTestPathExpression), storageTest, storagePosixNewP(strNew("/path/to"), .pathExpressionFunction = storageTestPathExpression),
"new storage /path/to with expression"); "new storage /path/to with expression");
TEST_RESULT_STR_Z(storagePathP(storageTest, NULL), "/path/to", " root dir"); TEST_RESULT_STR_Z(storagePathP(storageTest, NULL), "/path/to", " root dir");
TEST_RESULT_STR_Z(storagePathP(storageTest, strNew("/path/to")), "/path/to", " absolute root dir"); TEST_RESULT_STR_Z(storagePathP(storageTest, strNew("/path/to")), "/path/to", " absolute root dir");
@ -682,8 +683,7 @@ testRun(void)
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
TEST_ERROR_FMT( TEST_ERROR_FMT(
storagePathSyncP( storagePathSyncP(storagePosixNewP(strNew("/"), .write = true), strNew("/proc")),
storagePosixNew(strNew("/"), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL), strNew("/proc")),
PathSyncError, STORAGE_ERROR_PATH_SYNC ": [22] Invalid argument", "/proc"); PathSyncError, STORAGE_ERROR_PATH_SYNC ": [22] Invalid argument", "/proc");
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
@ -767,7 +767,7 @@ testRun(void)
// ***************************************************************************************************************************** // *****************************************************************************************************************************
if (testBegin("storagePut() and storageGet()")) if (testBegin("storagePut() and storageGet()"))
{ {
Storage *storageTest = storagePosixNew(strNew("/"), 0640, 0750, true, NULL); Storage *storageTest = storagePosixNewP(strNew("/"), .write = true);
TEST_ERROR_FMT( TEST_ERROR_FMT(
storageGetP(storageNewReadP(storageTest, strNew(testPath()))), FileReadError, storageGetP(storageNewReadP(storageTest, strNew(testPath()))), FileReadError,

View File

@ -22,8 +22,7 @@ testRun(void)
FUNCTION_HARNESS_VOID(); FUNCTION_HARNESS_VOID();
// Test storage // Test storage
Storage *storageTest = storagePosixNew( Storage *storageTest = storagePosixNewP(strNew(testPath()), .write = true);
strNew(testPath()), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL);
// Load configuration to set repo-path and stanza // Load configuration to set repo-path and stanza
StringList *argList = strLstNew(); StringList *argList = strLstNew();