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

Change meaning of TEST_RESULT_STR() macro.

This macro was created before the String object existed so subsequent usage with String always included a lot of strPtr() wrapping.

TEST_RESULT_STR_Z() had already been introduced but a wholesale replacement of TEST_RESULT_STR() was not done since the priority was on the C migration.

Update all calls to (old) TEST_RESULT_STR() with one of the following variants: (new) TEST_RESULT_STR(), TEST_RESULT_STR_Z(), TEST_RESULT_Z(), TEST_RESULT_Z_STR().
This commit is contained in:
David Steele 2019-12-26 18:08:27 -07:00
parent 02d3918b32
commit d41eea685a
58 changed files with 1226 additions and 1291 deletions

View File

@ -303,7 +303,7 @@ strLstAdd(argList, strNewFmt("--repo-path=%s/", strPtr(repoPath))); // add t
strLstAddZ(argList, "info"); // add the command
harnessCfgLoad(cfgCmdExpire, argList); // load the command and option list into the test harness
TEST_RESULT_STR(strPtr(infoRender()), "No stanzas exist in the repository.\n", "text - no stanzas"); // run the test
TEST_RESULT_STR_Z(infoRender(), "No stanzas exist in the repository.\n", "text - no stanzas"); // run the test
```
Tests are run via macros. All test macros expect the first parameter to be the function to call that is being tested. With the exception of TEST_RESULT_VOID, the second parameter is the expected result, and with the exception of TEST_ERROR, the third parameter is a short description of the test. The most common macros are:

View File

@ -338,7 +338,7 @@ strLstAdd(argList, strNewFmt("--repo-path=%s/", strPtr(repoPath))); // add t
strLstAddZ(argList, "info"); // add the command
harnessCfgLoad(cfgCmdExpire, argList); // load the command and option list into the test harness
TEST_RESULT_STR(strPtr(infoRender()), "No stanzas exist in the repository.\n", "text - no stanzas"); // run the test
TEST_RESULT_STR_Z(infoRender(), "No stanzas exist in the repository.\n", "text - no stanzas"); // run the test
</code-block>
<p>Tests are run via macros. All test macros expect the first parameter to be the function to call that is being tested. With the exception of TEST_RESULT_VOID, the second parameter is the expected result, and with the exception of TEST_ERROR, the third parameter is a short description of the test. The most common macros are:</p>

View File

@ -333,17 +333,19 @@ Macros to ease the use of common data types
#define TEST_RESULT_SIZE_NE(statement, resultExpected, ...) \
TEST_RESULT_SIZE_PARAM(statement, resultExpected, !=, __VA_ARGS__);
#define TEST_RESULT_STR_PARAM(statement, resultExpected, typeOp, ...) \
#define TEST_RESULT_Z_PARAM(statement, resultExpected, typeOp, ...) \
TEST_RESULT(statement, resultExpected, char *, "%s", TEST_TYPE_FORMAT_PTR, typeOp, TEST_TYPE_COMPARE_STR, __VA_ARGS__);
#define TEST_RESULT_STR(statement, resultExpected, ...) \
TEST_RESULT_STR_PARAM(statement, resultExpected, ==, __VA_ARGS__);
#define TEST_RESULT_STR_NE(statement, resultExpected, ...) \
TEST_RESULT_STR_PARAM(statement, resultExpected, !=, __VA_ARGS__);
#define TEST_RESULT_Z(statement, resultExpected, ...) \
TEST_RESULT_Z_PARAM(statement, resultExpected, ==, __VA_ARGS__);
#define TEST_RESULT_Z_NE(statement, resultExpected, ...) \
TEST_RESULT_Z_PARAM(statement, resultExpected, !=, __VA_ARGS__);
#define TEST_RESULT_STR_STR(statement, resultExpected, ...) \
TEST_RESULT_STR(strPtr(statement), strPtr(resultExpected), __VA_ARGS__);
#define TEST_RESULT_STR(statement, resultExpected, ...) \
TEST_RESULT_Z(strPtr(statement), strPtr(resultExpected), __VA_ARGS__);
#define TEST_RESULT_STR_Z(statement, resultExpected, ...) \
TEST_RESULT_STR(strPtr(statement), resultExpected, __VA_ARGS__);
TEST_RESULT_Z(strPtr(statement), resultExpected, __VA_ARGS__);
#define TEST_RESULT_Z_STR(statement, resultExpected, ...) \
TEST_RESULT_Z(statement, strPtr(resultExpected), __VA_ARGS__);
#define TEST_RESULT_U16_HEX(statement, resultExpected, ...) \
TEST_RESULT(statement, resultExpected, uint16_t, "%04X", TEST_TYPE_FORMAT, ==, TEST_TYPE_COMPARE, __VA_ARGS__);

View File

@ -119,8 +119,8 @@ testRun(void)
TEST_RESULT_VOID(
archiveAsyncStatusErrorWrite(archiveModeGet, walSegment, 25, strNew("error message")), "write error");
TEST_RESULT_STR(
strPtr(strNewBuf(storageGetP(storageNewReadP(storageTest, strNew("archive/db/in/000000010000000100000001.error"))))),
TEST_RESULT_STR_Z(
strNewBuf(storageGetP(storageNewReadP(storageTest, strNew("archive/db/in/000000010000000100000001.error")))),
"25\nerror message", "check error");
TEST_RESULT_VOID(
storageRemoveP(storageTest, strNew("archive/db/in/000000010000000100000001.error"), .errorOnMissing = true),
@ -128,8 +128,8 @@ testRun(void)
TEST_RESULT_VOID(
archiveAsyncStatusErrorWrite(archiveModeGet, NULL, 25, strNew("global error message")), "write global error");
TEST_RESULT_STR(
strPtr(strNewBuf(storageGetP(storageNewReadP(storageTest, strNew("archive/db/in/global.error"))))),
TEST_RESULT_STR_Z(
strNewBuf(storageGetP(storageNewReadP(storageTest, strNew("archive/db/in/global.error")))),
"25\nglobal error message", "check global error");
TEST_RESULT_VOID(
storageRemoveP(storageTest, strNew("archive/db/in/global.error"), .errorOnMissing = true),
@ -137,8 +137,8 @@ testRun(void)
TEST_RESULT_VOID(
archiveAsyncStatusOkWrite(archiveModeGet, walSegment, NULL), "write ok file");
TEST_RESULT_STR(
strPtr(strNewBuf(storageGetP(storageNewReadP(storageTest, strNew("archive/db/in/000000010000000100000001.ok"))))),
TEST_RESULT_STR_Z(
strNewBuf(storageGetP(storageNewReadP(storageTest, strNew("archive/db/in/000000010000000100000001.ok")))),
"", "check ok");
TEST_RESULT_VOID(
storageRemoveP(storageTest, strNew("archive/db/in/000000010000000100000001.ok"), .errorOnMissing = true),
@ -146,8 +146,8 @@ testRun(void)
TEST_RESULT_VOID(
archiveAsyncStatusOkWrite(archiveModeGet, walSegment, strNew("WARNING")), "write ok file with warning");
TEST_RESULT_STR(
strPtr(strNewBuf(storageGetP(storageNewReadP(storageTest, strNew("archive/db/in/000000010000000100000001.ok"))))),
TEST_RESULT_STR_Z(
strNewBuf(storageGetP(storageNewReadP(storageTest, strNew("archive/db/in/000000010000000100000001.ok")))),
"0\nWARNING", "check ok warning");
TEST_RESULT_VOID(
storageRemoveP(storageTest, strNew("archive/db/in/000000010000000100000001.ok"), .errorOnMissing = true),
@ -175,11 +175,10 @@ testRun(void)
const String *pgPath = storagePathP(storageTest, STRDEF("pg"));
storagePathCreateP(storageTest, pgPath);
TEST_RESULT_STR(
strPtr(walPath(strNew("/absolute/path"), pgPath, strNew("test"))), "/absolute/path", "absolute path");
TEST_RESULT_STR_Z(walPath(strNew("/absolute/path"), pgPath, strNew("test")), "/absolute/path", "absolute path");
THROW_ON_SYS_ERROR(chdir(strPtr(pgPath)) != 0, PathMissingError, "unable to chdir()");
TEST_RESULT_STR_STR(
TEST_RESULT_STR(
walPath(strNew("relative/path"), pgPath, strNew("test")), strNewFmt("%s/relative/path", strPtr(pgPath)),
"relative path");
@ -190,7 +189,7 @@ testRun(void)
"unable to create symlink '%s' to '%s'", strPtr(pgPath), strPtr(pgPathLink));
THROW_ON_SYS_ERROR(chdir(strPtr(pgPath)) != 0, PathMissingError, "unable to chdir()");
TEST_RESULT_STR_STR(
TEST_RESULT_STR(
walPath(strNew("relative/path"), pgPathLink, strNew("test")), strNewFmt("%s/relative/path", strPtr(pgPathLink)),
"relative path");
@ -245,8 +244,8 @@ testRun(void)
HARNESS_FORK_PARENT_BEGIN()
{
TEST_RESULT_STR(
strPtr(walSegmentFind(storageRepo(), strNew("9.6-2"), strNew("123456781234567812345678"), 1000)),
TEST_RESULT_STR_Z(
walSegmentFind(storageRepo(), strNew("9.6-2"), strNew("123456781234567812345678"), 1000),
"123456781234567812345678-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "found segment");
}
HARNESS_FORK_PARENT_END();
@ -275,47 +274,47 @@ testRun(void)
// *****************************************************************************************************************************
if (testBegin("walSegmentNext()"))
{
TEST_RESULT_STR(
strPtr(walSegmentNext(strNew("000000010000000100000001"), 16 * 1024 * 1024, PG_VERSION_10)),
"000000010000000100000002", "get next");
TEST_RESULT_STR(
strPtr(walSegmentNext(strNew("0000000100000001000000FE"), 16 * 1024 * 1024, PG_VERSION_93)),
"0000000100000001000000FF", "get next");
TEST_RESULT_STR(
strPtr(walSegmentNext(strNew("0000009900000001000000FF"), 16 * 1024 * 1024, PG_VERSION_93)),
"000000990000000200000000", "get next overflow >= 9.3");
TEST_RESULT_STR(
strPtr(walSegmentNext(strNew("0000000100000001000000FE"), 16 * 1024 * 1024, PG_VERSION_92)),
"000000010000000200000000", "get next overflow < 9.3");
TEST_RESULT_STR(
strPtr(walSegmentNext(strNew("000000010000000100000003"), 1024 * 1024 * 1024, PG_VERSION_11)),
"000000010000000200000000", "get next overflow >= 11/1GB");
TEST_RESULT_STR(
strPtr(walSegmentNext(strNew("000000010000006700000FFF"), 1024 * 1024, PG_VERSION_11)),
"000000010000006800000000", "get next overflow >= 11/1MB");
TEST_RESULT_STR_Z(
walSegmentNext(strNew("000000010000000100000001"), 16 * 1024 * 1024, PG_VERSION_10), "000000010000000100000002",
"get next");
TEST_RESULT_STR_Z(
walSegmentNext(strNew("0000000100000001000000FE"), 16 * 1024 * 1024, PG_VERSION_93), "0000000100000001000000FF",
"get next");
TEST_RESULT_STR_Z(
walSegmentNext(strNew("0000009900000001000000FF"), 16 * 1024 * 1024, PG_VERSION_93), "000000990000000200000000",
"get next overflow >= 9.3");
TEST_RESULT_STR_Z(
walSegmentNext(strNew("0000000100000001000000FE"), 16 * 1024 * 1024, PG_VERSION_92), "000000010000000200000000",
"get next overflow < 9.3");
TEST_RESULT_STR_Z(
walSegmentNext(strNew("000000010000000100000003"), 1024 * 1024 * 1024, PG_VERSION_11), "000000010000000200000000",
"get next overflow >= 11/1GB");
TEST_RESULT_STR_Z(
walSegmentNext(strNew("000000010000006700000FFF"), 1024 * 1024, PG_VERSION_11), "000000010000006800000000",
"get next overflow >= 11/1MB");
}
// *****************************************************************************************************************************
if (testBegin("walSegmentRange()"))
{
TEST_RESULT_STR(
strPtr(strLstJoin(walSegmentRange(strNew("000000010000000100000000"), 16 * 1024 * 1024, PG_VERSION_92, 1), "|")),
TEST_RESULT_STR_Z(
strLstJoin(walSegmentRange(strNew("000000010000000100000000"), 16 * 1024 * 1024, PG_VERSION_92, 1), "|"),
"000000010000000100000000", "get single");
TEST_RESULT_STR(
strPtr(strLstJoin(walSegmentRange(strNew("0000000100000001000000FD"), 16 * 1024 * 1024, PG_VERSION_92, 4), "|")),
TEST_RESULT_STR_Z(
strLstJoin(walSegmentRange(strNew("0000000100000001000000FD"), 16 * 1024 * 1024, PG_VERSION_92, 4), "|"),
"0000000100000001000000FD|0000000100000001000000FE|000000010000000200000000|000000010000000200000001",
"get range < 9.3");
TEST_RESULT_STR(
strPtr(strLstJoin(walSegmentRange(strNew("0000000100000001000000FD"), 16 * 1024 * 1024, PG_VERSION_93, 4), "|")),
TEST_RESULT_STR_Z(
strLstJoin(walSegmentRange(strNew("0000000100000001000000FD"), 16 * 1024 * 1024, PG_VERSION_93, 4), "|"),
"0000000100000001000000FD|0000000100000001000000FE|0000000100000001000000FF|000000010000000200000000",
"get range >= 9.3");
TEST_RESULT_STR(
strPtr(strLstJoin(walSegmentRange(strNew("000000080000000A00000000"), 1024 * 1024 * 1024, PG_VERSION_11, 8), "|")),
TEST_RESULT_STR_Z(
strLstJoin(walSegmentRange(strNew("000000080000000A00000000"), 1024 * 1024 * 1024, PG_VERSION_11, 8), "|"),
"000000080000000A00000000|000000080000000A00000001|000000080000000A00000002|000000080000000A00000003|"
"000000080000000B00000000|000000080000000B00000001|000000080000000B00000002|000000080000000B00000003",
"get range >= 11/1GB");
TEST_RESULT_STR(
strPtr(strLstJoin(walSegmentRange(strNew("000000070000000700000FFE"), 1024 * 1024, PG_VERSION_11, 4), "|")),
TEST_RESULT_STR_Z(
strLstJoin(walSegmentRange(strNew("000000070000000700000FFE"), 1024 * 1024, PG_VERSION_11, 4), "|"),
"000000070000000700000FFE|000000070000000700000FFF|000000070000000800000000|000000070000000800000001",
"get range >= 11/1MB");
}

View File

@ -89,8 +89,8 @@ testRun(void)
"repo/archive/test1/10-2/8765432187654321/876543218765432187654321-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")),
NULL);
TEST_RESULT_STR(
strPtr(archiveGetCheck(strNew("876543218765432187654321"), cipherTypeNone, NULL).archiveFileActual),
TEST_RESULT_STR_Z(
archiveGetCheck(strNew("876543218765432187654321"), cipherTypeNone, NULL).archiveFileActual,
"10-2/8765432187654321/876543218765432187654321-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "segment found");
// Write segment into an newer archive path
@ -102,8 +102,8 @@ testRun(void)
"repo/archive/test1/10-4/8765432187654321/876543218765432187654321-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")),
NULL);
TEST_RESULT_STR(
strPtr(archiveGetCheck(strNew("876543218765432187654321"), cipherTypeNone, NULL).archiveFileActual),
TEST_RESULT_STR_Z(
archiveGetCheck(strNew("876543218765432187654321"), cipherTypeNone, NULL).archiveFileActual,
"10-4/8765432187654321/876543218765432187654321-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", "newer segment found");
// Get history file
@ -113,11 +113,9 @@ testRun(void)
storagePutP(storageNewWriteP(storageTest, strNew("repo/archive/test1/10-4/00000009.history")), NULL);
TEST_RESULT_STR(
strPtr(
archiveGetCheck(
strNew("00000009.history"), cipherTypeNone, NULL).archiveFileActual), "10-4/00000009.history",
"history file found");
TEST_RESULT_STR_Z(
archiveGetCheck(strNew("00000009.history"), cipherTypeNone, NULL).archiveFileActual, "10-4/00000009.history",
"history file found");
}
// *****************************************************************************************************************************
@ -234,7 +232,7 @@ testRun(void)
TEST_RESULT_BOOL(
archiveGetProtocol(PROTOCOL_COMMAND_ARCHIVE_GET_STR, paramList, server), true, "protocol archive get");
TEST_RESULT_STR(strPtr(strNewBuf(serverWrite)), "{\"out\":0}\n", "check result");
TEST_RESULT_STR_Z(strNewBuf(serverWrite), "{\"out\":0}\n", "check result");
TEST_RESULT_BOOL(
storageExistsP(storageTest, strNewFmt("spool/archive/test1/in/%s", strPtr(archiveFile))), true, " check exists");
@ -264,15 +262,15 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
storagePathCreateP(storageSpoolWrite(), strNew(STORAGE_SPOOL_ARCHIVE_IN));
TEST_RESULT_STR(
strPtr(strLstJoin(queueNeed(strNew("000000010000000100000001"), false, queueSize, walSegmentSize, PG_VERSION_92), "|")),
TEST_RESULT_STR_Z(
strLstJoin(queueNeed(strNew("000000010000000100000001"), false, queueSize, walSegmentSize, PG_VERSION_92), "|"),
"000000010000000100000001|000000010000000100000002", "queue size smaller than min");
// -------------------------------------------------------------------------------------------------------------------------
queueSize = (16 * 1024 * 1024) * 3;
TEST_RESULT_STR(
strPtr(strLstJoin(queueNeed(strNew("000000010000000100000001"), false, queueSize, walSegmentSize, PG_VERSION_92), "|")),
TEST_RESULT_STR_Z(
strLstJoin(queueNeed(strNew("000000010000000100000001"), false, queueSize, walSegmentSize, PG_VERSION_92), "|"),
"000000010000000100000001|000000010000000100000002|000000010000000100000003", "empty queue");
// -------------------------------------------------------------------------------------------------------------------------
@ -286,13 +284,13 @@ testRun(void)
storageNewWriteP(
storageSpoolWrite(), strNew(STORAGE_SPOOL_ARCHIVE_IN "/0000000100000001000000FF")), walSegmentBuffer);
TEST_RESULT_STR(
strPtr(strLstJoin(queueNeed(strNew("0000000100000001000000FE"), false, queueSize, walSegmentSize, PG_VERSION_92), "|")),
TEST_RESULT_STR_Z(
strLstJoin(queueNeed(strNew("0000000100000001000000FE"), false, queueSize, walSegmentSize, PG_VERSION_92), "|"),
"000000010000000200000000|000000010000000200000001", "queue has wal < 9.3");
TEST_RESULT_STR(
strPtr(strLstJoin(storageListP(storageSpoolWrite(), strNew(STORAGE_SPOOL_ARCHIVE_IN)), "|")),
"0000000100000001000000FE", "check queue");
TEST_RESULT_STR_Z(
strLstJoin(storageListP(storageSpoolWrite(), strNew(STORAGE_SPOOL_ARCHIVE_IN)), "|"), "0000000100000001000000FE",
"check queue");
// -------------------------------------------------------------------------------------------------------------------------
walSegmentSize = 1024 * 1024;
@ -306,12 +304,12 @@ testRun(void)
storageNewWriteP(
storageSpoolWrite(), strNew(STORAGE_SPOOL_ARCHIVE_IN "/000000010000000A00000FFF")), walSegmentBuffer);
TEST_RESULT_STR(
strPtr(strLstJoin(queueNeed(strNew("000000010000000A00000FFD"), true, queueSize, walSegmentSize, PG_VERSION_11), "|")),
TEST_RESULT_STR_Z(
strLstJoin(queueNeed(strNew("000000010000000A00000FFD"), true, queueSize, walSegmentSize, PG_VERSION_11), "|"),
"000000010000000B00000000|000000010000000B00000001|000000010000000B00000002", "queue has wal >= 9.3");
TEST_RESULT_STR(
strPtr(strLstJoin(strLstSort(storageListP(storageSpool(), strNew(STORAGE_SPOOL_ARCHIVE_IN)), sortOrderAsc), "|")),
TEST_RESULT_STR_Z(
strLstJoin(strLstSort(storageListP(storageSpool(), strNew(STORAGE_SPOOL_ARCHIVE_IN)), sortOrderAsc), "|"),
"000000010000000A00000FFE|000000010000000A00000FFF", "check queue");
}
@ -463,11 +461,8 @@ testRun(void)
TEST_RESULT_BOOL(
storageExistsP(storageSpool(), strNew(STORAGE_SPOOL_ARCHIVE_IN "/000000010000000100000003.error")), false,
"check 000000010000000100000003.error not in spool");
TEST_RESULT_STR(
strPtr(
strNewBuf(
storageGetP(
storageNewReadP(storageSpool(), strNew(STORAGE_SPOOL_ARCHIVE_IN "/global.error"))))),
TEST_RESULT_STR_Z(
strNewBuf(storageGetP(storageNewReadP(storageSpool(), strNew(STORAGE_SPOOL_ARCHIVE_IN "/global.error")))),
"102\nlocal-1 process terminated unexpectedly [102]: unable to execute 'pgbackrest-bogus': "
"[2] No such file or directory",
"check global error");

View File

@ -67,12 +67,12 @@ testRun(void)
storagePutP(storageNewWriteP(storagePgWrite(), strNew("pg_wal/archive_status/000000010000000100000005.ready")), NULL);
storagePutP(storageNewWriteP(storagePgWrite(), strNew("pg_wal/archive_status/000000010000000100000006.ready")), NULL);
TEST_RESULT_STR(
strPtr(strLstJoin(archivePushProcessList(strNewFmt("%s/db/pg_wal", testPath())), "|")),
TEST_RESULT_STR_Z(
strLstJoin(archivePushProcessList(strNewFmt("%s/db/pg_wal", testPath())), "|"),
"000000010000000100000002|000000010000000100000005|000000010000000100000006", "ready list");
TEST_RESULT_STR(
strPtr(strLstJoin(strLstSort(storageListP(storageSpool(), strNew(STORAGE_SPOOL_ARCHIVE_OUT)), sortOrderAsc), "|")),
TEST_RESULT_STR_Z(
strLstJoin(strLstSort(storageListP(storageSpool(), strNew(STORAGE_SPOOL_ARCHIVE_OUT)), sortOrderAsc), "|"),
"000000010000000100000003.ok", "remaining status list");
// Test drop
@ -168,8 +168,8 @@ testRun(void)
TEST_RESULT_UINT(result.pgVersion, PG_VERSION_96, "check pg version");
TEST_RESULT_UINT(result.pgSystemId, 0xFACEFACEFACEFACE, "check pg system id");
TEST_RESULT_UINT(result.pgWalSegmentSize, 16 * 1024 * 1024, "check wal segment size");
TEST_RESULT_STR(strPtr(result.archiveId), "9.6-1", "check archive id");
TEST_RESULT_STR(strPtr(result.archiveCipherPass), NULL, "check archive cipher pass (not set in this test)");
TEST_RESULT_STR_Z(result.archiveId, "9.6-1", "check archive id");
TEST_RESULT_STR_Z(result.archiveCipherPass, NULL, "check archive cipher pass (not set in this test)");
}
// *****************************************************************************************************************************
@ -351,8 +351,8 @@ testRun(void)
TEST_RESULT_BOOL(
archivePushProtocol(PROTOCOL_COMMAND_ARCHIVE_PUSH_STR, paramList, server), true, "protocol archive put");
TEST_RESULT_STR(
strPtr(strNewBuf(serverWrite)),
TEST_RESULT_STR_Z(
strNewBuf(serverWrite),
"{\"out\":\"WAL file '000000010000000100000002' already exists in the archive with the same checksum"
"\\nHINT: this is valid in some recovery scenarios but may also indicate a problem.\"}\n",
"check result");
@ -580,12 +580,12 @@ testRun(void)
TEST_ERROR(cmdArchivePushAsync(), AssertError, "no WAL files to process");
TEST_RESULT_STR(
strPtr(strNewBuf(storageGetP(storageNewReadP(storageSpool(), strNew(STORAGE_SPOOL_ARCHIVE_OUT "/global.error"))))),
TEST_RESULT_STR_Z(
strNewBuf(storageGetP(storageNewReadP(storageSpool(), strNew(STORAGE_SPOOL_ARCHIVE_OUT "/global.error")))),
"25\nno WAL files to process", "check global.error");
TEST_RESULT_STR(
strPtr(strLstJoin(strLstSort(storageListP(storageSpool(), strNew(STORAGE_SPOOL_ARCHIVE_OUT)), sortOrderAsc), "|")),
TEST_RESULT_STR_Z(
strLstJoin(strLstSort(storageListP(storageSpool(), strNew(STORAGE_SPOOL_ARCHIVE_OUT)), sortOrderAsc), "|"),
"global.error", "check status files");
// Push WAL
@ -614,8 +614,8 @@ testRun(void)
TEST_64BIT() ? "f81d63dd5e258cd607534f3531bbd71442797e37" : "02d228126281e8e102b35a2737e45a0527946296")),
true, "check repo for WAL 1 file");
TEST_RESULT_STR(
strPtr(strLstJoin(strLstSort(storageListP(storageSpool(), strNew(STORAGE_SPOOL_ARCHIVE_OUT)), sortOrderAsc), "|")),
TEST_RESULT_STR_Z(
strLstJoin(strLstSort(storageListP(storageSpool(), strNew(STORAGE_SPOOL_ARCHIVE_OUT)), sortOrderAsc), "|"),
"000000010000000100000001.ok|000000010000000100000002.error", "check status files");
// Create WAL 2 segment
@ -643,8 +643,8 @@ testRun(void)
TEST_64BIT() ? "0aea6fa5d53500ce548b84a86bc3a29ae77fa048" : "408822a89ef44ef6740e785743bf1b870d8024a2")),
true, "check repo for WAL 2 file");
TEST_RESULT_STR(
strPtr(strLstJoin(strLstSort(storageListP(storageSpool(), strNew(STORAGE_SPOOL_ARCHIVE_OUT)), sortOrderAsc), "|")),
TEST_RESULT_STR_Z(
strLstJoin(strLstSort(storageListP(storageSpool(), strNew(STORAGE_SPOOL_ARCHIVE_OUT)), sortOrderAsc), "|"),
"000000010000000100000001.ok|000000010000000100000002.ok", "check status files");
// Check that drop functionality works
@ -663,22 +663,18 @@ testRun(void)
"P00 WARN: dropped WAL file '000000010000000100000001' because archive queue exceeded 16MB\n"
"P00 WARN: dropped WAL file '000000010000000100000002' because archive queue exceeded 16MB");
TEST_RESULT_STR(
strPtr(
strNewBuf(
storageGetP(
storageNewReadP(storageSpool(), strNew(STORAGE_SPOOL_ARCHIVE_OUT "/000000010000000100000001.ok"))))),
TEST_RESULT_STR_Z(
strNewBuf(
storageGetP(storageNewReadP(storageSpool(), strNew(STORAGE_SPOOL_ARCHIVE_OUT "/000000010000000100000001.ok")))),
"0\ndropped WAL file '000000010000000100000001' because archive queue exceeded 16MB", "check WAL 1 warning");
TEST_RESULT_STR(
strPtr(
strNewBuf(
storageGetP(
storageNewReadP(storageSpool(), strNew(STORAGE_SPOOL_ARCHIVE_OUT "/000000010000000100000002.ok"))))),
TEST_RESULT_STR_Z(
strNewBuf(
storageGetP(storageNewReadP(storageSpool(), strNew(STORAGE_SPOOL_ARCHIVE_OUT "/000000010000000100000002.ok")))),
"0\ndropped WAL file '000000010000000100000002' because archive queue exceeded 16MB", "check WAL 2 warning");
TEST_RESULT_STR(
strPtr(strLstJoin(strLstSort(storageListP(storageSpool(), strNew(STORAGE_SPOOL_ARCHIVE_OUT)), sortOrderAsc), "|")),
TEST_RESULT_STR_Z(
strLstJoin(strLstSort(storageListP(storageSpool(), strNew(STORAGE_SPOOL_ARCHIVE_OUT)), sortOrderAsc), "|"),
"000000010000000100000001.ok|000000010000000100000002.ok", "check status files");
}

View File

@ -48,7 +48,7 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
String *filter = backupRegExpP(.full = true);
TEST_RESULT_STR(strPtr(filter), "^[0-9]{8}\\-[0-9]{6}F$", "full backup regex with anchors");
TEST_RESULT_STR_Z(filter, "^[0-9]{8}\\-[0-9]{6}F$", "full backup regex with anchors");
TEST_RESULT_BOOL(regExpMatchOne(filter, incr), false, " does not exactly match incr");
TEST_RESULT_BOOL(regExpMatchOne(filter, diff), false, " does not exactly match diff");
TEST_RESULT_BOOL(regExpMatchOne(filter, full), true, " exactly matches full");
@ -56,9 +56,8 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
filter = backupRegExpP(.full = true, .incremental = true);
TEST_RESULT_STR(
strPtr(filter),
"^[0-9]{8}\\-[0-9]{6}F(\\_[0-9]{8}\\-[0-9]{6}I){0,1}$", "full and optional incr backup regex with anchors");
TEST_RESULT_STR_Z(
filter, "^[0-9]{8}\\-[0-9]{6}F(\\_[0-9]{8}\\-[0-9]{6}I){0,1}$", "full and optional incr backup regex with anchors");
TEST_RESULT_BOOL(regExpMatchOne(filter, incr), true, " match incr");
TEST_RESULT_BOOL(regExpMatchOne(filter, diff), false, " does not match diff");
TEST_RESULT_BOOL(regExpMatchOne(filter, full), true, " match full");
@ -72,9 +71,8 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
filter = backupRegExpP(.full = true, .differential = true);
TEST_RESULT_STR(
strPtr(filter),
"^[0-9]{8}\\-[0-9]{6}F(\\_[0-9]{8}\\-[0-9]{6}D){0,1}$", "full and optional diff backup regex with anchors");
TEST_RESULT_STR_Z(
filter, "^[0-9]{8}\\-[0-9]{6}F(\\_[0-9]{8}\\-[0-9]{6}D){0,1}$", "full and optional diff backup regex with anchors");
TEST_RESULT_BOOL(regExpMatchOne(filter, incr), false, " does not match incr");
TEST_RESULT_BOOL(regExpMatchOne(filter, diff), true, " match diff");
TEST_RESULT_BOOL(regExpMatchOne(filter, full), true, " match full");
@ -82,9 +80,9 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
filter = backupRegExpP(.full = true, .incremental = true, .differential = true);
TEST_RESULT_STR(
strPtr(filter),
"^[0-9]{8}\\-[0-9]{6}F(\\_[0-9]{8}\\-[0-9]{6}(D|I)){0,1}$", "full, optional diff and incr backup regex with anchors");
TEST_RESULT_STR_Z(
filter, "^[0-9]{8}\\-[0-9]{6}F(\\_[0-9]{8}\\-[0-9]{6}(D|I)){0,1}$",
"full, optional diff and incr backup regex with anchors");
TEST_RESULT_BOOL(regExpMatchOne(filter, incr), true, " match incr");
TEST_RESULT_BOOL(regExpMatchOne(filter, diff), true, " match diff");
TEST_RESULT_BOOL(regExpMatchOne(filter, full), true, " match full");
@ -92,9 +90,7 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
filter = backupRegExpP(.incremental = true, .differential = true, .noAnchorEnd = true);
TEST_RESULT_STR(
strPtr(filter),
"^[0-9]{8}\\-[0-9]{6}F\\_[0-9]{8}\\-[0-9]{6}(D|I)", "diff and incr backup regex with anchors");
TEST_RESULT_STR_Z(filter, "^[0-9]{8}\\-[0-9]{6}F\\_[0-9]{8}\\-[0-9]{6}(D|I)", "diff and incr backup regex with anchors");
TEST_RESULT_BOOL(regExpMatchOne(filter, incr), true, " match incr");
TEST_RESULT_BOOL(regExpMatchOne(filter, diff), true, " match diff");
TEST_RESULT_BOOL(regExpMatchOne(filter, full), false, " does not match full");
@ -105,9 +101,7 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
filter = backupRegExpP(.incremental = true);
TEST_RESULT_STR(
strPtr(filter),
"^[0-9]{8}\\-[0-9]{6}F\\_[0-9]{8}\\-[0-9]{6}I$", "incr backup regex with anchors");
TEST_RESULT_STR_Z(filter, "^[0-9]{8}\\-[0-9]{6}F\\_[0-9]{8}\\-[0-9]{6}I$", "incr backup regex with anchors");
TEST_RESULT_BOOL(regExpMatchOne(filter, incr), true, " match incr");
TEST_RESULT_BOOL(regExpMatchOne(filter, diff), false, " does not match diff");
TEST_RESULT_BOOL(regExpMatchOne(filter, full), false, " does not match full");
@ -115,9 +109,7 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
filter = backupRegExpP(.differential = true);
TEST_RESULT_STR(
strPtr(filter),
"^[0-9]{8}\\-[0-9]{6}F\\_[0-9]{8}\\-[0-9]{6}D$", "diff backup regex with anchors");
TEST_RESULT_STR_Z(filter, "^[0-9]{8}\\-[0-9]{6}F\\_[0-9]{8}\\-[0-9]{6}D$", "diff backup regex with anchors");
TEST_RESULT_BOOL(regExpMatchOne(filter, incr), false, " does not match incr");
TEST_RESULT_BOOL(regExpMatchOne(filter, diff), true, " match diff");
TEST_RESULT_BOOL(regExpMatchOne(filter, full), false, " does not match full");
@ -141,8 +133,8 @@ testRun(void)
ioWrite(write, buffer);
ioWriteClose(write);
TEST_RESULT_STR(
strPtr(jsonFromVar(ioFilterGroupResult(ioWriteFilterGroup(write), PAGE_CHECKSUM_FILTER_TYPE_STR))),
TEST_RESULT_STR_Z(
jsonFromVar(ioFilterGroupResult(ioWriteFilterGroup(write), PAGE_CHECKSUM_FILTER_TYPE_STR)),
"{\"align\":true,\"valid\":true}", "all zero pages");
// Single checksum error
@ -168,8 +160,8 @@ testRun(void)
ioWrite(write, buffer);
ioWriteClose(write);
TEST_RESULT_STR(
strPtr(jsonFromVar(ioFilterGroupResult(ioWriteFilterGroup(write), PAGE_CHECKSUM_FILTER_TYPE_STR))),
TEST_RESULT_STR_Z(
jsonFromVar(ioFilterGroupResult(ioWriteFilterGroup(write), PAGE_CHECKSUM_FILTER_TYPE_STR)),
"{\"align\":true,\"error\":[0],\"valid\":false}", "single checksum error");
// Various checksum errors some of which will be skipped because of the LSN
@ -215,8 +207,8 @@ testRun(void)
ioWrite(write, buffer);
ioWriteClose(write);
TEST_RESULT_STR(
strPtr(jsonFromVar(ioFilterGroupResult(ioWriteFilterGroup(write), PAGE_CHECKSUM_FILTER_TYPE_STR))),
TEST_RESULT_STR_Z(
jsonFromVar(ioFilterGroupResult(ioWriteFilterGroup(write), PAGE_CHECKSUM_FILTER_TYPE_STR)),
"{\"align\":false,\"error\":[0,[2,4],[6,7]],\"valid\":false}", "various checksum errors");
// Impossibly misaligned page
@ -232,8 +224,8 @@ testRun(void)
ioWrite(write, buffer);
ioWriteClose(write);
TEST_RESULT_STR(
strPtr(jsonFromVar(ioFilterGroupResult(ioWriteFilterGroup(write), PAGE_CHECKSUM_FILTER_TYPE_STR))),
TEST_RESULT_STR_Z(
jsonFromVar(ioFilterGroupResult(ioWriteFilterGroup(write), PAGE_CHECKSUM_FILTER_TYPE_STR)),
"{\"align\":false,\"valid\":false}", "misalignment");
// Two misaligned buffers in a row
@ -258,9 +250,9 @@ testRun(void)
TEST_RESULT_UINT(backupType(strNew("incr")), backupTypeIncr, "backup type incr");
TEST_ERROR(backupType(strNew("bogus")), AssertError, "invalid backup type 'bogus'");
TEST_RESULT_STR(strPtr(backupTypeStr(backupTypeFull)), "full", "backup type str full");
TEST_RESULT_STR(strPtr(backupTypeStr(backupTypeDiff)), "diff", "backup type str diff");
TEST_RESULT_STR(strPtr(backupTypeStr(backupTypeIncr)), "incr", "backup type str incr");
TEST_RESULT_STR_Z(backupTypeStr(backupTypeFull), "full", "backup type str full");
TEST_RESULT_STR_Z(backupTypeStr(backupTypeDiff), "diff", "backup type str diff");
TEST_RESULT_STR_Z(backupTypeStr(backupTypeIncr), "incr", "backup type str incr");
}
FUNCTION_HARNESS_RESULT_VOID();

View File

@ -459,7 +459,7 @@ testRun(void)
TEST_RESULT_BOOL(
backupProtocol(PROTOCOL_COMMAND_BACKUP_FILE_STR, paramList, server), true, "protocol backup file - skip");
TEST_RESULT_STR(strPtr(strNewBuf(serverWrite)), "{\"out\":[3,0,0,null,null]}\n", " check result");
TEST_RESULT_STR_Z(strNewBuf(serverWrite), "{\"out\":[3,0,0,null,null]}\n", " check result");
bufUsedSet(serverWrite, 0);
// Pg file missing - ignoreMissing=false
@ -534,8 +534,8 @@ testRun(void)
TEST_RESULT_BOOL(
backupProtocol(PROTOCOL_COMMAND_BACKUP_FILE_STR, paramList, server), true, "protocol backup file - pageChecksum");
TEST_RESULT_STR(
strPtr(strNewBuf(serverWrite)),
TEST_RESULT_STR_Z(
strNewBuf(serverWrite),
"{\"out\":[1,9,9,\"9bc8ab2dda60ef4beed07d1e19ce0676d5edde67\",{\"align\":false,\"valid\":false}]}\n",
" check result");
bufUsedSet(serverWrite, 0);
@ -576,9 +576,8 @@ testRun(void)
TEST_RESULT_BOOL(
backupProtocol(PROTOCOL_COMMAND_BACKUP_FILE_STR, paramList, server), true, "protocol backup file - noop");
TEST_RESULT_STR(
strPtr(strNewBuf(serverWrite)), "{\"out\":[4,9,0,\"9bc8ab2dda60ef4beed07d1e19ce0676d5edde67\",null]}\n",
" check result");
TEST_RESULT_STR_Z(
strNewBuf(serverWrite), "{\"out\":[4,9,0,\"9bc8ab2dda60ef4beed07d1e19ce0676d5edde67\",null]}\n", " check result");
bufUsedSet(serverWrite, 0);
// -------------------------------------------------------------------------------------------------------------------------
@ -716,9 +715,8 @@ testRun(void)
TEST_RESULT_BOOL(
backupProtocol(PROTOCOL_COMMAND_BACKUP_FILE_STR, paramList, server), true, "protocol backup file - copy, compress");
TEST_RESULT_STR(
strPtr(strNewBuf(serverWrite)), "{\"out\":[0,9,29,\"9bc8ab2dda60ef4beed07d1e19ce0676d5edde67\",null]}\n",
" check result");
TEST_RESULT_STR_Z(
strNewBuf(serverWrite), "{\"out\":[0,9,29,\"9bc8ab2dda60ef4beed07d1e19ce0676d5edde67\",null]}\n", " check result");
bufUsedSet(serverWrite, 0);
// -------------------------------------------------------------------------------------------------------------------------
@ -835,9 +833,8 @@ testRun(void)
TEST_RESULT_BOOL(
backupProtocol(PROTOCOL_COMMAND_BACKUP_FILE_STR, paramList, server), true, "protocol backup file - recopy, encrypt");
TEST_RESULT_STR(
strPtr(strNewBuf(serverWrite)), "{\"out\":[2,9,32,\"9bc8ab2dda60ef4beed07d1e19ce0676d5edde67\",null]}\n",
" check result");
TEST_RESULT_STR_Z(
strNewBuf(serverWrite), "{\"out\":[2,9,32,\"9bc8ab2dda60ef4beed07d1e19ce0676d5edde67\",null]}\n", " check result");
bufUsedSet(serverWrite, 0);
}
@ -862,7 +859,7 @@ testRun(void)
storagePathCreateP(storageRepoWrite(), STRDEF(STORAGE_REPO_BACKUP "/backup.history/2019"));
TEST_RESULT_STR_STR(backupLabelCreate(backupTypeFull, NULL, timestamp), backupLabel, "create label");
TEST_RESULT_STR(backupLabelCreate(backupTypeFull, NULL, timestamp), backupLabel, "create label");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("assign label when history is older");
@ -875,7 +872,7 @@ testRun(void)
strPtr(backupLabelFormat(backupTypeFull, NULL, timestamp - 4)))),
NULL);
TEST_RESULT_STR_STR(backupLabelCreate(backupTypeFull, NULL, timestamp), backupLabel, "create label");
TEST_RESULT_STR(backupLabelCreate(backupTypeFull, NULL, timestamp), backupLabel, "create label");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("assign label when backup is older");
@ -886,7 +883,7 @@ testRun(void)
strNewFmt(STORAGE_REPO_BACKUP "/%s", strPtr(backupLabelFormat(backupTypeFull, NULL, timestamp - 2)))),
NULL);
TEST_RESULT_STR_STR(backupLabelCreate(backupTypeFull, NULL, timestamp), backupLabel, "create label");
TEST_RESULT_STR(backupLabelCreate(backupTypeFull, NULL, timestamp), backupLabel, "create label");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("advance time when backup is same");

View File

@ -27,11 +27,10 @@ testRun(void)
strLstAddZ(argList, "--stanza=db");
harnessCfgLoad(cfgCmdArchiveGet, argList);
TEST_RESULT_STR(
strPtr(lockStopFileName(NULL)), hrnReplaceKey("{[path-data]}/lock/all" STOP_FILE_EXT), "stop file for all stanzas");
TEST_RESULT_STR(
strPtr(lockStopFileName(strNew("db"))), hrnReplaceKey("{[path-data]}/lock/db" STOP_FILE_EXT),
"stop file for on stanza");
TEST_RESULT_STR_Z(
lockStopFileName(NULL), hrnReplaceKey("{[path-data]}/lock/all" STOP_FILE_EXT), "stop file for all stanzas");
TEST_RESULT_STR_Z(
lockStopFileName(strNew("db")), hrnReplaceKey("{[path-data]}/lock/db" STOP_FILE_EXT), "stop file for on stanza");
}
// *****************************************************************************************************************************
@ -109,7 +108,7 @@ testRun(void)
StringList *lockPathList = NULL;
TEST_ASSIGN(lockPathList, storageListP(storageData, strNew("lock"), .errorOnMissing = true), " get file list");
TEST_RESULT_INT(strLstSize(lockPathList), 1, " only file in lock path");
TEST_RESULT_STR(strPtr(strLstGet(lockPathList, 0)), "db" STOP_FILE_EXT, " stanza stop exists");
TEST_RESULT_STR_Z(strLstGet(lockPathList, 0), "db" STOP_FILE_EXT, " stanza stop exists");
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_VOID(cmdStop(), "stanza, stop file already exists");

View File

@ -188,10 +188,10 @@ testRun(void)
TEST_RESULT_VOID(expireBackup(infoBackup, full2, backupExpired), "expire backup with no manifest - does not error");
TEST_RESULT_STR(
strPtr(strLstJoin(infoBackupDataLabelList(infoBackup, NULL), ", ")),
"20181119-152800F_20181119-152152D, 20181119-152800F_20181119-152155I, 20181119-152900F, "
"20181119-152900F_20181119-152600D",
TEST_RESULT_STR_Z(
strLstJoin(infoBackupDataLabelList(infoBackup, NULL), ", "),
"20181119-152800F_20181119-152152D, 20181119-152800F_20181119-152155I, 20181119-152900F"
", 20181119-152900F_20181119-152600D",
"only backups passed to expireBackup are removed from backup:current");
}
@ -220,10 +220,11 @@ testRun(void)
TEST_RESULT_UINT(expireFullBackup(infoBackup), 1, "retention-full=2 - one full backup expired");
TEST_RESULT_UINT(infoBackupDataTotal(infoBackup), 5, " current backups reduced by 1 full - no dependencies");
TEST_RESULT_STR(
strPtr(strLstJoin(infoBackupDataLabelList(infoBackup, NULL), ", ")),
"20181119-152800F, 20181119-152800F_20181119-152152D, 20181119-152800F_20181119-152155I, "
"20181119-152900F, 20181119-152900F_20181119-152600D", " remaining backups correct");
TEST_RESULT_STR_Z(
strLstJoin(infoBackupDataLabelList(infoBackup, NULL), ", "),
"20181119-152800F, 20181119-152800F_20181119-152152D, 20181119-152800F_20181119-152155I"
", 20181119-152900F, 20181119-152900F_20181119-152600D",
" remaining backups correct");
harnessLogResult("P00 INFO: expire full backup 20181119-152138F");
//--------------------------------------------------------------------------------------------------------------------------
@ -233,18 +234,18 @@ testRun(void)
TEST_RESULT_UINT(expireFullBackup(infoBackup), 3, "retention-full=1 - one full backup and dependencies expired");
TEST_RESULT_UINT(infoBackupDataTotal(infoBackup), 2, " current backups reduced by 1 full and dependencies");
TEST_RESULT_STR(
strPtr(strLstJoin(infoBackupDataLabelList(infoBackup, NULL), ", ")),
"20181119-152900F, 20181119-152900F_20181119-152600D", " remaining backups correct");
TEST_RESULT_STR_Z(
strLstJoin(infoBackupDataLabelList(infoBackup, NULL), ", "), "20181119-152900F, 20181119-152900F_20181119-152600D",
" remaining backups correct");
harnessLogResult(
"P00 INFO: expire full backup set: 20181119-152800F, 20181119-152800F_20181119-152152D, "
"20181119-152800F_20181119-152155I");
//--------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_UINT(expireFullBackup(infoBackup), 0, "retention-full=1 - not enough backups to expire any");
TEST_RESULT_STR(
strPtr(strLstJoin(infoBackupDataLabelList(infoBackup, NULL), ", ")),
"20181119-152900F, 20181119-152900F_20181119-152600D", " remaining backups correct");
TEST_RESULT_STR_Z(
strLstJoin(infoBackupDataLabelList(infoBackup, NULL), ", "), "20181119-152900F, 20181119-152900F_20181119-152600D",
" remaining backups correct");
}
// *****************************************************************************************************************************
@ -278,8 +279,8 @@ testRun(void)
TEST_RESULT_UINT(expireDiffBackup(infoBackup), 2, "retention-diff set - full considered in diff");
TEST_RESULT_UINT(infoBackupDataTotal(infoBackup), 4, " current backups reduced by 1 diff and dependent increment");
TEST_RESULT_STR(
strPtr(strLstJoin(infoBackupDataLabelList(infoBackup, NULL), ", ")),
TEST_RESULT_STR_Z(
strLstJoin(infoBackupDataLabelList(infoBackup, NULL), ", "),
"20181119-152138F, 20181119-152800F, 20181119-152900F, 20181119-152900F_20181119-152600D",
" remaining backups correct");
harnessLogResult(
@ -338,9 +339,8 @@ testRun(void)
TEST_RESULT_UINT(expireDiffBackup(infoBackup), 1, "retention-diff set - only oldest diff expired");
TEST_RESULT_UINT(infoBackupDataTotal(infoBackup), 2, " current backups reduced by one");
TEST_RESULT_STR(
strPtr(strLstJoin(infoBackupDataLabelList(infoBackup, NULL), ", ")),
"20181119-152800F, 20181119-152800F_20181119-152155D",
TEST_RESULT_STR_Z(
strLstJoin(infoBackupDataLabelList(infoBackup, NULL), ", "), "20181119-152800F, 20181119-152800F_20181119-152155D",
" remaining backups correct");
harnessLogResult(
"P00 INFO: expire diff backup 20181119-152800F_20181119-152152D");
@ -407,9 +407,10 @@ testRun(void)
"P00 INFO: remove expired backup 20181119-152100F_20181119-152152D\n"
"P00 INFO: remove expired backup 20181119-152100F");
TEST_RESULT_STR(
strPtr(strLstJoin(strLstSort(storageListP(storageTest, backupStanzaPath), sortOrderAsc), ", ")),
"20181118-152100F_20181119-152152D.save, 20181119-152138F, backup.info, bogus", " remaining file/directories correct");
TEST_RESULT_STR_Z(
strLstJoin(strLstSort(storageListP(storageTest, backupStanzaPath), sortOrderAsc), ", "),
"20181118-152100F_20181119-152152D.save, 20181119-152138F, backup.info, bogus",
" remaining file/directories correct");
//--------------------------------------------------------------------------------------------------------------------------
// Create backup.info without current backups
@ -432,8 +433,8 @@ testRun(void)
TEST_RESULT_VOID(removeExpiredBackup(infoBackup), "remove backups - backup.info current empty");
harnessLogResult("P00 INFO: remove expired backup 20181119-152138F");
TEST_RESULT_STR(
strPtr(strLstJoin(strLstSort(storageListP(storageTest, backupStanzaPath), sortOrderAsc), ", ")),
TEST_RESULT_STR_Z(
strLstJoin(strLstSort(storageListP(storageTest, backupStanzaPath), sortOrderAsc), ", "),
"20181118-152100F_20181119-152152D.save, backup.info, bogus", " remaining file/directories correct");
}
@ -580,19 +581,18 @@ testRun(void)
TEST_RESULT_VOID(removeExpiredArchive(infoBackup), "archive retention type = full (default), repo1-retention-archive=4");
TEST_RESULT_STR(
strPtr(strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "9.4-1", "0000000100000000")), sortOrderAsc), ", ")),
strPtr(archiveExpectList(2, 10, "0000000100000000")),
" only 9.4-1/0000000100000000/000000010000000000000001 removed");
strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "9.4-1", "0000000100000000")), sortOrderAsc), ", "),
archiveExpectList(2, 10, "0000000100000000"), " only 9.4-1/0000000100000000/000000010000000000000001 removed");
TEST_RESULT_STR(
strPtr(strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "9.4-1", "0000000200000000")), sortOrderAsc), ", ")),
strPtr(archiveExpectList(1, 10, "0000000200000000")),
strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "9.4-1", "0000000200000000")), sortOrderAsc), ", "),
archiveExpectList(1, 10, "0000000200000000"),
" none removed from 9.4-1/0000000200000000 - crossing timelines to play through PITR");
TEST_RESULT_STR(
strPtr(strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "10-2", "0000000100000000")), sortOrderAsc), ", ")),
strPtr(archiveExpectList(3, 10, "0000000100000000")),
strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "10-2", "0000000100000000")), sortOrderAsc), ", "),
archiveExpectList(3, 10, "0000000100000000"),
" 000000010000000000000001 and 000000010000000000000002 removed from 10-2/0000000100000000");
harnessLogResult(
"P00 INFO: full backup total < 4 - using oldest full backup for 9.4-1 archive retention\n"
@ -606,19 +606,19 @@ testRun(void)
TEST_RESULT_VOID(removeExpiredArchive(infoBackup), "archive retention type = full (default), repo1-retention-archive=2");
TEST_RESULT_STR(
strPtr(strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "9.4-1", "0000000100000000")), sortOrderAsc), ", ")),
strPtr(archiveExpectList(2, 2, "0000000100000000")),
strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "9.4-1", "0000000100000000")), sortOrderAsc), ", "),
archiveExpectList(2, 2, "0000000100000000"),
" only 9.4-1/0000000100000000/000000010000000000000002 remains in major wal 1");
TEST_RESULT_STR(
strPtr(strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "9.4-1", "0000000200000000")), sortOrderAsc), ", ")),
strPtr(archiveExpectList(2, 10, "0000000200000000")),
strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "9.4-1", "0000000200000000")), sortOrderAsc), ", "),
archiveExpectList(2, 10, "0000000200000000"),
" only 9.4-1/0000000200000000/000000010000000000000001 removed from major wal 2");
TEST_RESULT_STR(
strPtr(strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "10-2", "0000000100000000")), sortOrderAsc), ", ")),
strPtr(archiveExpectList(3, 10, "0000000100000000")),
strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "10-2", "0000000100000000")), sortOrderAsc), ", "),
archiveExpectList(3, 10, "0000000100000000"),
" none removed from 10-2/0000000100000000");
//--------------------------------------------------------------------------------------------------------------------------
@ -629,20 +629,19 @@ testRun(void)
TEST_RESULT_VOID(removeExpiredArchive(infoBackup), "archive retention type = full (default), repo1-retention-archive=1");
TEST_RESULT_STR(
strPtr(strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "9.4-1", "0000000100000000")), sortOrderAsc), ", ")),
strPtr(archiveExpectList(2, 2, "0000000100000000")),
strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "9.4-1", "0000000100000000")), sortOrderAsc), ", "),
archiveExpectList(2, 2, "0000000100000000"),
" only 9.4-1/0000000100000000/000000010000000000000002 remains in major wal 1");
TEST_RESULT_STR(
strPtr(strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "9.4-1", "0000000200000000")), sortOrderAsc), ", ")),
strPtr(archiveExpectList(2, 10, "0000000200000000")),
strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "9.4-1", "0000000200000000")), sortOrderAsc), ", "),
archiveExpectList(2, 10, "0000000200000000"),
" nothing removed from 9.4-1/0000000200000000 major wal 2 - each archiveId must have one backup to play through PITR");
TEST_RESULT_STR(
strPtr(strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "10-2", "0000000100000000")), sortOrderAsc), ", ")),
strPtr(archiveExpectList(3, 10, "0000000100000000")),
" none removed from 10-2/0000000100000000");
strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "10-2", "0000000100000000")), sortOrderAsc), ", "),
archiveExpectList(3, 10, "0000000100000000"), " none removed from 10-2/0000000100000000");
//--------------------------------------------------------------------------------------------------------------------------
argList = strLstDup(argListAvoidWarn);
@ -665,20 +664,18 @@ testRun(void)
strPtr(archiveExpectList(9, 10, "0000000200000000")));
TEST_RESULT_STR(
strPtr(strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "9.4-1", "0000000100000000")), sortOrderAsc), ", ")),
strPtr(archiveExpectList(2, 2, "0000000100000000")),
strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "9.4-1", "0000000100000000")), sortOrderAsc), ", "),
archiveExpectList(2, 2, "0000000100000000"),
" only 9.4-1/0000000100000000/000000010000000000000002 remains in major wal 1");
TEST_RESULT_STR(
strPtr(strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "9.4-1", "0000000200000000")), sortOrderAsc), ", ")),
strPtr(result),
" all in-between removed from 9.4-1/0000000200000000 major wal 2 - last backup able to play through PITR");
strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "9.4-1", "0000000200000000")), sortOrderAsc), ", "),
result, " all in-between removed from 9.4-1/0000000200000000 major wal 2 - last backup able to play through PITR");
TEST_RESULT_STR(
strPtr(strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "10-2", "0000000100000000")), sortOrderAsc), ", ")),
strPtr(archiveExpectList(3, 10, "0000000100000000")),
" none removed from 10-2/0000000100000000");
strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "10-2", "0000000100000000")), sortOrderAsc), ", "),
archiveExpectList(3, 10, "0000000100000000"), " none removed from 10-2/0000000100000000");
//--------------------------------------------------------------------------------------------------------------------------
argList = strLstDup(argListAvoidWarn);
@ -700,20 +697,18 @@ testRun(void)
strPtr(archiveExpectList(7, 10, "0000000200000000")));
TEST_RESULT_STR(
strPtr(strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "9.4-1", "0000000100000000")), sortOrderAsc), ", ")),
strPtr(archiveExpectList(2, 2, "0000000100000000")),
strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "9.4-1", "0000000100000000")), sortOrderAsc), ", "),
archiveExpectList(2, 2, "0000000100000000"),
" only 9.4-1/0000000100000000/000000010000000000000002 remains in major wal 1");
TEST_RESULT_STR(
strPtr(strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "9.4-1", "0000000200000000")), sortOrderAsc), ", ")),
strPtr(result),
" incremental and after remain in 9.4-1/0000000200000000 major wal 2");
strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "9.4-1", "0000000200000000")), sortOrderAsc), ", "),
result, " incremental and after remain in 9.4-1/0000000200000000 major wal 2");
TEST_RESULT_STR(
strPtr(strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "10-2", "0000000100000000")), sortOrderAsc), ", ")),
strPtr(archiveExpectList(3, 10, "0000000100000000")),
" none removed from 10-2/0000000100000000");
strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "10-2", "0000000100000000")), sortOrderAsc), ", "),
archiveExpectList(3, 10, "0000000100000000"), " none removed from 10-2/0000000100000000");
//--------------------------------------------------------------------------------------------------------------------------
argList = strLstDup(argListBase);
@ -775,8 +770,8 @@ testRun(void)
TEST_ASSIGN(infoBackup, infoBackupLoadFile(storageTest, backupInfoFileName, cipherTypeNone, NULL), " get backup.info");
TEST_RESULT_UINT(infoBackupDataTotal(infoBackup), 2, " backup.info updated on disk");
TEST_RESULT_STR(
strPtr(strLstJoin(strLstSort(infoBackupDataLabelList(infoBackup, NULL), sortOrderAsc), ", ")),
TEST_RESULT_STR_Z(
strLstJoin(strLstSort(infoBackupDataLabelList(infoBackup, NULL), sortOrderAsc), ", "),
"20181119-152900F, 20181119-152900F_20181119-152500I", " remaining current backups correct");
//--------------------------------------------------------------------------------------------------------------------------
@ -832,10 +827,9 @@ testRun(void)
TEST_RESULT_VOID(
removeExpiredArchive(infoBackup), "backup selected for retention does not have archive-start so do nothing");
TEST_RESULT_STR(
strPtr(strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "9.4-1", "0000000100000000")), sortOrderAsc), ", ")),
strPtr(archiveExpectList(1, 5, "0000000100000000")),
" nothing removed from 9.4-1/0000000100000000");
strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "9.4-1", "0000000100000000")), sortOrderAsc), ", "),
archiveExpectList(1, 5, "0000000100000000"), " nothing removed from 9.4-1/0000000100000000");
argList = strLstDup(argListAvoidWarn);
strLstAddZ(argList, "--repo1-retention-archive=4");
@ -845,10 +839,9 @@ testRun(void)
TEST_RESULT_VOID(
removeExpiredArchive(infoBackup), "full count as incr but not enough backups, retention set to first full");
TEST_RESULT_STR(
strPtr(strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "9.4-1", "0000000100000000")), sortOrderAsc), ", ")),
strPtr(archiveExpectList(2, 5, "0000000100000000")),
" only removed archive prior to first full");
strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "9.4-1", "0000000100000000")), sortOrderAsc), ", "),
archiveExpectList(2, 5, "0000000100000000"), " only removed archive prior to first full");
harnessLogResult(
"P00 INFO: full backup total < 4 - using oldest full backup for 9.4-1 archive retention");
@ -952,15 +945,13 @@ testRun(void)
"P00 INFO: expire full backup 20181119-152138F\n"
"P00 INFO: remove expired backup 20181119-152138F");
TEST_RESULT_STR(
strPtr(strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "10-1", "0000000100000000")), sortOrderAsc), ", ")),
strPtr(archiveExpectList(1, 7, "0000000100000000")),
" none removed from 10-1/0000000100000000");
strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "10-1", "0000000100000000")), sortOrderAsc), ", "),
archiveExpectList(1, 7, "0000000100000000"), " none removed from 10-1/0000000100000000");
TEST_RESULT_STR(
strPtr(strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "10-2", "0000000100000000")), sortOrderAsc), ", ")),
strPtr(archiveExpectList(1, 7, "0000000100000000")),
" none removed from 10-2/0000000100000000");
strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "10-2", "0000000100000000")), sortOrderAsc), ", "),
archiveExpectList(1, 7, "0000000100000000"), " none removed from 10-2/0000000100000000");
// archive.info old history db system id not the same as backup.info
//--------------------------------------------------------------------------------------------------------------------------
@ -1075,14 +1066,13 @@ testRun(void)
"P00 INFO: remove expired backup 20181119-152800F\n"
"P00 INFO: remove expired backup 20181119-152138F");
TEST_RESULT_STR(
strPtr(strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "10-1", "0000000100000000")), sortOrderAsc), ", ")),
strPtr(archiveExpectList(1, 7, "0000000100000000")),
" none removed from 10-1/0000000100000000");
strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "10-1", "0000000100000000")), sortOrderAsc), ", "),
archiveExpectList(1, 7, "0000000100000000"), " none removed from 10-1/0000000100000000");
TEST_RESULT_STR(
strPtr(strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "10-2", "0000000100000000")), sortOrderAsc), ", ")),
strPtr(archiveExpectList(6, 7, "0000000100000000")),
strLstJoin(strLstSort(storageListP(
storageTest, strNewFmt("%s/%s/%s", strPtr(archiveStanzaPath), "10-2", "0000000100000000")), sortOrderAsc), ", "),
archiveExpectList(6, 7, "0000000100000000"),
" all prior to 000000010000000000000006 removed from 10-2/0000000100000000");
}
@ -1095,11 +1085,10 @@ testRun(void)
strLstAddZ(list, "11-10");
strLstAddZ(list, "9.6-1");
TEST_RESULT_STR(strPtr(strLstJoin(strLstSort(list, sortOrderAsc), ", ")), "9.6-1, 10-4, 11-10", "sort ascending");
TEST_RESULT_STR_Z(strLstJoin(strLstSort(list, sortOrderAsc), ", "), "9.6-1, 10-4, 11-10", "sort ascending");
strLstAddZ(list, "9.4-2");
TEST_RESULT_STR(
strPtr(strLstJoin(strLstSort(list, sortOrderDesc), ", ")), "11-10, 10-4, 9.4-2, 9.6-1", "sort descending");
TEST_RESULT_STR_Z(strLstJoin(strLstSort(list, sortOrderDesc), ", "), "11-10, 10-4, 9.4-2, 9.6-1", "sort descending");
}
FUNCTION_HARNESS_RESULT_VOID();

View File

@ -46,18 +46,17 @@ testRun(void)
// *****************************************************************************************************************************
if (testBegin("helpRenderText()"))
{
TEST_RESULT_STR(
strPtr(helpRenderText(strNew("this is a short sentence"), 0, false, 80)), "this is a short sentence", "one line");
TEST_RESULT_STR_Z(helpRenderText(strNew("this is a short sentence"), 0, false, 80), "this is a short sentence", "one line");
TEST_RESULT_STR(
strPtr(helpRenderText(strNew("this is a short sentence"), 4, false, 14)),
TEST_RESULT_STR_Z(
helpRenderText(strNew("this is a short sentence"), 4, false, 14),
"this is a\n"
" short\n"
" sentence",
"three lines, no indent first");
TEST_RESULT_STR(
strPtr(helpRenderText(strNew("This is a short paragraph.\n\nHere is another one."), 2, true, 16)),
TEST_RESULT_STR_Z(
helpRenderText(strNew("This is a short paragraph.\n\nHere is another one."), 2, true, 16),
" This is a\n"
" short\n"
" paragraph.\n"
@ -70,11 +69,11 @@ testRun(void)
// *****************************************************************************************************************************
if (testBegin("helpRenderValue()"))
{
TEST_RESULT_STR(strPtr(helpRenderValue(varNewBool(true))), "y", "boolean y");
TEST_RESULT_STR(strPtr(helpRenderValue(varNewBool(false))), "n", "boolean n");
TEST_RESULT_STR(strPtr(helpRenderValue(varNewStrZ("test-string"))), "test-string", "string");
TEST_RESULT_STR(strPtr(helpRenderValue(varNewDbl(1.234))), "1.234", "double");
TEST_RESULT_STR(strPtr(helpRenderValue(varNewInt(1234))), "1234", "int");
TEST_RESULT_STR_Z(helpRenderValue(varNewBool(true)), "y", "boolean y");
TEST_RESULT_STR_Z(helpRenderValue(varNewBool(false)), "n", "boolean n");
TEST_RESULT_STR_Z(helpRenderValue(varNewStrZ("test-string")), "test-string", "string");
TEST_RESULT_STR_Z(helpRenderValue(varNewDbl(1.234)), "1.234", "double");
TEST_RESULT_STR_Z(helpRenderValue(varNewInt(1234)), "1234", "int");
}
// *****************************************************************************************************************************
@ -86,13 +85,13 @@ testRun(void)
argList = strLstNew();
strLstAddZ(argList, "/path/to/pgbackrest");
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "help from empty command line");
TEST_RESULT_STR(strPtr(helpRender()), generalHelp, " check text");
TEST_RESULT_STR_Z(helpRender(), generalHelp, " check text");
argList = strLstNew();
strLstAddZ(argList, "/path/to/pgbackrest");
strLstAddZ(argList, "help");
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "help from help command");
TEST_RESULT_STR(strPtr(helpRender()), generalHelp, " check text");
TEST_RESULT_STR_Z(helpRender(), generalHelp, " check text");
// -------------------------------------------------------------------------------------------------------------------------
const char *commandHelp = strPtr(strNewFmt(
@ -109,7 +108,7 @@ testRun(void)
strLstAddZ(argList, "help");
strLstAddZ(argList, "version");
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "help for version command");
TEST_RESULT_STR(strPtr(helpRender()), commandHelp, " check text");
TEST_RESULT_STR_Z(helpRender(), commandHelp, " check text");
// This test is broken up into multiple strings because C99 does not require compilers to support const strings > 4095 bytes
// -------------------------------------------------------------------------------------------------------------------------
@ -235,7 +234,7 @@ testRun(void)
strLstAddZ(argList, "--db-include=db2");
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "help for restore command");
unsetenv("PGBACKREST_REPO1_CIPHER_PASS");
TEST_RESULT_STR(strPtr(helpRender()), commandHelp, " check text");
TEST_RESULT_STR_Z(helpRender(), commandHelp, " check text");
// -------------------------------------------------------------------------------------------------------------------------
argList = strLstNew();
@ -280,13 +279,12 @@ testRun(void)
strLstAddZ(argList, "buffer-size");
TEST_RESULT_VOID(
configParse(strLstSize(argList), strLstPtr(argList), false), "help for archive-push command, buffer-size option");
TEST_RESULT_STR(strPtr(helpRender()), strPtr(strNewFmt("%s\ndefault: 4194304\n", optionHelp)), " check text");
TEST_RESULT_STR(helpRender(), strNewFmt("%s\ndefault: 4194304\n", optionHelp), " check text");
strLstAddZ(argList, "--buffer-size=32768");
TEST_RESULT_VOID(
configParse(strLstSize(argList), strLstPtr(argList), false), "help for archive-push command, buffer-size option");
TEST_RESULT_STR(
strPtr(helpRender()), strPtr(strNewFmt("%s\ncurrent: 32768\ndefault: 4194304\n", optionHelp)), " check text");
TEST_RESULT_STR(helpRender(), strNewFmt("%s\ncurrent: 32768\ndefault: 4194304\n", optionHelp), " check text");
// -------------------------------------------------------------------------------------------------------------------------
optionHelp = strPtr(strNewFmt(
@ -304,14 +302,13 @@ testRun(void)
strLstAddZ(argList, "repo1-s3-host");
TEST_RESULT_VOID(
configParse(strLstSize(argList), strLstPtr(argList), false), "help for archive-push command, repo1-s3-host option");
TEST_RESULT_STR(strPtr(helpRender()), optionHelp, " check text");
TEST_RESULT_STR_Z(helpRender(), optionHelp, " check text");
strLstAddZ(argList, "--repo1-type=s3");
strLstAddZ(argList, "--repo1-s3-host=s3-host");
TEST_RESULT_VOID(
configParse(strLstSize(argList), strLstPtr(argList), false), "help for archive-push command, repo1-s3-host option");
TEST_RESULT_STR(
strPtr(helpRender()), strPtr(strNewFmt("%s\ncurrent: s3-host\n", optionHelp)), " check text");
TEST_RESULT_STR(helpRender(), strNewFmt("%s\ncurrent: s3-host\n", optionHelp), " check text");
// -------------------------------------------------------------------------------------------------------------------------
optionHelp = strPtr(strNewFmt(
@ -334,7 +331,7 @@ testRun(void)
TEST_RESULT_VOID(
configParse(strLstSize(argList), strLstPtr(argList), false), "help for archive-push command, repo1-s3-host option");
unsetenv("PGBACKREST_REPO1_CIPHER_PASS");
TEST_RESULT_STR(strPtr(helpRender()), optionHelp, " check text");
TEST_RESULT_STR_Z(helpRender(), optionHelp, " check text");
// -------------------------------------------------------------------------------------------------------------------------
optionHelp = strPtr(strNewFmt(
@ -359,7 +356,7 @@ testRun(void)
strLstAddZ(argList, "repo-hardlink");
TEST_RESULT_VOID(
configParse(strLstSize(argList), strLstPtr(argList), false), "help for backup command, repo-hardlink option");
TEST_RESULT_STR(strPtr(helpRender()), optionHelp, " check text");
TEST_RESULT_STR_Z(helpRender(), optionHelp, " check text");
// Check admonition
// -------------------------------------------------------------------------------------------------------------------------
@ -392,7 +389,7 @@ testRun(void)
strLstAddZ(argList, "repo-retention-archive");
TEST_RESULT_VOID(
configParse(strLstSize(argList), strLstPtr(argList), false), "help for backup command, repo-retention-archive option");
TEST_RESULT_STR(strPtr(helpRender()), optionHelp, " check admonition text");
TEST_RESULT_STR_Z(helpRender(), optionHelp, " check admonition text");
}
// *****************************************************************************************************************************
@ -416,7 +413,7 @@ testRun(void)
Storage *storage = storagePosixNew(
strNew(testPath()), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, false, NULL);
TEST_RESULT_STR(strPtr(strNewBuf(storageGetP(storageNewReadP(storage, stdoutFile)))), generalHelp, " check text");
TEST_RESULT_STR_Z(strNewBuf(storageGetP(storageNewReadP(storage, stdoutFile))), generalHelp, " check text");
}
FUNCTION_HARNESS_RESULT_VOID();

View File

@ -36,10 +36,10 @@ testRun(void)
// No stanzas have been created
//--------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_STR(strPtr(infoRender()), "[]", "json - repo but no stanzas");
TEST_RESULT_STR_Z(infoRender(), "[]", "json - repo but no stanzas");
harnessCfgLoad(cfgCmdInfo, argListText);
TEST_RESULT_STR(strPtr(infoRender()), "No stanzas exist in the repository.\n", "text - no stanzas");
TEST_RESULT_STR_Z(infoRender(), "No stanzas exist in the repository.\n", "text - no stanzas");
storagePathCreateP(storageLocalWrite(), archivePath);
storagePathCreateP(storageLocalWrite(), backupPath);
@ -48,13 +48,16 @@ testRun(void)
//--------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_VOID(storagePathCreateP(storageLocalWrite(), backupStanza1Path), "backup stanza1 directory");
TEST_RESULT_VOID(storagePathCreateP(storageLocalWrite(), archiveStanza1Path), "archive stanza1 directory");
TEST_RESULT_STR(strPtr(infoRender()),
TEST_RESULT_STR_Z(
infoRender(),
"stanza: stanza1\n"
" status: error (missing stanza data)\n"
" cipher: none\n", "text - missing stanza data");
" cipher: none\n",
"text - missing stanza data");
harnessCfgLoad(cfgCmdInfo, argList);
TEST_RESULT_STR(strPtr(infoRender()),
TEST_RESULT_STR_Z(
infoRender(),
"["
"{"
"\"archive\":[],"
@ -67,7 +70,8 @@ testRun(void)
"\"message\":\"missing stanza data\""
"}"
"}"
"]", "json - missing stanza data");
"]",
"json - missing stanza data");
// backup.info file exists, but archive.info does not
//--------------------------------------------------------------------------------------------------------------------------
@ -128,7 +132,8 @@ testRun(void)
// archive section will cross reference backup db-id 2 to archive db-id 3 but db section will only use the db-ids from
// backup.info
TEST_RESULT_STR(strPtr(infoRender()),
TEST_RESULT_STR_Z(
infoRender(),
"["
"{"
"\"archive\":["
@ -161,10 +166,12 @@ testRun(void)
"\"message\":\"no valid backups\""
"}"
"}"
"]", "json - single stanza, no valid backups");
"]",
"json - single stanza, no valid backups");
harnessCfgLoad(cfgCmdInfo, argListText);
TEST_RESULT_STR(strPtr(infoRender()),
TEST_RESULT_STR_Z(
infoRender(),
"stanza: stanza1\n"
" status: error (no valid backups)\n"
" cipher: aes-256-cbc\n"
@ -186,7 +193,8 @@ testRun(void)
strLstAddZ(argList2, "--stanza=stanza1");
harnessCfgLoad(cfgCmdInfo, argList2);
TEST_RESULT_STR(strPtr(infoRender()),
TEST_RESULT_STR_Z(
infoRender(),
"stanza: stanza1\n"
" status: error (no valid backups)\n"
" cipher: aes-256-cbc\n"
@ -249,7 +257,8 @@ testRun(void)
storagePutP(storageNewWriteP(storageLocalWrite(), strNewFmt("%s/backup.info", strPtr(backupStanza1Path))),
harnessInfoChecksum(content)), "put backup info to file");
TEST_RESULT_STR(strPtr(infoRender()),
TEST_RESULT_STR_Z(
infoRender(),
"["
"{"
"\"archive\":["
@ -325,10 +334,12 @@ testRun(void)
"\"message\":\"ok\""
"}"
"}"
"]", "json - single stanza, valid backup, no priors, no archives in latest DB");
"]",
"json - single stanza, valid backup, no priors, no archives in latest DB");
harnessCfgLoad(cfgCmdInfo, argListText);
TEST_RESULT_STR(strPtr(infoRender()),
TEST_RESULT_STR_Z(
infoRender(),
"stanza: stanza1\n"
" status: ok\n"
" cipher: none\n"
@ -343,8 +354,8 @@ testRun(void)
" repository size: 3MB, repository backup size: 3KB\n"
"\n"
" db (current)\n"
" wal archive min/max (9.4-3): none present\n"
,"text - single stanza, valid backup, no priors, no archives in latest DB");
" wal archive min/max (9.4-3): none present\n",
"text - single stanza, valid backup, no priors, no archives in latest DB");
// backup.info/archive.info files exist, backups exist, archives exist
//--------------------------------------------------------------------------------------------------------------------------
@ -574,7 +585,8 @@ testRun(void)
harnessInfoChecksum(content)), "put backup info to file - stanza2");
harnessCfgLoad(cfgCmdInfo, argList);
TEST_RESULT_STR(strPtr(infoRender()),
TEST_RESULT_STR_Z(
infoRender(),
"["
"{"
"\"archive\":["
@ -734,10 +746,12 @@ testRun(void)
"\"message\":\"no valid backups\""
"}"
"}"
"]", "json - multiple stanzas, one with valid backups, archives in latest DB");
"]",
"json - multiple stanzas, one with valid backups, archives in latest DB");
harnessCfgLoad(cfgCmdInfo, argListText);
TEST_RESULT_STR(strPtr(infoRender()),
TEST_RESULT_STR_Z(
infoRender(),
"stanza: stanza1\n"
" status: ok\n"
" cipher: none\n"
@ -773,8 +787,8 @@ testRun(void)
" cipher: none\n"
"\n"
" db (current)\n"
" wal archive min/max (9.4-1): none present\n"
, "text - multiple stanzas, one with valid backups, archives in latest DB");
" wal archive min/max (9.4-1): none present\n",
"text - multiple stanzas, one with valid backups, archives in latest DB");
// Backup set requested
//--------------------------------------------------------------------------------------------------------------------------
@ -783,8 +797,8 @@ testRun(void)
strLstAddZ(argList2, "--set=20181119-152138F_20181119-152152I");
harnessCfgLoad(cfgCmdInfo, argList2);
TEST_RESULT_STR(strPtr(infoRender()),
TEST_RESULT_STR_Z(
infoRender(),
"stanza: stanza1\n"
" status: ok\n"
" cipher: none\n"
@ -804,8 +818,8 @@ testRun(void)
" pg_stat => ../pg_stat\n"
" tablespaces:\n"
" ts1 (1) => /tblspc/ts1\n"
" ts12 (12) => /tblspc/ts12\n"
, "text - backup set requested");
" ts12 (12) => /tblspc/ts12\n",
"text - backup set requested");
strLstAddZ(argList2, "--output=json");
harnessCfgLoad(cfgCmdInfo, argList2);
@ -844,7 +858,8 @@ testRun(void)
contentLoad),
"write manifest");
TEST_RESULT_STR(strPtr(infoRender()),
TEST_RESULT_STR_Z(
infoRender(),
"stanza: stanza1\n"
" status: ok\n"
" cipher: none\n"
@ -858,9 +873,8 @@ testRun(void)
" database size: 19.2MB, backup size: 8.2KB\n"
" repository size: 2.3MB, repository backup size: 346B\n"
" backup reference list: 20181119-152138F, 20181119-152138F_20181119-152152D\n"
" database list: mail (16456), postgres (12173)\n"
, "text - backup set requested, no links");
" database list: mail (16456), postgres (12173)\n",
"text - backup set requested, no links");
// Backup set requested but no databases
//--------------------------------------------------------------------------------------------------------------------------
@ -895,7 +909,8 @@ testRun(void)
contentLoad),
"write manifest");
TEST_RESULT_STR(strPtr(infoRender()),
TEST_RESULT_STR_Z(
infoRender(),
"stanza: stanza1\n"
" status: ok\n"
" cipher: none\n"
@ -909,15 +924,16 @@ testRun(void)
" database size: 19.2MB, backup size: 8.2KB\n"
" repository size: 2.3MB, repository backup size: 346B\n"
" backup reference list: 20181119-152138F, 20181119-152138F_20181119-152152D\n"
" database list: none\n"
, "text - backup set requested, no db");
" database list: none\n",
"text - backup set requested, no db");
// Stanza not found
//--------------------------------------------------------------------------------------------------------------------------
argList2 = strLstDup(argList);
strLstAddZ(argList2, "--stanza=silly");
harnessCfgLoad(cfgCmdInfo, argList2);
TEST_RESULT_STR(strPtr(infoRender()),
TEST_RESULT_STR_Z(
infoRender(),
"["
"{"
"\"backup\":[],"
@ -928,21 +944,24 @@ testRun(void)
"\"message\":\"missing stanza path\""
"}"
"}"
"]", "json - missing stanza path");
"]",
"json - missing stanza path");
StringList *argListText2 = strLstDup(argListText);
strLstAddZ(argListText2, "--stanza=silly");
harnessCfgLoad(cfgCmdInfo, argListText2);
TEST_RESULT_STR(strPtr(infoRender()),
"stanza: silly\n"
" status: error (missing stanza path)\n"
, "text - missing stanza path");
TEST_RESULT_STR_Z(
infoRender(),
"stanza: silly\n"
" status: error (missing stanza path)\n",
"text - missing stanza path");
// Stanza found
//--------------------------------------------------------------------------------------------------------------------------
strLstAddZ(argList, "--stanza=stanza2");
harnessCfgLoad(cfgCmdInfo, argList);
TEST_RESULT_STR(strPtr(infoRender()),
TEST_RESULT_STR_Z(
infoRender(),
"["
"{"
"\"archive\":["
@ -970,18 +989,20 @@ testRun(void)
"\"message\":\"no valid backups\""
"}"
"}"
"]", "json - multiple stanzas - selected found");
"]",
"json - multiple stanzas - selected found");
strLstAddZ(argListText, "--stanza=stanza2");
harnessCfgLoad(cfgCmdInfo, argListText);
TEST_RESULT_STR(strPtr(infoRender()),
TEST_RESULT_STR_Z(
infoRender(),
"stanza: stanza2\n"
" status: error (no valid backups)\n"
" cipher: none\n"
"\n"
" db (current)\n"
" wal archive min/max (9.4-1): none present\n"
,"text - multiple stanzas - selected found");
" wal archive min/max (9.4-1): none present\n",
"text - multiple stanzas - selected found");
// Crypto error
//--------------------------------------------------------------------------------------------------------------------------
@ -1052,15 +1073,16 @@ testRun(void)
String *result = strNew("");
formatTextDb(stanzaInfo, result, NULL);
TEST_RESULT_STR(strPtr(result),
TEST_RESULT_STR_Z(
result,
"\n"
" db (current)\n"
" full backup: 20181119-152138F\n"
" timestamp start/stop: 2018-11-16 15:47:56 / 2018-11-16 15:48:09\n"
" wal start/stop: n/a\n"
" database size: 0B, backup size: 0B\n"
" repository size: 0B, repository backup size: 0B\n"
,"formatTextDb only backup section (code coverage only)");
" repository size: 0B, repository backup size: 0B\n",
"formatTextDb only backup section (code coverage only)");
}
//******************************************************************************************************************************
@ -1087,8 +1109,8 @@ testRun(void)
Storage *storage = storagePosixNew(
strNew(testPath()), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, false, NULL);
TEST_RESULT_STR(
strPtr(strNewBuf(storageGetP(storageNewReadP(storage, stdoutFile)))), "No stanzas exist in the repository.\n",
TEST_RESULT_STR_Z(
strNewBuf(storageGetP(storageNewReadP(storage, stdoutFile))), "No stanzas exist in the repository.\n",
" check text");
//--------------------------------------------------------------------------------------------------------------------------

View File

@ -215,10 +215,9 @@ testRun(void)
TEST_RESULT_UINT(info.size, 7, " check size");
TEST_RESULT_UINT(info.mode, 0600, " check mode");
TEST_RESULT_UINT(info.timeModified, 1557432154, " check time");
TEST_RESULT_STR(strPtr(info.user), testUser(), " check user");
TEST_RESULT_STR(strPtr(info.group), testGroup(), " check group");
TEST_RESULT_STR(
strPtr(strNewBuf(storageGetP(storageNewReadP(storagePg(), strNew("normal"))))), "acefile", " check contents");
TEST_RESULT_STR_Z(info.user, testUser(), " check user");
TEST_RESULT_STR_Z(info.group, testGroup(), " check group");
TEST_RESULT_STR_Z(strNewBuf(storageGetP(storageNewReadP(storagePg(), strNew("normal")))), "acefile", " check contents");
// -------------------------------------------------------------------------------------------------------------------------
// Create a repo file
@ -232,8 +231,8 @@ testRun(void)
repoFile1, repoFileReferenceFull, false, strNew("delta"), strNew("9bc8ab2dda60ef4beed07d1e19ce0676d5edde67"),
false, 9, 1557432154, 0600, strNew(testUser()), strNew(testGroup()), 0, true, false, NULL),
true, "sha1 delta missing");
TEST_RESULT_STR(
strPtr(strNewBuf(storageGetP(storageNewReadP(storagePg(), strNew("delta"))))), "atestfile", " check contents");
TEST_RESULT_STR_Z(
strNewBuf(storageGetP(storageNewReadP(storagePg(), strNew("delta")))), "atestfile", " check contents");
size_t oldBufferSize = ioBufferSize();
ioBufferSizeSet(4);
@ -260,8 +259,8 @@ testRun(void)
repoFile1, repoFileReferenceFull, false, strNew("delta"), strNew("9bc8ab2dda60ef4beed07d1e19ce0676d5edde67"),
false, 9, 1557432154, 0600, strNew(testUser()), strNew(testGroup()), 0, true, false, NULL),
true, "sha1 delta existing, size differs");
TEST_RESULT_STR(
strPtr(strNewBuf(storageGetP(storageNewReadP(storagePg(), strNew("delta"))))), "atestfile", " check contents");
TEST_RESULT_STR_Z(
strNewBuf(storageGetP(storageNewReadP(storagePg(), strNew("delta")))), "atestfile", " check contents");
storagePutP(storageNewWriteP(storagePgWrite(), strNew("delta")), BUFSTRDEF("atestfile2"));
@ -270,8 +269,8 @@ testRun(void)
repoFile1, repoFileReferenceFull, false, strNew("delta"), strNew("9bc8ab2dda60ef4beed07d1e19ce0676d5edde67"),
false, 9, 1557432154, 0600, strNew(testUser()), strNew(testGroup()), 1557432155, true, true, NULL),
true, "delta force existing, size differs");
TEST_RESULT_STR(
strPtr(strNewBuf(storageGetP(storageNewReadP(storagePg(), strNew("delta"))))), "atestfile", " check contents");
TEST_RESULT_STR_Z(
strNewBuf(storageGetP(storageNewReadP(storagePg(), strNew("delta")))), "atestfile", " check contents");
// Change the existing file so it no longer matches by content
storagePutP(storageNewWriteP(storagePgWrite(), strNew("delta")), BUFSTRDEF("btestfile"));
@ -281,8 +280,8 @@ testRun(void)
repoFile1, repoFileReferenceFull, false, strNew("delta"), strNew("9bc8ab2dda60ef4beed07d1e19ce0676d5edde67"),
false, 9, 1557432154, 0600, strNew(testUser()), strNew(testGroup()), 0, true, false, NULL),
true, "sha1 delta existing, content differs");
TEST_RESULT_STR(
strPtr(strNewBuf(storageGetP(storageNewReadP(storagePg(), strNew("delta"))))), "atestfile", " check contents");
TEST_RESULT_STR_Z(
strNewBuf(storageGetP(storageNewReadP(storagePg(), strNew("delta")))), "atestfile", " check contents");
storagePutP(storageNewWriteP(storagePgWrite(), strNew("delta")), BUFSTRDEF("btestfile"));
@ -327,7 +326,7 @@ testRun(void)
varLstAdd(paramList, NULL);
TEST_RESULT_BOOL(restoreProtocol(PROTOCOL_COMMAND_RESTORE_FILE_STR, paramList, server), true, "protocol restore file");
TEST_RESULT_STR(strPtr(strNewBuf(serverWrite)), "{\"out\":true}\n", " check result");
TEST_RESULT_STR_Z(strNewBuf(serverWrite), "{\"out\":true}\n", " check result");
bufUsedSet(serverWrite, 0);
info = storageInfoP(storagePg(), strNew("protocol"));
@ -335,10 +334,10 @@ testRun(void)
TEST_RESULT_UINT(info.size, 9, " check size");
TEST_RESULT_UINT(info.mode, 0677, " check mode");
TEST_RESULT_UINT(info.timeModified, 1557432100, " check time");
TEST_RESULT_STR(strPtr(info.user), testUser(), " check user");
TEST_RESULT_STR(strPtr(info.group), testGroup(), " check group");
TEST_RESULT_STR(
strPtr(strNewBuf(storageGetP(storageNewReadP(storagePg(), strNew("protocol"))))), "atestfile", " check contents");
TEST_RESULT_STR_Z(info.user, testUser(), " check user");
TEST_RESULT_STR_Z(info.group, testGroup(), " check group");
TEST_RESULT_STR_Z(
strNewBuf(storageGetP(storageNewReadP(storagePg(), strNew("protocol")))), "atestfile", " check contents");
paramList = varLstNew();
varLstAdd(paramList, varNewStr(repoFile1));
@ -358,7 +357,7 @@ testRun(void)
varLstAdd(paramList, NULL);
TEST_RESULT_BOOL(restoreProtocol(PROTOCOL_COMMAND_RESTORE_FILE_STR, paramList, server), true, "protocol restore file");
TEST_RESULT_STR(strPtr(strNewBuf(serverWrite)), "{\"out\":false}\n", " check result");
TEST_RESULT_STR_Z(strNewBuf(serverWrite), "{\"out\":false}\n", " check result");
bufUsedSet(serverWrite, 0);
// Check invalid protocol function
@ -507,8 +506,7 @@ testRun(void)
harnessCfgLoad(cfgCmdRestore, argList);
TEST_RESULT_VOID(restoreManifestMap(manifest), "base directory is not remapped");
TEST_RESULT_STR_STR(
manifestTargetFind(manifest, MANIFEST_TARGET_PGDATA_STR)->path, pgPath, "base directory is not remapped");
TEST_RESULT_STR(manifestTargetFind(manifest, MANIFEST_TARGET_PGDATA_STR)->path, pgPath, "base directory is not remapped");
// Now change pg1-path so the data directory gets remapped
pgPath = strNewFmt("%s/pg2", testPath());
@ -520,7 +518,7 @@ testRun(void)
harnessCfgLoad(cfgCmdRestore, argList);
TEST_RESULT_VOID(restoreManifestMap(manifest), "base directory is remapped");
TEST_RESULT_STR_STR(manifestTargetFind(manifest, MANIFEST_TARGET_PGDATA_STR)->path, pgPath, "base directory is remapped");
TEST_RESULT_STR(manifestTargetFind(manifest, MANIFEST_TARGET_PGDATA_STR)->path, pgPath, "base directory is remapped");
TEST_RESULT_LOG("P00 INFO: remap data directory to '{[path]}/pg2'");
// -------------------------------------------------------------------------------------------------------------------------

View File

@ -32,12 +32,12 @@ testRun(void)
Buffer *output = bufNew(0);
cfgOptionSet(cfgOptOutput, cfgSourceParam, VARSTRDEF("text"));
TEST_RESULT_VOID(storageListRender(ioBufferWriteNew(output)), "missing directory (text)");
TEST_RESULT_STR(strNewBuf(output), "", " check output");
TEST_RESULT_STR_Z(strNewBuf(output), "", " check output");
output = bufNew(0);
cfgOptionSet(cfgOptOutput, cfgSourceParam, VARSTRDEF("json"));
TEST_RESULT_VOID(storageListRender(ioBufferWriteNew(output)), "missing directory (json)");
TEST_RESULT_STR(strPtr(strNewBuf(output)), "{}", " check output");
TEST_RESULT_STR_Z(strNewBuf(output), "{}", " check output");
// Empty directory
// -------------------------------------------------------------------------------------------------------------------------
@ -46,7 +46,7 @@ testRun(void)
output = bufNew(0);
cfgOptionSet(cfgOptOutput, cfgSourceParam, VARSTRDEF("text"));
TEST_RESULT_VOID(storageListRender(ioBufferWriteNew(output)), "empty directory (text)");
TEST_RESULT_STR(strPtr(strNewBuf(output)), "", " check output");
TEST_RESULT_STR_Z(strNewBuf(output), "", " check output");
output = bufNew(0);
cfgOptionSet(cfgOptOutput, cfgSourceParam, VARSTRDEF("json"));
@ -72,7 +72,7 @@ testRun(void)
output = bufNew(0);
cfgOptionSet(cfgOptOutput, cfgSourceParam, VARSTRDEF("text"));
TEST_RESULT_VOID(storageListRender(ioBufferWriteNew(output)), "path and file (text)");
TEST_RESULT_STR(strPtr(strNewBuf(output)), "aaa\nbbb\nlink\npipe", " check output");
TEST_RESULT_STR_Z(strNewBuf(output), "aaa\nbbb\nlink\npipe", " check output");
output = bufNew(0);
cfgOptionSet(cfgOptOutput, cfgSourceParam, VARSTRDEF("json"));
@ -95,7 +95,7 @@ testRun(void)
output = bufNew(0);
cfgOptionSet(cfgOptOutput, cfgSourceParam, VARSTRDEF("text"));
TEST_RESULT_VOID(storageListRender(ioBufferWriteNew(output)), "path and file (text)");
TEST_RESULT_STR(strPtr(strNewBuf(output)), "pipe\nlink\nbbb\naaa", " check output");
TEST_RESULT_STR_Z(strNewBuf(output), "pipe\nlink\nbbb\naaa", " check output");
// Recurse
// -------------------------------------------------------------------------------------------------------------------------
@ -105,7 +105,7 @@ testRun(void)
output = bufNew(0);
cfgOptionSet(cfgOptOutput, cfgSourceParam, VARSTRDEF("text"));
TEST_RESULT_VOID(storageListRender(ioBufferWriteNew(output)), "filter");
TEST_RESULT_STR(strPtr(strNewBuf(output)), "pipe\nlink\nbbb/ccc\nbbb\naaa", " check output");
TEST_RESULT_STR_Z(strNewBuf(output), "pipe\nlink\nbbb/ccc\nbbb\naaa", " check output");
// Filter
// -------------------------------------------------------------------------------------------------------------------------
@ -115,7 +115,7 @@ testRun(void)
output = bufNew(0);
cfgOptionSet(cfgOptOutput, cfgSourceParam, VARSTRDEF("text"));
TEST_RESULT_VOID(storageListRender(ioBufferWriteNew(output)), "filter");
TEST_RESULT_STR(strPtr(strNewBuf(output)), "aaa", " check output");
TEST_RESULT_STR_Z(strNewBuf(output), "aaa", " check output");
// Subdirectory
// -------------------------------------------------------------------------------------------------------------------------
@ -126,7 +126,7 @@ testRun(void)
output = bufNew(0);
cfgOptionSet(cfgOptOutput, cfgSourceParam, VARSTRDEF("text"));
TEST_RESULT_VOID(storageListRender(ioBufferWriteNew(output)), "subdirectory");
TEST_RESULT_STR(strPtr(strNewBuf(output)), "ccc", " check output");
TEST_RESULT_STR_Z(strNewBuf(output), "ccc", " check output");
// -------------------------------------------------------------------------------------------------------------------------
// Redirect stdout to a file
@ -141,7 +141,7 @@ testRun(void)
// Restore normal stdout
dup2(stdoutSave, STDOUT_FILENO);
TEST_RESULT_STR(strPtr(strNewBuf(storageGetP(storageNewReadP(storageTest, stdoutFile)))), "ccc\n", " check text");
TEST_RESULT_STR_Z(strNewBuf(storageGetP(storageNewReadP(storageTest, stdoutFile))), "ccc\n", " check text");
// Too many paths
// -------------------------------------------------------------------------------------------------------------------------

View File

@ -179,11 +179,11 @@ testRun(void)
{
GzipDecompress *decompress = (GzipDecompress *)ioFilterDriver(gzipDecompressNew(false));
TEST_RESULT_STR(strPtr(gzipDecompressToLog(decompress)), "{inputSame: false, done: false, availIn: 0}", "format object");
TEST_RESULT_STR_Z(gzipDecompressToLog(decompress), "{inputSame: false, done: false, availIn: 0}", "format object");
decompress->inputSame = true;
decompress->done = true;
TEST_RESULT_STR(strPtr(gzipDecompressToLog(decompress)), "{inputSame: true, done: true, availIn: 0}", "format object");
TEST_RESULT_STR_Z(gzipDecompressToLog(decompress), "{inputSame: true, done: true, availIn: 0}", "format object");
}
FUNCTION_HARNESS_RESULT_VOID();

View File

@ -51,8 +51,8 @@ testRun(void)
TEST_RESULT_UINT(cipherType(strNew("aes-256-cbc")), cipherTypeAes256Cbc, "aes-256-cbc type");
TEST_ERROR(cipherTypeName((CipherType)2), AssertError, "invalid cipher type 2");
TEST_RESULT_STR(strPtr(cipherTypeName(cipherTypeNone)), "none", "none name");
TEST_RESULT_STR(strPtr(cipherTypeName(cipherTypeAes256Cbc)), "aes-256-cbc", "aes-256-cbc name");
TEST_RESULT_STR_Z(cipherTypeName(cipherTypeNone), "none", "none name");
TEST_RESULT_STR_Z(cipherTypeName(cipherTypeAes256Cbc), "aes-256-cbc", "aes-256-cbc name");
// Test if the buffer was overrun
// -------------------------------------------------------------------------------------------------------------------------
@ -90,7 +90,7 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
CipherBlock *cipherBlock = (CipherBlock *)ioFilterDriver(
cipherBlockNew(cipherModeEncrypt, cipherTypeAes256Cbc, BUFSTRZ(TEST_PASS), NULL));
TEST_RESULT_STR(memContextName(cipherBlock->memContext), "CipherBlock", "mem context name is valid");
TEST_RESULT_Z(memContextName(cipherBlock->memContext), "CipherBlock", "mem context name is valid");
TEST_RESULT_INT(cipherBlock->mode, cipherModeEncrypt, "mode is valid");
TEST_RESULT_INT(cipherBlock->passSize, strlen(TEST_PASS), "passphrase size is valid");
TEST_RESULT_BOOL(memcmp(cipherBlock->pass, TEST_PASS, strlen(TEST_PASS)) == 0, true, "passphrase is valid");
@ -170,7 +170,7 @@ testRun(void)
ioFilterProcessInOut(blockDecryptFilter, NULL, decryptBuffer);
TEST_RESULT_INT(bufUsed(decryptBuffer), strlen(TEST_PLAINTEXT) * 2, "check final decrypt size");
TEST_RESULT_STR(strPtr(strNewBuf(decryptBuffer)), TEST_PLAINTEXT TEST_PLAINTEXT, "check final decrypt buffer");
TEST_RESULT_STR_Z(strNewBuf(decryptBuffer), TEST_PLAINTEXT TEST_PLAINTEXT, "check final decrypt buffer");
ioFilterFree(blockDecryptFilter);
@ -210,7 +210,7 @@ testRun(void)
ioFilterProcessInOut(blockDecryptFilter, NULL, decryptBuffer);
TEST_RESULT_INT(bufUsed(decryptBuffer), strlen(TEST_PLAINTEXT) * 2, "check final decrypt size");
TEST_RESULT_STR(strPtr(strNewBuf(decryptBuffer)), TEST_PLAINTEXT TEST_PLAINTEXT, "check final decrypt buffer");
TEST_RESULT_STR_Z(strNewBuf(decryptBuffer), TEST_PLAINTEXT TEST_PLAINTEXT, "check final decrypt buffer");
ioFilterFree(blockDecryptFilter);
@ -312,10 +312,9 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
TEST_ASSIGN(hash, cryptoHashNewVar(varVarLst(jsonToVar(strNewFmt("[\"%s\"]", HASH_TYPE_SHA1)))), "create sha1 hash");
TEST_RESULT_STR(
strPtr(bufHex(cryptoHash((CryptoHash *)ioFilterDriver(hash)))), HASH_TYPE_SHA1_ZERO, " check empty hash");
TEST_RESULT_STR(
strPtr(bufHex(cryptoHash((CryptoHash *)ioFilterDriver(hash)))), HASH_TYPE_SHA1_ZERO, " check empty hash again");
TEST_RESULT_STR_Z(bufHex(cryptoHash((CryptoHash *)ioFilterDriver(hash))), HASH_TYPE_SHA1_ZERO, " check empty hash");
TEST_RESULT_STR_Z(
bufHex(cryptoHash((CryptoHash *)ioFilterDriver(hash))), HASH_TYPE_SHA1_ZERO, " check empty hash again");
TEST_RESULT_VOID(ioFilterFree(hash), " free hash");
// -------------------------------------------------------------------------------------------------------------------------
@ -326,35 +325,31 @@ testRun(void)
TEST_RESULT_VOID(ioFilterProcessIn(hash, BUFSTRDEF("4")), " add 4");
TEST_RESULT_VOID(ioFilterProcessIn(hash, BUFSTRDEF("5")), " add 5");
TEST_RESULT_STR(
strPtr(varStr(ioFilterResult(hash))), "8cb2237d0679ca88db6464eac60da96345513964", " check small hash");
TEST_RESULT_STR_Z(varStr(ioFilterResult(hash)), "8cb2237d0679ca88db6464eac60da96345513964", " check small hash");
TEST_RESULT_VOID(ioFilterFree(hash), " free hash");
// -------------------------------------------------------------------------------------------------------------------------
TEST_ASSIGN(hash, cryptoHashNew(strNew(HASH_TYPE_MD5)), "create md5 hash");
TEST_RESULT_STR(strPtr(varStr(ioFilterResult(hash))), HASH_TYPE_MD5_ZERO, " check empty hash");
TEST_RESULT_STR_Z(varStr(ioFilterResult(hash)), HASH_TYPE_MD5_ZERO, " check empty hash");
// -------------------------------------------------------------------------------------------------------------------------
TEST_ASSIGN(hash, cryptoHashNew(strNew(HASH_TYPE_SHA256)), "create sha256 hash");
TEST_RESULT_STR(
strPtr(varStr(ioFilterResult(hash))), HASH_TYPE_SHA256_ZERO,
" check empty hash");
TEST_RESULT_STR_Z(varStr(ioFilterResult(hash)), HASH_TYPE_SHA256_ZERO, " check empty hash");
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_STR(
strPtr(bufHex(cryptoHashOne(strNew(HASH_TYPE_SHA1), BUFSTRDEF("12345")))), "8cb2237d0679ca88db6464eac60da96345513964",
TEST_RESULT_STR_Z(
bufHex(cryptoHashOne(strNew(HASH_TYPE_SHA1), BUFSTRDEF("12345"))), "8cb2237d0679ca88db6464eac60da96345513964",
" check small hash");
TEST_RESULT_STR(
strPtr(bufHex(cryptoHashOne(strNew(HASH_TYPE_SHA1), BUFSTRDEF("")))), HASH_TYPE_SHA1_ZERO, " check empty hash");
TEST_RESULT_STR_Z(
bufHex(cryptoHashOne(strNew(HASH_TYPE_SHA1), BUFSTRDEF(""))), HASH_TYPE_SHA1_ZERO, " check empty hash");
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_STR(
strPtr(
bufHex(
cryptoHmacOne(
strNew(HASH_TYPE_SHA256),
BUFSTRDEF("AWS4wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"),
BUFSTRDEF("20170412")))),
TEST_RESULT_STR_Z(
bufHex(
cryptoHmacOne(
strNew(HASH_TYPE_SHA256),
BUFSTRDEF("AWS4wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"),
BUFSTRDEF("20170412"))),
"8b05c497afe9e1f42c8ada4cb88392e118649db1e5c98f0f0fb0a158bdd2dd76",
" check hmac");
}

View File

@ -27,7 +27,7 @@ testRun(void)
if (testBegin("DEBUG_UNIT_EXTERN"))
{
const char *debugUnitExtern = STRINGIFY(DEBUG_UNIT_EXTERN);
TEST_RESULT_STR(debugUnitExtern, "static", "DEBUG_UNIT_EXTERN is static");
TEST_RESULT_Z(debugUnitExtern, "static", "DEBUG_UNIT_EXTERN is static");
}
FUNCTION_HARNESS_RESULT_VOID();

View File

@ -56,42 +56,42 @@ testRun(void)
char buffer[STACK_TRACE_PARAM_MAX];
TEST_RESULT_INT(objToLog(NULL, "Object", buffer, 4), 4, "truncated null");
TEST_RESULT_STR(buffer, "nul", " check truncated null");
TEST_RESULT_Z(buffer, "nul", " check truncated null");
TEST_RESULT_INT(objToLog(NULL, "Object", buffer, sizeof(buffer)), 4, "full null");
TEST_RESULT_STR(buffer, "null", " check full null");
TEST_RESULT_Z(buffer, "null", " check full null");
TEST_RESULT_INT(objToLog((void *)1, "Object", buffer, 4), 8, "truncated object");
TEST_RESULT_STR(buffer, "{Ob", " check truncated object");
TEST_RESULT_Z(buffer, "{Ob", " check truncated object");
TEST_RESULT_INT(objToLog((void *)1, "Object", buffer, sizeof(buffer)), 8, "full object");
TEST_RESULT_STR(buffer, "{Object}", " check full object");
TEST_RESULT_Z(buffer, "{Object}", " check full object");
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_INT(ptrToLog(NULL, "char *", buffer, 4), 4, "truncated null");
TEST_RESULT_STR(buffer, "nul", " check truncated null");
TEST_RESULT_Z(buffer, "nul", " check truncated null");
TEST_RESULT_INT(ptrToLog(NULL, "char *", buffer, sizeof(buffer)), 4, "full null");
TEST_RESULT_STR(buffer, "null", " check full null");
TEST_RESULT_Z(buffer, "null", " check full null");
TEST_RESULT_INT(ptrToLog((void *)1, "char *", buffer, 4), 8, "truncated pointer");
TEST_RESULT_STR(buffer, "(ch", " check truncated pointer");
TEST_RESULT_Z(buffer, "(ch", " check truncated pointer");
TEST_RESULT_INT(ptrToLog((void *)1, "char *", buffer, sizeof(buffer)), 8, "full pointer");
TEST_RESULT_STR(buffer, "(char *)", " check full pointer");
TEST_RESULT_Z(buffer, "(char *)", " check full pointer");
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_INT(strzToLog(NULL, buffer, 4), 4, "truncated null");
TEST_RESULT_STR(buffer, "nul", " check truncated null");
TEST_RESULT_Z(buffer, "nul", " check truncated null");
TEST_RESULT_INT(strzToLog(NULL, buffer, sizeof(buffer)), 4, "full null");
TEST_RESULT_STR(buffer, "null", " check full null");
TEST_RESULT_Z(buffer, "null", " check full null");
TEST_RESULT_INT(strzToLog("test", buffer, 4), 6, "truncated string");
TEST_RESULT_STR(buffer, "\"te", " check truncated string");
TEST_RESULT_Z(buffer, "\"te", " check truncated string");
TEST_RESULT_INT(strzToLog("test2", buffer, sizeof(buffer)), 7, "full string");
TEST_RESULT_STR(buffer, "\"test2\"", " check full string");
TEST_RESULT_Z(buffer, "\"test2\"", " check full string");
}
// *****************************************************************************************************************************
@ -110,7 +110,7 @@ testRun(void)
if (testBegin("DEBUG_UNIT_EXTERN"))
{
const char *debugUnitExtern = STRINGIFY(DEBUG_UNIT_EXTERN);
TEST_RESULT_STR(debugUnitExtern, "", "DEBUG_UNIT_EXTERN is blank (extern)");
TEST_RESULT_Z(debugUnitExtern, "", "DEBUG_UNIT_EXTERN is blank (extern)");
}
// *****************************************************************************************************************************

View File

@ -17,27 +17,27 @@ testRun(void)
char destinationEncode[256];
encodeToStr(encodeBase64, encode, 1, destinationEncode);
TEST_RESULT_STR(destinationEncode, "cw==", "1 character encode");
TEST_RESULT_Z(destinationEncode, "cw==", "1 character encode");
TEST_RESULT_INT(encodeToStrSize(encodeBase64, 1), strlen(destinationEncode), "check size");
encodeToStr(encodeBase64, encode, 2, destinationEncode);
TEST_RESULT_STR(destinationEncode, "c3Q=", "2 character encode");
TEST_RESULT_Z(destinationEncode, "c3Q=", "2 character encode");
TEST_RESULT_INT(encodeToStrSize(encodeBase64, 2), strlen(destinationEncode), "check size");
encodeToStr(encodeBase64, encode, 3, destinationEncode);
TEST_RESULT_STR(destinationEncode, "c3Ry", "3 character encode");
TEST_RESULT_Z(destinationEncode, "c3Ry", "3 character encode");
TEST_RESULT_INT(encodeToStrSize(encodeBase64, 3), strlen(destinationEncode), "check size");
encodeToStr(encodeBase64, encode, strlen((char *)encode) - 2, destinationEncode);
TEST_RESULT_STR(destinationEncode, "c3RyaW5nX3RvX2VuY29kZQ==", "encode full string");
TEST_RESULT_Z(destinationEncode, "c3RyaW5nX3RvX2VuY29kZQ==", "encode full string");
TEST_RESULT_INT(encodeToStrSize(encodeBase64, strlen((char *)encode) - 2), strlen(destinationEncode), "check size");
encodeToStr(encodeBase64, encode, strlen((char *)encode), destinationEncode);
TEST_RESULT_STR(destinationEncode, "c3RyaW5nX3RvX2VuY29kZQ0K", "encode full string with \\r\\n");
TEST_RESULT_Z(destinationEncode, "c3RyaW5nX3RvX2VuY29kZQ0K", "encode full string with \\r\\n");
TEST_RESULT_INT(encodeToStrSize(encodeBase64, strlen((char *)encode)), strlen(destinationEncode), "check size");
encodeToStr(encodeBase64, encode, strlen((char *)encode) + 1, destinationEncode);
TEST_RESULT_STR(destinationEncode, "c3RyaW5nX3RvX2VuY29kZQ0KAA==", "encode full string with \\r\\n and null");
TEST_RESULT_Z(destinationEncode, "c3RyaW5nX3RvX2VuY29kZQ0KAA==", "encode full string with \\r\\n and null");
TEST_RESULT_INT(encodeToStrSize(encodeBase64, strlen((char *)encode) + 1), strlen(destinationEncode), "check size");
TEST_ERROR(encodeToStr(999, encode, strlen((char *)encode), destinationEncode), AssertError, "invalid encode type 999");
@ -49,7 +49,7 @@ testRun(void)
memset(destinationDecode, 0xFF, sizeof(destinationDecode));
const char *decode = "c3RyaW5nX3RvX2VuY29kZQ0KAA==";
decodeToBin(encodeBase64, decode, destinationDecode);
TEST_RESULT_STR(destinationDecode, encode, "full string with \\r\\n and null decode");
TEST_RESULT_Z(destinationDecode, encode, "full string with \\r\\n and null decode");
TEST_RESULT_INT(destinationDecode[strlen((char *)encode) + 1], 0xFF, "check for overrun");
TEST_RESULT_INT(decodeToBinSize(encodeBase64, decode), strlen((char *)encode) + 1, "check size");

View File

@ -34,7 +34,7 @@ testRun(void)
String *message = strNew("ACKBYACK");
TEST_RESULT_VOID(ioWriteStrLine(execIoWrite(exec), message), "write cat exec");
ioWriteFlush(execIoWrite(exec));
TEST_RESULT_STR(strPtr(ioReadLine(execIoRead(exec))), strPtr(message), "read cat exec");
TEST_RESULT_STR(ioReadLine(execIoRead(exec)), message, "read cat exec");
TEST_RESULT_VOID(execFree(exec), "free exec");
// -------------------------------------------------------------------------------------------------------------------------
@ -62,7 +62,7 @@ testRun(void)
TEST_RESULT_VOID(ioWriteStrLine(execIoWrite(exec), message), "write cat exec");
ioWriteFlush(execIoWrite(exec));
TEST_RESULT_STR(strPtr(ioReadLine(execIoRead(exec))), " 1\tACKBYACK", "read cat exec");
TEST_RESULT_STR_Z(ioReadLine(execIoRead(exec)), " 1\tACKBYACK", "read cat exec");
TEST_RESULT_VOID(execFree(exec), "free exec");
// Run the same test as above but close all file descriptors first to ensure we don't accidentally close a required
@ -84,7 +84,7 @@ testRun(void)
TEST_RESULT_VOID(ioWriteStrLine(execIoWrite(exec), message), "write cat exec");
ioWriteFlush(execIoWrite(exec));
TEST_RESULT_STR(strPtr(ioReadLine(execIoRead(exec))), " 1\tACKBYACK", "read cat exec");
TEST_RESULT_STR_Z(ioReadLine(execIoRead(exec)), " 1\tACKBYACK", "read cat exec");
TEST_RESULT_VOID(execFree(exec), "free exec");
}
HARNESS_FORK_CHILD_END();

View File

@ -18,9 +18,9 @@ testRun(void)
// *****************************************************************************************************************************
if (testBegin("exitSignalName()"))
{
TEST_RESULT_STR(exitSignalName(signalTypeHup), "HUP", "SIGHUP name");
TEST_RESULT_STR(exitSignalName(signalTypeInt), "INT", "SIGINT name");
TEST_RESULT_STR(exitSignalName(signalTypeTerm), "TERM", "SIGTERM name");
TEST_RESULT_Z(exitSignalName(signalTypeHup), "HUP", "SIGHUP name");
TEST_RESULT_Z(exitSignalName(signalTypeInt), "INT", "SIGINT name");
TEST_RESULT_Z(exitSignalName(signalTypeTerm), "TERM", "SIGTERM name");
TEST_ERROR(exitSignalName(signalTypeNone), AssertError, "no name for signal none");
}

View File

@ -25,7 +25,7 @@ testRun(void)
forkDetach();
TEST_RESULT_BOOL(getsid(0) != sessionId, true, "new session id has been created");
TEST_RESULT_STR(getcwd(buffer, sizeof(buffer)), "/", "current working directory is '/'");
TEST_RESULT_Z(getcwd(buffer, sizeof(buffer)), "/", "current working directory is '/'");
TEST_RESULT_INT(write(STDIN_FILENO, buffer, strlen(buffer)), -1, "write to stdin fails");
TEST_RESULT_INT(write(STDOUT_FILENO, buffer, strlen(buffer)), -1, "write to stdout fails");
TEST_RESULT_INT(write(STDERR_FILENO, buffer, strlen(buffer)), -1, "write to stderr fails");

View File

@ -31,7 +31,7 @@ testRun(void)
String *result = strNew("");
TEST_RESULT_VOID(iniLoad(ioBufferReadNew(iniBuf), testIniLoadCallback, result), "load ini");
TEST_RESULT_STR(strPtr(result), "", " check ini");
TEST_RESULT_STR_Z(result, "", " check ini");
// Invalid section
// -------------------------------------------------------------------------------------------------------------------------
@ -81,8 +81,8 @@ testRun(void)
result = strNew("");
TEST_RESULT_VOID(iniLoad(ioBufferReadNew(iniBuf), testIniLoadCallback, result), "load ini");
TEST_RESULT_STR(
strPtr(result),
TEST_RESULT_STR_Z(
result,
"section1:key1:value1\n"
"section1:key2:value2\n",
" check ini");
@ -102,8 +102,8 @@ testRun(void)
result = strNew("");
TEST_RESULT_VOID(iniLoad(ioBufferReadNew(iniBuf), testIniLoadCallback, result), "load ini");
TEST_RESULT_STR(
strPtr(result),
TEST_RESULT_STR_Z(
result,
"section1:key1:value1\n"
"section1:key2:value2\n"
"section2:key1:\n"
@ -139,28 +139,27 @@ testRun(void)
}
MEM_CONTEXT_TEMP_END();
TEST_RESULT_STR(strPtr(iniGet(ini, strNew("section1"), strNew("key1"))), "11", "get section, key");
TEST_RESULT_STR(strPtr(iniGet(ini, strNew("section1"), strNew("key2"))), "1.234", "get section, key");
TEST_RESULT_STR_Z(iniGet(ini, strNew("section1"), strNew("key1")), "11", "get section, key");
TEST_RESULT_STR_Z(iniGet(ini, strNew("section1"), strNew("key2")), "1.234", "get section, key");
TEST_ERROR(iniGet(ini, strNew("section2"), strNew("key2")), FormatError, "section 'section2', key 'key2' does not exist");
TEST_RESULT_STR(strPtr(iniGetDefault(ini, strNew("section1"), strNew("key1"), NULL)), "11", "get section, key, int");
TEST_RESULT_STR_Z(iniGetDefault(ini, strNew("section1"), strNew("key1"), NULL), "11", "get section, key, int");
TEST_RESULT_PTR(iniGetDefault(ini, strNew("section2"), strNew("key2"), NULL), NULL, "get section, key, NULL");
TEST_RESULT_STR(
strPtr(iniGetDefault(ini, strNew("section3"), strNew("key3"), strNew("true"))), "true", "get section, key, bool");
TEST_RESULT_STR_Z(iniGetDefault(ini, strNew("section3"), strNew("key3"), strNew("true")), "true", "get section, key, bool");
TEST_RESULT_INT(strLstSize(iniSectionKeyList(ini, strNew("bogus"))), 0, "get keys for missing section");
TEST_RESULT_STR(strPtr(strLstJoin(iniSectionKeyList(ini, strNew("section1")), "|")), "key1|key2", "get keys for section");
TEST_RESULT_STR_Z(strLstJoin(iniSectionKeyList(ini, strNew("section1")), "|"), "key1|key2", "get keys for section");
TEST_RESULT_VOID(iniSet(ini, strNew("section2"), strNew("key2"), strNew("2")), "set section2, key");
TEST_RESULT_INT(strLstSize(iniSectionList(ini)), 2, "number of sections");
TEST_RESULT_STR(strPtr(strLstJoin(iniSectionList(ini), "|")), "section1|section2", "get sections");
TEST_RESULT_STR_Z(strLstJoin(iniSectionList(ini), "|"), "section1|section2", "get sections");
TEST_RESULT_BOOL(iniSectionKeyIsList(ini, strNew("section1"), strNew("key1")), false, "single value is not list");
TEST_RESULT_VOID(iniSet(ini, strNew("section2"), strNew("key2"), strNew("7")), "set section2, key");
TEST_RESULT_BOOL(iniSectionKeyIsList(ini, strNew("section2"), strNew("key2")), true, "section2, key2 is a list");
TEST_RESULT_STR(strPtr(strLstJoin(iniGetList(ini, strNew("section2"), strNew("key2")), "|")), "2|7", "get list");
TEST_RESULT_STR(iniGetList(ini, strNew("section2"), strNew("key-missing")), NULL, "get missing list");
TEST_RESULT_STR_Z(strLstJoin(iniGetList(ini, strNew("section2"), strNew("key2")), "|"), "2|7", "get list");
TEST_RESULT_PTR(iniGetList(ini, strNew("section2"), strNew("key-missing")), NULL, "get missing list");
TEST_RESULT_VOID(iniFree(ini), "free ini");
}
@ -194,8 +193,8 @@ testRun(void)
TEST_RESULT_VOID(iniParse(ini, content), "load ini");
TEST_RESULT_STR(strPtr(iniGet(ini, strNew("global"), strNew("compress"))), "y", "get compress");
TEST_RESULT_STR(strPtr(iniGet(ini, strNew("db"), strNew("pg1-path"))), "/path/to/pg", "get pg1-path");
TEST_RESULT_STR_Z(iniGet(ini, strNew("global"), strNew("compress")), "y", "get compress");
TEST_RESULT_STR_Z(iniGet(ini, strNew("db"), strNew("pg1-path")), "/path/to/pg", "get pg1-path");
}
FUNCTION_HARNESS_RESULT_VOID();

View File

@ -307,8 +307,8 @@ testRun(void)
if (testBegin("httpUriEncode"))
{
TEST_RESULT_PTR(httpUriEncode(NULL, false), NULL, "null encodes to null");
TEST_RESULT_STR(strPtr(httpUriEncode(strNew("0-9_~/A Z.az"), false)), "0-9_~%2FA%20Z.az", "non-path encoding");
TEST_RESULT_STR(strPtr(httpUriEncode(strNew("0-9_~/A Z.az"), true)), "0-9_~/A%20Z.az", "path encoding");
TEST_RESULT_STR_Z(httpUriEncode(strNew("0-9_~/A Z.az"), false), "0-9_~%2FA%20Z.az", "non-path encoding");
TEST_RESULT_STR_Z(httpUriEncode(strNew("0-9_~/A Z.az"), true), "0-9_~/A%20Z.az", "path encoding");
}
// *****************************************************************************************************************************
@ -330,13 +330,13 @@ testRun(void)
TEST_RESULT_PTR(httpHeaderAdd(header, strNew("key2"), strNew("value2b")), header, "add header");
TEST_RESULT_PTR(httpHeaderAdd(header, strNew("key1"), strNew("value1")), header, "add header");
TEST_RESULT_STR(strPtr(strLstJoin(httpHeaderList(header), ", ")), "key1, key2", "header list");
TEST_RESULT_STR_Z(strLstJoin(httpHeaderList(header), ", "), "key1, key2", "header list");
TEST_RESULT_STR(strPtr(httpHeaderGet(header, strNew("key1"))), "value1", "get value");
TEST_RESULT_STR(strPtr(httpHeaderGet(header, strNew("key2"))), "value2a, value2b", "get value");
TEST_RESULT_STR_Z(httpHeaderGet(header, strNew("key1")), "value1", "get value");
TEST_RESULT_STR_Z(httpHeaderGet(header, strNew("key2")), "value2a, value2b", "get value");
TEST_RESULT_PTR(httpHeaderGet(header, strNew(BOGUS_STR)), NULL, "get missing value");
TEST_RESULT_STR(strPtr(httpHeaderToLog(header)), "{key1: 'value1', key2: 'value2a, value2b'}", "log output");
TEST_RESULT_STR_Z(httpHeaderToLog(header), "{key1: 'value1', key2: 'value2a, value2b'}", "log output");
TEST_RESULT_VOID(httpHeaderFree(header), "free header");
@ -349,18 +349,18 @@ testRun(void)
httpHeaderAdd(header, strNew("secret"), strNew("secret-value"));
httpHeaderAdd(header, strNew("public"), strNew("public-value"));
TEST_RESULT_STR(strPtr(httpHeaderToLog(header)), "{public: 'public-value', secret: <redacted>}", "log output");
TEST_RESULT_STR_Z(httpHeaderToLog(header), "{public: 'public-value', secret: <redacted>}", "log output");
// Duplicate
// -------------------------------------------------------------------------------------------------------------------------
redact = strLstNew();
strLstAddZ(redact, "public");
TEST_RESULT_STR(
strPtr(httpHeaderToLog(httpHeaderDup(header, NULL))),
"{public: 'public-value', secret: <redacted>}", "dup and keep redactions");
TEST_RESULT_STR(
strPtr(httpHeaderToLog(httpHeaderDup(header, redact))), "{public: <redacted>, secret: 'secret-value'}",
TEST_RESULT_STR_Z(
httpHeaderToLog(httpHeaderDup(header, NULL)), "{public: 'public-value', secret: <redacted>}",
"dup and keep redactions");
TEST_RESULT_STR_Z(
httpHeaderToLog(httpHeaderDup(header, redact)), "{public: <redacted>, secret: 'secret-value'}",
"dup and change redactions");
TEST_RESULT_PTR(httpHeaderDup(NULL, NULL), NULL, "dup null http header");
}
@ -385,17 +385,17 @@ testRun(void)
TEST_RESULT_PTR(httpQueryAdd(query, strNew("key2"), strNew("value2")), query, "add query");
TEST_ERROR(httpQueryAdd(query, strNew("key2"), strNew("value2")), AssertError, "key 'key2' already exists");
TEST_RESULT_PTR(httpQueryPut(query, strNew("key2"), strNew("value2a")), query, "put query");
TEST_RESULT_STR(strPtr(httpQueryRender(query)), "key2=value2a", "render one query item");
TEST_RESULT_STR_Z(httpQueryRender(query), "key2=value2a", "render one query item");
TEST_RESULT_PTR(httpQueryAdd(query, strNew("key1"), strNew("value 1?")), query, "add query");
TEST_RESULT_STR(strPtr(strLstJoin(httpQueryList(query), ", ")), "key1, key2", "query list");
TEST_RESULT_STR(strPtr(httpQueryRender(query)), "key1=value%201%3F&key2=value2a", "render two query items");
TEST_RESULT_STR_Z(strLstJoin(httpQueryList(query), ", "), "key1, key2", "query list");
TEST_RESULT_STR_Z(httpQueryRender(query), "key1=value%201%3F&key2=value2a", "render two query items");
TEST_RESULT_STR(strPtr(httpQueryGet(query, strNew("key1"))), "value 1?", "get value");
TEST_RESULT_STR(strPtr(httpQueryGet(query, strNew("key2"))), "value2a", "get value");
TEST_RESULT_STR_Z(httpQueryGet(query, strNew("key1")), "value 1?", "get value");
TEST_RESULT_STR_Z(httpQueryGet(query, strNew("key2")), "value2a", "get value");
TEST_RESULT_PTR(httpQueryGet(query, strNew(BOGUS_STR)), NULL, "get missing value");
TEST_RESULT_STR(strPtr(httpQueryToLog(query)), "{key1: 'value 1?', key2: 'value2a'}", "log output");
TEST_RESULT_STR_Z(httpQueryToLog(query), "{key1: 'value 1?', key2: 'value2a'}", "log output");
TEST_RESULT_VOID(httpQueryFree(query), "free query");
}
@ -408,7 +408,7 @@ testRun(void)
// Reset statistics
httpClientStatLocal = (HttpClientStat){0};
TEST_RESULT_STR(httpClientStatStr(), NULL, "no stats yet");
TEST_RESULT_PTR(httpClientStatStr(), NULL, "no stats yet");
TEST_ASSIGN(
client, httpClientNew(strNew("localhost"), harnessTlsTestPort(), 500, testContainer(), NULL, NULL), "new client");
@ -475,10 +475,10 @@ testRun(void)
TEST_RESULT_VOID(
httpClientRequest(client, strNew("GET"), strNew("/"), query, headerRequest, NULL, false), "request with no content");
TEST_RESULT_UINT(httpClientResponseCode(client), 200, " check response code");
TEST_RESULT_STR(strPtr(httpClientResponseMessage(client)), "OK", " check response message");
TEST_RESULT_STR_Z(httpClientResponseMessage(client), "OK", " check response message");
TEST_RESULT_UINT(httpClientEof(client), true, " io is eof");
TEST_RESULT_STR(
strPtr(httpHeaderToLog(httpClientResponseHeader(client))), "{connection: 'ack', key1: '0', key2: 'value2'}",
TEST_RESULT_STR_Z(
httpHeaderToLog(httpClientResponseHeader(client)), "{connection: 'ack', key1: '0', key2: 'value2'}",
" check response headers");
// Head request with content-length but no content
@ -486,31 +486,30 @@ testRun(void)
httpClientRequest(client, strNew("HEAD"), strNew("/"), NULL, httpHeaderNew(NULL), NULL, true),
"head request with content-length");
TEST_RESULT_UINT(httpClientResponseCode(client), 200, " check response code");
TEST_RESULT_STR(strPtr(httpClientResponseMessage(client)), "OK", " check response message");
TEST_RESULT_STR_Z(httpClientResponseMessage(client), "OK", " check response message");
TEST_RESULT_BOOL(httpClientEof(client), true, " io is eof");
TEST_RESULT_BOOL(httpClientBusy(client), false, " client is not busy");
TEST_RESULT_STR(
strPtr(httpHeaderToLog(httpClientResponseHeader(client))), "{content-length: '380'}", " check response headers");
TEST_RESULT_STR_Z(
httpHeaderToLog(httpClientResponseHeader(client)), "{content-length: '380'}", " check response headers");
// Head request with transfer encoding but no content
TEST_RESULT_VOID(
httpClientRequest(client, strNew("HEAD"), strNew("/"), NULL, httpHeaderNew(NULL), NULL, true),
"head request with transfer encoding");
TEST_RESULT_UINT(httpClientResponseCode(client), 200, " check response code");
TEST_RESULT_STR(strPtr(httpClientResponseMessage(client)), "OK", " check response message");
TEST_RESULT_STR_Z(httpClientResponseMessage(client), "OK", " check response message");
TEST_RESULT_BOOL(httpClientEof(client), true, " io is eof");
TEST_RESULT_BOOL(httpClientBusy(client), false, " client is not busy");
TEST_RESULT_STR(
strPtr(httpHeaderToLog(httpClientResponseHeader(client))), "{transfer-encoding: 'chunked'}",
" check response headers");
TEST_RESULT_STR_Z(
httpHeaderToLog(httpClientResponseHeader(client)), "{transfer-encoding: 'chunked'}", " check response headers");
// Error with content length 0
TEST_RESULT_VOID(
httpClientRequest(client, strNew("GET"), strNew("/"), NULL, NULL, NULL, false), "error with content length 0");
TEST_RESULT_UINT(httpClientResponseCode(client), 404, " check response code");
TEST_RESULT_STR(strPtr(httpClientResponseMessage(client)), "Not Found", " check response message");
TEST_RESULT_STR(
strPtr(httpHeaderToLog(httpClientResponseHeader(client))), "{content-length: '0'}", " check response headers");
TEST_RESULT_STR_Z(httpClientResponseMessage(client), "Not Found", " check response message");
TEST_RESULT_STR_Z(
httpHeaderToLog(httpClientResponseHeader(client)), "{content-length: '0'}", " check response headers");
// Error with content
Buffer *buffer = NULL;
@ -518,10 +517,10 @@ testRun(void)
TEST_ASSIGN(
buffer, httpClientRequest(client, strNew("GET"), strNew("/"), NULL, NULL, NULL, false), "error with content length");
TEST_RESULT_UINT(httpClientResponseCode(client), 403, " check response code");
TEST_RESULT_STR(strPtr(httpClientResponseMessage(client)), "Auth Error", " check response message");
TEST_RESULT_STR(
strPtr(httpHeaderToLog(httpClientResponseHeader(client))), "{content-length: '7'}", " check response headers");
TEST_RESULT_STR(strPtr(strNewBuf(buffer)), "CONTENT", " check response");
TEST_RESULT_STR_Z(httpClientResponseMessage(client), "Auth Error", " check response message");
TEST_RESULT_STR_Z(
httpHeaderToLog(httpClientResponseHeader(client)), "{content-length: '7'}", " check response headers");
TEST_RESULT_STR_Z(strNewBuf(buffer), "CONTENT", " check response");
// Request with content using content-length
ioBufferSizeSet(30);
@ -533,17 +532,17 @@ testRun(void)
httpHeaderAdd(httpHeaderNew(NULL), strNew("content-length"), strNew("30")),
BUFSTRDEF("012345678901234567890123456789"), true),
"request with content length");
TEST_RESULT_STR(
strPtr(httpHeaderToLog(httpClientResponseHeader(client))), "{connection: 'close', content-length: '32'}",
TEST_RESULT_STR_Z(
httpHeaderToLog(httpClientResponseHeader(client)), "{connection: 'close', content-length: '32'}",
" check response headers");
TEST_RESULT_STR(strPtr(strNewBuf(buffer)), "01234567890123456789012345678901", " check response");
TEST_RESULT_STR_Z(strNewBuf(buffer), "01234567890123456789012345678901", " check response");
TEST_RESULT_UINT(httpClientRead(client, bufNew(1), true), 0, " call internal read to check eof");
// Request with eof before content complete with retry
TEST_ASSIGN(
buffer, httpClientRequest(client, strNew("GET"), strNew("/path/file 1.txt"), NULL, NULL, NULL, true),
"request with content length retry");
TEST_RESULT_STR(strPtr(strNewBuf(buffer)), "01234567890123456789012345678901", " check response");
TEST_RESULT_STR_Z(strNewBuf(buffer), "01234567890123456789012345678901", " check response");
TEST_RESULT_UINT(httpClientRead(client, bufNew(1), true), 0, " call internal read to check eof");
// Request with eof before content and error
@ -558,13 +557,12 @@ testRun(void)
// Request with content using chunked encoding
TEST_RESULT_VOID(
httpClientRequest(client, strNew("GET"), strNew("/"), NULL, NULL, NULL, false), "request with chunked encoding");
TEST_RESULT_STR(
strPtr(httpHeaderToLog(httpClientResponseHeader(client))), "{transfer-encoding: 'chunked'}",
" check response headers");
TEST_RESULT_STR_Z(
httpHeaderToLog(httpClientResponseHeader(client)), "{transfer-encoding: 'chunked'}", " check response headers");
buffer = bufNew(35);
TEST_RESULT_VOID(ioRead(httpClientIoRead(client), buffer), " read response");
TEST_RESULT_STR(strPtr(strNewBuf(buffer)), "01234567890123456789012345678901012", " check response");
TEST_RESULT_STR_Z(strNewBuf(buffer), "01234567890123456789012345678901012", " check response");
TEST_RESULT_BOOL(httpClientStatStr() != NULL, true, "check statistics exist");

View File

@ -308,8 +308,8 @@ testRun(void)
IoFilter *bufferFilter = ioBufferNew();
TEST_RESULT_VOID(ioFilterGroupAdd(ioReadFilterGroup(bufferRead), bufferFilter), " add filter to filter group");
TEST_RESULT_PTR(ioFilterMove(NULL, memContextTop()), NULL, " move NULL filter to top context");
TEST_RESULT_STR(
strPtr(jsonFromVar(ioFilterGroupParamAll(ioReadFilterGroup(bufferRead)))),
TEST_RESULT_STR_Z(
jsonFromVar(ioFilterGroupParamAll(ioReadFilterGroup(bufferRead))),
"[{\"size\":null},{\"double\":[\"double\",2,3]},{\"size\":null},{\"buffer\":null}]", " check filter params");
TEST_RESULT_BOOL(ioReadOpen(bufferRead), true, " open");
@ -317,27 +317,27 @@ testRun(void)
TEST_RESULT_BOOL(ioReadEof(bufferRead), false, " not eof");
TEST_RESULT_SIZE(ioRead(bufferRead, buffer), 2, " read 2 bytes");
TEST_RESULT_SIZE(ioRead(bufferRead, buffer), 0, " read 0 bytes (full buffer)");
TEST_RESULT_STR(strPtr(strNewBuf(buffer)), "11", " check read");
TEST_RESULT_STR(strPtr(ioFilterType(sizeFilter)), "size", "check filter type");
TEST_RESULT_STR_Z(strNewBuf(buffer), "11", " check read");
TEST_RESULT_STR_Z(ioFilterType(sizeFilter), "size", "check filter type");
TEST_RESULT_BOOL(ioReadEof(bufferRead), false, " not eof");
TEST_RESULT_VOID(bufUsedZero(buffer), " zero buffer");
TEST_RESULT_SIZE(ioRead(bufferRead, buffer), 2, " read 2 bytes");
TEST_RESULT_STR(strPtr(strNewBuf(buffer)), "22", " check read");
TEST_RESULT_STR_Z(strNewBuf(buffer), "22", " check read");
TEST_ASSIGN(buffer, bufNew(3), "change output buffer size to 3");
TEST_RESULT_SIZE(ioRead(bufferRead, buffer), 3, " read 3 bytes");
TEST_RESULT_STR(strPtr(strNewBuf(buffer)), "33X", " check read");
TEST_RESULT_STR_Z(strNewBuf(buffer), "33X", " check read");
TEST_RESULT_VOID(bufUsedZero(buffer), " zero buffer");
TEST_RESULT_SIZE(ioRead(bufferRead, buffer), 2, " read 2 bytes");
TEST_RESULT_STR(strPtr(strNewBuf(buffer)), "XX", " check read");
TEST_RESULT_STR_Z(strNewBuf(buffer), "XX", " check read");
TEST_RESULT_BOOL(ioReadEof(bufferRead), true, " eof");
TEST_RESULT_BOOL(ioBufferRead(ioReadDriver(bufferRead), buffer, true), 0, " eof from driver");
TEST_RESULT_SIZE(ioRead(bufferRead, buffer), 0, " read 0 bytes");
TEST_RESULT_VOID(ioReadClose(bufferRead), " close buffer read object");
TEST_RESULT_STR(
strPtr(jsonFromVar(ioFilterGroupResultAll(ioReadFilterGroup(bufferRead)))),
TEST_RESULT_STR_Z(
jsonFromVar(ioFilterGroupResultAll(ioReadFilterGroup(bufferRead))),
"{\"buffer\":null,\"double\":null,\"size\":[3,9]}",
" check filter result all");
@ -379,7 +379,7 @@ testRun(void)
" add filter that produces output with no input");
TEST_RESULT_BOOL(ioReadOpen(bufferRead), true, " open read");
TEST_RESULT_UINT(ioRead(bufferRead, buffer), 5, " read 5 chars");
TEST_RESULT_STR(strPtr(strNewBuf(buffer)), "YYYYY", " check buffer");
TEST_RESULT_STR_Z(strNewBuf(buffer), "YYYYY", " check buffer");
// Mixed line and buffer read
// -------------------------------------------------------------------------------------------------------------------------
@ -390,24 +390,24 @@ testRun(void)
// Start with a buffer read
TEST_RESULT_INT(ioRead(read, buffer), 3, "read buffer");
TEST_RESULT_STR(strPtr(strNewBuf(buffer)), "AAA", " check buffer");
TEST_RESULT_STR_Z(strNewBuf(buffer), "AAA", " check buffer");
// Do line reads of various lengths
TEST_RESULT_STR(strPtr(ioReadLine(read)), "123", "read line");
TEST_RESULT_STR(strPtr(ioReadLine(read)), "1234", "read line");
TEST_RESULT_STR(strPtr(ioReadLine(read)), "", "read line");
TEST_RESULT_STR(strPtr(ioReadLine(read)), "12", "read line");
TEST_RESULT_STR_Z(ioReadLine(read), "123", "read line");
TEST_RESULT_STR_Z(ioReadLine(read), "1234", "read line");
TEST_RESULT_STR_Z(ioReadLine(read), "", "read line");
TEST_RESULT_STR_Z(ioReadLine(read), "12", "read line");
// Read what was left in the line buffer
TEST_RESULT_INT(ioRead(read, buffer), 0, "read buffer");
bufUsedSet(buffer, 2);
TEST_RESULT_INT(ioRead(read, buffer), 1, "read buffer");
TEST_RESULT_STR(strPtr(strNewBuf(buffer)), "AAB", " check buffer");
TEST_RESULT_STR_Z(strNewBuf(buffer), "AAB", " check buffer");
bufUsedSet(buffer, 0);
// Now do a full buffer read from the input
TEST_RESULT_INT(ioRead(read, buffer), 3, "read buffer");
TEST_RESULT_STR(strPtr(strNewBuf(buffer)), "DDD", " check buffer");
TEST_RESULT_STR_Z(strNewBuf(buffer), "DDD", " check buffer");
// Read line doesn't work without a linefeed
TEST_ERROR(ioReadLine(read), FileReadError, "unexpected eof while reading line");
@ -415,11 +415,11 @@ testRun(void)
// But those bytes can be picked up by a buffer read
buffer = bufNew(2);
TEST_RESULT_INT(ioRead(read, buffer), 2, "read buffer");
TEST_RESULT_STR(strPtr(strNewBuf(buffer)), "EF", " check buffer");
TEST_RESULT_STR_Z(strNewBuf(buffer), "EF", " check buffer");
buffer = bufNew(1);
TEST_RESULT_INT(ioRead(read, buffer), 1, "read buffer");
TEST_RESULT_STR(strPtr(strNewBuf(buffer)), "F", " check buffer");
TEST_RESULT_STR_Z(strNewBuf(buffer), "F", " check buffer");
// Nothing left to read
TEST_ERROR(ioReadLine(read), FileReadError, "unexpected eof while reading line");
@ -434,7 +434,7 @@ testRun(void)
// Read line without eof
read = ioBufferReadNew(BUFSTRDEF("1234"));
ioReadOpen(read);
TEST_RESULT_STR(strPtr(ioReadLineParam(read, true)), "1234", "read line without eof");
TEST_RESULT_STR_Z(ioReadLineParam(read, true), "1234", "read line without eof");
// Read IO into a buffer
// -------------------------------------------------------------------------------------------------------------------------
@ -443,7 +443,7 @@ testRun(void)
bufferRead = ioBufferReadNew(BUFSTRDEF("a test string"));
ioReadOpen(bufferRead);
TEST_RESULT_STR(strPtr(strNewBuf(ioReadBuf(bufferRead))), "a test string", "read into buffer");
TEST_RESULT_STR_Z(strNewBuf(ioReadBuf(bufferRead)), "a test string", "read into buffer");
// Drain read IO
// -------------------------------------------------------------------------------------------------------------------------
@ -499,15 +499,15 @@ testRun(void)
TEST_RESULT_VOID(ioWriteLine(bufferWrite, BUFSTRDEF("AB")), " write line");
TEST_RESULT_VOID(ioWrite(bufferWrite, bufNew(0)), " write 0 bytes");
TEST_RESULT_VOID(ioWrite(bufferWrite, NULL), " write 0 bytes");
TEST_RESULT_STR(strPtr(strNewBuf(buffer)), "AABB\n\n", " check write");
TEST_RESULT_STR_Z(strNewBuf(buffer), "AABB\n\n", " check write");
TEST_RESULT_VOID(ioWriteStr(bufferWrite, STRDEF("Z")), " write string");
TEST_RESULT_STR(strPtr(strNewBuf(buffer)), "AABB\n\n", " no change because output buffer is not full");
TEST_RESULT_STR_Z(strNewBuf(buffer), "AABB\n\n", " no change because output buffer is not full");
TEST_RESULT_VOID(ioWriteStr(bufferWrite, STRDEF("12345")), " write bytes");
TEST_RESULT_STR(strPtr(strNewBuf(buffer)), "AABB\n\nZZ1122334455", " check write");
TEST_RESULT_STR_Z(strNewBuf(buffer), "AABB\n\nZZ1122334455", " check write");
TEST_RESULT_VOID(ioWriteClose(bufferWrite), " close buffer write object");
TEST_RESULT_STR(strPtr(strNewBuf(buffer)), "AABB\n\nZZ1122334455XXXY", " check write after close");
TEST_RESULT_STR_Z(strNewBuf(buffer), "AABB\n\nZZ1122334455XXXY", " check write after close");
TEST_RESULT_PTR(ioWriteFilterGroup(bufferWrite), filterGroup, " check filter group");
TEST_RESULT_UINT(
@ -561,7 +561,7 @@ testRun(void)
TEST_RESULT_PTR(ioReadDriver(read), read->driver, "check driver");
// Read a string
TEST_RESULT_STR(strPtr(ioReadLine(read)), "test string 1", "read test string");
TEST_RESULT_STR_Z(ioReadLine(read), "test string 1", "read test string");
// Only part of the buffer is written before timeout
Buffer *buffer = bufNew(16);
@ -576,7 +576,7 @@ testRun(void)
TEST_RESULT_UINT(ioRead(read, buffer), 12, "read buffer");
bufLimitClear(buffer);
TEST_RESULT_UINT(ioRead(read, buffer), 4, "read buffer");
TEST_RESULT_STR(strPtr(strNewBuf(buffer)), "1234567812345678", "check buffer");
TEST_RESULT_STR_Z(strNewBuf(buffer), "1234567812345678", "check buffer");
// Check EOF
buffer = bufNew(16);

View File

@ -208,7 +208,7 @@ testRun(void)
// Reset statistics
tlsClientStatLocal = (TlsClientStat){0};
TEST_RESULT_STR(tlsClientStatStr(), NULL, "no stats yet");
TEST_RESULT_PTR(tlsClientStatStr(), NULL, "no stats yet");
testTlsServer();
ioBufferSizeSet(12);
@ -221,17 +221,17 @@ testRun(void)
TEST_RESULT_VOID(ioWrite(tlsClientIoWrite(client), input), "write input");
ioWriteFlush(tlsClientIoWrite(client));
TEST_RESULT_STR(strPtr(ioReadLine(tlsClientIoRead(client))), "something:0", "read line");
TEST_RESULT_STR_Z(ioReadLine(tlsClientIoRead(client)), "something:0", "read line");
TEST_RESULT_BOOL(ioReadEof(tlsClientIoRead(client)), false, " check eof = false");
Buffer *output = bufNew(12);
TEST_RESULT_INT(ioRead(tlsClientIoRead(client), output), 12, "read output");
TEST_RESULT_STR(strPtr(strNewBuf(output)), "some content", " check output");
TEST_RESULT_STR_Z(strNewBuf(output), "some content", " check output");
TEST_RESULT_BOOL(ioReadEof(tlsClientIoRead(client)), false, " check eof = false");
output = bufNew(8);
TEST_RESULT_INT(ioRead(tlsClientIoRead(client), output), 8, "read output");
TEST_RESULT_STR(strPtr(strNewBuf(output)), "AND MORE", " check output");
TEST_RESULT_STR_Z(strNewBuf(output), "AND MORE", " check output");
TEST_RESULT_BOOL(ioReadEof(tlsClientIoRead(client)), false, " check eof = false");
output = bufNew(12);
@ -247,7 +247,7 @@ testRun(void)
output = bufNew(12);
TEST_RESULT_INT(ioRead(tlsClientIoRead(client), output), 12, "read output");
TEST_RESULT_STR(strPtr(strNewBuf(output)), "0123456789AB", " check output");
TEST_RESULT_STR_Z(strNewBuf(output), "0123456789AB", " check output");
TEST_RESULT_BOOL(ioReadEof(tlsClientIoRead(client)), false, " check eof = false");
output = bufNew(12);

View File

@ -108,9 +108,9 @@ testRun(void)
TEST_RESULT_INT(logLevelEnum("TRACE"), logLevelTrace, "log level 'TRACE' found");
TEST_ERROR(logLevelStr(999), AssertError, "assertion 'logLevel <= LOG_LEVEL_MAX' failed");
TEST_RESULT_STR(logLevelStr(logLevelOff), "OFF", "log level 'OFF' found");
TEST_RESULT_STR(logLevelStr(logLevelInfo), "INFO", "log level 'INFO' found");
TEST_RESULT_STR(logLevelStr(logLevelTrace), "TRACE", "log level 'TRACE' found");
TEST_RESULT_Z(logLevelStr(logLevelOff), "OFF", "log level 'OFF' found");
TEST_RESULT_Z(logLevelStr(logLevelInfo), "INFO", "log level 'INFO' found");
TEST_RESULT_Z(logLevelStr(logLevelTrace), "TRACE", "log level 'TRACE' found");
}
// *****************************************************************************************************************************
@ -196,7 +196,7 @@ testRun(void)
logBuffer[0] = 0;
TEST_RESULT_VOID(
logInternalFmt(logLevelWarn, LOG_LEVEL_MIN, LOG_LEVEL_MAX, 0, "file", "function", 0, "format %d", 99), "log warn");
TEST_RESULT_STR(logBuffer, "P00 WARN: format 99\n", " check log");
TEST_RESULT_Z(logBuffer, "P00 WARN: format 99\n", " check log");
// This won't be logged due to the range
TEST_RESULT_VOID(
@ -205,13 +205,13 @@ testRun(void)
logBuffer[0] = 0;
TEST_RESULT_VOID(
logInternal(logLevelError, LOG_LEVEL_MIN, LOG_LEVEL_MAX, 0, "file", "function", 26, "message"), "log error");
TEST_RESULT_STR(logBuffer, "P00 ERROR: [026]: message\n", " check log");
TEST_RESULT_Z(logBuffer, "P00 ERROR: [026]: message\n", " check log");
logBuffer[0] = 0;
TEST_RESULT_VOID(
logInternal(logLevelError, LOG_LEVEL_MIN, LOG_LEVEL_MAX, 0, "file", "function", 26, "message1\nmessage2"),
"log error with multiple lines");
TEST_RESULT_STR(logBuffer, "P00 ERROR: [026]: message1\nmessage2\n", " check log");
TEST_RESULT_Z(logBuffer, "P00 ERROR: [026]: message1\nmessage2\n", " check log");
TEST_RESULT_VOID(logInit(logLevelDebug, logLevelDebug, logLevelDebug, false, 999), "init logging to debug");
@ -224,7 +224,7 @@ testRun(void)
TEST_RESULT_VOID(
logInternal(
logLevelDebug, LOG_LEVEL_MIN, LOG_LEVEL_MAX, 999, "test.c", "test_func", 0, "message\nmessage2"), "log debug");
TEST_RESULT_STR(logBuffer, "P999 DEBUG: test::test_func: message\nmessage2\n", " check log");
TEST_RESULT_Z(logBuffer, "P999 DEBUG: test::test_func: message\nmessage2\n", " check log");
// This won't be logged due to the range
TEST_RESULT_VOID(
@ -233,7 +233,7 @@ testRun(void)
logBuffer[0] = 0;
TEST_RESULT_VOID(
logInternal(logLevelTrace, LOG_LEVEL_MIN, LOG_LEVEL_MAX, 0, "test.c", "test_func", 0, "message"), "log debug");
TEST_RESULT_STR(logBuffer, "P000 TRACE: test::test_func: message\n", " check log");
TEST_RESULT_Z(logBuffer, "P000 TRACE: test::test_func: message\n", " check log");
// Reopen the log file
TEST_RESULT_VOID(logInit(logLevelDebug, logLevelDebug, logLevelDebug, false, 99), "reduce log size");
@ -242,10 +242,10 @@ testRun(void)
logBuffer[0] = 0;
TEST_RESULT_VOID(
logInternal(logLevelInfo, LOG_LEVEL_MIN, LOG_LEVEL_MAX, 1, "test.c", "test_func", 0, "info message"), "log info");
TEST_RESULT_STR(logBuffer, "P01 INFO: info message\n", " check log");
TEST_RESULT_Z(logBuffer, "P01 INFO: info message\n", " check log");
TEST_RESULT_VOID(
logInternal(logLevelInfo, LOG_LEVEL_MIN, LOG_LEVEL_MAX, 99, "test.c", "test_func", 0, "info message 2"), "log info");
TEST_RESULT_STR(logBuffer, "P99 INFO: info message 2\n", " check log");
TEST_RESULT_Z(logBuffer, "P99 INFO: info message 2\n", " check log");
// Reopen invalid log file
TEST_RESULT_BOOL(logFileSet("/" BOGUS_STR), false, "attempt to open bogus file");

View File

@ -93,7 +93,7 @@ testRun(void)
if (testBegin("memContextNew() and memContextFree()"))
{
// Make sure top context was created
TEST_RESULT_STR(memContextName(memContextTop()), "TOP", "top context should exist");
TEST_RESULT_Z(memContextName(memContextTop()), "TOP", "top context should exist");
TEST_RESULT_INT(memContextTop()->contextChildListSize, 0, "top context should init with zero children");
TEST_RESULT_PTR(memContextTop()->contextChildList, NULL, "top context child list empty");
@ -104,7 +104,7 @@ testRun(void)
TEST_ERROR(memContextNew(""), AssertError, "assertion 'name[0] != '\\0'' failed");
MemContext *memContext = memContextNew("test1");
TEST_RESULT_STR(memContextName(memContext), "test1", "test1 context name");
TEST_RESULT_Z(memContextName(memContext), "test1", "test1 context name");
TEST_RESULT_PTR(memContext->contextParent, memContextTop(), "test1 context parent is top");
TEST_RESULT_INT(memContextTop()->contextChildListSize, MEM_CONTEXT_INITIAL_SIZE, "initial top context child list size");
@ -118,7 +118,7 @@ testRun(void)
memContextNew("test-filler");
TEST_RESULT_BOOL(
memContextTop()->contextChildList[contextIdx]->state == memContextStateActive, true, "new context is active");
TEST_RESULT_STR(memContextName(memContextTop()->contextChildList[contextIdx]), "test-filler", "new context name");
TEST_RESULT_Z(memContextName(memContextTop()->contextChildList[contextIdx]), "test-filler", "new context name");
}
// This forces the child context array to grow
@ -138,7 +138,7 @@ testRun(void)
TEST_RESULT_BOOL(
memContextTop()->contextChildList[1]->state == memContextStateActive,
true, "new context in same index as freed context is active");
TEST_RESULT_STR(memContextName(memContextTop()->contextChildList[1]), "test-reuse", "new context name");
TEST_RESULT_Z(memContextName(memContextTop()->contextChildList[1]), "test-reuse", "new context name");
TEST_RESULT_UINT(memContextTop()->contextChildFreeIdx, 2, "check context free idx");
// Next context will be at the end
@ -276,23 +276,23 @@ testRun(void)
// Check normal block
MEM_CONTEXT_BEGIN(memContext)
{
TEST_RESULT_STR(memContextName(memContextCurrent()), "test-block", "context is now test-block");
TEST_RESULT_Z(memContextName(memContextCurrent()), "test-block", "context is now test-block");
}
MEM_CONTEXT_END();
TEST_RESULT_STR(memContextName(memContextCurrent()), "TOP", "context is now top");
TEST_RESULT_Z(memContextName(memContextCurrent()), "TOP", "context is now top");
// Check block that errors
TEST_ERROR(
MEM_CONTEXT_BEGIN(memContext)
{
TEST_RESULT_STR(memContextName(memContextCurrent()), "test-block", "context is now test-block");
TEST_RESULT_Z(memContextName(memContextCurrent()), "test-block", "context is now test-block");
THROW(AssertError, "error in test block");
}
MEM_CONTEXT_END(),
AssertError, "error in test block");
TEST_RESULT_STR(memContextName(memContextCurrent()), "TOP", "context is now top");
TEST_RESULT_Z(memContextName(memContextCurrent()), "TOP", "context is now top");
// Reset temp mem context after a single interaction
// -------------------------------------------------------------------------------------------------------------------------
@ -320,7 +320,7 @@ testRun(void)
{
memContext = MEM_CONTEXT_NEW();
TEST_RESULT_PTR(memContext, memContextCurrent(), "new mem context is current");
TEST_RESULT_STR(memContextName(memContext), memContextTestName, "context is now '%s'", memContextTestName);
TEST_RESULT_Z(memContextName(memContext), memContextTestName, "context is now '%s'", memContextTestName);
}
MEM_CONTEXT_NEW_END();
@ -338,7 +338,7 @@ testRun(void)
MEM_CONTEXT_NEW_BEGIN(memContextTestName)
{
memContext = MEM_CONTEXT_NEW();
TEST_RESULT_STR(memContextName(memContext), memContextTestName, "context is now '%s'", memContextTestName);
TEST_RESULT_Z(memContextName(memContext), memContextTestName, "context is now '%s'", memContextTestName);
THROW(AssertError, "create failed");
}
MEM_CONTEXT_NEW_END();

View File

@ -61,20 +61,20 @@ testRun(void)
TEST_RESULT_PTR(regExpPrefix(strNew("ABC")), NULL, "expression without begin anchor has no prefix");
TEST_RESULT_PTR(regExpPrefix(strNew("^.")), NULL, "expression with no regular character has no prefix");
TEST_RESULT_STR(strPtr(regExpPrefix(strNew("^ABC^"))), "ABC", "prefix stops at special character");
TEST_RESULT_STR(strPtr(regExpPrefix(strNew("^ABC$"))), "ABC", "prefix stops at special character");
TEST_RESULT_STR(strPtr(regExpPrefix(strNew("^ABC*"))), "ABC", "prefix stops at special character");
TEST_RESULT_STR(strPtr(regExpPrefix(strNew("^ABC+"))), "ABC", "prefix stops at special character");
TEST_RESULT_STR(strPtr(regExpPrefix(strNew("^ABC-"))), "ABC", "prefix stops at special character");
TEST_RESULT_STR(strPtr(regExpPrefix(strNew("^ABC?"))), "ABC", "prefix stops at special character");
TEST_RESULT_STR(strPtr(regExpPrefix(strNew("^ABC("))), "ABC", "prefix stops at special character");
TEST_RESULT_STR(strPtr(regExpPrefix(strNew("^ABC["))), "ABC", "prefix stops at special character");
TEST_RESULT_STR(strPtr(regExpPrefix(strNew("^ABC{"))), "ABC", "prefix stops at special character");
TEST_RESULT_STR(strPtr(regExpPrefix(strNew("^ABC "))), "ABC", "prefix stops at special character");
TEST_RESULT_STR(strPtr(regExpPrefix(strNew("^ABC|"))), "ABC", "prefix stops at special character");
TEST_RESULT_STR(strPtr(regExpPrefix(strNew("^ABC\\"))), "ABC", "prefix stops at special character");
TEST_RESULT_STR_Z(regExpPrefix(strNew("^ABC^")), "ABC", "prefix stops at special character");
TEST_RESULT_STR_Z(regExpPrefix(strNew("^ABC$")), "ABC", "prefix stops at special character");
TEST_RESULT_STR_Z(regExpPrefix(strNew("^ABC*")), "ABC", "prefix stops at special character");
TEST_RESULT_STR_Z(regExpPrefix(strNew("^ABC+")), "ABC", "prefix stops at special character");
TEST_RESULT_STR_Z(regExpPrefix(strNew("^ABC-")), "ABC", "prefix stops at special character");
TEST_RESULT_STR_Z(regExpPrefix(strNew("^ABC?")), "ABC", "prefix stops at special character");
TEST_RESULT_STR_Z(regExpPrefix(strNew("^ABC(")), "ABC", "prefix stops at special character");
TEST_RESULT_STR_Z(regExpPrefix(strNew("^ABC[")), "ABC", "prefix stops at special character");
TEST_RESULT_STR_Z(regExpPrefix(strNew("^ABC{")), "ABC", "prefix stops at special character");
TEST_RESULT_STR_Z(regExpPrefix(strNew("^ABC ")), "ABC", "prefix stops at special character");
TEST_RESULT_STR_Z(regExpPrefix(strNew("^ABC|")), "ABC", "prefix stops at special character");
TEST_RESULT_STR_Z(regExpPrefix(strNew("^ABC\\")), "ABC", "prefix stops at special character");
TEST_RESULT_STR(strPtr(regExpPrefix(strNew("^ABCDEF"))), "ABCDEF", "prefix is entire expression");
TEST_RESULT_STR_Z(regExpPrefix(strNew("^ABCDEF")), "ABCDEF", "prefix is entire expression");
}
// *****************************************************************************************************************************

View File

@ -17,11 +17,11 @@ testRun(void)
char buffer[8];
TEST_RESULT_INT(stackTraceFmt(buffer, 8, 0, "%s", "1234567"), 7, "fill buffer");
TEST_RESULT_STR(buffer, "1234567", " check buffer");
TEST_RESULT_Z(buffer, "1234567", " check buffer");
TEST_RESULT_INT(stackTraceFmt(buffer, 8, 7, "%s", "1234567"), 7, "try to fill buffer - at end");
TEST_RESULT_STR(buffer, "1234567", " check buffer is unmodified");
TEST_RESULT_Z(buffer, "1234567", " check buffer is unmodified");
TEST_RESULT_INT(stackTraceFmt(buffer, 8, 8, "%s", "1234567"), 7, "try to fill buffer - past end");
TEST_RESULT_STR(buffer, "1234567", " check buffer is unmodified");
TEST_RESULT_Z(buffer, "1234567", " check buffer is unmodified");
}
// *****************************************************************************************************************************
@ -88,14 +88,14 @@ testRun(void)
stackTraceToZ(buffer, sizeof(buffer), "file1.c", "function2", 99);
#ifdef WITH_BACKTRACE
TEST_RESULT_STR(
TEST_RESULT_Z(
buffer,
"file1:function2:99:(test build required for parameters)\n"
" ... function(s) omitted ...\n"
"file1:function1:0:(void)",
" check stack trace");
#else
TEST_RESULT_STR(
TEST_RESULT_Z(
buffer,
"file1:function2:99:(test build required for parameters)\n"
" ... function(s) omitted ...\n"
@ -153,7 +153,7 @@ testRun(void)
stackTraceToZ(buffer, sizeof(buffer), "file4.c", "function4", 99);
#ifdef WITH_BACKTRACE
TEST_RESULT_STR(
TEST_RESULT_Z(
buffer,
"file4:function4:99:(buffer full - parameters not available)\n"
"file3:function3:7777:(param1: value1, param2: value2)\n"
@ -162,7 +162,7 @@ testRun(void)
"file1:function1:7777:(void)",
"stack trace");
#else
TEST_RESULT_STR(
TEST_RESULT_Z(
buffer,
"file4:function4:99:(buffer full - parameters not available)\n"
"file3:function3:(param1: value1, param2: value2)\n"

View File

@ -126,33 +126,33 @@ testRun(void)
// *****************************************************************************************************************************
if (testBegin("bufHex()"))
{
TEST_RESULT_STR(strPtr(bufHex(BUFSTRDEF("ABC-CBA"))), "4142432d434241", "buffer to hex");
TEST_RESULT_STR_Z(bufHex(BUFSTRDEF("ABC-CBA")), "4142432d434241", "buffer to hex");
}
// *****************************************************************************************************************************
if (testBegin("bufCat*()"))
{
TEST_RESULT_STR(strPtr(strNewBuf(bufCat(bufNewC("123", 3), NULL))), "123", "cat null buffer");
TEST_RESULT_STR(strPtr(strNewBuf(bufCat(bufNewC("123", 3), bufNew(0)))), "123", "cat empty buffer");
TEST_RESULT_STR(strPtr(strNewBuf(bufCat(bufNewC("123", 3), BUFSTRDEF("ABC")))), "123ABC", "cat buffer");
TEST_RESULT_STR_Z(strNewBuf(bufCat(bufNewC("123", 3), NULL)), "123", "cat null buffer");
TEST_RESULT_STR_Z(strNewBuf(bufCat(bufNewC("123", 3), bufNew(0))), "123", "cat empty buffer");
TEST_RESULT_STR_Z(strNewBuf(bufCat(bufNewC("123", 3), BUFSTRDEF("ABC"))), "123ABC", "cat buffer");
TEST_RESULT_STR(strPtr(strNewBuf(bufCatSub(bufNewC("123", 3), NULL, 0, 0))), "123", "cat sub null buffer");
TEST_RESULT_STR(strPtr(strNewBuf(bufCatSub(bufNewC("123", 3), bufNew(0), 0, 0))), "123", "cat sub empty buffer");
TEST_RESULT_STR(strPtr(strNewBuf(bufCatSub(bufNewC("123", 3), BUFSTRDEF("ABC"), 1, 2))), "123BC", "cat sub buffer");
TEST_RESULT_STR_Z(strNewBuf(bufCatSub(bufNewC("123", 3), NULL, 0, 0)), "123", "cat sub null buffer");
TEST_RESULT_STR_Z(strNewBuf(bufCatSub(bufNewC("123", 3), bufNew(0), 0, 0)), "123", "cat sub empty buffer");
TEST_RESULT_STR_Z(strNewBuf(bufCatSub(bufNewC("123", 3), BUFSTRDEF("ABC"), 1, 2)), "123BC", "cat sub buffer");
Buffer *buffer = NULL;
TEST_ASSIGN(buffer, bufNew(2), "new buffer with space");
TEST_RESULT_STR(strPtr(strNewBuf(bufCat(buffer, BUFSTRDEF("AB")))), "AB", "cat buffer with space");
TEST_RESULT_STR_Z(strNewBuf(bufCat(buffer, BUFSTRDEF("AB"))), "AB", "cat buffer with space");
}
// *****************************************************************************************************************************
if (testBegin("bufToLog()"))
{
Buffer *buffer = bufNew(100);
TEST_RESULT_STR(strPtr(bufToLog(buffer)), "{used: 0, size: 100, limit: <off>}", "buf to log");
TEST_RESULT_STR_Z(bufToLog(buffer), "{used: 0, size: 100, limit: <off>}", "buf to log");
bufLimitSet(buffer, 50);
TEST_RESULT_STR(strPtr(bufToLog(buffer)), "{used: 0, size: 100, limit: 50}", "buf to log");
TEST_RESULT_STR_Z(bufToLog(buffer), "{used: 0, size: 100, limit: 50}", "buf to log");
}
FUNCTION_HARNESS_RESULT_VOID();

View File

@ -19,9 +19,9 @@ testRun(void)
TEST_ERROR(cvtBoolToZ(true, buffer, 4), AssertError, "buffer overflow");
TEST_RESULT_INT(cvtBoolToZ(true, buffer, STACK_TRACE_PARAM_MAX), 4, "convert true bool to string");
TEST_RESULT_STR(buffer, "true", " check buffer");
TEST_RESULT_Z(buffer, "true", " check buffer");
TEST_RESULT_INT(cvtBoolToZ(false, buffer, STACK_TRACE_PARAM_MAX), 5, "convert false bool to string");
TEST_RESULT_STR(buffer, "false", " check buffer");
TEST_RESULT_Z(buffer, "false", " check buffer");
}
// *****************************************************************************************************************************
@ -32,7 +32,7 @@ testRun(void)
TEST_ERROR(cvtCharToZ('A', buffer, 1), AssertError, "buffer overflow");
TEST_RESULT_INT(cvtCharToZ('C', buffer, STACK_TRACE_PARAM_MAX), 1, "convert char to string");
TEST_RESULT_STR(buffer, "C", " check buffer");
TEST_RESULT_Z(buffer, "C", " check buffer");
}
// *****************************************************************************************************************************
@ -43,13 +43,13 @@ testRun(void)
TEST_ERROR(cvtDoubleToZ(999.1234, buffer, 4), AssertError, "buffer overflow");
TEST_RESULT_INT(cvtDoubleToZ(999.1234, buffer, STACK_TRACE_PARAM_MAX), 8, "convert double to string");
TEST_RESULT_STR(buffer, "999.1234", " check buffer");
TEST_RESULT_Z(buffer, "999.1234", " check buffer");
TEST_RESULT_INT(cvtDoubleToZ(999999999.123456, buffer, STACK_TRACE_PARAM_MAX), 16, "convert double to string");
TEST_RESULT_STR(buffer, "999999999.123456", " check buffer");
TEST_RESULT_Z(buffer, "999999999.123456", " check buffer");
TEST_RESULT_INT(cvtDoubleToZ(999.0, buffer, STACK_TRACE_PARAM_MAX), 3, "convert double to string");
TEST_RESULT_STR(buffer, "999", " check buffer");
TEST_RESULT_Z(buffer, "999", " check buffer");
TEST_ERROR(cvtZToDouble("AAA"), FormatError, "unable to convert string 'AAA' to double");
TEST_RESULT_DOUBLE(cvtZToDouble("0"), 0, "convert string to double");
@ -65,7 +65,7 @@ testRun(void)
TEST_ERROR(cvtIntToZ(9999, buffer, 4), AssertError, "buffer overflow");
TEST_RESULT_INT(cvtIntToZ(1234567890, buffer, STACK_TRACE_PARAM_MAX), 10, "convert int to string");
TEST_RESULT_STR(buffer, "1234567890", " check buffer");
TEST_RESULT_Z(buffer, "1234567890", " check buffer");
TEST_ERROR(cvtZToInt("FEF"), FormatError, "unable to convert base 10 string 'FEF' to int");
TEST_ERROR(cvtZToInt("9223372036854775807"), FormatError, "unable to convert base 10 string '9223372036854775807' to int");
@ -86,7 +86,7 @@ testRun(void)
TEST_ERROR(cvtModeToZ(0750, buffer, 4), AssertError, "buffer overflow");
TEST_RESULT_INT(cvtModeToZ(0777, buffer, STACK_TRACE_PARAM_MAX), 4, "convert mode to string");
TEST_RESULT_STR(buffer, "0777", " check buffer");
TEST_RESULT_Z(buffer, "0777", " check buffer");
TEST_RESULT_UINT(cvtZToMode("0700"), 0700, "convert string to mode");
}
@ -99,13 +99,13 @@ testRun(void)
TEST_ERROR(cvtSizeToZ(9999, buffer, 4), AssertError, "buffer overflow");
TEST_RESULT_UINT(cvtSizeToZ(4294967295, buffer, STACK_TRACE_PARAM_MAX), 10, "convert size to string");
TEST_RESULT_STR(buffer, "4294967295", " check buffer");
TEST_RESULT_Z(buffer, "4294967295", " check buffer");
// ------------------------------------------------------------------------------------------------------------------------
TEST_ERROR(cvtSSizeToZ(-9999, buffer, 4), AssertError, "buffer overflow");
TEST_RESULT_INT(cvtSSizeToZ(-9999, buffer, STACK_TRACE_PARAM_MAX), 5, "convert ssize to string");
TEST_RESULT_STR(buffer, "-9999", " check buffer");
TEST_RESULT_Z(buffer, "-9999", " check buffer");
}
// *****************************************************************************************************************************
@ -116,7 +116,7 @@ testRun(void)
TEST_ERROR(cvtTimeToZ(9999, buffer, 4), AssertError, "buffer overflow");
TEST_RESULT_UINT(cvtTimeToZ(1573222014, buffer, STACK_TRACE_PARAM_MAX), 10, "convert time to string");
TEST_RESULT_STR(buffer, "1573222014", " check buffer");
TEST_RESULT_Z(buffer, "1573222014", " check buffer");
}
// *****************************************************************************************************************************
@ -127,7 +127,7 @@ testRun(void)
TEST_ERROR(cvtUIntToZ(9999, buffer, 4), AssertError, "buffer overflow");
TEST_RESULT_INT(cvtUIntToZ(4294967295, buffer, STACK_TRACE_PARAM_MAX), 10, "convert unsigned int to string");
TEST_RESULT_STR(buffer, "4294967295", " check buffer");
TEST_RESULT_Z(buffer, "4294967295", " check buffer");
TEST_ERROR(cvtZToUInt("-1"), FormatError, "unable to convert base 10 string '-1' to unsigned int");
TEST_ERROR(cvtZToUInt("5000000000"), FormatError, "unable to convert base 10 string '5000000000' to unsigned int");
@ -144,7 +144,7 @@ testRun(void)
TEST_ERROR(cvtInt64ToZ(9999, buffer, 4), AssertError, "buffer overflow");
TEST_RESULT_INT(cvtInt64ToZ(9223372036854775807, buffer, STACK_TRACE_PARAM_MAX), 19, "convert int64 to string");
TEST_RESULT_STR(buffer, "9223372036854775807", " check buffer");
TEST_RESULT_Z(buffer, "9223372036854775807", " check buffer");
TEST_ERROR(cvtZToInt64("123INV"), FormatError, "unable to convert base 10 string '123INV' to int64");
TEST_ERROR(cvtZToInt64("FEF"), FormatError, "unable to convert base 10 string 'FEF' to int64");
@ -169,7 +169,7 @@ testRun(void)
TEST_ERROR(cvtUInt64ToZ(9999, buffer, 4), AssertError, "buffer overflow");
TEST_RESULT_INT(cvtUInt64ToZ(0xFFFFFFFFFFFFFFFF, buffer, STACK_TRACE_PARAM_MAX), 20, "convert uint64 to string");
TEST_RESULT_STR(buffer, "18446744073709551615", " check buffer");
TEST_RESULT_Z(buffer, "18446744073709551615", " check buffer");
TEST_ERROR(cvtZToUInt64("FEF"), FormatError, "unable to convert base 10 string 'FEF' to uint64");
TEST_ERROR(cvtZToUInt64(" 10"), FormatError, "unable to convert base 10 string ' 10' to uint64");

View File

@ -41,9 +41,9 @@ testRun(void)
TEST_ERROR(jsonToStr(strNew("nullz")), JsonFormatError, "unexpected characters after string at 'z'");
TEST_RESULT_PTR(jsonToStr(strNew("null")), NULL, "null string");
TEST_RESULT_STR(strPtr(jsonToStr(strNew(" \"test\""))), "test", "simple string");
TEST_RESULT_STR(strPtr(jsonToStr(strNew("\"te\\\"st\" "))), "te\"st", "string with quote");
TEST_RESULT_STR(strPtr(jsonToStr(strNew("\"\\\"\\\\\\/\\b\\n\\r\\t\\f\""))), "\"\\/\b\n\r\t\f", "string with escapes");
TEST_RESULT_STR_Z(jsonToStr(strNew(" \"test\"")), "test", "simple string");
TEST_RESULT_STR_Z(jsonToStr(strNew("\"te\\\"st\" ")), "te\"st", "string with quote");
TEST_RESULT_STR_Z(jsonToStr(strNew("\"\\\"\\\\\\/\\b\\n\\r\\t\\f\"")), "\"\\/\b\n\r\t\f", "string with escapes");
}
// *****************************************************************************************************************************
@ -59,7 +59,7 @@ testRun(void)
TEST_ASSIGN(kv, jsonToKv(strNew("{\"key1\": 747, \"key2\":\"value2\",\"key3\"\t:\t[\t] }")), "object");
TEST_RESULT_UINT(varLstSize(kvKeyList(kv)), 3, "check key total");
TEST_RESULT_UINT(varUInt64(kvGet(kv, varNewStr(strNew("key1")))), 747, "check object uint");
TEST_RESULT_STR(strPtr(varStr(kvGet(kv, varNewStr(strNew("key2"))))), "value2", "check object str");
TEST_RESULT_STR_Z(varStr(kvGet(kv, varNewStr(strNew("key2")))), "value2", "check object str");
TEST_RESULT_UINT(varLstSize(varVarLst(kvGet(kv, varNewStr(strNew("key3"))))), 0, "check empty array");
TEST_ASSIGN(kv, jsonToKv(strNew("\t{\n} ")), "empty object");
@ -74,10 +74,9 @@ testRun(void)
TEST_ERROR(jsonToVar(strNew("z")), JsonFormatError, "invalid type at 'z'");
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_STR(strPtr(varStr(jsonToVar(strNew(" \"test\"")))), "test", "simple string");
TEST_RESULT_STR(strPtr(varStr(jsonToVar(strNew("\"te\\\"st\" ")))), "te\"st", "string with quote");
TEST_RESULT_STR(
strPtr(varStr(jsonToVar(strNew("\"\\\"\\\\\\/\\b\\n\\r\\t\\f\"")))), "\"\\/\b\n\r\t\f", "string with escapes");
TEST_RESULT_STR_Z(varStr(jsonToVar(strNew(" \"test\""))), "test", "simple string");
TEST_RESULT_STR_Z(varStr(jsonToVar(strNew("\"te\\\"st\" "))), "te\"st", "string with quote");
TEST_RESULT_STR_Z(varStr(jsonToVar(strNew("\"\\\"\\\\\\/\\b\\n\\r\\t\\f\""))), "\"\\/\b\n\r\t\f", "string with escapes");
// -------------------------------------------------------------------------------------------------------------------------
TEST_ERROR(jsonToVar(strNew("ton")), JsonFormatError, "expected boolean at 'ton'");
@ -95,7 +94,7 @@ testRun(void)
TEST_ASSIGN(valueList, varVarLst(jsonToVar(strNew("[1, \"test\", false]"))), "array");
TEST_RESULT_UINT(varLstSize(valueList), 3, "check array size");
TEST_RESULT_INT(varUInt64(varLstGet(valueList, 0)), 1, "check array int");
TEST_RESULT_STR(strPtr(varStr(varLstGet(valueList, 1))), "test", "check array str");
TEST_RESULT_STR_Z(varStr(varLstGet(valueList, 1)), "test", "check array str");
TEST_RESULT_BOOL(varBool(varLstGet(valueList, 2)), false, "check array bool");
TEST_ASSIGN(valueList, varVarLst(jsonToVar(strNew("[ ]"))), "empty array");
@ -114,32 +113,31 @@ testRun(void)
TEST_ERROR(jsonToVarLst(strNew("[")), JsonFormatError, "expected data");
TEST_ERROR(jsonToVarLst(strNew(" [] ZZZ")), JsonFormatError, "unexpected characters after array at 'ZZZ'");
TEST_RESULT_STR(
strPtr(strLstJoin(strLstNewVarLst(jsonToVarLst(strNew("[\"e1\", \"e2\"]"))), "|")), "e1|e2", "json list");
TEST_RESULT_STR_Z(strLstJoin(strLstNewVarLst(jsonToVarLst(strNew("[\"e1\", \"e2\"]"))), "|"), "e1|e2", "json list");
}
// *****************************************************************************************************************************
if (testBegin("jsonFromBool()"))
{
TEST_RESULT_STR(strPtr(jsonFromBool(true)), "true", "json bool true");
TEST_RESULT_STR(strPtr(jsonFromBool(false)), "false", "json bool true");
TEST_RESULT_STR_Z(jsonFromBool(true), "true", "json bool true");
TEST_RESULT_STR_Z(jsonFromBool(false), "false", "json bool true");
}
// *****************************************************************************************************************************
if (testBegin("jsonFromInt(), jsonFromInt64(), jsonFromUInt() and jsonFromUInt64()"))
{
TEST_RESULT_STR(strPtr(jsonFromInt(-2147483648)), "-2147483648", "json int");
TEST_RESULT_STR(strPtr(jsonFromInt64(-9223372036854775807L)), "-9223372036854775807", "json int64");
TEST_RESULT_STR(strPtr(jsonFromUInt(4294967295)), "4294967295", "json uint");
TEST_RESULT_STR(strPtr(jsonFromUInt64(18446744073709551615UL)), "18446744073709551615", "json uint64");
TEST_RESULT_STR_Z(jsonFromInt(-2147483648), "-2147483648", "json int");
TEST_RESULT_STR_Z(jsonFromInt64(-9223372036854775807L), "-9223372036854775807", "json int64");
TEST_RESULT_STR_Z(jsonFromUInt(4294967295), "4294967295", "json uint");
TEST_RESULT_STR_Z(jsonFromUInt64(18446744073709551615UL), "18446744073709551615", "json uint64");
}
// *****************************************************************************************************************************
if (testBegin("jsonFromStr() and jsonFromStrInternal()"))
{
TEST_RESULT_STR(strPtr(jsonFromStr(NULL)), "null", "null string");
TEST_RESULT_STR(strPtr(jsonFromStr(strNew("simple string"))), "\"simple string\"", "simple string");
TEST_RESULT_STR(strPtr(jsonFromStr(strNew("\"\\/\b\n\r\t\f"))), "\"\\\"\\\\/\\b\\n\\r\\t\\f\"", "string escapes");
TEST_RESULT_STR_Z(jsonFromStr(NULL), "null", "null string");
TEST_RESULT_STR_Z(jsonFromStr(strNew("simple string")), "\"simple string\"", "simple string");
TEST_RESULT_STR_Z(jsonFromStr(strNew("\"\\/\b\n\r\t\f")), "\"\\\"\\\\/\\b\\n\\r\\t\\f\"", "string escapes");
}
// *****************************************************************************************************************************
@ -149,11 +147,11 @@ testRun(void)
String *json = NULL;
TEST_ASSIGN(json, jsonFromKv(keyValue), "kvToJson - empty");
TEST_RESULT_STR(strPtr(json), "{}", " empty curly brackets");
TEST_RESULT_STR_Z(json, "{}", " empty curly brackets");
kvPut(keyValue, varNewStrZ("backup"), varNewVarLst(varLstNew()));
TEST_ASSIGN(json, jsonFromKv(keyValue), "kvToJson - kv with empty array");
TEST_RESULT_STR(strPtr(json), "{\"backup\":[]}", " kv with empty array brackets");
TEST_RESULT_STR_Z(json, "{\"backup\":[]}", " kv with empty array brackets");
kvPutKv(keyValue, varNewStr(strNew("archive")));
kvPutKv(keyValue, varNewStr(strNew("empty")));
@ -172,8 +170,8 @@ testRun(void)
kvPut(keyValue, varNewStrZ("null-list"), varNewVarLst(NULL));
TEST_ASSIGN(json, jsonFromKv(keyValue), "kvToJson - kv with empty array, kv, varList with values");
TEST_RESULT_STR(
strPtr(json),
TEST_RESULT_STR_Z(
json,
"{"
"\"archive\":{},"
"\"backup\":[],"
@ -190,7 +188,8 @@ testRun(void)
"\"empty\":{},"
"\"null-list\":null,"
"\"null-str\":null"
"}", " kv with empty array, kv, varList with values");
"}",
" kv with empty array, kv, varList with values");
TEST_ASSIGN(
keyValue,
@ -202,7 +201,8 @@ testRun(void)
"\"checksum-page-error\":[1,[4,6]],\"backup-timestamp-start\":1482182951}"))),
"multiple values with array");
TEST_ASSIGN(json, jsonFromKv(keyValue), " kvToJson - sorted");
TEST_RESULT_STR(strPtr(json),
TEST_RESULT_STR_Z(
json,
"{\"backup-info-size-delta\":1982702,\"backup-prior\":\"20161219-212741F_20161219-212803I\","
"\"backup-reference\":[\"20161219-212741F\",\"20161219-212741F_20161219-212803I\"],"
"\"backup-timestamp-start\":1482182951,\"checksum-page-error\":[1,[4,6]]}",
@ -243,7 +243,8 @@ testRun(void)
kvAdd(sectionKv, varNewStr(strNew("escape")), varNewStr(strNew("\"\\/\b\n\r\t\f")));
TEST_ASSIGN(json, jsonFromVar(keyValue), "KeyValue");
TEST_RESULT_STR(strPtr(json),
TEST_RESULT_STR_Z(
json,
"{\"backup-info-size-delta\":1982702,\"backup-prior\":\"20161219-212741F_20161219-212803I\","
"\"backup-reference\":[\"20161219-212741F\",\"20161219-212741F_20161219-212803I\",null],"
"\"backup-timestamp-start\":1482182951,\"checksum-page-error\":[1],"
@ -254,7 +255,7 @@ testRun(void)
Variant *varListOuter = NULL;
TEST_ASSIGN(json, jsonFromVar(varNewVarLst(varLstNew())), "VariantList");
TEST_RESULT_STR(strPtr(json), "[]", " empty list no pretty print");
TEST_RESULT_STR_Z(json, "[]", " empty list no pretty print");
TEST_ASSIGN(varListOuter, varNewVarLst(varLstNew()), "new variant list with keyValues");
varLstAdd(varVarLst(varListOuter), varNewStrZ("ASTRING"));
@ -266,7 +267,8 @@ testRun(void)
varLstAdd(varVarLst(varListOuter), keyValue);
TEST_ASSIGN(json, jsonFromVar(varListOuter), "VariantList");
TEST_RESULT_STR(strPtr(json),
TEST_RESULT_STR_Z(
json,
"[\"ASTRING\",9223372036854775807,2147483647,true,[],null,{\"backup-info-size-delta\":1982702,"
"\"backup-prior\":\"20161219-212741F_20161219-212803I\","
"\"backup-reference\":[\"20161219-212741F\",\"20161219-212741F_20161219-212803I\",null],"
@ -278,7 +280,8 @@ testRun(void)
varLstAdd(varVarLst(varListOuter), keyValue2);
TEST_ASSIGN(json, jsonFromVar(varListOuter), "VariantList - multiple elements");
TEST_RESULT_STR(strPtr(json),
TEST_RESULT_STR_Z(
json,
"[\"ASTRING\",9223372036854775807,2147483647,true,[],null,{\"backup-info-size-delta\":1982702,"
"\"backup-prior\":\"20161219-212741F_20161219-212803I\","
"\"backup-reference\":[\"20161219-212741F\",\"20161219-212741F_20161219-212803I\",null],"
@ -294,14 +297,14 @@ testRun(void)
varLstAdd(varList, varNewUInt(32));
varLstAdd(varList, varNewUInt64(10000000000));
TEST_RESULT_STR(strPtr(jsonFromVar(varNewVarLst(varList))), "[32,10000000000]", "list various types");
TEST_RESULT_STR_Z(jsonFromVar(varNewVarLst(varList)), "[32,10000000000]", "list various types");
//--------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_STR(strPtr(jsonFromVar(NULL)), "null", "null variant");
TEST_RESULT_STR(strPtr(jsonFromVar(varNewBool(true))), "true", "bool variant");
TEST_RESULT_STR(strPtr(jsonFromVar(varNewUInt(66))), "66", "uint variant");
TEST_RESULT_STR(strPtr(jsonFromVar(varNewUInt64(10000000001))), "10000000001", "uint64 variant");
TEST_RESULT_STR(strPtr(jsonFromVar(varNewStrZ("test \" string"))), "\"test \\\" string\"", "string variant");
TEST_RESULT_STR_Z(jsonFromVar(NULL), "null", "null variant");
TEST_RESULT_STR_Z(jsonFromVar(varNewBool(true)), "true", "bool variant");
TEST_RESULT_STR_Z(jsonFromVar(varNewUInt(66)), "66", "uint variant");
TEST_RESULT_STR_Z(jsonFromVar(varNewUInt64(10000000001)), "10000000001", "uint64 variant");
TEST_RESULT_STR_Z(jsonFromVar(varNewStrZ("test \" string")), "\"test \\\" string\"", "string variant");
}
FUNCTION_HARNESS_RESULT_VOID();

View File

@ -45,7 +45,7 @@ testRun(void)
// Get the types and make sure they have the correct value
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_STR(strPtr(varStr(kvGet(store, varNewStr(strNew("str-key"))))), "str-value", "get string/string");
TEST_RESULT_STR_Z(varStr(kvGet(store, varNewStr(strNew("str-key")))), "str-value", "get string/string");
TEST_RESULT_INT(varInt(kvGet(store, varNewInt(42))), 57, "get int/int");
TEST_RESULT_INT(varInt(varLstGet(kvGetList(store, varNewInt(42)), 0)), 57, "get int/int");
TEST_RESULT_INT(varInt(kvGet(store, varNewStr(strNew("str-key-int")))), 99, "get string/int");
@ -92,8 +92,8 @@ testRun(void)
KeyValue *storeSub = kvPutKv(store, varNewStr(strNew("kv-key")));
kvPut(storeSub, varNewStr(strNew("str-sub-key")), varNewStr(strNew("str-sub-value")));
TEST_RESULT_STR(
strPtr(varStr(kvGet(varKv(kvGet(store, varNewStr(strNew("kv-key")))), varNewStr(strNew("str-sub-key"))))),
TEST_RESULT_STR_Z(
varStr(kvGet(varKv(kvGet(store, varNewStr(strNew("kv-key")))), varNewStr(strNew("str-sub-key")))),
"str-sub-value", "get string/kv");
// Duplicate the kv
@ -102,8 +102,8 @@ testRun(void)
TEST_RESULT_INT(varBool(kvGet(store, varNewInt(78))), false, "get int/bool");
TEST_RESULT_INT(varInt(varLstGet(varVarLst(kvGet(store, varNewInt(99))), 2)), 3, "get int/int");
TEST_RESULT_STR(
strPtr(varStr(kvGet(varKv(kvGet(storeDup, varNewStr(strNew("kv-key")))), varNewStr(strNew("str-sub-key"))))),
TEST_RESULT_STR_Z(
varStr(kvGet(varKv(kvGet(storeDup, varNewStr(strNew("kv-key")))), varNewStr(strNew("str-sub-key")))),
"str-sub-value", "get string/kv");
TEST_RESULT_VOID(kvFree(storeDup), "free dup store");

View File

@ -42,10 +42,10 @@ testRun(void)
void *ptr = NULL;
TEST_RESULT_VOID(lstAdd(list, &ptr), "add item");
TEST_RESULT_STR(strPtr(lstToLog(list)), "{size: 1}", "check log");
TEST_RESULT_STR_Z(lstToLog(list), "{size: 1}", "check log");
TEST_RESULT_VOID(lstClear(list), "clear list");
TEST_RESULT_STR(strPtr(lstToLog(list)), "{size: 0}", "check log after clear");
TEST_RESULT_STR_Z(lstToLog(list), "{size: 0}", "check log after clear");
TEST_RESULT_VOID(lstFree(list), "free list");
TEST_RESULT_VOID(lstFree(lstNew(1)), "free empty list");
@ -61,8 +61,8 @@ testRun(void)
String *string3 = strNew("string3");
TEST_RESULT_PTR(lstFindDefault(list, &string3, (void *)1), (void *)1, " find string3 returns default");
TEST_RESULT_BOOL(lstExists(list, &string3), false, " string3 does not exist");
TEST_RESULT_STR(strPtr(*(String **)lstFind(list, &string2)), "string2", " find string2");
TEST_RESULT_STR(strPtr(*(String **)lstFindDefault(list, &string2, NULL)), "string2", " find string2 no default");
TEST_RESULT_STR_Z(*(String **)lstFind(list, &string2), "string2", " find string2");
TEST_RESULT_STR_Z(*(String **)lstFindDefault(list, &string2, NULL), "string2", " find string2 no default");
TEST_RESULT_BOOL(lstExists(list, &string2), true, " string2 exists");
TEST_RESULT_BOOL(lstRemove(list, &string2), true, " remove string2");

View File

@ -20,14 +20,14 @@ testRun(void)
TEST_RESULT_PTR(mcvResult(mcv), NULL, "immediate result is null");
TEST_RESULT_VOID(mcvUpdate(mcv, varNewStrZ("string1")), "update string1");
TEST_RESULT_STR(strPtr(varStr(mcvResult(mcv))), "string1", "result is string1");
TEST_RESULT_STR_Z(varStr(mcvResult(mcv)), "string1", "result is string1");
TEST_RESULT_VOID(mcvUpdate(mcv, varNewStrZ("string2")), "update string2");
TEST_RESULT_STR(strPtr(varStr(mcvResult(mcv))), "string1", "result is string1");
TEST_RESULT_STR_Z(varStr(mcvResult(mcv)), "string1", "result is string1");
TEST_RESULT_VOID(mcvUpdate(mcv, varNewUInt(555)), "update 555");
TEST_RESULT_VOID(mcvUpdate(mcv, varNewStrZ("string2")), "update string2");
TEST_RESULT_STR(strPtr(varStr(mcvResult(mcv))), "string2", "result is string2");
TEST_RESULT_STR_Z(varStr(mcvResult(mcv)), "string2", "result is string2");
TEST_RESULT_VOID(mcvFree(mcv), "free mcv");

View File

@ -26,7 +26,7 @@ testRun(void)
TEST_ERROR(CHECK_SIZE(STRING_SIZE_MAX + 1), AssertError, "string size must be <= 1073741824 bytes");
String *string = strNew("static string");
TEST_RESULT_STR(strPtr(string), "static string", "new with static string");
TEST_RESULT_STR_Z(string, "static string", "new with static string");
TEST_RESULT_INT(strSize(string), 13, "check size");
TEST_RESULT_BOOL(strEmpty(string), false, "is not empty");
TEST_RESULT_INT(strlen(strPtr(string)), 13, "check size with strlen()");
@ -35,18 +35,18 @@ testRun(void)
TEST_RESULT_VOID(strFree(string), "free string");
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_STR(strPtr(strNewN("testmorestring", 4)), "test", "new string with size limit");
TEST_RESULT_STR_Z(strNewN("testmorestring", 4), "test", "new string with size limit");
// -------------------------------------------------------------------------------------------------------------------------
Buffer *buffer = bufNew(8);
memcpy(bufPtr(buffer), "12345678", 8);
bufUsedSet(buffer, 8);
TEST_RESULT_STR(strPtr(strNewBuf(buffer)), "12345678", "new string from buffer");
TEST_RESULT_STR_Z(strNewBuf(buffer), "12345678", "new string from buffer");
// -------------------------------------------------------------------------------------------------------------------------
string = strNewFmt("formatted %s %04d", "string", 1);
TEST_RESULT_STR(strPtr(string), "formatted string 0001", "new with formatted string");
TEST_RESULT_STR_Z(string, "formatted string 0001", "new with formatted string");
TEST_RESULT_PTR(strPtr(NULL), NULL, "null string pointer");
TEST_RESULT_VOID(strFree(string), "free string");
@ -56,22 +56,22 @@ testRun(void)
// *****************************************************************************************************************************
if (testBegin("STRING_STATIC()"))
{
TEST_RESULT_STR(strPtr(TEST_STRING), "a very interesting string!", "check static string");
TEST_RESULT_STR(strPtr(strSubN(TEST_STRING, 0, 6)), "a very", "read-only strSub() works");
TEST_RESULT_STR_Z(TEST_STRING, "a very interesting string!", "check static string");
TEST_RESULT_STR_Z(strSubN(TEST_STRING, 0, 6), "a very", "read-only strSub() works");
}
// *****************************************************************************************************************************
if (testBegin("strBase(), strPath(), and strPathAbsolute()"))
{
TEST_RESULT_STR(strPtr(strBase(STRDEF(""))), "", "empty string");
TEST_RESULT_STR(strPtr(strBase(STRDEF("/"))), "", "/ only");
TEST_RESULT_STR(strPtr(strBase(STRDEF("/file"))), "file", "root file");
TEST_RESULT_STR(strPtr(strBase(STRDEF("/dir1/dir2/file"))), "file", "subdirectory file");
TEST_RESULT_STR_Z(strBase(STRDEF("")), "", "empty string");
TEST_RESULT_STR_Z(strBase(STRDEF("/")), "", "/ only");
TEST_RESULT_STR_Z(strBase(STRDEF("/file")), "file", "root file");
TEST_RESULT_STR_Z(strBase(STRDEF("/dir1/dir2/file")), "file", "subdirectory file");
TEST_RESULT_STR(strPtr(strPath(STRDEF(""))), "", "empty string");
TEST_RESULT_STR(strPtr(strPath(STRDEF("/"))), "/", "/ only");
TEST_RESULT_STR(strPtr(strPath(STRDEF("/file"))), "/", "root path");
TEST_RESULT_STR(strPtr(strPath(STRDEF("/dir1/dir2/file"))), "/dir1/dir2", "subdirectory file");
TEST_RESULT_STR_Z(strPath(STRDEF("")), "", "empty string");
TEST_RESULT_STR_Z(strPath(STRDEF("/")), "/", "/ only");
TEST_RESULT_STR_Z(strPath(STRDEF("/file")), "/", "root path");
TEST_RESULT_STR_Z(strPath(STRDEF("/dir1/dir2/file")), "/dir1/dir2", "subdirectory file");
TEST_ERROR(strPathAbsolute(STRDEF("/.."), NULL), AssertError, "result path '/..' is not absolute");
TEST_ERROR(strPathAbsolute(STRDEF("//"), NULL), AssertError, "result path '//' is not absolute");
@ -92,14 +92,14 @@ testRun(void)
String *string = strNew("XXXX");
String *string2 = strNew("ZZZZ");
TEST_RESULT_STR(strPtr(strCat(string, "YYYY")), "XXXXYYYY", "cat string");
TEST_RESULT_STR_Z(strCat(string, "YYYY"), "XXXXYYYY", "cat string");
TEST_RESULT_SIZE(string->extra, 4, "check extra");
TEST_RESULT_STR(strPtr(strCatFmt(string, "%05d", 777)), "XXXXYYYY00777", "cat formatted string");
TEST_RESULT_STR_Z(strCatFmt(string, "%05d", 777), "XXXXYYYY00777", "cat formatted string");
TEST_RESULT_SIZE(string->extra, 6, "check extra");
TEST_RESULT_STR(strPtr(strCatChr(string, '!')), "XXXXYYYY00777!", "cat chr");
TEST_RESULT_STR_Z(strCatChr(string, '!'), "XXXXYYYY00777!", "cat chr");
TEST_RESULT_SIZE(string->extra, 5, "check extra");
TEST_RESULT_STR(strPtr(string2), "ZZZZ", "check unaltered string");
TEST_RESULT_STR_Z(string2, "ZZZZ", "check unaltered string");
}
// *****************************************************************************************************************************
@ -107,7 +107,7 @@ testRun(void)
{
const String *string = STRDEF("duplicated string");
String *stringDup = strDup(string);
TEST_RESULT_STR(strPtr(stringDup), strPtr(string), "duplicated strings match");
TEST_RESULT_STR(stringDup, string, "duplicated strings match");
TEST_RESULT_PTR(strDup(NULL), NULL, "duplicate null string");
}
@ -160,57 +160,57 @@ testRun(void)
// *****************************************************************************************************************************
if (testBegin("strFirstUpper(), strFirstLower(), strUpper(), strLower()"))
{
TEST_RESULT_STR(strPtr(strFirstUpper(strNew(""))), "", "empty first upper");
TEST_RESULT_STR(strPtr(strFirstUpper(strNew("aaa"))), "Aaa", "first upper");
TEST_RESULT_STR(strPtr(strFirstUpper(strNew("Aaa"))), "Aaa", "first already upper");
TEST_RESULT_STR_Z(strFirstUpper(strNew("")), "", "empty first upper");
TEST_RESULT_STR_Z(strFirstUpper(strNew("aaa")), "Aaa", "first upper");
TEST_RESULT_STR_Z(strFirstUpper(strNew("Aaa")), "Aaa", "first already upper");
TEST_RESULT_STR(strPtr(strFirstLower(strNew(""))), "", "empty first lower");
TEST_RESULT_STR(strPtr(strFirstLower(strNew("AAA"))), "aAA", "first lower");
TEST_RESULT_STR(strPtr(strFirstLower(strNew("aAA"))), "aAA", "first already lower");
TEST_RESULT_STR_Z(strFirstLower(strNew("")), "", "empty first lower");
TEST_RESULT_STR_Z(strFirstLower(strNew("AAA")), "aAA", "first lower");
TEST_RESULT_STR_Z(strFirstLower(strNew("aAA")), "aAA", "first already lower");
TEST_RESULT_STR(strPtr(strLower(strNew("K123aBc"))), "k123abc", "all lower");
TEST_RESULT_STR(strPtr(strLower(strNew("k123abc"))), "k123abc", "already lower");
TEST_RESULT_STR(strPtr(strLower(strNew("C"))), "c", "char lower");
TEST_RESULT_STR(strPtr(strLower(strNew(""))), "", "empty lower");
TEST_RESULT_STR_Z(strLower(strNew("K123aBc")), "k123abc", "all lower");
TEST_RESULT_STR_Z(strLower(strNew("k123abc")), "k123abc", "already lower");
TEST_RESULT_STR_Z(strLower(strNew("C")), "c", "char lower");
TEST_RESULT_STR_Z(strLower(strNew("")), "", "empty lower");
TEST_RESULT_STR(strPtr(strUpper(strNew("K123aBc"))), "K123ABC", "all upper");
TEST_RESULT_STR(strPtr(strUpper(strNew("K123ABC"))), "K123ABC", "already upper");
TEST_RESULT_STR(strPtr(strUpper(strNew("c"))), "C", "char upper");
TEST_RESULT_STR(strPtr(strUpper(strNew(""))), "", "empty upper");
TEST_RESULT_STR_Z(strUpper(strNew("K123aBc")), "K123ABC", "all upper");
TEST_RESULT_STR_Z(strUpper(strNew("K123ABC")), "K123ABC", "already upper");
TEST_RESULT_STR_Z(strUpper(strNew("c")), "C", "char upper");
TEST_RESULT_STR_Z(strUpper(strNew("")), "", "empty upper");
}
// *****************************************************************************************************************************
if (testBegin("strQuote()"))
{
TEST_RESULT_STR(strPtr(strQuote(STRDEF("abcd"), STRDEF("'"))), "'abcd'", "quote string");
TEST_RESULT_STR_Z(strQuote(STRDEF("abcd"), STRDEF("'")), "'abcd'", "quote string");
}
// *****************************************************************************************************************************
if (testBegin("strReplaceChr()"))
{
TEST_RESULT_STR(strPtr(strReplaceChr(strNew("ABCD"), 'B', 'R')), "ARCD", "replace chr");
TEST_RESULT_STR_Z(strReplaceChr(strNew("ABCD"), 'B', 'R'), "ARCD", "replace chr");
}
// *****************************************************************************************************************************
if (testBegin("strSub() and strSubN()"))
{
TEST_RESULT_STR(strPtr(strSub(STRDEF("ABCD"), 2)), "CD", "sub string");
TEST_RESULT_STR_Z(strSub(STRDEF("ABCD"), 2), "CD", "sub string");
TEST_RESULT_STR_Z(strSub(STRDEF("AB"), 2), "", "zero sub string");
TEST_RESULT_STR(strPtr(strSubN(STRDEF("ABCD"), 1, 2)), "BC", "sub string with length");
TEST_RESULT_STR_Z(strSubN(STRDEF("ABCD"), 1, 2), "BC", "sub string with length");
TEST_RESULT_STR_Z(strSubN(STRDEF("D"), 1, 0), "", "zero sub string with length");
}
// *****************************************************************************************************************************
if (testBegin("strTrim()"))
{
TEST_RESULT_STR(strPtr(strTrim(strNew(""))), "", "trim empty");
TEST_RESULT_STR(strPtr(strTrim(strNew("X"))), "X", "no trim (one char)");
TEST_RESULT_STR(strPtr(strTrim(strNew("no-trim"))), "no-trim", "no trim (string)");
TEST_RESULT_STR(strPtr(strTrim(strNew(" \t\r\n"))), "", "all whitespace");
TEST_RESULT_STR(strPtr(strTrim(strNew(" \tbegin-only"))), "begin-only", "trim begin");
TEST_RESULT_STR(strPtr(strTrim(strNew("end-only\t "))), "end-only", "trim end");
TEST_RESULT_STR(strPtr(strTrim(strNew("\n\rboth\r\n"))), "both", "trim both");
TEST_RESULT_STR(strPtr(strTrim(strNew("begin \r\n\tend"))), "begin \r\n\tend", "ignore whitespace in middle");
TEST_RESULT_STR_Z(strTrim(strNew("")), "", "trim empty");
TEST_RESULT_STR_Z(strTrim(strNew("X")), "X", "no trim (one char)");
TEST_RESULT_STR_Z(strTrim(strNew("no-trim")), "no-trim", "no trim (string)");
TEST_RESULT_STR_Z(strTrim(strNew(" \t\r\n")), "", "all whitespace");
TEST_RESULT_STR_Z(strTrim(strNew(" \tbegin-only")), "begin-only", "trim begin");
TEST_RESULT_STR_Z(strTrim(strNew("end-only\t ")), "end-only", "trim end");
TEST_RESULT_STR_Z(strTrim(strNew("\n\rboth\r\n")), "both", "trim both");
TEST_RESULT_STR_Z(strTrim(strNew("begin \r\n\tend")), "begin \r\n\tend", "ignore whitespace in middle");
}
// *****************************************************************************************************************************
@ -227,41 +227,41 @@ testRun(void)
"assertion 'idx >= 0 && (size_t)idx <= this->size' failed");
TEST_ERROR(strTrunc(val, -1), AssertError, "assertion 'idx >= 0 && (size_t)idx <= this->size' failed");
TEST_RESULT_STR(strPtr(strTrunc(val, strChr(val, 'd'))), "abc", "simple string truncated");
TEST_RESULT_STR_Z(strTrunc(val, strChr(val, 'd')), "abc", "simple string truncated");
strCat(val, "\r\n to end");
TEST_RESULT_STR(strPtr(strTrunc(val, strChr(val, 'n'))), "abc\r\n to e", "complex string truncated");
TEST_RESULT_STR(strPtr(strTrunc(val, strChr(val, 'a'))), "", "complete string truncated - empty string");
TEST_RESULT_STR_Z(strTrunc(val, strChr(val, 'n')), "abc\r\n to e", "complex string truncated");
TEST_RESULT_STR_Z(strTrunc(val, strChr(val, 'a')), "", "complete string truncated - empty string");
TEST_RESULT_INT(strSize(val), 0, "0 size");
TEST_RESULT_STR(strPtr(strTrunc(val, 0)), "", "test coverage of empty string - no error thrown for index 0");
TEST_RESULT_STR_Z(strTrunc(val, 0), "", "test coverage of empty string - no error thrown for index 0");
}
// *****************************************************************************************************************************
if (testBegin("strToLog() and strObjToLog()"))
{
TEST_RESULT_STR(strPtr(strToLog(STRDEF("test"))), "{\"test\"}", "format string");
TEST_RESULT_STR(strPtr(strToLog(NULL)), "null", "format null string");
TEST_RESULT_STR_Z(strToLog(STRDEF("test")), "{\"test\"}", "format string");
TEST_RESULT_STR_Z(strToLog(NULL), "null", "format null string");
char buffer[256];
TEST_RESULT_UINT(strObjToLog(NULL, (StrObjToLogFormat)strToLog, buffer, sizeof(buffer)), 4, "format null string");
TEST_RESULT_STR(buffer, "null", "check null string");
TEST_RESULT_Z(buffer, "null", "check null string");
TEST_RESULT_UINT(strObjToLog(STRDEF("teststr"), (StrObjToLogFormat)strToLog, buffer, sizeof(buffer)), 11, "format string");
TEST_RESULT_STR(buffer, "{\"teststr\"}", "check string");
TEST_RESULT_Z(buffer, "{\"teststr\"}", "check string");
}
// *****************************************************************************************************************************
if (testBegin("strSizeFormat()"))
{
TEST_RESULT_STR(strPtr(strSizeFormat(0)), "0B", "zero bytes");
TEST_RESULT_STR(strPtr(strSizeFormat(1023)), "1023B", "1023 bytes");
TEST_RESULT_STR(strPtr(strSizeFormat(1024)), "1KB", "1 KB");
TEST_RESULT_STR(strPtr(strSizeFormat(2200)), "2.1KB", "2.1 KB");
TEST_RESULT_STR(strPtr(strSizeFormat(1048576)), "1MB", "1 MB");
TEST_RESULT_STR(strPtr(strSizeFormat(20162900)), "19.2MB", "19.2 MB");
TEST_RESULT_STR(strPtr(strSizeFormat(1073741824)), "1GB", "1 GB");
TEST_RESULT_STR(strPtr(strSizeFormat(1073741824 + 107374183)), "1.1GB", "1.1 GB");
TEST_RESULT_STR(strPtr(strSizeFormat(UINT64_MAX)), "17179869183GB", "uint64 max");
TEST_RESULT_STR_Z(strSizeFormat(0), "0B", "zero bytes");
TEST_RESULT_STR_Z(strSizeFormat(1023), "1023B", "1023 bytes");
TEST_RESULT_STR_Z(strSizeFormat(1024), "1KB", "1 KB");
TEST_RESULT_STR_Z(strSizeFormat(2200), "2.1KB", "2.1 KB");
TEST_RESULT_STR_Z(strSizeFormat(1048576), "1MB", "1 MB");
TEST_RESULT_STR_Z(strSizeFormat(20162900), "19.2MB", "19.2 MB");
TEST_RESULT_STR_Z(strSizeFormat(1073741824), "1GB", "1 GB");
TEST_RESULT_STR_Z(strSizeFormat(1073741824 + 107374183), "1.1GB", "1.1 GB");
TEST_RESULT_STR_Z(strSizeFormat(UINT64_MAX), "17179869183GB", "uint64 max");
}
// *****************************************************************************************************************************
@ -283,7 +283,7 @@ testRun(void)
}
else
{
TEST_RESULT_STR_STR(
TEST_RESULT_STR(
strLstAdd(list, strNewFmt("STR%02d", listIdx)), strNewFmt("STR%02d", listIdx), "add item %d", listIdx);
}
}
@ -303,7 +303,9 @@ testRun(void)
TEST_RESULT_PTR(strLstGet(list, listIdx), NULL, "check null item");
}
else
TEST_RESULT_STR(strPtr(strLstGet(list, listIdx)), strPtr(strNewFmt("STR%02u", listIdx)), "check item %u", listIdx);
{
TEST_RESULT_STR(strLstGet(list, listIdx), strNewFmt("STR%02u", listIdx), "check item %u", listIdx);
}
}
TEST_RESULT_VOID(strLstFree(list), "free string list");
@ -327,24 +329,23 @@ testRun(void)
// *****************************************************************************************************************************
if (testBegin("strLstNewSplit()"))
{
TEST_RESULT_STR(strPtr(strLstJoin(strLstNewSplit(STRDEF(""), STRDEF(", ")), ", ")), "", "empty list");
TEST_RESULT_STR(strPtr(strLstJoin(strLstNewSplit(STRDEF("item1"), STRDEF(", ")), ", ")), "item1", "one item");
TEST_RESULT_STR(
strPtr(strLstJoin(strLstNewSplit(STRDEF("item1, item2"), STRDEF(", ")), ", ")), "item1, item2", "two items");
TEST_RESULT_STR_Z(strLstJoin(strLstNewSplit(STRDEF(""), STRDEF(", ")), ", "), "", "empty list");
TEST_RESULT_STR_Z(strLstJoin(strLstNewSplit(STRDEF("item1"), STRDEF(", ")), ", "), "item1", "one item");
TEST_RESULT_STR_Z(strLstJoin(strLstNewSplit(STRDEF("item1, item2"), STRDEF(", ")), ", "), "item1, item2", "two items");
}
// *****************************************************************************************************************************
if (testBegin("strLstNewSplitSize()"))
{
TEST_RESULT_STR(strPtr(strLstJoin(strLstNewSplitSize(STRDEF(""), STRDEF(" "), 0), ", ")), "", "empty list");
TEST_RESULT_STR(strPtr(strLstJoin(strLstNewSplitSizeZ(STRDEF("abc def"), " ", 3), "-")), "abc-def", "two items");
TEST_RESULT_STR(strPtr(strLstJoin(strLstNewSplitSizeZ(STRDEF("abc def"), " ", 4), "-")), "abc-def", "one items");
TEST_RESULT_STR(strPtr(strLstJoin(strLstNewSplitSizeZ(STRDEF("abc def ghi"), " ", 4), "-")), "abc-def-ghi", "three items");
TEST_RESULT_STR(strPtr(strLstJoin(strLstNewSplitSizeZ(STRDEF("abc def ghi"), " ", 8), "-")), "abc def-ghi", "three items");
TEST_RESULT_STR(strPtr(strLstJoin(strLstNewSplitSizeZ(STRDEF("abc def "), " ", 4), "-")), "abc-def ", "two items");
TEST_RESULT_STR_Z(strLstJoin(strLstNewSplitSize(STRDEF(""), STRDEF(" "), 0), ", "), "", "empty list");
TEST_RESULT_STR_Z(strLstJoin(strLstNewSplitSizeZ(STRDEF("abc def"), " ", 3), "-"), "abc-def", "two items");
TEST_RESULT_STR_Z(strLstJoin(strLstNewSplitSizeZ(STRDEF("abc def"), " ", 4), "-"), "abc-def", "one items");
TEST_RESULT_STR_Z(strLstJoin(strLstNewSplitSizeZ(STRDEF("abc def ghi"), " ", 4), "-"), "abc-def-ghi", "three items");
TEST_RESULT_STR_Z(strLstJoin(strLstNewSplitSizeZ(STRDEF("abc def ghi"), " ", 8), "-"), "abc def-ghi", "three items");
TEST_RESULT_STR_Z(strLstJoin(strLstNewSplitSizeZ(STRDEF("abc def "), " ", 4), "-"), "abc-def ", "two items");
TEST_RESULT_STR(
strPtr(strLstJoin(strLstNewSplitSize(STRDEF("this is a short sentence"), STRDEF(" "), 10), "\n")),
TEST_RESULT_STR_Z(
strLstJoin(strLstNewSplitSize(STRDEF("this is a short sentence"), STRDEF(" "), 10), "\n"),
"this is a\n"
"short\n"
"sentence",
@ -359,7 +360,7 @@ testRun(void)
varLstAdd(varList, varNewStr(STRDEF("string1")));
varLstAdd(varList, varNewStr(STRDEF("string2")));
TEST_RESULT_STR(strPtr(strLstJoin(strLstNewVarLst(varList), ", ")), "string1, string2", "string list from variant list");
TEST_RESULT_STR_Z(strLstJoin(strLstNewVarLst(varList), ", "), "string1, string2", "string list from variant list");
TEST_RESULT_PTR(strLstNewVarLst(NULL), NULL, "null list from null var list");
varLstFree(varList);
@ -391,7 +392,9 @@ testRun(void)
TEST_RESULT_PTR(szList[listIdx], NULL, "check null item");
}
else
TEST_RESULT_STR(szList[listIdx], strPtr(strNewFmt("STR%02u", listIdx)), "check item %u", listIdx);
{
TEST_RESULT_Z_STR(szList[listIdx], strNewFmt("STR%02u", listIdx), "check item %u", listIdx);
}
}
TEST_RESULT_PTR(szList[strLstSize(list)], NULL, "check null terminator");
@ -417,18 +420,18 @@ testRun(void)
{
StringList *list = strLstNew();
TEST_RESULT_STR(strPtr(strLstJoin(list, ", ")), "", "empty list");
TEST_RESULT_STR_Z(strLstJoin(list, ", "), "", "empty list");
strLstAdd(list, STRDEF("item1"));
strLstAddZ(list, "item2");
TEST_RESULT_STR(strPtr(strLstJoin(list, ", ")), "item1, item2", "list");
TEST_RESULT_STR_Z(strLstJoin(list, ", "), "item1, item2", "list");
strLstAdd(list, NULL);
TEST_RESULT_STR(strPtr(strLstJoin(list, ", ")), "item1, item2, [NULL]", "list with NULL at end");
TEST_RESULT_STR_Z(strLstJoin(list, ", "), "item1, item2, [NULL]", "list with NULL at end");
TEST_RESULT_STR(strPtr(strLstJoin(strLstDup(list), ", ")), "item1, item2, [NULL]", "dup'd list with NULL at end");
TEST_RESULT_STR_Z(strLstJoin(strLstDup(list), ", "), "item1, item2, [NULL]", "dup'd list with NULL at end");
TEST_RESULT_PTR(strLstDup(NULL), NULL, "dup NULL list");
strLstFree(list);
@ -440,20 +443,20 @@ testRun(void)
StringList *list = strLstNew();
StringList *anti = strLstNew();
TEST_RESULT_STR(strPtr(strLstJoin(strLstMergeAnti(list, anti), ", ")), "", "list and anti empty");
TEST_RESULT_STR_Z(strLstJoin(strLstMergeAnti(list, anti), ", "), "", "list and anti empty");
strLstAddZ(anti, "item2");
strLstAddZ(anti, "item3");
TEST_RESULT_STR(strPtr(strLstJoin(strLstMergeAnti(list, anti), ", ")), "", "list empty");
TEST_RESULT_STR_Z(strLstJoin(strLstMergeAnti(list, anti), ", "), "", "list empty");
strLstAddZ(list, "item1");
strLstAddZ(list, "item3");
strLstAddZ(list, "item4");
strLstAddZ(list, "item5");
TEST_RESULT_STR(strPtr(strLstJoin(strLstMergeAnti(list, anti), ", ")), "item1, item4, item5", "list results");
TEST_RESULT_STR(strPtr(strLstJoin(strLstMergeAnti(list, strLstNew()), ", ")), "item1, item3, item4, item5", "anti empty");
TEST_RESULT_STR_Z(strLstJoin(strLstMergeAnti(list, anti), ", "), "item1, item4, item5", "list results");
TEST_RESULT_STR_Z(strLstJoin(strLstMergeAnti(list, strLstNew()), ", "), "item1, item3, item4, item5", "anti empty");
list = strLstNew();
strLstAddZ(list, "item2");
@ -465,7 +468,7 @@ testRun(void)
strLstAddZ(anti, "item4");
strLstAddZ(anti, "item7");
TEST_RESULT_STR(strPtr(strLstJoin(strLstMergeAnti(list, anti), ", ")), "item2, item6", "list results");
TEST_RESULT_STR_Z(strLstJoin(strLstMergeAnti(list, anti), ", "), "item2, item6", "list results");
list = strLstNew();
strLstAddZ(list, "item7");
@ -475,7 +478,7 @@ testRun(void)
strLstAddZ(anti, "item4");
strLstAddZ(anti, "item6");
TEST_RESULT_STR(strPtr(strLstJoin(strLstMergeAnti(list, anti), ", ")), "item7", "list results");
TEST_RESULT_STR_Z(strLstJoin(strLstMergeAnti(list, anti), ", "), "item7", "list results");
}
// *****************************************************************************************************************************
@ -487,11 +490,11 @@ testRun(void)
strLstAddZ(list, "a");
strLstAddZ(list, "b");
TEST_RESULT_STR(strPtr(strLstJoin(strLstSort(list, sortOrderAsc), ", ")), "a, b, c", "sort ascending");
TEST_RESULT_STR(strPtr(strLstJoin(strLstSort(list, sortOrderDesc), ", ")), "c, b, a", "sort descending");
TEST_RESULT_STR_Z(strLstJoin(strLstSort(list, sortOrderAsc), ", "), "a, b, c", "sort ascending");
TEST_RESULT_STR_Z(strLstJoin(strLstSort(list, sortOrderDesc), ", "), "c, b, a", "sort descending");
strLstComparatorSet(list, lstComparatorStr);
TEST_RESULT_STR(strPtr(strLstJoin(strLstSort(list, sortOrderAsc), ", ")), "a, b, c", "sort ascending");
TEST_RESULT_STR_Z(strLstJoin(strLstSort(list, sortOrderAsc), ", "), "a, b, c", "sort ascending");
}
// *****************************************************************************************************************************
@ -499,14 +502,14 @@ testRun(void)
{
StringList *list = strLstNew();
TEST_RESULT_STR(strPtr(strLstToLog(list)), "{[]}", "format empty list");
TEST_RESULT_STR_Z(strLstToLog(list), "{[]}", "format empty list");
strLstInsertZ(list, 0, "item3");
TEST_RESULT_STR(strPtr(strLstToLog(list)), "{[\"item3\"]}", "format 1 item list");
TEST_RESULT_STR_Z(strLstToLog(list), "{[\"item3\"]}", "format 1 item list");
strLstInsert(list, 0, STRDEF("item1"));
strLstInsertZ(list, 1, "item2");
TEST_RESULT_STR(strPtr(strLstToLog(list)), "{[\"item1\", \"item2\", \"item3\"]}", "format 3 item list");
TEST_RESULT_STR_Z(strLstToLog(list), "{[\"item1\", \"item2\", \"item3\"]}", "format 3 item list");
}
FUNCTION_HARNESS_RESULT_VOID();

View File

@ -298,7 +298,7 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
Variant *string = varNewStr(strNew("test-str"));
TEST_RESULT_STR(strPtr(varStr(string)), "test-str", "string pointer");
TEST_RESULT_STR_Z(varStr(string), "test-str", "string pointer");
varFree(string);
TEST_RESULT_PTR(varStr(NULL), NULL, "get null string variant");
@ -321,13 +321,13 @@ testRun(void)
TEST_ERROR(varBoolForce(VARSTRDEF(BOGUS_STR)), FormatError, "unable to convert str 'BOGUS' to bool");
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_STR(strPtr(varStrForce(VARSTRDEF("teststring"))), "teststring", "force string to string");
TEST_RESULT_STR(strPtr(varStrForce(VARINT(999))), "999", "force int to string");
TEST_RESULT_STR(strPtr(varStrForce(VARINT64(9223372036854775807L))), "9223372036854775807", "force int64 to string");
TEST_RESULT_STR(strPtr(varStrForce(VARDBL((double)999999999.123456))), "999999999.123456", "force double to string");
TEST_RESULT_STR(strPtr(varStrForce(varNewBool(true))), "true", "force bool to string");
TEST_RESULT_STR(strPtr(varStrForce(varNewBool(false))), "false", "force bool to string");
TEST_RESULT_STR(strPtr(varStrForce(VARUINT64(18446744073709551615U))), "18446744073709551615", "force uint64 to string");
TEST_RESULT_STR_Z(varStrForce(VARSTRDEF("teststring")), "teststring", "force string to string");
TEST_RESULT_STR_Z(varStrForce(VARINT(999)), "999", "force int to string");
TEST_RESULT_STR_Z(varStrForce(VARINT64(9223372036854775807L)), "9223372036854775807", "force int64 to string");
TEST_RESULT_STR_Z(varStrForce(VARDBL((double)999999999.123456)), "999999999.123456", "force double to string");
TEST_RESULT_STR_Z(varStrForce(varNewBool(true)), "true", "force bool to string");
TEST_RESULT_STR_Z(varStrForce(varNewBool(false)), "false", "force bool to string");
TEST_RESULT_STR_Z(varStrForce(VARUINT64(18446744073709551615U)), "18446744073709551615", "force uint64 to string");
TEST_ERROR(varStrForce(varNewKv(kvNew())), FormatError, "unable to force KeyValue to String");
@ -337,12 +337,12 @@ testRun(void)
varFree(string);
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_STR(strPtr(varStr(VARSTRDEF("test-z-str"))), "test-z-str", "new zero-terminated string");
TEST_RESULT_STR_Z(varStr(VARSTRDEF("test-z-str")), "test-z-str", "new zero-terminated string");
TEST_RESULT_PTR(strPtr(varStr(VARSTR(NULL))), NULL, "new null strz");
TEST_RESULT_PTR(strPtr(varStr(varNewStrZ(NULL))), NULL, "new null strz");
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_STR(strPtr(varStr(varDup(VARSTRDEF("yabba-dabba-doo")))), "yabba-dabba-doo", "dup string");
TEST_RESULT_STR_Z(varStr(varDup(VARSTRDEF("yabba-dabba-doo"))), "yabba-dabba-doo", "dup string");
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_PTR(varDup(NULL), NULL, "dup NULL");
@ -396,11 +396,11 @@ testRun(void)
// *****************************************************************************************************************************
if (testBegin("varToLog"))
{
TEST_RESULT_STR(strPtr(varToLog(varNewStrZ("testme"))), "{\"testme\"}", "format String");
TEST_RESULT_STR(strPtr(varToLog(varNewBool(false))), "{false}", "format bool");
TEST_RESULT_STR(strPtr(varToLog(varNewKv(kvNew()))), "{KeyValue}", "format KeyValue");
TEST_RESULT_STR(strPtr(varToLog(varNewVarLst(varLstNew()))), "{VariantList}", "format VariantList");
TEST_RESULT_STR(strPtr(varToLog(NULL)), "null", "format null");
TEST_RESULT_STR_Z(varToLog(varNewStrZ("testme")), "{\"testme\"}", "format String");
TEST_RESULT_STR_Z(varToLog(varNewBool(false)), "{false}", "format bool");
TEST_RESULT_STR_Z(varToLog(varNewKv(kvNew())), "{KeyValue}", "format KeyValue");
TEST_RESULT_STR_Z(varToLog(varNewVarLst(varLstNew())), "{VariantList}", "format VariantList");
TEST_RESULT_STR_Z(varToLog(NULL), "null", "format null");
}
// *****************************************************************************************************************************
@ -422,7 +422,7 @@ testRun(void)
TEST_RESULT_INT(varLstSize(list), 2, "list size");
TEST_RESULT_INT(varInt(varLstGet(list, 0)), 27, "check int");
TEST_RESULT_STR(strPtr(varStr(varLstGet(list, 1))), "test-str", "check string");
TEST_RESULT_STR_Z(varStr(varLstGet(list, 1)), "test-str", "check string");
TEST_RESULT_VOID(varLstFree(list), "free list");
TEST_RESULT_VOID(varLstFree(NULL), "free null list");
@ -436,9 +436,7 @@ testRun(void)
varLstAdd(list, varNewStrZ("string1"));
varLstAdd(list, varNewStrZ("string2"));
TEST_RESULT_STR(
strPtr(strLstJoin(strLstNewVarLst(varLstDup(list)), ", ")),
"string1, string2", "duplicate variant list");
TEST_RESULT_STR_Z(strLstJoin(strLstNewVarLst(varLstDup(list)), ", "), "string1, string2", "duplicate variant list");
TEST_RESULT_PTR(varLstDup(NULL), NULL, "duplicate null list");
}
@ -451,9 +449,8 @@ testRun(void)
strLstAdd(listStr, strNew("string1"));
strLstAdd(listStr, strNew("string2"));
TEST_RESULT_STR(
strPtr(strLstJoin(strLstNewVarLst(varLstNewStrLst(listStr)), ", ")),
"string1, string2", "variant list from string list");
TEST_RESULT_STR_Z(
strLstJoin(strLstNewVarLst(varLstNewStrLst(listStr)), ", "), "string1, string2", "variant list from string list");
TEST_RESULT_PTR(varLstNewStrLst(NULL), NULL, "variant list from null string list");
}

View File

@ -48,7 +48,7 @@ testRun(void)
XmlNode *nodeMaxKeys = NULL;
TEST_ASSIGN(nodeMaxKeys, xmlNodeChild(rootNode, strNew("MaxKeys"), true), "get max keys");
TEST_RESULT_STR(strPtr(xmlNodeContent(nodeMaxKeys)), "1000", " check MaxKeys content");
TEST_RESULT_STR_Z(xmlNodeContent(nodeMaxKeys), "1000", " check MaxKeys content");
TEST_RESULT_PTR(xmlNodeContent(NULL), NULL, " get null content for null node");
@ -56,21 +56,21 @@ testRun(void)
TEST_RESULT_VOID(xmlNodeFree(NULL), "free null node");
TEST_RESULT_UINT(xmlNodeChildTotal(rootNode, strNew("Contents")), 2, "Contents child total");
TEST_RESULT_STR(
strPtr(xmlNodeContent(xmlNodeChild(xmlNodeChildN(rootNode, strNew("Contents"), 0, true), strNew("Key"), true))),
TEST_RESULT_STR_Z(
xmlNodeContent(xmlNodeChild(xmlNodeChildN(rootNode, strNew("Contents"), 0, true), strNew("Key"), true)),
"test1.txt", "Contents index 0 Key");
TEST_RESULT_STR(
strPtr(xmlNodeContent(xmlNodeChild(xmlNodeChildN(rootNode, strNew("Contents"), 1, true), strNew("Key"), true))),
TEST_RESULT_STR_Z(
xmlNodeContent(xmlNodeChild(xmlNodeChildN(rootNode, strNew("Contents"), 1, true), strNew("Key"), true)),
"test2.txt", "Contents index 1 Key");
XmlNodeList *list = NULL;
TEST_ASSIGN(list, xmlNodeChildList(rootNode, strNew("Contents")), "create node list");
TEST_RESULT_UINT(xmlNodeLstSize(list), 2, " check size");
TEST_RESULT_STR(
strPtr(xmlNodeContent(xmlNodeChild(xmlNodeLstGet(list, 0), strNew("Key"), true))), "test1.txt",
TEST_RESULT_STR_Z(
xmlNodeContent(xmlNodeChild(xmlNodeLstGet(list, 0), strNew("Key"), true)), "test1.txt",
" check Contents index 0 Key");
TEST_RESULT_STR(
strPtr(xmlNodeContent(xmlNodeChild(xmlNodeLstGet(list, 1), strNew("Key"), true))), "test2.txt",
TEST_RESULT_STR_Z(
xmlNodeContent(xmlNodeChild(xmlNodeLstGet(list, 1), strNew("Key"), true)), "test2.txt",
" check Contents index 1 Key");
TEST_RESULT_VOID(xmlNodeLstFree(list), " free list");
@ -80,8 +80,7 @@ testRun(void)
TEST_RESULT_PTR(xmlNodeChildN(rootNode, strNew("Contents"), 2, false), NULL, "get missing child without error");
TEST_RESULT_PTR(xmlNodeAttribute(rootNode, strNew(BOGUS_STR)), NULL, "attempt to get missing attribute");
TEST_RESULT_STR(
strPtr(xmlNodeAttribute(xmlNodeChild(rootNode, strNew("Name"), true), strNew("id"))), "test", "get attribute");
TEST_RESULT_STR_Z(xmlNodeAttribute(xmlNodeChild(rootNode, strNew("Name"), true), strNew("id")), "test", "get attribute");
TEST_RESULT_VOID(xmlDocumentFree(xmlDocument), "free xmldoc");
@ -98,8 +97,8 @@ testRun(void)
TEST_RESULT_VOID(xmlNodeContentSet(xmlNodeAdd(partNode, strNew("PartNumber")), strNew("2")), "set part number 2");
TEST_RESULT_VOID(xmlNodeContentSet(xmlNodeAdd(partNode, strNew("ETag")), strNew("E2")), "set etag 2");
TEST_RESULT_STR(
strPtr(strNewBuf(xmlDocumentBuf(xmlDocument))),
TEST_RESULT_STR_Z(
strNewBuf(xmlDocumentBuf(xmlDocument)),
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<CompleteMultipartUpload>"
"<Part><PartNumber>1</PartNumber><ETag>E1</ETag></Part>"

View File

@ -23,7 +23,7 @@ testRun(void)
cfgCommandDefIdFromId(CFG_COMMAND_TOTAL), AssertError, "assertion 'commandId < cfgCmdNone' failed");
TEST_RESULT_INT(cfgCommandDefIdFromId(cfgCmdBackup), cfgDefCmdBackup, "command id to def id");
TEST_RESULT_STR(cfgCommandName(cfgCmdBackup), "backup", "command name from id");
TEST_RESULT_Z(cfgCommandName(cfgCmdBackup), "backup", "command name from id");
TEST_RESULT_INT(cfgOptionDefIdFromId(cfgOptPgHost + 6), cfgDefOptPgHost, "option id to def id");
@ -45,7 +45,7 @@ testRun(void)
TEST_RESULT_INT(cfgOptionIndexTotal(cfgOptPgPath), 8, "option index total");
TEST_RESULT_INT(cfgOptionIndexTotal(cfgOptLogLevelConsole), 1, "option index total");
TEST_RESULT_STR(cfgOptionName(cfgOptBackupStandby), "backup-standby", "option id from name");
TEST_RESULT_Z(cfgOptionName(cfgOptBackupStandby), "backup-standby", "option id from name");
}
// *****************************************************************************************************************************
@ -103,7 +103,7 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_PTR(cfgExe(), NULL, "exe defaults to null");
TEST_RESULT_VOID(cfgExeSet(strNew("/path/to/exe")), "set exe");
TEST_RESULT_STR(strPtr(cfgExe()), "/path/to/exe", "exe is set");
TEST_RESULT_Z(strPtr(cfgExe()), "/path/to/exe", "exe is set");
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_BOOL(cfgOptionNegate(cfgOptConfig), false, "negate defaults to false");
@ -190,7 +190,7 @@ testRun(void)
cfgOptionSet(cfgOptStanza, cfgSourceParam, varNewDbl(1.1)), AssertError,
"option 'stanza' must be set with String variant");
TEST_RESULT_VOID(cfgOptionSet(cfgOptStanza, cfgSourceConfig, varNewStrZ("db")), "set stanza");
TEST_RESULT_STR(strPtr(cfgOptionStr(cfgOptStanza)), "db", "stanza is set");
TEST_RESULT_STR_Z(cfgOptionStr(cfgOptStanza), "db", "stanza is set");
TEST_ERROR(
cfgOptionInt(cfgOptStanza), AssertError,
"assertion 'varType(configOptionValue[optionId].value) == varTypeInt64' failed");
@ -210,14 +210,14 @@ testRun(void)
cfgOptionValidSet(cfgOptRepoS3Host, true);
cfgOptionSet(cfgOptRepoS3Host, cfgSourceConfig, varNewStrZ("host.com")) ;
TEST_RESULT_STR(strPtr(cfgOptionHostPort(cfgOptRepoS3Host, &port)), "host.com", "check plain host");
TEST_RESULT_STR_Z(cfgOptionHostPort(cfgOptRepoS3Host, &port), "host.com", "check plain host");
TEST_RESULT_UINT(port, 55555, "check that port was not updated");
cfgOptionSet(cfgOptRepoS3Host, cfgSourceConfig, varNewStrZ("myhost.com:777")) ;
TEST_RESULT_STR(strPtr(cfgOptionHostPort(cfgOptRepoS3Host, &port)), "myhost.com", "check host with port");
TEST_RESULT_STR_Z(cfgOptionHostPort(cfgOptRepoS3Host, &port), "myhost.com", "check host with port");
TEST_RESULT_UINT(port, 777, "check that port was updated");
TEST_RESULT_STR(strPtr(cfgOptionHostPort(cfgOptRepoS3Endpoint, &port)), NULL, "check null host");
TEST_RESULT_STR_Z(cfgOptionHostPort(cfgOptRepoS3Endpoint, &port), NULL, "check null host");
TEST_RESULT_UINT(port, 777, "check that port was not updated");
cfgOptionSet(cfgOptRepoS3Host, cfgSourceConfig, varNewStrZ("myhost.com:777:888")) ;
@ -244,7 +244,7 @@ testRun(void)
TEST_ERROR(
strPtr(varStr(cfgOptionDefaultValue(cfgOptDbInclude))), AssertError, "default value not available for option type 4");
TEST_RESULT_STR(strPtr(varStr(cfgOptionDefault(cfgOptType))), "incr", "backup type default");
TEST_RESULT_STR_Z(varStr(cfgOptionDefault(cfgOptType)), "incr", "backup type default");
TEST_RESULT_BOOL(varBool(cfgOptionDefault(cfgOptCompress)), "true", "backup compress default");
TEST_RESULT_DOUBLE(varDbl(cfgOptionDefault(cfgOptProtocolTimeout)), 1830, "backup protocol-timeout default");
TEST_RESULT_INT(varIntForce(cfgOptionDefault(cfgOptCompressLevel)), 6, "backup compress-level default");
@ -253,14 +253,14 @@ testRun(void)
TEST_RESULT_VOID(cfgOptionSet(cfgOptPgHost, cfgSourceParam, varNewStrZ("backup")), "backup host set");
TEST_RESULT_VOID(cfgOptionDefaultSet(cfgOptPgHost, varNewStrZ("backup-default")), "backup host default");
TEST_RESULT_VOID(cfgOptionDefaultSet(cfgOptPgHost, varNewStrZ("backup-default2")), "reset backup host default");
TEST_RESULT_STR(strPtr(varStr(cfgOption(cfgOptPgHost))), "backup", "backup host value");
TEST_RESULT_STR(strPtr(varStr(cfgOptionDefault(cfgOptPgHost))), "backup-default2", "backup host default");
TEST_RESULT_STR_Z(varStr(cfgOption(cfgOptPgHost)), "backup", "backup host value");
TEST_RESULT_STR_Z(varStr(cfgOptionDefault(cfgOptPgHost)), "backup-default2", "backup host default");
TEST_RESULT_VOID(cfgOptionSet(cfgOptPgSocketPath, cfgSourceDefault, NULL), "backup pg-socket-path set");
TEST_RESULT_VOID(cfgOptionDefaultSet(cfgOptPgSocketPath, varNewStrZ("/to/socket")), "backup pg-socket-path default");
TEST_RESULT_VOID(cfgOptionDefaultSet(cfgOptPgSocketPath, varNewStrZ("/to/socket2")), "reset backup pg-socket-path default");
TEST_RESULT_STR(strPtr(varStr(cfgOption(cfgOptPgSocketPath))), "/to/socket2", "backup pg-socket-path value");
TEST_RESULT_STR(strPtr(varStr(cfgOptionDefault(cfgOptPgSocketPath))), "/to/socket2", "backup pg-socket-path value default");
TEST_RESULT_STR_Z(varStr(cfgOption(cfgOptPgSocketPath)), "/to/socket2", "backup pg-socket-path value");
TEST_RESULT_STR_Z(varStr(cfgOptionDefault(cfgOptPgSocketPath)), "/to/socket2", "backup pg-socket-path value default");
}
FUNCTION_HARNESS_RESULT_VOID();

View File

@ -16,7 +16,7 @@ testRun(void)
// *****************************************************************************************************************************
if (testBegin("check known values"))
{
TEST_RESULT_STR(cfgDefOptionName(cfgDefOptConfig), "config", "option name");
TEST_RESULT_Z(cfgDefOptionName(cfgDefOptConfig), "config", "option name");
TEST_RESULT_INT(cfgDefOptionId("repo-host"), cfgDefOptRepoHost, "define id");
TEST_RESULT_INT(cfgDefOptionId(BOGUS_STR), -1, "invalid define id");
@ -29,9 +29,9 @@ testRun(void)
TEST_RESULT_INT(cfgDefOptionAllowListValueTotal(cfgDefCmdBackup, cfgDefOptType), 3, "allow list total");
TEST_RESULT_STR(cfgDefOptionAllowListValue(cfgDefCmdBackup, cfgDefOptType, 0), "full", "allow list value 0");
TEST_RESULT_STR(cfgDefOptionAllowListValue(cfgDefCmdBackup, cfgDefOptType, 1), "diff", "allow list value 1");
TEST_RESULT_STR(cfgDefOptionAllowListValue(cfgDefCmdBackup, cfgDefOptType, 2), "incr", "allow list value 2");
TEST_RESULT_Z(cfgDefOptionAllowListValue(cfgDefCmdBackup, cfgDefOptType, 0), "full", "allow list value 0");
TEST_RESULT_Z(cfgDefOptionAllowListValue(cfgDefCmdBackup, cfgDefOptType, 1), "diff", "allow list value 1");
TEST_RESULT_Z(cfgDefOptionAllowListValue(cfgDefCmdBackup, cfgDefOptType, 2), "incr", "allow list value 2");
TEST_ERROR(
cfgDefOptionAllowListValue(cfgDefCmdBackup, cfgDefOptType, 3), AssertError,
"assertion 'valueId < cfgDefOptionAllowListValueTotal(commandDefId, optionDefId)' failed");
@ -56,10 +56,10 @@ testRun(void)
TEST_ERROR(cfgDefOptionDefault(
cfgDefCmdBackup, cfgDefOptionTotal()), AssertError,
"assertion 'optionDefId < cfgDefOptionTotal()' failed");
TEST_RESULT_STR(cfgDefOptionDefault(cfgDefCmdBackup, cfgDefOptCompressLevel), "6", "option default exists");
TEST_RESULT_STR(cfgDefOptionDefault(cfgDefCmdRestore, cfgDefOptType), "default", "command default exists");
TEST_RESULT_STR(cfgDefOptionDefault(cfgDefCmdLocal, cfgDefOptType), NULL, "command default does not exist");
TEST_RESULT_STR(cfgDefOptionDefault(cfgDefCmdBackup, cfgDefOptRepoHost), NULL, "default does not exist");
TEST_RESULT_Z(cfgDefOptionDefault(cfgDefCmdBackup, cfgDefOptCompressLevel), "6", "option default exists");
TEST_RESULT_Z(cfgDefOptionDefault(cfgDefCmdRestore, cfgDefOptType), "default", "command default exists");
TEST_RESULT_Z(cfgDefOptionDefault(cfgDefCmdLocal, cfgDefOptType), NULL, "command default does not exist");
TEST_RESULT_Z(cfgDefOptionDefault(cfgDefCmdBackup, cfgDefOptRepoHost), NULL, "default does not exist");
TEST_RESULT_BOOL(cfgDefOptionDepend(cfgDefCmdRestore, cfgDefOptRepoS3Key), true, "has depend option");
TEST_RESULT_BOOL(cfgDefOptionDepend(cfgDefCmdRestore, cfgDefOptType), false, "does not have depend option");
@ -68,9 +68,9 @@ testRun(void)
TEST_RESULT_INT(cfgDefOptionDependOption(cfgDefCmdBackup, cfgDefOptRepoHostCmd), cfgDefOptRepoHost, "depend option id");
TEST_RESULT_INT(cfgDefOptionDependValueTotal(cfgDefCmdRestore, cfgDefOptTarget), 3, "depend option value total");
TEST_RESULT_STR(cfgDefOptionDependValue(cfgDefCmdRestore, cfgDefOptTarget, 0), "name", "depend option value 0");
TEST_RESULT_STR(cfgDefOptionDependValue(cfgDefCmdRestore, cfgDefOptTarget, 1), "time", "depend option value 1");
TEST_RESULT_STR(cfgDefOptionDependValue(cfgDefCmdRestore, cfgDefOptTarget, 2), "xid", "depend option value 2");
TEST_RESULT_Z(cfgDefOptionDependValue(cfgDefCmdRestore, cfgDefOptTarget, 0), "name", "depend option value 0");
TEST_RESULT_Z(cfgDefOptionDependValue(cfgDefCmdRestore, cfgDefOptTarget, 1), "time", "depend option value 1");
TEST_RESULT_Z(cfgDefOptionDependValue(cfgDefCmdRestore, cfgDefOptTarget, 2), "xid", "depend option value 2");
TEST_ERROR(
cfgDefOptionDependValue(cfgDefCmdRestore, cfgDefOptTarget, 3), AssertError,
"assertion 'valueId < cfgDefOptionDependValueTotal(commandDefId, optionDefId)' failed");
@ -93,8 +93,8 @@ testRun(void)
TEST_RESULT_BOOL(cfgDefOptionMulti(cfgDefOptDbInclude), true, "db-include is multi");
TEST_RESULT_BOOL(cfgDefOptionMulti(cfgDefOptStartFast), false, "start-fast is not multi");
TEST_RESULT_STR(cfgDefOptionPrefix(cfgDefOptPgHost), "pg", "option prefix");
TEST_RESULT_STR(cfgDefOptionPrefix(cfgDefOptType), NULL, "option has no prefix");
TEST_RESULT_Z(cfgDefOptionPrefix(cfgDefOptPgHost), "pg", "option prefix");
TEST_RESULT_Z(cfgDefOptionPrefix(cfgDefOptType), NULL, "option has no prefix");
TEST_RESULT_BOOL(cfgDefOptionRequired(cfgDefCmdBackup, cfgDefOptConfig), true, "option required");
TEST_RESULT_BOOL(cfgDefOptionRequired(cfgDefCmdRestore, cfgDefOptRepoHost), false, "option not required");
@ -123,27 +123,27 @@ testRun(void)
TEST_RESULT_BOOL(cfgDefOptionHelpNameAlt(cfgDefOptRepoHost), true, "name alt exists");
TEST_RESULT_BOOL(cfgDefOptionHelpNameAlt(cfgDefOptSet), false, "name alt not exists");
TEST_RESULT_INT(cfgDefOptionHelpNameAltValueTotal(cfgDefOptRepoHost), 1, "name alt value total");
TEST_RESULT_STR(cfgDefOptionHelpNameAltValue(cfgDefOptRepoHost, 0), "backup-host", "name alt value 0");
TEST_RESULT_Z(cfgDefOptionHelpNameAltValue(cfgDefOptRepoHost, 0), "backup-host", "name alt value 0");
TEST_ERROR(
cfgDefOptionHelpNameAltValue(cfgDefOptRepoHost, 1), AssertError,
"assertion 'valueId < cfgDefOptionHelpNameAltValueTotal(optionDefId)' failed");
TEST_RESULT_STR(cfgDefCommandHelpSummary(cfgDefCmdBackup), "Backup a database cluster.", "backup command help summary");
TEST_RESULT_STR(
TEST_RESULT_Z(cfgDefCommandHelpSummary(cfgDefCmdBackup), "Backup a database cluster.", "backup command help summary");
TEST_RESULT_Z(
cfgDefCommandHelpDescription(cfgDefCmdBackup),
"pgBackRest does not have a built-in scheduler so it's best to run it from cron or some other scheduling mechanism.",
"backup command help description");
TEST_RESULT_STR(cfgDefOptionHelpSection(cfgDefOptCompress), "general", "compress option help section");
TEST_RESULT_STR(
TEST_RESULT_Z(cfgDefOptionHelpSection(cfgDefOptCompress), "general", "compress option help section");
TEST_RESULT_Z(
cfgDefOptionHelpSummary(cfgDefCmdBackup, cfgDefOptCompress), "Use gzip file compression.",
"backup command, compress option help summary");
TEST_RESULT_STR(
TEST_RESULT_Z(
cfgDefOptionHelpDescription(cfgDefCmdBackup, cfgDefOptCompress),
"Backup files are compatible with command-line gzip tools.", "backup command, compress option help description");
TEST_RESULT_STR(
TEST_RESULT_Z(
cfgDefOptionHelpSummary(cfgDefCmdBackup, cfgDefOptType), "Backup type.", "backup command, type option help summary");
TEST_RESULT_STR(
TEST_RESULT_Z(
cfgDefOptionHelpDescription(cfgDefCmdBackup, cfgDefOptType),
"The following backup types are supported:\n"
"\n"

View File

@ -31,12 +31,11 @@ testRun(void)
unsetenv("PGBACKREST_REPO1_CIPHER_PASS");
TEST_RESULT_STR(
strPtr(strLstJoin(cfgExecParam(cfgCmdLocal, NULL, false), "|")),
strPtr(
strNewFmt(
"--no-config|--log-subprocess|--reset-neutral-umask|--pg1-path=\"%s/db path\"|--repo1-path=%s/repo"
"|--stanza=test1|local",
testPath(), testPath())),
strLstJoin(cfgExecParam(cfgCmdLocal, NULL, false), "|"),
strNewFmt(
"--no-config|--log-subprocess|--reset-neutral-umask|--pg1-path=\"%s/db path\"|--repo1-path=%s/repo"
"|--stanza=test1|local",
testPath(), testPath()),
"exec archive-get -> local");
// -------------------------------------------------------------------------------------------------------------------------
@ -60,12 +59,11 @@ testRun(void)
kvPut(optionReplace, varNewStr(strNew("stanza")), NULL);
TEST_RESULT_STR(
strPtr(strLstJoin(cfgExecParam(cfgCmdRestore, optionReplace, true), "|")),
strPtr(
strNewFmt(
"--db-include=1|--db-include=2|--pg1-path=%s/db|--recovery-option=a=b|--recovery-option=c=d"
"|--repo1-path=/replace/path|restore",
testPath())),
strLstJoin(cfgExecParam(cfgCmdRestore, optionReplace, true), "|"),
strNewFmt(
"--db-include=1|--db-include=2|--pg1-path=%s/db|--recovery-option=a=b|--recovery-option=c=d"
"|--repo1-path=/replace/path|restore",
testPath()),
"exec restore -> restore");
}

View File

@ -84,12 +84,12 @@ testRun(void)
cfgOptionSet(cfgOptRepoHost, cfgSourceParam, varNewStrZ("repo-host"));
TEST_RESULT_VOID(cfgLoadUpdateOption(), "repo remote command is updated");
TEST_RESULT_STR(strPtr(cfgOptionStr(cfgOptRepoHostCmd)), strPtr(exe), " check repo1-host-cmd");
TEST_RESULT_STR(cfgOptionStr(cfgOptRepoHostCmd), exe, " check repo1-host-cmd");
cfgOptionSet(cfgOptRepoHostCmd, cfgSourceParam, varNewStr(exeOther));
TEST_RESULT_VOID(cfgLoadUpdateOption(), "repo remote command was already set");
TEST_RESULT_STR(strPtr(cfgOptionStr(cfgOptRepoHostCmd)), strPtr(exeOther), " check repo1-host-cmd");
TEST_RESULT_STR(cfgOptionStr(cfgOptRepoHostCmd), exeOther, " check repo1-host-cmd");
cfgOptionSet(cfgOptRepoHost, cfgSourceParam, NULL);
@ -106,11 +106,10 @@ testRun(void)
cfgOptionSet(cfgOptPgHost + cfgOptionIndexTotal(cfgOptPgHost) - 1, cfgSourceParam, varNewStrZ("pgX-host"));
TEST_RESULT_VOID(cfgLoadUpdateOption(), "pg remote command is updated");
TEST_RESULT_STR(strPtr(cfgOptionStr(cfgOptPgHostCmd)), strPtr(exe), " check pg1-host-cmd");
TEST_RESULT_STR(strPtr(cfgOptionStr(cfgOptPgHostCmd + 1)), strPtr(exeOther), " check pg2-host-cmd is already set");
TEST_RESULT_STR(strPtr(cfgOptionStr(cfgOptPgHostCmd + 2)), NULL, " check pg3-host-cmd is not set");
TEST_RESULT_STR(
strPtr(cfgOptionStr(cfgOptPgHostCmd + cfgOptionIndexTotal(cfgOptPgHost) - 1)), strPtr(exe), " check pgX-host-cmd");
TEST_RESULT_STR(cfgOptionStr(cfgOptPgHostCmd), exe, " check pg1-host-cmd");
TEST_RESULT_STR(cfgOptionStr(cfgOptPgHostCmd + 1), exeOther, " check pg2-host-cmd is already set");
TEST_RESULT_STR(cfgOptionStr(cfgOptPgHostCmd + 2), NULL, " check pg3-host-cmd is not set");
TEST_RESULT_STR(cfgOptionStr(cfgOptPgHostCmd + cfgOptionIndexTotal(cfgOptPgHost) - 1), exe, " check pgX-host-cmd");
// -------------------------------------------------------------------------------------------------------------------------
cfgInit();
@ -281,7 +280,7 @@ testRun(void)
strLstAdd(argList, strNew("--repo1-path=/repo"));
TEST_RESULT_VOID(harnessCfgLoad(cfgCmdArchiveGet, argList), "invalid bucket with no verification");
TEST_RESULT_STR(strPtr(cfgOptionStr(cfgOptRepoS3Bucket)), "bogus.bucket", " check bucket value");
TEST_RESULT_STR_Z(cfgOptionStr(cfgOptRepoS3Bucket), "bogus.bucket", " check bucket value");
// Valid bucket name
argList = strLstNew();
@ -293,7 +292,7 @@ testRun(void)
strLstAdd(argList, strNew("--repo1-path=/repo"));
TEST_RESULT_VOID(harnessCfgLoad(cfgCmdArchiveGet, argList), "valid bucket name");
TEST_RESULT_STR(strPtr(cfgOptionStr(cfgOptRepoS3Bucket)), "cool-bucket", " check bucket value");
TEST_RESULT_STR_Z(cfgOptionStr(cfgOptRepoS3Bucket), "cool-bucket", " check bucket value");
unsetenv("PGBACKREST_REPO1_S3_KEY");
unsetenv("PGBACKREST_REPO1_S3_KEY_SECRET");
@ -315,7 +314,7 @@ testRun(void)
// On the error case is tested here, success is tested in cfgLoad()
TEST_RESULT_VOID(cfgLoadLogFile(), "attempt to open bogus log file");
TEST_RESULT_STR(strPtr(cfgOptionStr(cfgOptLogLevelFile)), "off", "log-level-file should now be off");
TEST_RESULT_STR_Z(cfgOptionStr(cfgOptLogLevelFile), "off", "log-level-file should now be off");
}
// *****************************************************************************************************************************

View File

@ -50,8 +50,8 @@ testRun(void)
// Check old config file constants
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_STR(PGBACKREST_CONFIG_ORIG_PATH_FILE, "/etc/pgbackrest.conf", "check old config path");
TEST_RESULT_STR(strPtr(PGBACKREST_CONFIG_ORIG_PATH_FILE_STR), "/etc/pgbackrest.conf", "check old config path str");
TEST_RESULT_Z(PGBACKREST_CONFIG_ORIG_PATH_FILE, "/etc/pgbackrest.conf", "check old config path");
TEST_RESULT_STR_Z(PGBACKREST_CONFIG_ORIG_PATH_FILE_STR, "/etc/pgbackrest.conf", "check old config path str");
// Confirm same behavior with multiple config include files
//--------------------------------------------------------------------------------------------------------------------------
@ -114,7 +114,7 @@ testRun(void)
"P00 WARN: configuration file contains stanza-only option 'pg1-path' in global section 'global:backup'")));
TEST_RESULT_BOOL(cfgOptionTest(cfgOptPgHost), false, " pg1-host is not set (command line reset override)");
TEST_RESULT_STR(strPtr(cfgOptionStr(cfgOptPgPath)), "/path/to/db", " pg1-path is set");
TEST_RESULT_STR_Z(cfgOptionStr(cfgOptPgPath), "/path/to/db", " pg1-path is set");
TEST_RESULT_INT(cfgOptionSource(cfgOptPgPath), cfgSourceConfig, " pg1-path is source config");
TEST_RESULT_BOOL(cfgOptionBool(cfgOptCompress), false, " compress not is set");
TEST_RESULT_INT(cfgOptionSource(cfgOptCompress), cfgSourceConfig, " compress is source config");
@ -163,8 +163,8 @@ testRun(void)
TEST_RESULT_VOID(cfgFileLoadPart(NULL, NULL), "check null part");
TEST_RESULT_STR(strPtr(cfgFileLoad(parseOptionList, backupCmdDefConfigValue,
backupCmdDefConfigInclPathValue, oldConfigDefault)),
TEST_RESULT_STR_Z(
cfgFileLoad(parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault),
"[global]\n"
"compress-level=3\n"
"spool-path=/path/to/spool\n"
@ -212,10 +212,9 @@ testRun(void)
parseOptionList[cfgOptConfigIncludePath].found = false;
parseOptionList[cfgOptConfigIncludePath].source = cfgSourceDefault;
TEST_RESULT_STR(strPtr(cfgFileLoad(parseOptionList, backupCmdDefConfigValue,
backupCmdDefConfigInclPathValue, oldConfigDefault)),
NULL,
"config default, config-include-path default but nothing to read");
TEST_RESULT_STR_Z(
cfgFileLoad(parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault),
NULL, "config default, config-include-path default but nothing to read");
// Config not passed as parameter - config does not exist. config-include-path passed as parameter - only include read
//--------------------------------------------------------------------------------------------------------------------------
@ -228,8 +227,8 @@ testRun(void)
parseOptionList[cfgOptConfigIncludePath].source = cfgSourceParam;
parseOptionList[cfgOptConfigIncludePath].valueList = value;
TEST_RESULT_STR(strPtr(cfgFileLoad(parseOptionList, backupCmdDefConfigValue,
backupCmdDefConfigInclPathValue, oldConfigDefault)),
TEST_RESULT_STR_Z(
cfgFileLoad(parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault),
"[db]\n"
"pg1-host=db\n"
"pg1-path=/path/to/db\n"
@ -253,8 +252,8 @@ testRun(void)
// Pass actual location of config files as "default" - not setting valueList above, so these are the only possible values
// to choose.
TEST_RESULT_STR(strPtr(cfgFileLoad(parseOptionList, configFile, configIncludePath,
oldConfigDefault)),
TEST_RESULT_STR_Z(
cfgFileLoad(parseOptionList, configFile, configIncludePath, oldConfigDefault),
"[global]\n"
"compress-level=3\n"
"spool-path=/path/to/spool\n"
@ -277,8 +276,8 @@ testRun(void)
parseOptionList[cfgOptConfigIncludePath].source = cfgSourceParam;
parseOptionList[cfgOptConfigIncludePath].valueList = value;
TEST_RESULT_STR(strPtr(cfgFileLoad(parseOptionList, backupCmdDefConfigValue,
backupCmdDefConfigInclPathValue, oldConfigDefault)),
TEST_RESULT_STR_Z(
cfgFileLoad(parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault),
"[global:backup]\n"
"buffer-size=65536\n"
"\n"
@ -300,8 +299,8 @@ testRun(void)
parseOptionList[cfgOptConfigIncludePath].source = cfgSourceParam;
parseOptionList[cfgOptConfigIncludePath].valueList = value;
TEST_RESULT_STR(strPtr(cfgFileLoad(parseOptionList, backupCmdDefConfigValue,
backupCmdDefConfigInclPathValue, oldConfigDefault)),
TEST_RESULT_STR_Z(
cfgFileLoad(parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault),
"[db]\n"
"pg1-host=db\n"
"pg1-path=/path/to/db\n"
@ -316,10 +315,9 @@ testRun(void)
parseOptionList[cfgOptConfigIncludePath].found = false;
parseOptionList[cfgOptConfigIncludePath].source = cfgSourceDefault;
TEST_RESULT_STR(strPtr(cfgFileLoad(parseOptionList, backupCmdDefConfigValue,
configIncludePath, oldConfigDefault)),
NULL,
"--no-config, config-include-path default, nothing read");
TEST_RESULT_STR_Z(
cfgFileLoad(parseOptionList, backupCmdDefConfigValue, configIncludePath, oldConfigDefault),
NULL, "--no-config, config-include-path default, nothing read");
// config passed and config-include-path default exists with files - only config read
//--------------------------------------------------------------------------------------------------------------------------
@ -333,8 +331,8 @@ testRun(void)
parseOptionList[cfgOptConfigIncludePath].found = false;
parseOptionList[cfgOptConfigIncludePath].source = cfgSourceDefault;
TEST_RESULT_STR(strPtr(cfgFileLoad(parseOptionList, backupCmdDefConfigValue,
configIncludePath, oldConfigDefault)),
TEST_RESULT_STR_Z(
cfgFileLoad(parseOptionList, backupCmdDefConfigValue, configIncludePath, oldConfigDefault),
"[global]\n"
"compress-level=3\n"
"spool-path=/path/to/spool\n",
@ -351,8 +349,8 @@ testRun(void)
parseOptionList[cfgOptConfigIncludePath].source = cfgSourceParam;
parseOptionList[cfgOptConfigIncludePath].valueList = value;
TEST_RESULT_STR(strPtr(cfgFileLoad(parseOptionList, configFile,
backupCmdDefConfigInclPathValue, oldConfigDefault)),
TEST_RESULT_STR_Z(
cfgFileLoad(parseOptionList, configFile, backupCmdDefConfigInclPathValue, oldConfigDefault),
"[global]\n"
"compress-level=3\n"
"spool-path=/path/to/spool\n"
@ -371,8 +369,8 @@ testRun(void)
parseOptionList[cfgOptConfigIncludePath].source = cfgSourceDefault;
// File exists in old default config location but not in current default.
TEST_RESULT_STR(strPtr(cfgFileLoad(parseOptionList, backupCmdDefConfigValue,
configIncludePath, oldConfigDefault)),
TEST_RESULT_STR_Z(
cfgFileLoad(parseOptionList, backupCmdDefConfigValue, configIncludePath, oldConfigDefault),
"[global:backup]\n"
"buffer-size=65536\n"
"\n"
@ -392,8 +390,8 @@ testRun(void)
// Override default paths for config and config-include-path - but no pgbackrest.conf file in override path only in old
// default so ignored
TEST_RESULT_STR(strPtr(cfgFileLoad(parseOptionList, backupCmdDefConfigValue,
backupCmdDefConfigInclPathValue, oldConfigDefault)),
TEST_RESULT_STR_Z(
cfgFileLoad(parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault),
"[db]\n"
"pg1-host=db\n"
"pg1-path=/path/to/db\n"
@ -411,8 +409,8 @@ testRun(void)
// Passing --config and --config-path - default config-include-path overwritten and config is required and is loaded and
// config-include-path files will attempt to be loaded but not required
TEST_RESULT_STR(strPtr(cfgFileLoad(parseOptionList, backupCmdDefConfigValue,
backupCmdDefConfigInclPathValue, oldConfigDefault)),
TEST_RESULT_STR_Z(
cfgFileLoad(parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault),
"[global]\n"
"compress-level=3\n"
"spool-path=/path/to/spool\n"
@ -430,8 +428,8 @@ testRun(void)
// Passing --config and bogus --config-path - default config-include-path overwritten, config is required and is loaded and
// config-include-path files will attempt to be loaded but doesn't exist - no error since not required
TEST_RESULT_STR(strPtr(cfgFileLoad(parseOptionList, backupCmdDefConfigValue,
backupCmdDefConfigInclPathValue, oldConfigDefault)),
TEST_RESULT_STR_Z(
cfgFileLoad(parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault),
"[global]\n"
"compress-level=3\n"
"spool-path=/path/to/spool\n",
@ -456,8 +454,8 @@ testRun(void)
parseOptionList[cfgOptConfigPath].valueList = value;
// Override default paths for config and config-include-path with --config-path
TEST_RESULT_STR(strPtr(cfgFileLoad(parseOptionList, backupCmdDefConfigValue,
backupCmdDefConfigInclPathValue, oldConfigDefault)),
TEST_RESULT_STR_Z(
cfgFileLoad(parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault),
"[global]\n"
"compress-level=3\n"
"spool-path=/path/to/spool\n"
@ -486,8 +484,8 @@ testRun(void)
parseOptionList[cfgOptConfigIncludePath].source = cfgSourceParam;
parseOptionList[cfgOptConfigIncludePath].valueList = value;
TEST_RESULT_STR(strPtr(cfgFileLoad(parseOptionList, configFile,
backupCmdDefConfigInclPathValue, oldConfigDefault)),
TEST_RESULT_STR_Z(
cfgFileLoad(parseOptionList, configFile, backupCmdDefConfigInclPathValue, oldConfigDefault),
"[global]\n"
"compress-level=3\n"
"spool-path=/path/to/spool\n",
@ -507,10 +505,9 @@ testRun(void)
parseOptionList[cfgOptConfigIncludePath].source = cfgSourceParam;
parseOptionList[cfgOptConfigIncludePath].valueList = value;
TEST_RESULT_STR(strPtr(cfgFileLoad(parseOptionList, backupCmdDefConfigValue,
backupCmdDefConfigInclPathValue, backupCmdDefConfigValue)),
NULL,
"config default does not exist, config-include-path passed but only empty conf file - nothing read");
TEST_RESULT_STR_Z(
cfgFileLoad(parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, backupCmdDefConfigValue),
NULL, "config default does not exist, config-include-path passed but only empty conf file - nothing read");
}
// *****************************************************************************************************************************
@ -532,68 +529,68 @@ testRun(void)
strCat(value, "10");
convertToByte(&value, &valueDbl);
TEST_RESULT_DOUBLE(valueDbl, 10, "valueDbl no character identifier - straight to bytes");
TEST_RESULT_STR(strPtr(value), "10", "value no character identifier - straight to bytes");
TEST_RESULT_STR_Z(value, "10", "value no character identifier - straight to bytes");
strCat(value, "B");
convertToByte(&value, &valueDbl);
TEST_RESULT_DOUBLE(valueDbl, 10, "valueDbl B to bytes");
TEST_RESULT_STR(strPtr(value), "10", "value B to bytes");
TEST_RESULT_STR_Z(value, "10", "value B to bytes");
strCat(value, "Kb");
convertToByte(&value, &valueDbl);
TEST_RESULT_DOUBLE(valueDbl, 10240, "valueDbl KB to bytes");
TEST_RESULT_STR(strPtr(value), "10240", "value KB to bytes");
TEST_RESULT_STR_Z(value, "10240", "value KB to bytes");
strTrunc(value, strChr(value, '2'));
strCat(value, "k");
convertToByte(&value, &valueDbl);
TEST_RESULT_DOUBLE(valueDbl, 10240, "valueDbl k to bytes");
TEST_RESULT_STR(strPtr(value), "10240", "value k to bytes");
TEST_RESULT_STR_Z(value, "10240", "value k to bytes");
strCat(value, "pB");
convertToByte(&value, &valueDbl);
TEST_RESULT_DOUBLE(valueDbl, 11529215046068469760U, "valueDbl Pb to bytes");
TEST_RESULT_STR(strPtr(value), "11529215046068469760", "value Pb to bytes");
TEST_RESULT_STR_Z(value, "11529215046068469760", "value Pb to bytes");
strTrunc(value, strChr(value, '5'));
strCat(value, "GB");
convertToByte(&value, &valueDbl);
TEST_RESULT_DOUBLE(valueDbl, 11811160064U, "valueDbl GB to bytes");
TEST_RESULT_STR(strPtr(value), "11811160064", "value GB to bytes");
TEST_RESULT_STR_Z(value, "11811160064", "value GB to bytes");
strTrunc(value, strChr(value, '8'));
strCat(value, "g");
convertToByte(&value, &valueDbl);
TEST_RESULT_DOUBLE(valueDbl, 11811160064U, "valueDbl g to bytes");
TEST_RESULT_STR(strPtr(value), "11811160064", "value g to bytes");
TEST_RESULT_STR_Z(value, "11811160064", "value g to bytes");
strTrunc(value, strChr(value, '8'));
strCat(value, "T");
convertToByte(&value, &valueDbl);
TEST_RESULT_DOUBLE(valueDbl, 12094627905536U, "valueDbl T to bytes");
TEST_RESULT_STR(strPtr(value), "12094627905536", "value T to bytes");
TEST_RESULT_STR_Z(value, "12094627905536", "value T to bytes");
strTrunc(value, strChr(value, '0'));
strCat(value, "tb");
convertToByte(&value, &valueDbl);
TEST_RESULT_DOUBLE(valueDbl, 13194139533312U, "valueDbl tb to bytes");
TEST_RESULT_STR(strPtr(value), "13194139533312", "value tb to bytes");
TEST_RESULT_STR_Z(value, "13194139533312", "value tb to bytes");
strTrunc(value, strChr(value, '3'));
strCat(value, "0m");
convertToByte(&value, &valueDbl);
TEST_RESULT_DOUBLE(valueDbl, 10485760, "valueDbl m to bytes");
TEST_RESULT_STR(strPtr(value), "10485760", "value m to bytes");
TEST_RESULT_STR_Z(value, "10485760", "value m to bytes");
strCat(value, "mb");
convertToByte(&value, &valueDbl);
TEST_RESULT_DOUBLE(valueDbl, 10995116277760U, "valueDbl mb to bytes");
TEST_RESULT_STR(strPtr(value), "10995116277760", "value mb to bytes");
TEST_RESULT_STR_Z(value, "10995116277760", "value mb to bytes");
strTrunc(value, strChr(value, '0'));
strCat(value, "99999999999999999999p");
convertToByte(&value, &valueDbl);
TEST_RESULT_STR(strPtr(value), "225179981368524800000000000000000000", "value really large to bytes");
TEST_RESULT_STR_Z(value, "225179981368524800000000000000000000", "value really large to bytes");
}
// *****************************************************************************************************************************
@ -1138,8 +1135,8 @@ testRun(void)
strLstAdd(argList, strNew("000000010000000200000003"));
strLstAdd(argList, strNew("/path/to/wal/RECOVERYWAL"));
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "command arguments");
TEST_RESULT_STR(
strPtr(strLstJoin(cfgCommandParam(), "|")), "000000010000000200000003|/path/to/wal/RECOVERYWAL",
TEST_RESULT_STR_Z(
strLstJoin(cfgCommandParam(), "|"), "000000010000000200000003|/path/to/wal/RECOVERYWAL",
" check command arguments");
// -------------------------------------------------------------------------------------------------------------------------
@ -1159,17 +1156,17 @@ testRun(void)
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), TEST_COMMAND_BACKUP " command");
TEST_RESULT_INT(cfgCommand(), cfgCmdBackup, " command is " TEST_COMMAND_BACKUP);
TEST_RESULT_STR(strPtr(cfgExe()), TEST_BACKREST_EXE, " exe is set");
TEST_RESULT_STR_Z(cfgExe(), TEST_BACKREST_EXE, " exe is set");
TEST_RESULT_BOOL(cfgOptionTest(cfgOptConfig), false, " config is not set");
TEST_RESULT_INT(cfgOptionSource(cfgOptConfig), cfgSourceParam, " config is source param");
TEST_RESULT_BOOL(cfgOptionNegate(cfgOptConfig), true, " config is negated");
TEST_RESULT_INT(cfgOptionSource(cfgOptStanza), cfgSourceParam, " stanza is source param");
TEST_RESULT_STR(strPtr(cfgOptionStr(cfgOptStanza)), "db", " stanza is set");
TEST_RESULT_STR_Z(cfgOptionStr(cfgOptStanza), "db", " stanza is set");
TEST_RESULT_INT(cfgOptionSource(cfgOptStanza), cfgSourceParam, " stanza is source param");
TEST_RESULT_STR(strPtr(cfgOptionStr(cfgOptPgPath)), "/path/to/db", " pg1-path is set");
TEST_RESULT_STR_Z(cfgOptionStr(cfgOptPgPath), "/path/to/db", " pg1-path is set");
TEST_RESULT_INT(cfgOptionSource(cfgOptPgPath), cfgSourceParam, " pg1-path is source param");
TEST_RESULT_STR(strPtr(cfgOptionStr(cfgOptRepoS3KeySecret)), "xxx", " repo1-s3-secret is set");
TEST_RESULT_STR_Z(cfgOptionStr(cfgOptRepoS3KeySecret), "xxx", " repo1-s3-secret is set");
TEST_RESULT_INT(cfgOptionSource(cfgOptRepoS3KeySecret), cfgSourceConfig, " repo1-s3-secret is source env");
TEST_RESULT_BOOL(cfgOptionBool(cfgOptOnline), false, " online is not set");
TEST_RESULT_INT(cfgOptionSource(cfgOptOnline), cfgSourceParam, " online is source default");
@ -1245,11 +1242,11 @@ testRun(void)
"P00 WARN: configuration file contains stanza-only option 'pg1-path' in global section 'global:backup'")));
TEST_RESULT_BOOL(cfgOptionTest(cfgOptPgHost), false, " pg1-host is not set (command line reset override)");
TEST_RESULT_STR(strPtr(cfgOptionStr(cfgOptPgPath)), "/path/to/db", " pg1-path is set");
TEST_RESULT_STR_Z(cfgOptionStr(cfgOptPgPath), "/path/to/db", " pg1-path is set");
TEST_RESULT_INT(cfgOptionSource(cfgOptPgPath), cfgSourceConfig, " pg1-path is source config");
TEST_RESULT_STR(strPtr(cfgOptionStr(cfgOptLockPath)), "/", " lock-path is set");
TEST_RESULT_STR_Z(cfgOptionStr(cfgOptLockPath), "/", " lock-path is set");
TEST_RESULT_INT(cfgOptionSource(cfgOptLockPath), cfgSourceConfig, " lock-path is source config");
TEST_RESULT_STR(strPtr(cfgOptionStr(cfgOptPgSocketPath)), "/path/to/socket", " pg1-socket-path is set");
TEST_RESULT_STR_Z(cfgOptionStr(cfgOptPgSocketPath), "/path/to/socket", " pg1-socket-path is set");
TEST_RESULT_INT(cfgOptionSource(cfgOptPgSocketPath), cfgSourceConfig, " pg1-socket-path is config param");
TEST_RESULT_BOOL(cfgOptionBool(cfgOptOnline), false, " online not is set");
TEST_RESULT_INT(cfgOptionSource(cfgOptOnline), cfgSourceParam, " online is source param");
@ -1336,8 +1333,8 @@ testRun(void)
const VariantList *includeList = NULL;
TEST_ASSIGN(includeList, cfgOptionLst(cfgOptDbInclude), "get db include options");
TEST_RESULT_STR(strPtr(varStr(varLstGet(includeList, 0))), "abc", "check db include option");
TEST_RESULT_STR(strPtr(varStr(varLstGet(includeList, 1))), "def", "check db include option");
TEST_RESULT_STR_Z(varStr(varLstGet(includeList, 0)), "abc", "check db include option");
TEST_RESULT_STR_Z(varStr(varLstGet(includeList, 1)), "def", "check db include option");
// -------------------------------------------------------------------------------------------------------------------------
argList = strLstNew();
@ -1351,8 +1348,8 @@ testRun(void)
const KeyValue *recoveryKv = NULL;
TEST_ASSIGN(recoveryKv, cfgOptionKv(cfgOptRecoveryOption), "get recovery options");
TEST_RESULT_STR(strPtr(varStr(kvGet(recoveryKv, varNewStr(strNew("a"))))), "b", "check recovery option");
TEST_RESULT_STR(strPtr(varStr(kvGet(recoveryKv, varNewStr(strNew("c"))))), "de=fg hi", "check recovery option");
TEST_RESULT_STR_Z(varStr(kvGet(recoveryKv, varNewStr(strNew("a")))), "b", "check recovery option");
TEST_RESULT_STR_Z(varStr(kvGet(recoveryKv, varNewStr(strNew("c")))), "de=fg hi", "check recovery option");
// -------------------------------------------------------------------------------------------------------------------------
argList = strLstNew();
@ -1374,8 +1371,8 @@ testRun(void)
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), TEST_COMMAND_RESTORE " command");
TEST_ASSIGN(recoveryKv, cfgOptionKv(cfgOptRecoveryOption), "get recovery options");
TEST_RESULT_STR(strPtr(varStr(kvGet(recoveryKv, varNewStr(strNew("f"))))), "g", "check recovery option");
TEST_RESULT_STR(strPtr(varStr(kvGet(recoveryKv, varNewStr(strNew("hijk"))))), "l", "check recovery option");
TEST_RESULT_STR_Z(varStr(kvGet(recoveryKv, varNewStr(strNew("f")))), "g", "check recovery option");
TEST_RESULT_STR_Z(varStr(kvGet(recoveryKv, varNewStr(strNew("hijk")))), "l", "check recovery option");
// -------------------------------------------------------------------------------------------------------------------------
argList = strLstNew();
@ -1390,9 +1387,9 @@ testRun(void)
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), TEST_COMMAND_RESTORE " command");
TEST_ASSIGN(recoveryKv, cfgOptionKv(cfgOptRecoveryOption), "get recovery options");
TEST_RESULT_STR(strPtr(varStr(kvGet(recoveryKv, varNewStr(strNew("f"))))), "g", "check recovery option");
TEST_RESULT_STR(strPtr(varStr(kvGet(recoveryKv, varNewStr(strNew("hijk"))))), "l", "check recovery option");
TEST_RESULT_STR(strPtr(varStr(varLstGet(cfgOptionLst(cfgOptDbInclude), 0))), "77", "check db include option");
TEST_RESULT_STR_Z(varStr(kvGet(recoveryKv, varNewStr(strNew("f")))), "g", "check recovery option");
TEST_RESULT_STR_Z(varStr(kvGet(recoveryKv, varNewStr(strNew("hijk")))), "l", "check recovery option");
TEST_RESULT_STR_Z(varStr(varLstGet(cfgOptionLst(cfgOptDbInclude), 0)), "77", "check db include option");
TEST_RESULT_UINT(varLstSize(cfgOptionLst(cfgOptDbInclude)), 1, "check db include option size");
unsetenv("PGBACKREST_STANZA");
@ -1417,7 +1414,7 @@ testRun(void)
"repo1-path=/not/the/path\n"));
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "info command");
TEST_RESULT_STR(strPtr(cfgOptionStr(cfgOptRepoPath)), "/path/to/repo", "check repo1-path option");
TEST_RESULT_STR_Z(cfgOptionStr(cfgOptRepoPath), "/path/to/repo", "check repo1-path option");
}
// *****************************************************************************************************************************

View File

@ -54,8 +54,8 @@ testRun(void)
varLstAdd(list, varNewStr(strNew("repo1-host")));
varLstAdd(list, varNewStr(strNew("repo1-host-user")));
TEST_RESULT_STR(
strPtr(strLstJoin(strLstNewVarLst(configProtocolOption(client, list)), "|")), "repo-host|repo-host-user",
TEST_RESULT_STR_Z(
strLstJoin(strLstNewVarLst(configProtocolOption(client, list)), "|"), "repo-host|repo-host-user",
"get options");
protocolClientFree(client);

View File

@ -125,7 +125,7 @@ testRun(void)
// Open the database, but don't free it so the server is forced to do it on shutdown
TEST_ASSIGN(db, dbNew(NULL, client, strNew("test")), "create db");
TEST_RESULT_VOID(dbOpen(db), "open db");
TEST_RESULT_STR(strPtr(dbWalSwitch(db)), "000000030000000200000003", " wal switch");
TEST_RESULT_STR_Z(dbWalSwitch(db), "000000030000000200000003", " wal switch");
TEST_RESULT_VOID(memContextCallbackClear(db->memContext), "clear context so close is not called");
TEST_RESULT_VOID(protocolClientFree(client), "free client");
@ -512,7 +512,7 @@ testRun(void)
TEST_RESULT_INT(result.standbyId, 0, " check standby id");
TEST_RESULT_BOOL(result.standby == NULL, true, " check standby");
TEST_RESULT_INT(dbPgVersion(result.primary), PG_VERSION_84, " version set");
TEST_RESULT_STR(strPtr(dbPgDataPath(result.primary)), "/pgdata", " path set");
TEST_RESULT_STR_Z(dbPgDataPath(result.primary), "/pgdata", " path set");
TEST_RESULT_VOID(dbFree(result.primary), "free primary");
@ -622,9 +622,9 @@ testRun(void)
TEST_RESULT_INT(result.primaryId, 8, " check primary id");
TEST_RESULT_BOOL(result.primary != NULL, true, " check primary");
TEST_RESULT_STR(strPtr(dbArchiveMode(result.primary)), "on", " dbArchiveMode");
TEST_RESULT_STR(strPtr(dbArchiveCommand(result.primary)), PROJECT_BIN, " dbArchiveCommand");
TEST_RESULT_STR(strPtr(dbWalSwitch(result.primary)), "000000010000000200000003", " wal switch");
TEST_RESULT_STR_Z(dbArchiveMode(result.primary), "on", " dbArchiveMode");
TEST_RESULT_STR_Z(dbArchiveCommand(result.primary), PROJECT_BIN, " dbArchiveCommand");
TEST_RESULT_STR_Z(dbWalSwitch(result.primary), "000000010000000200000003", " wal switch");
TEST_RESULT_INT(result.standbyId, 1, " check standby id");
TEST_RESULT_BOOL(result.standby != NULL, true, " check standby");

View File

@ -37,7 +37,7 @@ testRun(void)
InfoArchive *info = NULL;
TEST_ASSIGN(info, infoArchiveNewLoad(ioBufferReadNew(contentLoad)), " load new archive info");
TEST_RESULT_STR(strPtr(infoArchiveId(info)), "9.4-1", " archiveId set");
TEST_RESULT_STR_Z(infoArchiveId(info), "9.4-1", " archiveId set");
TEST_RESULT_PTR(infoArchivePg(info), info->infoPg, " infoPg set");
TEST_RESULT_PTR(infoArchiveCipherPass(info), NULL, " no cipher sub");
@ -45,13 +45,13 @@ testRun(void)
Buffer *contentSave = bufNew(0);
TEST_RESULT_VOID(infoArchiveSave(info, ioBufferWriteNew(contentSave)), "info archive save");
TEST_RESULT_STR(strPtr(strNewBuf(contentSave)), strPtr(strNewBuf(contentLoad)), " check save");
TEST_RESULT_STR(strNewBuf(contentSave), strNewBuf(contentLoad), " check save");
// Create the same content by creating a new object
// -------------------------------------------------------------------------------------------------------------------------
TEST_ASSIGN(
info, infoArchiveNew(PG_VERSION_94, 6569239123849665679, NULL), "infoArchiveNew() - no sub cipher");
TEST_RESULT_STR(strPtr(infoArchiveId(info)), "9.4-1", " archiveId set");
TEST_RESULT_STR_Z(infoArchiveId(info), "9.4-1", " archiveId set");
TEST_RESULT_PTR(infoArchivePg(info), info->infoPg, " infoPg set");
TEST_RESULT_PTR(infoArchiveCipherPass(info), NULL, " no cipher sub");
TEST_RESULT_INT(infoPgDataTotal(info->infoPg), 1, " history set");
@ -59,7 +59,7 @@ testRun(void)
Buffer *contentCompare = bufNew(0);
TEST_RESULT_VOID(infoArchiveSave(info, ioBufferWriteNew(contentCompare)), "info archive save");
TEST_RESULT_STR(strPtr(strNewBuf(contentCompare)), strPtr(strNewBuf(contentSave)), " check save");
TEST_RESULT_STR(strNewBuf(contentCompare), strNewBuf(contentSave), " check save");
// Remove both files and recreate from scratch with cipher
// -------------------------------------------------------------------------------------------------------------------------
@ -74,9 +74,9 @@ testRun(void)
TEST_RESULT_VOID(infoArchiveSave(info, ioBufferWriteNew(contentSave)), " save new with cipher");
TEST_ASSIGN(info, infoArchiveNewLoad(ioBufferReadNew(contentSave)), " load encrypted archive info");
TEST_RESULT_STR(strPtr(infoArchiveId(info)), "10-1", " archiveId set");
TEST_RESULT_STR_Z(infoArchiveId(info), "10-1", " archiveId set");
TEST_RESULT_PTR(infoArchivePg(info), info->infoPg, " infoPg set");
TEST_RESULT_STR(strPtr(infoArchiveCipherPass(info)),
TEST_RESULT_STR_Z(infoArchiveCipherPass(info),
"zWa/6Xtp-IVZC5444yXB+cgFDFl7MxGlgkZSaoPvTGirhPygu4jOKOXf9LO4vjfO", " cipher sub set");
TEST_RESULT_INT(infoPgDataTotal(info->infoPg), 1, " history set");
@ -107,9 +107,9 @@ testRun(void)
);
TEST_ASSIGN(info, infoArchiveNewLoad(ioBufferReadNew(contentLoad)), "new archive info");
TEST_RESULT_STR(strPtr(infoArchiveIdHistoryMatch(info, 2, 90500, 6626363367545678089)), "9.5-2", " full match found");
TEST_RESULT_STR_Z(infoArchiveIdHistoryMatch(info, 2, 90500, 6626363367545678089), "9.5-2", " full match found");
TEST_RESULT_STR(strPtr(infoArchiveIdHistoryMatch(info, 2, 90400, 6625592122879095702)), "9.4-1", " partial match found");
TEST_RESULT_STR_Z(infoArchiveIdHistoryMatch(info, 2, 90400, 6625592122879095702), "9.4-1", " partial match found");
TEST_ERROR(infoArchiveIdHistoryMatch(info, 2, 90400, 6625592122879095799), ArchiveMismatchError,
"unable to retrieve the archive id for database version '9.4' and system-id '6625592122879095799'");

View File

@ -57,7 +57,7 @@ testRun(void)
infoBackup, infoBackupNew(PG_VERSION_94, 6569239123849665679, NULL),
"infoBackupNew() - no cipher sub");
TEST_RESULT_VOID(infoBackupSave(infoBackup, ioBufferWriteNew(contentCompare)), " save backup info from new");
TEST_RESULT_STR(strPtr(strNewBuf(contentCompare)), strPtr(strNewBuf(contentSave)), " check save");
TEST_RESULT_STR(strNewBuf(contentCompare), strNewBuf(contentSave), " check save");
TEST_ASSIGN(infoBackup, infoBackupNewLoad(ioBufferReadNew(contentCompare)), "load backup info");
TEST_RESULT_PTR(infoBackupPg(infoBackup), infoBackup->infoPg, " infoPg set");
@ -79,7 +79,7 @@ testRun(void)
infoBackup = NULL;
TEST_ASSIGN(infoBackup, infoBackupNewLoad(ioBufferReadNew(contentSave)), " load backup info with cipher sub");
TEST_RESULT_PTR(infoBackupPg(infoBackup), infoBackup->infoPg, " infoPg set");
TEST_RESULT_STR(strPtr(infoBackupCipherPass(infoBackup)),
TEST_RESULT_STR_Z(infoBackupCipherPass(infoBackup),
"zWa/6Xtp-IVZC5444yXB+cgFDFl7MxGlgkZSaoPvTGirhPygu4jOKOXf9LO4vjfO", " cipher sub set");
TEST_RESULT_INT(infoPgDataTotal(infoBackup->infoPg), 1, " history set");
@ -140,12 +140,12 @@ testRun(void)
InfoBackupData backupData = infoBackupData(infoBackup, 0);
TEST_RESULT_STR(strPtr(backupData.backupLabel), "20161219-212741F", "full backup label");
TEST_RESULT_STR(strPtr(backupData.backupType), "full", " backup type full");
TEST_RESULT_STR_Z(backupData.backupLabel, "20161219-212741F", "full backup label");
TEST_RESULT_STR_Z(backupData.backupType, "full", " backup type full");
TEST_RESULT_INT(backupData.backrestFormat, 5, " backrest format");
TEST_RESULT_STR(strPtr(backupData.backrestVersion), "2.04", " backrest version");
TEST_RESULT_STR(strPtr(backupData.backupArchiveStart), "00000007000000000000001C", " archive start");
TEST_RESULT_STR(strPtr(backupData.backupArchiveStop), "00000007000000000000001C", " archive stop");
TEST_RESULT_STR_Z(backupData.backrestVersion, "2.04", " backrest version");
TEST_RESULT_STR_Z(backupData.backupArchiveStart, "00000007000000000000001C", " archive start");
TEST_RESULT_STR_Z(backupData.backupArchiveStop, "00000007000000000000001C", " archive stop");
TEST_RESULT_INT(backupData.backupInfoRepoSize, 3159776, " repo size");
TEST_RESULT_INT(backupData.backupInfoRepoSizeDelta, 3159776, " repo delta");
TEST_RESULT_INT(backupData.backupInfoSize, 26897030, " backup size");
@ -157,23 +157,23 @@ testRun(void)
TEST_RESULT_INT(backupData.backupTimestampStop, 1482182861, " timestamp stop");
backupData = infoBackupData(infoBackup, 1);
TEST_RESULT_STR(strPtr(backupData.backupLabel), "20161219-212741F_20161219-212803D", "diff backup label");
TEST_RESULT_STR(strPtr(backupData.backupType), "diff", " backup type diff");
TEST_RESULT_STR_Z(backupData.backupLabel, "20161219-212741F_20161219-212803D", "diff backup label");
TEST_RESULT_STR_Z(backupData.backupType, "diff", " backup type diff");
TEST_RESULT_INT(backupData.backupInfoRepoSize, 3159811, " repo size");
TEST_RESULT_INT(backupData.backupInfoRepoSizeDelta, 15765, " repo delta");
TEST_RESULT_INT(backupData.backupInfoSize, 26897030, " backup size");
TEST_RESULT_INT(backupData.backupInfoSizeDelta, 163866, " backup delta");
TEST_RESULT_STR(strPtr(backupData.backupPrior), "20161219-212741F", " backup prior exists");
TEST_RESULT_STR_Z(backupData.backupPrior, "20161219-212741F", " backup prior exists");
TEST_RESULT_BOOL(
(strLstSize(backupData.backupReference) == 1 && strLstExistsZ(backupData.backupReference, "20161219-212741F")), true,
" backup reference exists");
backupData = infoBackupData(infoBackup, 2);
TEST_RESULT_STR(strPtr(backupData.backupLabel), "20161219-212741F_20161219-212918I", "incr backup label");
TEST_RESULT_STR_Z(backupData.backupLabel, "20161219-212741F_20161219-212918I", "incr backup label");
TEST_RESULT_PTR(backupData.backupArchiveStart, NULL, " archive start NULL");
TEST_RESULT_PTR(backupData.backupArchiveStop, NULL, " archive stop NULL");
TEST_RESULT_STR(strPtr(backupData.backupType), "incr", " backup type incr");
TEST_RESULT_STR(strPtr(backupData.backupPrior), "20161219-212741F", " backup prior exists");
TEST_RESULT_STR_Z(backupData.backupType, "incr", " backup type incr");
TEST_RESULT_STR_Z(backupData.backupPrior, "20161219-212741F", " backup prior exists");
TEST_RESULT_BOOL(
(strLstSize(backupData.backupReference) == 2 && strLstExistsZ(backupData.backupReference, "20161219-212741F") &&
strLstExistsZ(backupData.backupReference, "20161219-212741F_20161219-212803D")), true, " backup reference exists");
@ -189,32 +189,33 @@ testRun(void)
contentSave = bufNew(0);
TEST_RESULT_VOID(infoBackupSave(infoBackup, ioBufferWriteNew(contentSave)), "info backup save");
TEST_RESULT_STR(strPtr(strNewBuf(contentSave)), strPtr(strNewBuf(contentLoad)), " check save");
TEST_RESULT_STR(strNewBuf(contentSave), strNewBuf(contentLoad), " check save");
// infoBackupDataLabelList and infoBackupDataDelete
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_STR(
strPtr(strLstJoin(strLstSort(infoBackupDataLabelList(infoBackup, NULL), sortOrderAsc), ", ")),
TEST_RESULT_STR_Z(
strLstJoin(strLstSort(infoBackupDataLabelList(infoBackup, NULL), sortOrderAsc), ", "),
"20161219-212741F, 20161219-212741F_20161219-212803D, 20161219-212741F_20161219-212918I",
"infoBackupDataLabelList without expression");
TEST_RESULT_STR(
strPtr(strLstJoin(strLstSort(infoBackupDataLabelList(
infoBackup, backupRegExpP(.full=true, .differential=true, .incremental=true)), sortOrderAsc), ", ")),
TEST_RESULT_STR_Z(
strLstJoin(
strLstSort(
infoBackupDataLabelList(
infoBackup, backupRegExpP(.full = true, .differential = true, .incremental = true)), sortOrderAsc), ", "),
"20161219-212741F, 20161219-212741F_20161219-212803D, 20161219-212741F_20161219-212918I",
"infoBackupDataLabelList with expression");
TEST_RESULT_STR(
strPtr(strLstJoin(infoBackupDataLabelList(infoBackup, backupRegExpP(.full=true)), ", ")),
"20161219-212741F", " full=true");
TEST_RESULT_STR(
strPtr(strLstJoin(infoBackupDataLabelList(infoBackup, backupRegExpP(.differential=true)), ", ")),
TEST_RESULT_STR_Z(
strLstJoin(infoBackupDataLabelList(infoBackup, backupRegExpP(.full=true)), ", "), "20161219-212741F", " full=true");
TEST_RESULT_STR_Z(
strLstJoin(infoBackupDataLabelList(infoBackup, backupRegExpP(.differential=true)), ", "),
"20161219-212741F_20161219-212803D", "differential=true");
TEST_RESULT_STR(
strPtr(strLstJoin(infoBackupDataLabelList(infoBackup, backupRegExpP(.incremental=true)), ", ")),
TEST_RESULT_STR_Z(
strLstJoin(infoBackupDataLabelList(infoBackup, backupRegExpP(.incremental=true)), ", "),
"20161219-212741F_20161219-212918I", "incremental=true");
TEST_RESULT_VOID(infoBackupDataDelete(infoBackup, strNew("20161219-212741F_20161219-212918I")), "delete a backup");
TEST_RESULT_STR(
strPtr(strLstJoin(strLstSort(infoBackupDataLabelList(infoBackup, NULL), sortOrderAsc), ", ")),
TEST_RESULT_STR_Z(
strLstJoin(strLstSort(infoBackupDataLabelList(infoBackup, NULL), sortOrderAsc), ", "),
"20161219-212741F, 20161219-212741F_20161219-212803D", " backup deleted");
TEST_RESULT_VOID(infoBackupDataDelete(infoBackup, strNew("20161219-212741F_20161219-212803D")), "delete all backups");
@ -223,8 +224,8 @@ testRun(void)
// infoBackupDataToLog
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_STR(
strPtr(infoBackupDataToLog(&backupData)), "{label: 20161219-212741F_20161219-212918I, pgId: 1}", "check log format");
TEST_RESULT_STR_Z(
infoBackupDataToLog(&backupData), "{label: 20161219-212741F_20161219-212918I, pgId: 1}", "check log format");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("infoBackupDataAdd - full backup");
@ -299,13 +300,13 @@ testRun(void)
TEST_RESULT_VOID(infoBackupDataAdd(infoBackup, manifest), "add a backup");
TEST_RESULT_UINT(infoBackupDataTotal(infoBackup), 1, "backup added to current");
TEST_ASSIGN(backupData, infoBackupData(infoBackup, 0), "get added backup");
TEST_RESULT_STR(strPtr(backupData.backupLabel), "20190818-084502F", "backup label set");
TEST_RESULT_STR_Z(backupData.backupLabel, "20190818-084502F", "backup label set");
TEST_RESULT_UINT(backupData.backrestFormat, REPOSITORY_FORMAT, "backrest format");
TEST_RESULT_STR(strPtr(backupData.backrestVersion), PROJECT_VERSION, "backuprest version");
TEST_RESULT_STR_Z(backupData.backrestVersion, PROJECT_VERSION, "backuprest version");
TEST_RESULT_INT(backupData.backupPgId, 1, "pg id");
TEST_RESULT_PTR(backupData.backupArchiveStart, NULL, "archive start NULL");
TEST_RESULT_PTR(backupData.backupArchiveStop, NULL, "archive stop NULL");
TEST_RESULT_STR(strPtr(backupData.backupType), "full", "backup type set");
TEST_RESULT_STR_Z(backupData.backupType, "full", "backup type set");
TEST_RESULT_PTR(strPtr(backupData.backupPrior), NULL, "no backup prior");
TEST_RESULT_PTR(backupData.backupReference, NULL, "no backup reference");
TEST_RESULT_INT(backupData.backupTimestampStart, 1565282140, "timestamp start");
@ -407,15 +408,15 @@ testRun(void)
TEST_RESULT_VOID(infoBackupDataAdd(infoBackup, manifest), "add a backup");
TEST_RESULT_UINT(infoBackupDataTotal(infoBackup), 2, "backup added to current");
TEST_ASSIGN(backupData, infoBackupData(infoBackup, 1), "get added backup");
TEST_RESULT_STR(strPtr(backupData.backupLabel), "20190818-084502F_20190820-084502I", "backup label set");
TEST_RESULT_STR_Z(backupData.backupLabel, "20190818-084502F_20190820-084502I", "backup label set");
TEST_RESULT_UINT(backupData.backrestFormat, REPOSITORY_FORMAT, "backrest format");
TEST_RESULT_STR(strPtr(backupData.backrestVersion), PROJECT_VERSION, "backuprest version");
TEST_RESULT_STR(strPtr(backupData.backupArchiveStart), "000000030000028500000089", "archive start set");
TEST_RESULT_STR(strPtr(backupData.backupArchiveStop), "000000030000028500000090", "archive stop set");
TEST_RESULT_STR(strPtr(backupData.backupType), "diff", "backup type set");
TEST_RESULT_STR(strPtr(backupData.backupPrior), "20190818-084502F", "backup prior set");
TEST_RESULT_STR(
strPtr(strLstJoin(backupData.backupReference, ", ")),
TEST_RESULT_STR_Z(backupData.backrestVersion, PROJECT_VERSION, "backuprest version");
TEST_RESULT_STR_Z(backupData.backupArchiveStart, "000000030000028500000089", "archive start set");
TEST_RESULT_STR_Z(backupData.backupArchiveStop, "000000030000028500000090", "archive stop set");
TEST_RESULT_STR_Z(backupData.backupType, "diff", "backup type set");
TEST_RESULT_STR_Z(backupData.backupPrior, "20190818-084502F", "backup prior set");
TEST_RESULT_STR_Z(
strLstJoin(backupData.backupReference, ", "),
"20190818-084502F, 20190818-084502F_20190819-084506D, 20190818-084502F_20190819-084506I",
"backup reference set and ordered");
TEST_RESULT_BOOL(backupData.optionArchiveCheck, true, "option archive check");
@ -670,9 +671,14 @@ testRun(void)
storagePathCreateP(storageRepoWrite(), strNew(STORAGE_REPO_BACKUP "/20190818-084502F")),
"create backup on disk that is in current but no manifest");
TEST_RESULT_STR(
strPtr(strLstJoin(strLstSort(storageListP(storageRepo(), STORAGE_REPO_BACKUP_STR,
.expression = backupRegExpP(.full = true, .differential = true, .incremental = true)), sortOrderAsc), ", ")),
TEST_RESULT_STR_Z(
strLstJoin(
strLstSort(
storageListP(
storageRepo(), STORAGE_REPO_BACKUP_STR,
.expression = backupRegExpP(.full = true, .differential = true, .incremental = true)),
sortOrderAsc),
", "),
"20190818-084444F, 20190818-084502F, 20190818-084555F, 20190818-084666F, 20190818-084777F, 20190923-164324F",
"confirm backups on disk");
@ -693,7 +699,8 @@ testRun(void)
"reconstruct");
TEST_RESULT_INT(infoBackupDataTotal(infoBackup), 1, "backup list contains 1 backup");
TEST_ASSIGN(backupData, infoBackupData(infoBackup, 0), "get the backup");
TEST_RESULT_STR(strPtr(backupData.backupLabel), "20190923-164324F",
TEST_RESULT_STR_Z(
backupData.backupLabel, "20190923-164324F",
"backups not on disk removed, valid backup on disk added, manifest copy-only ignored");
harnessLogResult(
"P00 WARN: invalid backup '20190818-084555F' cannot be added to current backups\n"
@ -716,8 +723,8 @@ testRun(void)
TEST_ASSIGN(
infoBackup, infoBackupLoadFileReconstruct(storageRepo(), INFO_BACKUP_PATH_FILE_STR, cipherTypeNone, NULL),
"reconstruct");
TEST_RESULT_STR(
strPtr(strLstJoin(infoBackupDataLabelList(infoBackup, NULL), ", ")), "20190818-084444F, 20190923-164324F",
TEST_RESULT_STR_Z(
strLstJoin(infoBackupDataLabelList(infoBackup, NULL), ", "), "20190818-084444F, 20190923-164324F",
"previously ignored pgId=1 manifest copy-only now added before existing");
harnessLogResult(
"P00 WARN: backup '20190818-084444F' found in repository added to backup.info\n"

View File

@ -37,12 +37,12 @@ testRun(void)
TEST_ASSIGN(infoPg, infoPgNew(infoPgBackup, NULL), "infoPgNew(cipherTypeNone, NULL)");
TEST_RESULT_INT(infoPgDataTotal(infoPg), 0, " 0 history");
TEST_RESULT_STR(strPtr(infoCipherPass(infoPgInfo(infoPg))), NULL, " cipherPass NULL");
TEST_RESULT_STR(infoCipherPass(infoPgInfo(infoPg)), NULL, " cipherPass NULL");
TEST_RESULT_INT(infoPgDataCurrentId(infoPg), 0, " 0 historyCurrent");
TEST_ASSIGN(infoPg, infoPgNew(infoPgArchive, strNew("123xyz")), "infoPgNew(cipherTypeAes256Cbc, 123xyz)");
TEST_RESULT_INT(infoPgDataTotal(infoPg), 0, " 0 history");
TEST_RESULT_STR(strPtr(infoCipherPass(infoPgInfo(infoPg))), "123xyz", " cipherPass set");
TEST_RESULT_STR_Z(infoCipherPass(infoPgInfo(infoPg)), "123xyz", " cipherPass set");
TEST_RESULT_INT(infoPgDataCurrentId(infoPg), 0, " 0 historyCurrent");
//--------------------------------------------------------------------------------------------------------------------------
@ -64,7 +64,7 @@ testRun(void)
TEST_RESULT_INT(pgData.id, 2, " current id updated");
TEST_RESULT_INT(pgData.systemId, 6569239123849665999, " system-id updated");
TEST_RESULT_INT(pgData.version, PG_VERSION_95, " version updated");
TEST_RESULT_STR(strPtr(infoCipherPass(infoPgInfo(infoPg))), NULL, " cipherPass not set");
TEST_RESULT_STR(infoCipherPass(infoPgInfo(infoPg)), NULL, " cipherPass not set");
//--------------------------------------------------------------------------------------------------------------------------
TEST_ASSIGN(
@ -76,7 +76,7 @@ testRun(void)
TEST_RESULT_INT(pgData.id, 1, " id set");
TEST_RESULT_INT(pgData.systemId, 6569239123849665679, " system-id set");
TEST_RESULT_INT(pgData.version, PG_VERSION_94, " version set");
TEST_RESULT_STR(strPtr(infoCipherPass(infoPgInfo(infoPg))), "123xyz", " cipherPass set");
TEST_RESULT_STR_Z(infoCipherPass(infoPgInfo(infoPg)), "123xyz", " cipherPass set");
}
// *****************************************************************************************************************************
@ -108,8 +108,8 @@ testRun(void)
TEST_ASSIGN(
infoPg, infoPgNewLoad(ioBufferReadNew(contentLoad), infoPgArchive, harnessInfoLoadNewCallback, callbackContent),
"load file");
TEST_RESULT_STR(
strPtr(callbackContent),
TEST_RESULT_STR_Z(
callbackContent,
"[backup:current] 20161219-212741F={}\n"
"[db:backup] key=value\n"
"[later] key=value\n",
@ -121,13 +121,13 @@ testRun(void)
TEST_RESULT_INT(pgData.version, PG_VERSION_94, " version set");
TEST_RESULT_INT(pgData.systemId, 6569239123849665679, " system-id set");
TEST_RESULT_INT(infoPgDataTotal(infoPg), 1, " check pg data total");
TEST_RESULT_STR(strPtr(infoPgArchiveId(infoPg, 0)), "9.4-1", " check pg archive id");
TEST_RESULT_STR_Z(infoPgArchiveId(infoPg, 0), "9.4-1", " check pg archive id");
TEST_RESULT_PTR(infoPgCipherPass(infoPg), NULL, " no cipher passphrase");
Buffer *contentSave = bufNew(0);
TEST_RESULT_VOID(infoPgSave(infoPg, ioBufferWriteNew(contentSave), testInfoBackupSaveCallback, (void *)1), "info save");
TEST_RESULT_STR(strPtr(strNewBuf(contentSave)), strPtr(strNewBuf(contentLoad)), " check save");
TEST_RESULT_STR(strNewBuf(contentSave), strNewBuf(contentLoad), " check save");
// Backup info
//--------------------------------------------------------------------------------------------------------------------------
@ -157,7 +157,7 @@ testRun(void)
callbackContent = strNew("");
TEST_ASSIGN(infoPg, infoPgNewLoad(ioBufferReadNew(contentLoad), infoPgBackup, NULL, NULL), "load file");
TEST_RESULT_STR(strPtr(callbackContent), "", " check callback content");
TEST_RESULT_STR_Z(callbackContent, "", " check callback content");
TEST_RESULT_INT(infoPgDataTotal(infoPg), 2, " check pg data total");
@ -174,9 +174,7 @@ testRun(void)
contentSave = bufNew(0);
TEST_RESULT_VOID(infoPgSave(infoPg, ioBufferWriteNew(contentSave), NULL, NULL), "info save");
TEST_RESULT_STR(
strPtr(strNewBuf(contentSave)), strPtr(strNewBuf(harnessInfoChecksumZ(CONTENT_DB CONTENT_DB_HISTORY))),
" check save");
TEST_RESULT_STR(strNewBuf(contentSave), strNewBuf(harnessInfoChecksumZ(CONTENT_DB CONTENT_DB_HISTORY)), " check save");
// infoPgAdd
//--------------------------------------------------------------------------------------------------------------------------
@ -196,8 +194,8 @@ testRun(void)
pgDataTest.id = (unsigned int)4294967295;
pgDataTest.version = (unsigned int)4294967295;
pgDataTest.systemId = 18446744073709551615U;
TEST_RESULT_STR(
strPtr(infoPgDataToLog(&pgDataTest)), "{id: 4294967295, version: 4294967295, systemId: 18446744073709551615}",
TEST_RESULT_STR_Z(
infoPgDataToLog(&pgDataTest), "{id: 4294967295, version: 4294967295, systemId: 18446744073709551615}",
" check max format");
}
}

View File

@ -79,7 +79,7 @@ testRun(void)
Info *info = NULL;
TEST_ASSIGN(info, infoNew(strNew("123xyz")), "infoNew(cipher)");
TEST_RESULT_STR(strPtr(infoCipherPass(info)), "123xyz", " cipherPass is set");
TEST_RESULT_STR_Z(infoCipherPass(info), "123xyz", " cipherPass is set");
TEST_ASSIGN(info, infoNew(NULL), "infoNew(NULL)");
TEST_RESULT_PTR(infoCipherPass(info), NULL, " cipherPass is NULL");
@ -99,7 +99,7 @@ testRun(void)
TEST_ERROR(
infoNewLoad(ioBufferReadNew(contentLoad), harnessInfoLoadNewCallback, callbackContent), FormatError,
"expected format 5 but found 4");
TEST_RESULT_STR(strPtr(callbackContent), "", " check callback content");
TEST_RESULT_STR_Z(callbackContent, "", " check callback content");
// Checksum not found
// --------------------------------------------------------------------------------------------------------------------------
@ -110,7 +110,7 @@ testRun(void)
TEST_ERROR(
infoNewLoad(ioBufferReadNew(contentLoad), harnessInfoLoadNewCallback, callbackContent), ChecksumError,
"invalid checksum, actual 'a3765a8c2c1e5d35274a0b0ce118f4031faff0bd' but no checksum found");
TEST_RESULT_STR(strPtr(callbackContent), "", " check callback content");
TEST_RESULT_STR_Z(callbackContent, "", " check callback content");
// Checksum invalid
// --------------------------------------------------------------------------------------------------------------------------
@ -124,7 +124,7 @@ testRun(void)
TEST_ERROR(
infoNewLoad(ioBufferReadNew(contentLoad), harnessInfoLoadNewCallback, callbackContent), ChecksumError,
"invalid checksum, actual 'fe989a75dcf7a0261e57d210707c0db741462763' but expected 'BOGUS'");
TEST_RESULT_STR(strPtr(callbackContent), "", " check callback content");
TEST_RESULT_STR_Z(callbackContent, "", " check callback content");
// Crypto expected
// --------------------------------------------------------------------------------------------------------------------------
@ -141,7 +141,7 @@ testRun(void)
infoNewLoad(read, harnessInfoLoadNewCallback, callbackContent), CryptoError,
"cipher header invalid\n"
"HINT: is or was the repo encrypted?");
TEST_RESULT_STR(strPtr(callbackContent), "", " check callback content");
TEST_RESULT_STR_Z(callbackContent, "", " check callback content");
// Base file with other content in cipher (this is to test that future additions don't break the code)
// --------------------------------------------------------------------------------------------------------------------------
@ -154,7 +154,7 @@ testRun(void)
TEST_ASSIGN(
info, infoNewLoad(ioBufferReadNew(contentLoad), harnessInfoLoadNewCallback, callbackContent), "info with other cipher");
TEST_RESULT_STR(strPtr(callbackContent), "", " check callback content");
TEST_RESULT_STR_Z(callbackContent, "", " check callback content");
TEST_RESULT_PTR(infoCipherPass(info), NULL, " check cipher pass not set");
// Base file with content
@ -170,13 +170,13 @@ testRun(void)
TEST_ASSIGN(
info, infoNewLoad(ioBufferReadNew(contentLoad), harnessInfoLoadNewCallback, callbackContent), "info with content");
TEST_RESULT_STR(strPtr(callbackContent), "[c] key=1\n[d] key=1\n", " check callback content");
TEST_RESULT_STR_Z(callbackContent, "[c] key=1\n[d] key=1\n", " check callback content");
TEST_RESULT_PTR(infoCipherPass(info), NULL, " check cipher pass not set");
Buffer *contentSave = bufNew(0);
TEST_RESULT_VOID(infoSave(info, ioBufferWriteNew(contentSave), testInfoSaveCallback, strNew("1")), "info save");
TEST_RESULT_STR(strPtr(strNewBuf(contentSave)), strPtr(strNewBuf(contentLoad)), " check save");
TEST_RESULT_STR(strNewBuf(contentSave), strNewBuf(contentLoad), " check save");
// File with content and cipher
// --------------------------------------------------------------------------------------------------------------------------
@ -195,14 +195,14 @@ testRun(void)
TEST_ASSIGN(
info,
infoNewLoad(ioBufferReadNew(contentLoad), harnessInfoLoadNewCallback, callbackContent), "info with content and cipher");
TEST_RESULT_STR(strPtr(callbackContent), "[c] key=1\n[d] key=1\n", " check callback content");
TEST_RESULT_STR(strPtr(infoCipherPass(info)), "somepass", " check cipher pass set");
TEST_RESULT_STR(strPtr(infoBackrestVersion(info)), PROJECT_VERSION, " check backrest version");
TEST_RESULT_STR_Z(callbackContent, "[c] key=1\n[d] key=1\n", " check callback content");
TEST_RESULT_STR_Z(infoCipherPass(info), "somepass", " check cipher pass set");
TEST_RESULT_STR_Z(infoBackrestVersion(info), PROJECT_VERSION, " check backrest version");
contentSave = bufNew(0);
TEST_RESULT_VOID(infoSave(info, ioBufferWriteNew(contentSave), testInfoSaveCallback, strNew("1")), "info save");
TEST_RESULT_STR(strPtr(strNewBuf(contentSave)), strPtr(strNewBuf(contentLoad)), " check save");
TEST_RESULT_STR(strNewBuf(contentSave), strNewBuf(contentLoad), " check save");
}
// *****************************************************************************************************************************

View File

@ -265,7 +265,7 @@ testRun(void)
Buffer *contentSave = bufNew(0);
TEST_RESULT_VOID(manifestSave(manifest, ioBufferWriteNew(contentSave)), "save manifest");
TEST_RESULT_STR_STR(
TEST_RESULT_STR(
strNewBuf(contentSave),
strNewBuf(harnessInfoChecksumZ(hrnReplaceKey(
TEST_MANIFEST_HEADER
@ -387,7 +387,7 @@ testRun(void)
contentSave = bufNew(0);
TEST_RESULT_VOID(manifestSave(manifest, ioBufferWriteNew(contentSave)), "save manifest");
TEST_RESULT_STR_STR(
TEST_RESULT_STR(
strNewBuf(contentSave),
strNewBuf(harnessInfoChecksumZ(hrnReplaceKey(
TEST_MANIFEST_HEADER
@ -510,7 +510,7 @@ testRun(void)
contentSave = bufNew(0);
TEST_RESULT_VOID(manifestSave(manifest, ioBufferWriteNew(contentSave)), "save manifest");
TEST_RESULT_STR_STR(
TEST_RESULT_STR(
strNewBuf(contentSave),
strNewBuf(harnessInfoChecksumZ(hrnReplaceKey(
TEST_MANIFEST_HEADER
@ -600,7 +600,7 @@ testRun(void)
contentSave = bufNew(0);
TEST_RESULT_VOID(manifestSave(manifest, ioBufferWriteNew(contentSave)), "save manifest");
TEST_RESULT_STR_STR(
TEST_RESULT_STR(
strNewBuf(contentSave),
strNewBuf(harnessInfoChecksumZ(hrnReplaceKey(
TEST_MANIFEST_HEADER
@ -682,7 +682,7 @@ testRun(void)
contentSave = bufNew(0);
TEST_RESULT_VOID(manifestSave(manifest, ioBufferWriteNew(contentSave)), "save manifest");
TEST_RESULT_STR_STR(
TEST_RESULT_STR(
strNewBuf(contentSave),
strNewBuf(harnessInfoChecksumZ(hrnReplaceKey(
TEST_MANIFEST_HEADER
@ -821,7 +821,7 @@ testRun(void)
contentSave = bufNew(0);
TEST_RESULT_VOID(manifestSave(manifest, ioBufferWriteNew(contentSave)), "save manifest");
TEST_RESULT_STR_STR(
TEST_RESULT_STR(
strNewBuf(contentSave),
strNewBuf(harnessInfoChecksumZ(hrnReplaceKey(
TEST_MANIFEST_HEADER
@ -932,7 +932,7 @@ testRun(void)
contentSave = bufNew(0);
TEST_RESULT_VOID(manifestSave(manifest, ioBufferWriteNew(contentSave)), "save manifest");
TEST_RESULT_STR_STR(
TEST_RESULT_STR(
strNewBuf(contentSave),
strNewBuf(harnessInfoChecksumZ(hrnReplaceKey(
TEST_MANIFEST_HEADER
@ -1000,7 +1000,7 @@ testRun(void)
contentSave = bufNew(0);
TEST_RESULT_VOID(manifestSave(manifest, ioBufferWriteNew(contentSave)), "save manifest");
TEST_RESULT_STR_STR(
TEST_RESULT_STR(
strNewBuf(contentSave),
strNewBuf(harnessInfoChecksumZ(hrnReplaceKey(
TEST_MANIFEST_HEADER
@ -1281,7 +1281,7 @@ testRun(void)
Buffer *contentSave = bufNew(0);
TEST_RESULT_VOID(manifestSave(manifest, ioBufferWriteNew(contentSave)), "save manifest");
TEST_RESULT_STR_STR(
TEST_RESULT_STR(
strNewBuf(contentSave),
strNewBuf(harnessInfoChecksumZ(hrnReplaceKey(
TEST_MANIFEST_HEADER_PRE
@ -1331,7 +1331,7 @@ testRun(void)
contentSave = bufNew(0);
TEST_RESULT_VOID(manifestSave(manifest, ioBufferWriteNew(contentSave)), "save manifest");
TEST_RESULT_STR_STR(
TEST_RESULT_STR(
strNewBuf(contentSave),
strNewBuf(harnessInfoChecksumZ(hrnReplaceKey(
TEST_MANIFEST_HEADER_PRE
@ -1385,7 +1385,7 @@ testRun(void)
contentSave = bufNew(0);
TEST_RESULT_VOID(manifestSave(manifest, ioBufferWriteNew(contentSave)), "save manifest");
TEST_RESULT_STR_STR(
TEST_RESULT_STR(
strNewBuf(contentSave),
strNewBuf(harnessInfoChecksumZ(hrnReplaceKey(
TEST_MANIFEST_HEADER_PRE
@ -1437,7 +1437,7 @@ testRun(void)
contentSave = bufNew(0);
TEST_RESULT_VOID(manifestSave(manifest, ioBufferWriteNew(contentSave)), "save manifest");
TEST_RESULT_STR_STR(
TEST_RESULT_STR(
strNewBuf(contentSave),
strNewBuf(harnessInfoChecksumZ(hrnReplaceKey(
TEST_MANIFEST_HEADER_PRE
@ -1497,7 +1497,7 @@ testRun(void)
contentSave = bufNew(0);
TEST_RESULT_VOID(manifestSave(manifest, ioBufferWriteNew(contentSave)), "save manifest");
TEST_RESULT_STR_STR(
TEST_RESULT_STR(
strNewBuf(contentSave),
strNewBuf(harnessInfoChecksumZ(hrnReplaceKey(
TEST_MANIFEST_HEADER_PRE
@ -1602,7 +1602,7 @@ testRun(void)
Buffer *contentSave = bufNew(0);
TEST_RESULT_VOID(manifestSave(manifest, ioBufferWriteNew(contentSave)), "save manifest");
TEST_RESULT_STR_STR(strNewBuf(contentSave), strNewBuf(contentLoad), " check save");
TEST_RESULT_STR(strNewBuf(contentSave), strNewBuf(contentLoad), " check save");
// Manifest with all features
// -------------------------------------------------------------------------------------------------------------------------
@ -1914,7 +1914,7 @@ testRun(void)
TEST_MANIFEST_PATH_DEFAULT
);
TEST_RESULT_STR_STR(strNewBuf(contentSave), strNewBuf(contentCompare), " check save");
TEST_RESULT_STR(strNewBuf(contentSave), strNewBuf(contentCompare), " check save");
TEST_RESULT_VOID(manifestFileRemove(manifest, STRDEF("pg_data/PG_VERSION")), "remove file");
TEST_ERROR(
@ -2005,7 +2005,7 @@ testRun(void)
storagePutP(storageNewWriteP(storageTest, strNew(BACKUP_MANIFEST_FILE INFO_COPY_EXT)), content), "write copy");
TEST_ASSIGN(manifest, manifestLoadFile(storageTest, STRDEF(BACKUP_MANIFEST_FILE), cipherTypeNone, NULL), "load copy");
TEST_RESULT_UINT(manifestData(manifest)->pgSystemId, 1000000000000000094, " check file loaded");
TEST_RESULT_STR(strPtr(manifestData(manifest)->backrestVersion), PROJECT_VERSION, " check backrest version");
TEST_RESULT_STR_Z(manifestData(manifest)->backrestVersion, PROJECT_VERSION, " check backrest version");
storageRemoveP(storageTest, strNew(BACKUP_MANIFEST_FILE INFO_COPY_EXT), .errorOnMissing = true);

View File

@ -280,8 +280,8 @@ testRun(void)
" from pg_class where relname in ('pg_class', 'pg_proc')"
" order by relname");
TEST_RESULT_STR(
strPtr(jsonFromVar(varNewVarLst(pgClientQuery(client, query)))),
TEST_RESULT_STR_Z(
jsonFromVar(varNewVarLst(pgClientQuery(client, query))),
"[[1259,null,\"pg_class\",true],[1255,\"\",\"pg_proc\",false]]", "simple query");
// Close connection

View File

@ -25,9 +25,9 @@ testRun(void)
TEST_RESULT_INT(pgVersionFromStr(strNew("9.6")), 90600, "valid pg version 9.6");
//--------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_STR(strPtr(pgVersionToStr(PG_VERSION_11)), "11", "infoPgVersionToString 11");
TEST_RESULT_STR(strPtr(pgVersionToStr(PG_VERSION_96)), "9.6", "infoPgVersionToString 9.6");
TEST_RESULT_STR(strPtr(pgVersionToStr(83456)), "8.34", "infoPgVersionToString 83456");
TEST_RESULT_STR_Z(pgVersionToStr(PG_VERSION_11), "11", "infoPgVersionToString 11");
TEST_RESULT_STR_Z(pgVersionToStr(PG_VERSION_96), "9.6", "infoPgVersionToString 9.6");
TEST_RESULT_STR_Z(pgVersionToStr(83456), "8.34", "infoPgVersionToString 83456");
}
// *****************************************************************************************************************************
@ -156,22 +156,22 @@ testRun(void)
// *****************************************************************************************************************************
if (testBegin("pgLsnName(), pgTablespaceId(), pgWalName(), pgWalPath(), and pgXactPath()"))
{
TEST_RESULT_STR(strPtr(pgLsnName(PG_VERSION_96)), "location", "check location name");
TEST_RESULT_STR(strPtr(pgLsnName(PG_VERSION_10)), "lsn", "check lsn name");
TEST_RESULT_STR_Z(pgLsnName(PG_VERSION_96), "location", "check location name");
TEST_RESULT_STR_Z(pgLsnName(PG_VERSION_10), "lsn", "check lsn name");
TEST_RESULT_STR_Z(pgTablespaceId(PG_VERSION_84), NULL, "check 8.4 tablespace id");
TEST_RESULT_STR_Z(pgTablespaceId(PG_VERSION_90), "PG_9.0_201008051", "check 9.0 tablespace id");
TEST_RESULT_STR_Z(pgTablespaceId(PG_VERSION_94), "PG_9.4_201409291", "check 9.4 tablespace id");
TEST_RESULT_STR_Z(pgTablespaceId(PG_VERSION_11), "PG_11_201809051", "check 11 tablespace id");
TEST_RESULT_STR(strPtr(pgWalName(PG_VERSION_96)), "xlog", "check xlog name");
TEST_RESULT_STR(strPtr(pgWalName(PG_VERSION_10)), "wal", "check wal name");
TEST_RESULT_STR_Z(pgWalName(PG_VERSION_96), "xlog", "check xlog name");
TEST_RESULT_STR_Z(pgWalName(PG_VERSION_10), "wal", "check wal name");
TEST_RESULT_STR_Z(pgWalPath(PG_VERSION_96), "pg_xlog", "check xlog path");
TEST_RESULT_STR_Z(pgWalPath(PG_VERSION_10), "pg_wal", "check wal path");
TEST_RESULT_STR(strPtr(pgXactPath(PG_VERSION_96)), "pg_clog", "check pg_clog name");
TEST_RESULT_STR(strPtr(pgXactPath(PG_VERSION_10)), "pg_xact", "check pg_xact name");
TEST_RESULT_STR_Z(pgXactPath(PG_VERSION_96), "pg_clog", "check pg_clog name");
TEST_RESULT_STR_Z(pgXactPath(PG_VERSION_10), "pg_xact", "check pg_xact name");
}
// *****************************************************************************************************************************
@ -232,9 +232,9 @@ testRun(void)
.pageChecksum = true
};
TEST_RESULT_STR(
strPtr(pgControlToLog(&pgControl)),
"{version: 110000, systemId: 1030522662895, walSegmentSize: 16777216, pageChecksum: true}", "check log");
TEST_RESULT_STR_Z(
pgControlToLog(&pgControl), "{version: 110000, systemId: 1030522662895, walSegmentSize: 16777216, pageChecksum: true}",
"check log");
}
// *****************************************************************************************************************************
@ -246,9 +246,7 @@ testRun(void)
.systemId = 0xFEFEFEFEFE
};
TEST_RESULT_STR(
strPtr(pgWalToLog(&pgWal)),
"{version: 100000, systemId: 1095199817470}", "check log");
TEST_RESULT_STR_Z(pgWalToLog(&pgWal), "{version: 100000, systemId: 1095199817470}", "check log");
}
FUNCTION_HARNESS_RESULT_VOID();

View File

@ -107,8 +107,8 @@ testRun(void)
TEST_RESULT_UINT(protocolStorageTypeEnum(PROTOCOL_STORAGE_TYPE_REPO_STR), protocolStorageTypeRepo, "repo enum");
TEST_ERROR(protocolStorageTypeEnum(STRDEF(BOGUS_STR)), AssertError, "invalid protocol storage type 'BOGUS'");
TEST_RESULT_STR_STR(protocolStorageTypeStr(protocolStorageTypePg), PROTOCOL_STORAGE_TYPE_PG_STR, "pg str");
TEST_RESULT_STR_STR(protocolStorageTypeStr(protocolStorageTypeRepo), PROTOCOL_STORAGE_TYPE_REPO_STR, "repo str");
TEST_RESULT_STR(protocolStorageTypeStr(protocolStorageTypePg), PROTOCOL_STORAGE_TYPE_PG_STR, "pg str");
TEST_RESULT_STR(protocolStorageTypeStr(protocolStorageTypeRepo), PROTOCOL_STORAGE_TYPE_REPO_STR, "repo str");
TEST_ERROR(protocolStorageTypeStr((ProtocolStorageType)999), AssertError, "invalid protocol storage type 999");
}
@ -171,12 +171,10 @@ testRun(void)
strLstAddZ(argList, "archive-get");
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList));
TEST_RESULT_STR(
strPtr(strLstJoin(protocolLocalParam(protocolStorageTypeRepo, 1, 0), "|")),
strPtr(
strNew(
"--command=archive-get|--host-id=1|--log-level-file=off|--log-level-stderr=error|--process=0|--stanza=test1"
"|--type=backup|local")),
TEST_RESULT_STR_Z(
strLstJoin(protocolLocalParam(protocolStorageTypeRepo, 1, 0), "|"),
"--command=archive-get|--host-id=1|--log-level-file=off|--log-level-stderr=error|--process=0|--stanza=test1"
"|--type=backup|local",
"local repo protocol params");
// -------------------------------------------------------------------------------------------------------------------------
@ -189,12 +187,10 @@ testRun(void)
strLstAddZ(argList, "backup");
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList));
TEST_RESULT_STR(
strPtr(strLstJoin(protocolLocalParam(protocolStorageTypePg, 2, 1), "|")),
strPtr(
strNew(
"--command=backup|--host-id=2|--log-level-file=info|--log-level-stderr=error|--log-subprocess|--pg1-path=/pg"
"|--process=1|--stanza=test1|--type=db|local")),
TEST_RESULT_STR_Z(
strLstJoin(protocolLocalParam(protocolStorageTypePg, 2, 1), "|"),
"--command=backup|--host-id=2|--log-level-file=info|--log-level-stderr=error|--log-subprocess|--pg1-path=/pg"
"|--process=1|--stanza=test1|--type=db|local",
"local pg protocol params");
}
@ -215,13 +211,11 @@ testRun(void)
strLstAddZ(argList, "archive-get");
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList));
TEST_RESULT_STR(
strPtr(strLstJoin(protocolRemoteParam(protocolStorageTypeRepo, 0, 0), "|")),
strPtr(
strNew(
"-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|repo-host-user@repo-host"
"|pgbackrest --command=archive-get --log-level-file=off --log-level-stderr=error --process=0"
" --stanza=test1 --type=backup remote")),
TEST_RESULT_STR_Z(
strLstJoin(protocolRemoteParam(protocolStorageTypeRepo, 0, 0), "|"),
"-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|repo-host-user@repo-host"
"|pgbackrest --command=archive-get --log-level-file=off --log-level-stderr=error --process=0"
" --stanza=test1 --type=backup remote",
"remote protocol params");
// -------------------------------------------------------------------------------------------------------------------------
@ -238,14 +232,12 @@ testRun(void)
strLstAddZ(argList, "archive-get");
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList));
TEST_RESULT_STR(
strPtr(strLstJoin(protocolRemoteParam(protocolStorageTypeRepo, 1, 0), "|")),
strPtr(
strNew(
"-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|-p|444|repo-host-user@repo-host"
"|pgbackrest --command=archive-get --config=/path/pgbackrest.conf --config-include-path=/path/include"
" --config-path=/path/config --log-level-file=info --log-level-stderr=error --log-subprocess --process=1"
" --stanza=test1 --type=backup remote")),
TEST_RESULT_STR_Z(
strLstJoin(protocolRemoteParam(protocolStorageTypeRepo, 1, 0), "|"),
"-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|-p|444|repo-host-user@repo-host"
"|pgbackrest --command=archive-get --config=/path/pgbackrest.conf --config-include-path=/path/include"
" --config-path=/path/config --log-level-file=info --log-level-stderr=error --log-subprocess --process=1"
" --stanza=test1 --type=backup remote",
"remote protocol params with replacements");
// -------------------------------------------------------------------------------------------------------------------------
@ -260,13 +252,11 @@ testRun(void)
strLstAddZ(argList, "local");
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList));
TEST_RESULT_STR(
strPtr(strLstJoin(protocolRemoteParam(protocolStorageTypeRepo, 66, 0), "|")),
strPtr(
strNew(
"-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|pgbackrest@repo-host"
"|pgbackrest --command=archive-get --log-level-file=off --log-level-stderr=error --process=3"
" --stanza=test1 --type=backup remote")),
TEST_RESULT_STR_Z(
strLstJoin(protocolRemoteParam(protocolStorageTypeRepo, 66, 0), "|"),
"-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|pgbackrest@repo-host"
"|pgbackrest --command=archive-get --log-level-file=off --log-level-stderr=error --process=3"
" --stanza=test1 --type=backup remote",
"remote protocol params for backup local");
// -------------------------------------------------------------------------------------------------------------------------
@ -279,13 +269,11 @@ testRun(void)
strLstAddZ(argList, "backup");
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList));
TEST_RESULT_STR(
strPtr(strLstJoin(protocolRemoteParam(protocolStorageTypePg, 1, 0), "|")),
strPtr(
strNew(
"-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|postgres@pg1-host"
"|pgbackrest --command=backup --log-level-file=off --log-level-stderr=error --pg1-path=/path/to/1"
" --process=1 --stanza=test1 --type=db remote")),
TEST_RESULT_STR_Z(
strLstJoin(protocolRemoteParam(protocolStorageTypePg, 1, 0), "|"),
"-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|postgres@pg1-host"
"|pgbackrest --command=backup --log-level-file=off --log-level-stderr=error --pg1-path=/path/to/1"
" --process=1 --stanza=test1 --type=db remote",
"remote protocol params for db backup");
// -------------------------------------------------------------------------------------------------------------------------
@ -304,13 +292,11 @@ testRun(void)
strLstAddZ(argList, "local");
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList));
TEST_RESULT_STR(
strPtr(strLstJoin(protocolRemoteParam(protocolStorageTypePg, 1, 1), "|")),
strPtr(
strNew(
"-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|postgres@pg2-host"
"|pgbackrest --command=backup --log-level-file=off --log-level-stderr=error --pg1-path=/path/to/2"
" --process=4 --stanza=test1 --type=db remote")),
TEST_RESULT_STR_Z(
strLstJoin(protocolRemoteParam(protocolStorageTypePg, 1, 1), "|"),
"-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|postgres@pg2-host"
"|pgbackrest --command=backup --log-level-file=off --log-level-stderr=error --pg1-path=/path/to/2"
" --process=4 --stanza=test1 --type=db remote",
"remote protocol params for db local");
// -------------------------------------------------------------------------------------------------------------------------
@ -329,13 +315,11 @@ testRun(void)
strLstAddZ(argList, "local");
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList));
TEST_RESULT_STR(
strPtr(strLstJoin(protocolRemoteParam(protocolStorageTypePg, 1, 2), "|")),
strPtr(
strNew(
"-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|postgres@pg3-host"
"|pgbackrest --command=backup --log-level-file=off --log-level-stderr=error --pg1-path=/path/to/3"
" --pg1-port=3333 --pg1-socket-path=/socket3 --process=4 --stanza=test1 --type=db remote")),
TEST_RESULT_STR_Z(
strLstJoin(protocolRemoteParam(protocolStorageTypePg, 1, 2), "|"),
"-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|postgres@pg3-host"
"|pgbackrest --command=backup --log-level-file=off --log-level-stderr=error --pg1-path=/path/to/3"
" --pg1-port=3333 --pg1-socket-path=/socket3 --process=4 --stanza=test1 --type=db remote",
"remote protocol params for db local");
}
@ -355,14 +339,13 @@ testRun(void)
}
MEM_CONTEXT_TEMP_END();
TEST_RESULT_STR(strPtr(protocolCommandToLog(command)), "{command: command1}", "check log");
TEST_RESULT_STR(
strPtr(protocolCommandJson(command)), "{\"cmd\":\"command1\",\"param\":[\"param1\",\"param2\"]}", "check json");
TEST_RESULT_STR_Z(protocolCommandToLog(command), "{command: command1}", "check log");
TEST_RESULT_STR_Z(protocolCommandJson(command), "{\"cmd\":\"command1\",\"param\":[\"param1\",\"param2\"]}", "check json");
// -------------------------------------------------------------------------------------------------------------------------
TEST_ASSIGN(command, protocolCommandNew(strNew("command2")), "create command");
TEST_RESULT_STR(strPtr(protocolCommandToLog(command)), "{command: command2}", "check log");
TEST_RESULT_STR(strPtr(protocolCommandJson(command)), "{\"cmd\":\"command2\"}", "check json");
TEST_RESULT_STR_Z(protocolCommandToLog(command), "{command: command2}", "check log");
TEST_RESULT_STR_Z(protocolCommandJson(command), "{\"cmd\":\"command2\"}", "check json");
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_VOID(protocolCommandFree(command), "free command");
@ -398,53 +381,52 @@ testRun(void)
ioWriteStrLine(write, strNew("{\"name\":\"pgBackRest\",\"service\":\"test\",\"version\":\"" PROJECT_VERSION "\"}"));
ioWriteFlush(write);
TEST_RESULT_STR(strPtr(ioReadLine(read)), "{\"cmd\":\"noop\"}", "noop");
TEST_RESULT_STR_Z(ioReadLine(read), "{\"cmd\":\"noop\"}", "noop");
ioWriteStrLine(write, strNew("{}"));
ioWriteFlush(write);
// Throw errors
TEST_RESULT_STR(strPtr(ioReadLine(read)), "{\"cmd\":\"noop\"}", "noop with error text");
TEST_RESULT_STR_Z(ioReadLine(read), "{\"cmd\":\"noop\"}", "noop with error text");
ioWriteStrLine(write, strNew("{\"err\":25,\"out\":\"sample error message\",\"errStack\":\"stack data\"}"));
ioWriteFlush(write);
TEST_RESULT_STR(strPtr(ioReadLine(read)), "{\"cmd\":\"noop\"}", "noop with no error text");
TEST_RESULT_STR_Z(ioReadLine(read), "{\"cmd\":\"noop\"}", "noop with no error text");
ioWriteStrLine(write, strNew("{\"err\":255}"));
ioWriteFlush(write);
// No output expected
TEST_RESULT_STR(strPtr(ioReadLine(read)), "{\"cmd\":\"noop\"}", "noop with parameters returned");
TEST_RESULT_STR_Z(ioReadLine(read), "{\"cmd\":\"noop\"}", "noop with parameters returned");
ioWriteStrLine(write, strNew("{\"out\":[\"bogus\"]}"));
ioWriteFlush(write);
// Send output
TEST_RESULT_STR(strPtr(ioReadLine(read)), "{\"cmd\":\"test\"}", "test command");
TEST_RESULT_STR_Z(ioReadLine(read), "{\"cmd\":\"test\"}", "test command");
ioWriteStrLine(write, strNew(".OUTPUT"));
ioWriteStrLine(write, strNew("{\"out\":[\"value1\",\"value2\"]}"));
ioWriteFlush(write);
// invalid line
TEST_RESULT_STR(strPtr(ioReadLine(read)), "{\"cmd\":\"invalid-line\"}", "invalid line command");
TEST_RESULT_STR_Z(ioReadLine(read), "{\"cmd\":\"invalid-line\"}", "invalid line command");
ioWrite(write, LF_BUF);
ioWriteFlush(write);
// error instead of output
TEST_RESULT_STR(
strPtr(ioReadLine(read)), "{\"cmd\":\"error-instead-of-output\"}", "error instead of output command");
TEST_RESULT_STR_Z(ioReadLine(read), "{\"cmd\":\"error-instead-of-output\"}", "error instead of output command");
ioWriteStrLine(write, strNew("{\"err\":255}"));
ioWriteFlush(write);
// unexpected output
TEST_RESULT_STR(strPtr(ioReadLine(read)), "{\"cmd\":\"unexpected-output\"}", "unexpected output");
TEST_RESULT_STR_Z(ioReadLine(read), "{\"cmd\":\"unexpected-output\"}", "unexpected output");
ioWriteStrLine(write, strNew("{}"));
ioWriteFlush(write);
// invalid prefix
TEST_RESULT_STR(strPtr(ioReadLine(read)), "{\"cmd\":\"invalid-prefix\"}", "invalid prefix");
TEST_RESULT_STR_Z(ioReadLine(read), "{\"cmd\":\"invalid-prefix\"}", "invalid prefix");
ioWriteStrLine(write, strNew("~line"));
ioWriteFlush(write);
// Wait for exit
TEST_RESULT_STR(strPtr(ioReadLine(read)), "{\"cmd\":\"exit\"}", "exit command");
TEST_RESULT_STR_Z(ioReadLine(read), "{\"cmd\":\"exit\"}", "exit command");
}
HARNESS_FORK_CHILD_END();
@ -514,8 +496,8 @@ testRun(void)
TEST_RESULT_STR_Z(protocolClientReadLine(client), "OUTPUT", "check output");
TEST_ASSIGN(output, varVarLst(protocolClientReadOutput(client, true)), "execute command with output");
TEST_RESULT_UINT(varLstSize(output), 2, "check output size");
TEST_RESULT_STR(strPtr(varStr(varLstGet(output, 0))), "value1", "check value1");
TEST_RESULT_STR(strPtr(varStr(varLstGet(output, 1))), "value2", "check value2");
TEST_RESULT_STR_Z(varStr(varLstGet(output, 0)), "value1", "check value1");
TEST_RESULT_STR_Z(varStr(varLstGet(output, 1)), "value2", "check value2");
// Invalid line
TEST_RESULT_VOID(
@ -562,14 +544,14 @@ testRun(void)
ioWriteOpen(write);
// Check greeting
TEST_RESULT_STR(
strPtr(ioReadLine(read)), "{\"name\":\"pgBackRest\",\"service\":\"test\",\"version\":\"" PROJECT_VERSION "\"}",
TEST_RESULT_STR_Z(
ioReadLine(read), "{\"name\":\"pgBackRest\",\"service\":\"test\",\"version\":\"" PROJECT_VERSION "\"}",
"check greeting");
// Noop
TEST_RESULT_VOID(ioWriteStrLine(write, strNew("{\"cmd\":\"noop\"}")), "write noop");
TEST_RESULT_VOID(ioWriteFlush(write), "flush noop");
TEST_RESULT_STR(strPtr(ioReadLine(read)), "{}", "noop result");
TEST_RESULT_STR_Z(ioReadLine(read), "{}", "noop result");
// Invalid command
KeyValue *result = NULL;
@ -578,26 +560,26 @@ testRun(void)
TEST_RESULT_VOID(ioWriteFlush(write), "flush bogus");
TEST_ASSIGN(result, varKv(jsonToVar(ioReadLine(read))), "parse error result");
TEST_RESULT_INT(varIntForce(kvGet(result, VARSTRDEF("err"))), 39, " check code");
TEST_RESULT_STR(strPtr(varStr(kvGet(result, VARSTRDEF("out")))), "invalid command 'bogus'", " check message");
TEST_RESULT_STR_Z(varStr(kvGet(result, VARSTRDEF("out"))), "invalid command 'bogus'", " check message");
TEST_RESULT_BOOL(kvGet(result, VARSTRDEF("errStack")) != NULL, true, " check stack exists");
// Simple request
TEST_RESULT_VOID(ioWriteStrLine(write, strNew("{\"cmd\":\"request-simple\"}")), "write simple request");
TEST_RESULT_VOID(ioWriteFlush(write), "flush simple request");
TEST_RESULT_STR(strPtr(ioReadLine(read)), "{\"out\":true}", "simple request result");
TEST_RESULT_STR_Z(ioReadLine(read), "{\"out\":true}", "simple request result");
// Throw an assert error which will include a stack trace
TEST_RESULT_VOID(ioWriteStrLine(write, strNew("{\"cmd\":\"assert\"}")), "write assert");
TEST_RESULT_VOID(ioWriteFlush(write), "flush assert error");
TEST_ASSIGN(result, varKv(jsonToVar(ioReadLine(read))), "parse error result");
TEST_RESULT_INT(varIntForce(kvGet(result, VARSTRDEF("err"))), 25, " check code");
TEST_RESULT_STR(strPtr(varStr(kvGet(result, VARSTRDEF("out")))), "test assert", " check message");
TEST_RESULT_STR_Z(varStr(kvGet(result, VARSTRDEF("out"))), "test assert", " check message");
TEST_RESULT_BOOL(kvGet(result, VARSTRDEF("errStack")) != NULL, true, " check stack exists");
// Complex request -- after process loop has been restarted
TEST_RESULT_VOID(ioWriteStrLine(write, strNew("{\"cmd\":\"request-complex\"}")), "write complex request");
TEST_RESULT_VOID(ioWriteFlush(write), "flush complex request");
TEST_RESULT_STR(strPtr(ioReadLine(read)), "{\"out\":false}", "complex request result");
TEST_RESULT_STR_Z(ioReadLine(read), "{\"out\":false}", "complex request result");
TEST_RESULT_STR_Z(ioReadLine(read), ".LINEOFTEXT", "complex request result");
TEST_RESULT_STR_Z(ioReadLine(read), ".", "complex request result");
@ -681,17 +663,17 @@ testRun(void)
ioWriteStrLine(write, strNew("{\"name\":\"pgBackRest\",\"service\":\"test\",\"version\":\"" PROJECT_VERSION "\"}"));
ioWriteFlush(write);
TEST_RESULT_STR(strPtr(ioReadLine(read)), "{\"cmd\":\"noop\"}", "noop");
TEST_RESULT_STR_Z(ioReadLine(read), "{\"cmd\":\"noop\"}", "noop");
ioWriteStrLine(write, strNew("{}"));
ioWriteFlush(write);
TEST_RESULT_STR(strPtr(ioReadLine(read)), "{\"cmd\":\"command1\",\"param\":[\"param1\",\"param2\"]}", "command1");
TEST_RESULT_STR_Z(ioReadLine(read), "{\"cmd\":\"command1\",\"param\":[\"param1\",\"param2\"]}", "command1");
sleepMSec(4000);
ioWriteStrLine(write, strNew("{\"out\":1}"));
ioWriteFlush(write);
// Wait for exit
TEST_RESULT_STR(strPtr(ioReadLine(read)), "{\"cmd\":\"exit\"}", "exit command");
TEST_RESULT_STR_Z(ioReadLine(read), "{\"cmd\":\"exit\"}", "exit command");
}
HARNESS_FORK_CHILD_END();
@ -707,22 +689,22 @@ testRun(void)
ioWriteStrLine(write, strNew("{\"name\":\"pgBackRest\",\"service\":\"test\",\"version\":\"" PROJECT_VERSION "\"}"));
ioWriteFlush(write);
TEST_RESULT_STR(strPtr(ioReadLine(read)), "{\"cmd\":\"noop\"}", "noop");
TEST_RESULT_STR_Z(ioReadLine(read), "{\"cmd\":\"noop\"}", "noop");
ioWriteStrLine(write, strNew("{}"));
ioWriteFlush(write);
TEST_RESULT_STR(strPtr(ioReadLine(read)), "{\"cmd\":\"command2\",\"param\":[\"param1\"]}", "command2");
TEST_RESULT_STR_Z(ioReadLine(read), "{\"cmd\":\"command2\",\"param\":[\"param1\"]}", "command2");
sleepMSec(1000);
ioWriteStrLine(write, strNew("{\"out\":2}"));
ioWriteFlush(write);
TEST_RESULT_STR(strPtr(ioReadLine(read)), "{\"cmd\":\"command3\",\"param\":[\"param1\"]}", "command3");
TEST_RESULT_STR_Z(ioReadLine(read), "{\"cmd\":\"command3\",\"param\":[\"param1\"]}", "command3");
ioWriteStrLine(write, strNew("{\"err\":39,\"out\":\"very serious error\"}"));
ioWriteFlush(write);
// Wait for exit
TEST_RESULT_STR(strPtr(ioReadLine(read)), "{\"cmd\":\"exit\"}", "exit command");
TEST_RESULT_STR_Z(ioReadLine(read), "{\"cmd\":\"exit\"}", "exit command");
}
HARNESS_FORK_CHILD_END();
@ -732,8 +714,7 @@ testRun(void)
TestParallelJobCallback data = {.jobList = lstNew(sizeof(ProtocolParallelJob *))};
ProtocolParallel *parallel = NULL;
TEST_ASSIGN(parallel, protocolParallelNew(2000, testParallelJobCallback, &data), "create parallel");
TEST_RESULT_STR(
strPtr(protocolParallelToLog(parallel)), "{state: pending, clientTotal: 0, jobTotal: 0}", "check log");
TEST_RESULT_STR_Z(protocolParallelToLog(parallel), "{state: pending, clientTotal: 0, jobTotal: 0}", "check log");
// Add client
unsigned int clientTotal = 2;
@ -795,7 +776,7 @@ testRun(void)
TEST_RESULT_INT(protocolParallelProcess(parallel), 1, "process jobs");
TEST_ASSIGN(job, protocolParallelResult(parallel), "get result");
TEST_RESULT_STR(strPtr(varStr(protocolParallelJobKey(job))), "job2", "check key is job2");
TEST_RESULT_STR_Z(varStr(protocolParallelJobKey(job)), "job2", "check key is job2");
TEST_RESULT_BOOL(
protocolParallelJobProcessId(job) >= 1 && protocolParallelJobProcessId(job) <= 2, true,
"check process id is valid");
@ -807,10 +788,10 @@ testRun(void)
TEST_RESULT_INT(protocolParallelProcess(parallel), 1, "process jobs");
TEST_ASSIGN(job, protocolParallelResult(parallel), "get result");
TEST_RESULT_STR(strPtr(varStr(protocolParallelJobKey(job))), "job3", "check key is job3");
TEST_RESULT_STR_Z(varStr(protocolParallelJobKey(job)), "job3", "check key is job3");
TEST_RESULT_INT(protocolParallelJobErrorCode(job), 39, "check error code");
TEST_RESULT_STR(
strPtr(protocolParallelJobErrorMessage(job)), "raised from test client 1: very serious error",
TEST_RESULT_STR_Z(
protocolParallelJobErrorMessage(job), "raised from test client 1: very serious error",
"check error message");
TEST_RESULT_PTR(protocolParallelJobResult(job), NULL, "check result is null");
@ -825,7 +806,7 @@ testRun(void)
TEST_RESULT_INT(protocolParallelProcess(parallel), 1, "process jobs");
TEST_ASSIGN(job, protocolParallelResult(parallel), "get result");
TEST_RESULT_STR(strPtr(varStr(protocolParallelJobKey(job))), "job1", "check key is job1");
TEST_RESULT_STR_Z(varStr(protocolParallelJobKey(job)), "job1", "check key is job1");
TEST_RESULT_INT(varIntForce(protocolParallelJobResult(job)), 1, "check result is 1");
TEST_RESULT_BOOL(protocolParallelDone(parallel), true, "check done");
@ -896,10 +877,10 @@ testRun(void)
strLstAddZ(argList, "--type=db");
harnessCfgLoad(cfgCmdLocal, argList);
TEST_RESULT_STR(strPtr(cfgOptionStr(cfgOptRepoCipherPass)), "acbd", "check cipher pass before");
TEST_RESULT_STR_Z(cfgOptionStr(cfgOptRepoCipherPass), "acbd", "check cipher pass before");
TEST_ASSIGN(client, protocolRemoteGet(protocolStorageTypeRepo, 1), "get remote protocol");
TEST_RESULT_PTR(protocolHelper.clientRemote[0].client, client, "check position in cache");
TEST_RESULT_STR(strPtr(cfgOptionStr(cfgOptRepoCipherPass)), "acbd", "check cipher pass after");
TEST_RESULT_STR_Z(cfgOptionStr(cfgOptRepoCipherPass), "acbd", "check cipher pass after");
TEST_RESULT_VOID(protocolFree(), "free remote protocol objects");
@ -923,7 +904,7 @@ testRun(void)
TEST_RESULT_PTR(cfgOptionStr(cfgOptRepoCipherPass), NULL, "check cipher pass before");
TEST_ASSIGN(client, protocolRemoteGet(protocolStorageTypeRepo, 1), "get remote protocol");
TEST_RESULT_STR(strPtr(cfgOptionStr(cfgOptRepoCipherPass)), "dcba", "check cipher pass after");
TEST_RESULT_STR_Z(cfgOptionStr(cfgOptRepoCipherPass), "dcba", "check cipher pass after");
TEST_RESULT_VOID(protocolFree(), "free remote protocol objects");

View File

@ -23,7 +23,7 @@ testRun(void)
const Storage *storage = NULL;
TEST_ASSIGN(storage, storageRepoGet(strNew(STORAGE_TYPE_CIFS), true), "get cifs repo storage");
TEST_RESULT_STR(strPtr(storage->type), "cifs", "check storage type");
TEST_RESULT_STR_Z(storage->type, "cifs", "check storage type");
TEST_RESULT_BOOL(storageFeature(storage, storageFeaturePath), true, " check path feature");
TEST_RESULT_BOOL(storageFeature(storage, storageFeatureCompress), true, " check compress feature");

View File

@ -66,7 +66,7 @@ testRun(void)
{
Storage *storageTest = NULL;
TEST_ASSIGN(storageTest, storagePosixNew(strNew("/"), 0640, 0750, false, NULL), "new storage (defaults)");
TEST_RESULT_STR(strPtr(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->modePath, 0750, " check path mode");
TEST_RESULT_BOOL(storageTest->write, false, " check write");
@ -75,7 +75,7 @@ testRun(void)
TEST_ASSIGN(
storageTest, storagePosixNew(strNew("/path/to"), 0600, 0700, true, storageTestPathExpression),
"new storage (non-default)");
TEST_RESULT_STR(strPtr(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->modePath, 0700, " check path mode");
TEST_RESULT_BOOL(storageTest->write, true, " check write");
@ -184,9 +184,9 @@ testRun(void)
TEST_RESULT_UINT(info.timeModified, 1555160000, " check mod time");
TEST_RESULT_PTR(info.linkDestination, NULL, " no link destination");
TEST_RESULT_UINT(info.userId, getuid(), " check user id");
TEST_RESULT_STR(strPtr(info.user), testUser(), " check user");
TEST_RESULT_STR_Z(info.user, testUser(), " check user");
TEST_RESULT_UINT(info.groupId, getgid(), " check group id");
TEST_RESULT_STR(strPtr(info.group), testGroup(), " check group");
TEST_RESULT_STR_Z(info.group, testGroup(), " check group");
// -------------------------------------------------------------------------------------------------------------------------
const Buffer *buffer = BUFSTRDEF("TESTFILE");
@ -205,8 +205,8 @@ testRun(void)
TEST_RESULT_INT(info.mode, 0640, " check mode");
TEST_RESULT_UINT(info.timeModified, 1555155555, " check mod time");
TEST_RESULT_PTR(info.linkDestination, NULL, " no link destination");
TEST_RESULT_STR(strPtr(info.user), NULL, " check user");
TEST_RESULT_STR(strPtr(info.group), NULL, " check group");
TEST_RESULT_STR(info.user, NULL, " check user");
TEST_RESULT_STR(info.group, NULL, " check group");
storageRemoveP(storageTest, fileName, .errorOnMissing = true);
@ -220,9 +220,9 @@ testRun(void)
TEST_RESULT_INT(info.type, storageTypeLink, " check type");
TEST_RESULT_INT(info.size, 0, " check size");
TEST_RESULT_INT(info.mode, 0777, " check mode");
TEST_RESULT_STR(strPtr(info.linkDestination), "/tmp", " check link destination");
TEST_RESULT_STR(strPtr(info.user), testUser(), " check user");
TEST_RESULT_STR(strPtr(info.group), testGroup(), " check group");
TEST_RESULT_STR_Z(info.linkDestination, "/tmp", " check link destination");
TEST_RESULT_STR_Z(info.user, testUser(), " check user");
TEST_RESULT_STR_Z(info.group, testGroup(), " check group");
TEST_ASSIGN(info, storageInfoP(storageTest, linkName, .followLink = true), "get info from path pointed to by link");
TEST_RESULT_PTR(info.name, NULL, " name is not set");
@ -230,9 +230,9 @@ testRun(void)
TEST_RESULT_INT(info.type, storageTypePath, " check type");
TEST_RESULT_INT(info.size, 0, " check size");
TEST_RESULT_INT(info.mode, 0777, " check mode");
TEST_RESULT_STR(strPtr(info.linkDestination), NULL, " check link destination");
TEST_RESULT_STR(strPtr(info.user), "root", " check user");
TEST_RESULT_STR(strPtr(info.group), "root", " check group");
TEST_RESULT_STR(info.linkDestination, NULL, " check link destination");
TEST_RESULT_STR_Z(info.user, "root", " check user");
TEST_RESULT_STR_Z(info.group, "root", " check group");
storageRemoveP(storageTest, linkName, .errorOnMissing = true);
@ -246,9 +246,9 @@ testRun(void)
TEST_RESULT_INT(info.type, storageTypeSpecial, " check type");
TEST_RESULT_INT(info.size, 0, " check size");
TEST_RESULT_INT(info.mode, 0666, " check mode");
TEST_RESULT_STR(strPtr(info.linkDestination), NULL, " check link destination");
TEST_RESULT_STR(strPtr(info.user), testUser(), " check user");
TEST_RESULT_STR(strPtr(info.group), testGroup(), " check group");
TEST_RESULT_STR(info.linkDestination, NULL, " check link destination");
TEST_RESULT_STR_Z(info.user, testUser(), " check user");
TEST_RESULT_STR_Z(info.group, testGroup(), " check group");
storageRemoveP(storageTest, pipeName, .errorOnMissing = true);
}
@ -393,14 +393,12 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_VOID(
storagePutP(storageNewWriteP(storageTest, strNew(".aaa.txt")), BUFSTRDEF("aaa")), "write aaa.text");
TEST_RESULT_STR(
strPtr(strLstJoin(strLstSort(storageListP(storageTest, NULL), sortOrderAsc), ", ")), ".aaa.txt, noperm",
"dir list");
TEST_RESULT_STR_Z(
strLstJoin(strLstSort(storageListP(storageTest, NULL), sortOrderAsc), ", "), ".aaa.txt, noperm", "dir list");
TEST_RESULT_VOID(
storagePutP(storageNewWriteP(storageTest, strNew("bbb.txt")), BUFSTRDEF("bbb")), "write bbb.text");
TEST_RESULT_STR(
strPtr(strLstJoin(storageListP(storageTest, NULL, .expression = strNew("^bbb")), ", ")), "bbb.txt", "dir list");
TEST_RESULT_STR_Z(strLstJoin(storageListP(storageTest, NULL, .expression = strNew("^bbb")), ", "), "bbb.txt", "dir list");
}
// *****************************************************************************************************************************
@ -472,9 +470,8 @@ testRun(void)
TEST_RESULT_VOID(storageMoveP(storageTest, source, destination), "move file to subpath");
TEST_RESULT_BOOL(storageExistsP(storageTest, sourceFile), false, "check source file not exists");
TEST_RESULT_BOOL(storageExistsP(storageTest, destinationFile), true, "check destination file exists");
TEST_RESULT_STR(
strPtr(strNewBuf(storageGetP(storageNewReadP(storageTest, destinationFile)))), "TESTFILE",
"check destination contents");
TEST_RESULT_STR_Z(
strNewBuf(storageGetP(storageNewReadP(storageTest, destinationFile))), "TESTFILE", "check destination contents");
// -------------------------------------------------------------------------------------------------------------------------
sourceFile = destinationFile;
@ -523,9 +520,9 @@ testRun(void)
Storage *storageTest = NULL;
TEST_ASSIGN(storageTest, storagePosixNew(strNew("/"), 0640, 0750, false, NULL), "new storage /");
TEST_RESULT_STR(strPtr(storagePathP(storageTest, NULL)), "/", " root dir");
TEST_RESULT_STR(strPtr(storagePathP(storageTest, strNew("/"))), "/", " same as root dir");
TEST_RESULT_STR(strPtr(storagePathP(storageTest, strNew("subdir"))), "/subdir", " simple subdir");
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("subdir")), "/subdir", " simple subdir");
TEST_ERROR(
storagePathP(storageTest, strNew("<TEST>")), AssertError, "expression '<TEST>' not valid without callback function");
@ -534,9 +531,9 @@ testRun(void)
TEST_ASSIGN(
storageTest, storagePosixNew(strNew("/path/to"), 0640, 0750, false, storageTestPathExpression),
"new storage /path/to with expression");
TEST_RESULT_STR(strPtr(storagePathP(storageTest, NULL)), "/path/to", " root dir");
TEST_RESULT_STR(strPtr(storagePathP(storageTest, strNew("/path/to"))), "/path/to", " absolute root dir");
TEST_RESULT_STR(strPtr(storagePathP(storageTest, strNew("is/a/subdir"))), "/path/to/is/a/subdir", " subdir");
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("is/a/subdir")), "/path/to/is/a/subdir", " subdir");
TEST_ERROR(
storagePathP(storageTest, strNew("/bogus")), AssertError, "absolute path '/bogus' is not in base path '/path/to'");
@ -545,18 +542,18 @@ testRun(void)
"absolute path '/path/toot' is not in base path '/path/to'");
// Path enforcement disabled for a single call
TEST_RESULT_STR(strPtr(storagePathP(storageTest, strNew("/bogus"), .noEnforce = true)), "/bogus", "path enforce disabled");
TEST_RESULT_STR_Z(storagePathP(storageTest, strNew("/bogus"), .noEnforce = true), "/bogus", "path enforce disabled");
TEST_ERROR(storagePathP(storageTest, strNew("<TEST")), AssertError, "end > not found in path expression '<TEST'");
TEST_ERROR(
storagePathP(storageTest, strNew("<TEST>" BOGUS_STR)), AssertError,
"'/' should separate expression and path '<TEST>BOGUS'");
TEST_RESULT_STR(strPtr(storagePathP(storageTest, strNew("<TEST>"))), "/path/to/test", " expression");
TEST_RESULT_STR_Z(storagePathP(storageTest, strNew("<TEST>")), "/path/to/test", " expression");
TEST_ERROR(strPtr(storagePathP(storageTest, strNew("<TEST>/"))), AssertError, "path '<TEST>/' should not end in '/'");
TEST_RESULT_STR(
strPtr(storagePathP(storageTest, strNew("<TEST>/something"))), "/path/to/test/something", " expression with path");
TEST_RESULT_STR_Z(
storagePathP(storageTest, strNew("<TEST>/something")), "/path/to/test/something", " expression with path");
TEST_ERROR(storagePathP(storageTest, strNew("<NULL>")), AssertError, "evaluated path '<NULL>' cannot be null");
@ -827,7 +824,7 @@ testRun(void)
TEST_ASSIGN(file, storageNewReadP(storageTest, fileNoPerm, .ignoreMissing = true), "new read file");
TEST_RESULT_PTR(storageRead(file), file->driver, " check driver");
TEST_RESULT_BOOL(storageReadIgnoreMissing(file), true, " check ignore missing");
TEST_RESULT_STR(strPtr(storageReadName(file)), strPtr(fileNoPerm), " check name");
TEST_RESULT_STR(storageReadName(file), fileNoPerm, " check name");
// -------------------------------------------------------------------------------------------------------------------------
TEST_ASSIGN(file, storageNewReadP(storageTest, fileNoPerm), "new no perm read file");
@ -872,8 +869,8 @@ testRun(void)
MEM_CONTEXT_TEMP_END();
TEST_RESULT_BOOL(ioReadOpen(storageReadIo(file)), true, " open file");
TEST_RESULT_STR(strPtr(storageReadName(file)), strPtr(fileName), " check file name");
TEST_RESULT_STR(strPtr(storageReadType(file)), "posix", " check file type");
TEST_RESULT_STR(storageReadName(file), fileName, " check file name");
TEST_RESULT_STR_Z(storageReadType(file), "posix", " check file type");
TEST_RESULT_VOID(ioRead(storageReadIo(file), outBuffer), " load data");
bufCat(buffer, outBuffer);
@ -931,7 +928,7 @@ testRun(void)
TEST_RESULT_PTR(storageWriteDriver(file), file->driver, " check file driver");
TEST_RESULT_INT(storageWriteModeFile(file), 0444, " check mode file");
TEST_RESULT_INT(storageWriteModePath(file), 0555, " check mode path");
TEST_RESULT_STR(strPtr(storageWriteName(file)), strPtr(fileNoPerm), " check name");
TEST_RESULT_STR(storageWriteName(file), fileNoPerm, " check name");
TEST_RESULT_BOOL(storageWriteSyncPath(file), false, " check sync path");
TEST_RESULT_BOOL(storageWriteSyncFile(file), false, " check sync file");
@ -953,7 +950,7 @@ testRun(void)
const Buffer *buffer = BUFSTRDEF("TESTFILE\n");
TEST_ASSIGN(file, storageNewWriteP(storageTest, fileName), "new write file");
TEST_RESULT_STR(strPtr(storageWriteName(file)), strPtr(fileName), " check file name");
TEST_RESULT_STR(storageWriteName(file), fileName, " check file name");
TEST_RESULT_VOID(ioWriteOpen(storageWriteIo(file)), " open file");
// Close the file handle so operations will fail
@ -979,8 +976,8 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
TEST_ASSIGN(file, storageNewWriteP(storageTest, fileName), "new write file");
TEST_RESULT_STR(strPtr(storageWriteName(file)), strPtr(fileName), " check file name");
TEST_RESULT_STR(strPtr(storageWriteType(file)), "posix", " check file type");
TEST_RESULT_STR(storageWriteName(file), fileName, " check file name");
TEST_RESULT_STR_Z(storageWriteType(file), "posix", " check file type");
TEST_RESULT_VOID(ioWriteOpen(storageWriteIo(file)), " open file");
// Rename the file back to original name from tmp -- this will cause the rename in close to fail
@ -1047,7 +1044,7 @@ testRun(void)
TEST_RESULT_PTR(storageHelper.storageLocal, storage, "local storage cached");
TEST_RESULT_PTR(storageLocal(), storage, "get cached storage");
TEST_RESULT_STR(strPtr(storagePathP(storage, NULL)), "/", "check base path");
TEST_RESULT_STR_Z(storagePathP(storage, NULL), "/", "check base path");
TEST_ERROR(storageNewWriteP(storage, writeFile), AssertError, "assertion 'this->write' failed");
@ -1057,7 +1054,7 @@ testRun(void)
TEST_RESULT_PTR(storageHelper.storageLocalWrite, storage, "local storage cached");
TEST_RESULT_PTR(storageLocalWrite(), storage, "get cached storage");
TEST_RESULT_STR(strPtr(storagePathP(storage, NULL)), "/", "check base path");
TEST_RESULT_STR_Z(storagePathP(storage, NULL), "/", "check base path");
TEST_RESULT_VOID(storageNewWriteP(storage, writeFile), "writes are allowed");
}
@ -1085,26 +1082,24 @@ testRun(void)
TEST_ERROR(storagePathP(storage, strNew("<BOGUS>/path")), AssertError, "invalid expression '<BOGUS>'");
TEST_ERROR(storageNewWriteP(storage, writeFile), AssertError, "assertion 'this->write' failed");
TEST_RESULT_STR(strPtr(storagePathP(storage, NULL)), testPath(), "check base path");
TEST_RESULT_STR_Z(storagePathP(storage, NULL), testPath(), "check base path");
TEST_RESULT_STR(
strPtr(storagePathP(storage, STORAGE_REPO_ARCHIVE_STR)), strPtr(strNewFmt("%s/archive/db", testPath())),
"check archive path");
storagePathP(storage, STORAGE_REPO_ARCHIVE_STR), strNewFmt("%s/archive/db", testPath()), "check archive path");
TEST_RESULT_STR(
strPtr(storagePathP(storage, strNew(STORAGE_REPO_ARCHIVE "/simple"))),
strPtr(strNewFmt("%s/archive/db/simple", testPath())), "check simple path");
storagePathP(storage, strNew(STORAGE_REPO_ARCHIVE "/simple")), strNewFmt("%s/archive/db/simple", testPath()),
"check simple path");
TEST_RESULT_STR(
strPtr(storagePathP(storage, strNew(STORAGE_REPO_ARCHIVE "/9.4-1/700000007000000070000000"))),
strPtr(strNewFmt("%s/archive/db/9.4-1/7000000070000000/700000007000000070000000", testPath())), "check segment path");
storagePathP(storage, strNew(STORAGE_REPO_ARCHIVE "/9.4-1/700000007000000070000000")),
strNewFmt("%s/archive/db/9.4-1/7000000070000000/700000007000000070000000", testPath()), "check segment path");
TEST_RESULT_STR(
strPtr(storagePathP(storage, strNew(STORAGE_REPO_ARCHIVE "/9.4-1/00000008.history"))),
strPtr(strNewFmt("%s/archive/db/9.4-1/00000008.history", testPath())), "check history path");
storagePathP(storage, strNew(STORAGE_REPO_ARCHIVE "/9.4-1/00000008.history")),
strNewFmt("%s/archive/db/9.4-1/00000008.history", testPath()), "check history path");
TEST_RESULT_STR(
strPtr(storagePathP(storage, strNew(STORAGE_REPO_ARCHIVE "/9.4-1/000000010000014C0000001A.00000028.backup"))),
strPtr(strNewFmt("%s/archive/db/9.4-1/000000010000014C/000000010000014C0000001A.00000028.backup", testPath())),
storagePathP(storage, strNew(STORAGE_REPO_ARCHIVE "/9.4-1/000000010000014C0000001A.00000028.backup")),
strNewFmt("%s/archive/db/9.4-1/000000010000014C/000000010000014C0000001A.00000028.backup", testPath()),
"check archive backup path");
TEST_RESULT_STR(
strPtr(storagePathP(storage, STORAGE_REPO_BACKUP_STR)), strPtr(strNewFmt("%s/backup/db", testPath())),
"check backup path");
storagePathP(storage, STORAGE_REPO_BACKUP_STR), strNewFmt("%s/backup/db", testPath()), "check backup path");
// Change the stanza to NULL with the stanzaInit flag still true, make sure helper does not fail when stanza option not set
// -------------------------------------------------------------------------------------------------------------------------
@ -1116,17 +1111,17 @@ testRun(void)
TEST_RESULT_PTR(storageHelper.stanza, NULL, "stanza NULL");
TEST_RESULT_STR(
strPtr(storagePathP(storage, STORAGE_REPO_ARCHIVE_STR)), strPtr(strNewFmt("%s/archive", testPath())),
storagePathP(storage, STORAGE_REPO_ARCHIVE_STR), strNewFmt("%s/archive", testPath()),
"check archive path - NULL stanza");
TEST_RESULT_STR(
strPtr(storagePathP(storage, strNew(STORAGE_REPO_ARCHIVE "/simple"))),
strPtr(strNewFmt("%s/archive/simple", testPath())), "check simple archive path - NULL stanza");
storagePathP(storage, strNew(STORAGE_REPO_ARCHIVE "/simple")),
strNewFmt("%s/archive/simple", testPath()), "check simple archive path - NULL stanza");
TEST_RESULT_STR(
strPtr(storagePathP(storage, STORAGE_REPO_BACKUP_STR)), strPtr(strNewFmt("%s/backup", testPath())),
storagePathP(storage, STORAGE_REPO_BACKUP_STR), strNewFmt("%s/backup", testPath()),
"check backup path - NULL stanza");
TEST_RESULT_STR(
strPtr(storagePathP(storage, strNew(STORAGE_REPO_BACKUP "/simple"))),
strPtr(strNewFmt("%s/backup/simple", testPath())), "check simple backup path - NULL stanza");
storagePathP(storage, strNew(STORAGE_REPO_BACKUP "/simple")),
strNewFmt("%s/backup/simple", testPath()), "check simple backup path - NULL stanza");
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_PTR(storageHelper.storageRepoWrite, NULL, "repo write storage not cached");
@ -1157,20 +1152,20 @@ testRun(void)
TEST_RESULT_PTR(storageSpool(), storage, "get cached storage");
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_STR(strPtr(storagePathP(storage, NULL)), testPath(), "check base path");
TEST_RESULT_STR_Z(storagePathP(storage, NULL), testPath(), "check base path");
TEST_RESULT_STR(
strPtr(storagePathP(storage, strNew(STORAGE_SPOOL_ARCHIVE_OUT))), strPtr(strNewFmt("%s/archive/db/out", testPath())),
storagePathP(storage, strNew(STORAGE_SPOOL_ARCHIVE_OUT)), strNewFmt("%s/archive/db/out", testPath()),
"check spool out path");
TEST_RESULT_STR(
strPtr(storagePathP(storage, strNewFmt("%s/%s", STORAGE_SPOOL_ARCHIVE_OUT, "file.ext"))),
strPtr(strNewFmt("%s/archive/db/out/file.ext", testPath())), "check spool out file");
storagePathP(storage, strNewFmt("%s/%s", STORAGE_SPOOL_ARCHIVE_OUT, "file.ext")),
strNewFmt("%s/archive/db/out/file.ext", testPath()), "check spool out file");
TEST_RESULT_STR(
strPtr(storagePathP(storage, strNew(STORAGE_SPOOL_ARCHIVE_IN))), strPtr(strNewFmt("%s/archive/db/in", testPath())),
storagePathP(storage, strNew(STORAGE_SPOOL_ARCHIVE_IN)), strNewFmt("%s/archive/db/in", testPath()),
"check spool in path");
TEST_RESULT_STR(
strPtr(storagePathP(storage, strNewFmt("%s/%s", STORAGE_SPOOL_ARCHIVE_IN, "file.ext"))),
strPtr(strNewFmt("%s/archive/db/in/file.ext", testPath())), "check spool in file");
storagePathP(storage, strNewFmt("%s/%s", STORAGE_SPOOL_ARCHIVE_IN, "file.ext")),
strNewFmt("%s/archive/db/in/file.ext", testPath()), "check spool in file");
TEST_ERROR(storagePathP(storage, strNew("<" BOGUS_STR ">")), AssertError, "invalid expression '<BOGUS>'");
@ -1190,18 +1185,17 @@ testRun(void)
TEST_RESULT_PTR(storageHelper.storagePg[0], storage, "pg storage cached");
TEST_RESULT_PTR(storagePg(), storage, "get cached pg storage");
TEST_RESULT_STR(strPtr(storage->path), strPtr(strNewFmt("%s/db", testPath())), "check pg storage path");
TEST_RESULT_STR(storage->path, strNewFmt("%s/db", testPath()), "check pg storage path");
TEST_RESULT_BOOL(storage->write, false, "check pg storage write");
TEST_RESULT_STR(strPtr(storagePgId(2)->path), strPtr(strNewFmt("%s/db2", testPath())), "check pg 2 storage path");
TEST_RESULT_STR(storagePgId(2)->path, strNewFmt("%s/db2", testPath()), "check pg 2 storage path");
TEST_RESULT_PTR(storageHelper.storagePgWrite, NULL, "pg write storage not cached");
TEST_ASSIGN(storage, storagePgWrite(), "new pg write storage");
TEST_RESULT_PTR(storageHelper.storagePgWrite[0], storage, "pg write storage cached");
TEST_RESULT_PTR(storagePgWrite(), storage, "get cached pg write storage");
TEST_RESULT_STR(
strPtr(storagePgIdWrite(2)->path), strPtr(strNewFmt("%s/db2", testPath())), "check pg 2 write storage path");
TEST_RESULT_STR(storagePgIdWrite(2)->path, strNewFmt("%s/db2", testPath()), "check pg 2 write storage path");
TEST_RESULT_STR(strPtr(storage->path), strPtr(strNewFmt("%s/db", testPath())), "check pg write storage path");
TEST_RESULT_STR(storage->path, strNewFmt("%s/db", testPath()), "check pg write storage path");
TEST_RESULT_BOOL(storage->write, true, "check pg write storage write");
// Pg storage from another host id
@ -1209,7 +1203,7 @@ testRun(void)
cfgOptionSet(cfgOptHostId, cfgSourceParam, VARUINT64(2));
cfgOptionValidSet(cfgOptHostId, true);
TEST_RESULT_STR(strPtr(storagePg()->path), strPtr(strNewFmt("%s/db2", testPath())), "check pg-2 storage path");
TEST_RESULT_STR(storagePg()->path, strNewFmt("%s/db2", testPath()), "check pg-2 storage path");
// Change the stanza to NULL, stanzaInit flag to false and make sure helper fails because stanza is required
// -------------------------------------------------------------------------------------------------------------------------

View File

@ -65,13 +65,13 @@ testRun(void)
TEST_RESULT_UINT(storageInterface(storageRemote).feature, storageInterface(storageTest).feature, " check features");
TEST_RESULT_BOOL(storageFeature(storageRemote, storageFeaturePath), true, " check path feature");
TEST_RESULT_BOOL(storageFeature(storageRemote, storageFeatureCompress), true, " check compress feature");
TEST_RESULT_STR_STR(storagePathP(storageRemote, NULL), strNewFmt("%s/repo", testPath()), " check path");
TEST_RESULT_STR(storagePathP(storageRemote, NULL), strNewFmt("%s/repo", testPath()), " check path");
// Check protocol function directly
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_BOOL(
storageRemoteProtocol(PROTOCOL_COMMAND_STORAGE_FEATURE_STR, varLstNew(), server), true, "protocol feature");
TEST_RESULT_STR_STR(
TEST_RESULT_STR(
strNewBuf(serverWrite),
strNewFmt(".\"%s/repo\"\n.%" PRIu64 "\n{}\n", testPath(), storageInterface(storageTest).feature),
"check result");
@ -106,7 +106,7 @@ testRun(void)
TEST_RESULT_BOOL(
storageRemoteProtocol(PROTOCOL_COMMAND_STORAGE_EXISTS_STR, paramList, server), true, "protocol exists");
TEST_RESULT_STR(strPtr(strNewBuf(serverWrite)), "{\"out\":true}\n", "check result");
TEST_RESULT_STR_Z(strNewBuf(serverWrite), "{\"out\":true}\n", "check result");
bufUsedSet(serverWrite, 0);
@ -152,9 +152,9 @@ testRun(void)
TEST_RESULT_UINT(info.timeModified, 1555160000, " check mod time");
TEST_RESULT_PTR(info.linkDestination, NULL, " no link destination");
TEST_RESULT_UINT(info.userId, getuid(), " check user id");
TEST_RESULT_STR(strPtr(info.user), testUser(), " check user");
TEST_RESULT_STR_Z(info.user, testUser(), " check user");
TEST_RESULT_UINT(info.groupId, getgid(), " check group id");
TEST_RESULT_STR(strPtr(info.group), testGroup(), " check group");
TEST_RESULT_STR_Z(info.group, testGroup(), " check group");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("file info");
@ -170,9 +170,9 @@ testRun(void)
TEST_RESULT_UINT(info.timeModified, 1555160001, " check mod time");
TEST_RESULT_PTR(info.linkDestination, NULL, " no link destination");
TEST_RESULT_UINT(info.userId, getuid(), " check user id");
TEST_RESULT_STR(strPtr(info.user), testUser(), " check user");
TEST_RESULT_STR_Z(info.user, testUser(), " check user");
TEST_RESULT_UINT(info.groupId, getgid(), " check group id");
TEST_RESULT_STR(strPtr(info.group), testGroup(), " check group");
TEST_RESULT_STR_Z(info.group, testGroup(), " check group");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("special info");
@ -187,9 +187,9 @@ testRun(void)
TEST_RESULT_INT(info.mode, 0666, " check mode");
TEST_RESULT_PTR(info.linkDestination, NULL, " no link destination");
TEST_RESULT_UINT(info.userId, getuid(), " check user id");
TEST_RESULT_STR(strPtr(info.user), testUser(), " check user");
TEST_RESULT_STR_Z(info.user, testUser(), " check user");
TEST_RESULT_UINT(info.groupId, getgid(), " check group id");
TEST_RESULT_STR(strPtr(info.group), testGroup(), " check group");
TEST_RESULT_STR_Z(info.group, testGroup(), " check group");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("link info");
@ -204,9 +204,9 @@ testRun(void)
TEST_RESULT_INT(info.mode, 0777, " check mode");
TEST_RESULT_STR_Z(info.linkDestination, "../repo/test", " check link destination");
TEST_RESULT_UINT(info.userId, getuid(), " check user id");
TEST_RESULT_STR(strPtr(info.user), testUser(), " check user");
TEST_RESULT_STR_Z(info.user, testUser(), " check user");
TEST_RESULT_UINT(info.groupId, getgid(), " check group id");
TEST_RESULT_STR(strPtr(info.group), testGroup(), " check group");
TEST_RESULT_STR_Z(info.group, testGroup(), " check group");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("link info follow");
@ -219,9 +219,9 @@ testRun(void)
TEST_RESULT_INT(info.mode, 0640, " check mode");
TEST_RESULT_PTR(info.linkDestination, NULL, " no link destination");
TEST_RESULT_UINT(info.userId, getuid(), " check user id");
TEST_RESULT_STR(strPtr(info.user), testUser(), " check user");
TEST_RESULT_STR_Z(info.user, testUser(), " check user");
TEST_RESULT_UINT(info.groupId, getgid(), " check group id");
TEST_RESULT_STR(strPtr(info.group), testGroup(), " check group");
TEST_RESULT_STR_Z(info.group, testGroup(), " check group");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("protocol storage types that are not tested elsewhere");
@ -230,7 +230,7 @@ testRun(void)
TEST_RESULT_VOID(storageRemoteInfoWriteType(server, storageTypeSpecial), "write special type");
ioWriteFlush(serverWriteIo);
TEST_RESULT_STR(strPtr(strNewBuf(serverWrite)), ".p\n.s\n", "check result");
TEST_RESULT_STR_Z(strNewBuf(serverWrite), ".p\n.s\n", "check result");
bufUsedSet(serverWrite, 0);
@ -241,7 +241,7 @@ testRun(void)
TEST_RESULT_VOID(storageRemoteInfoWrite(server, &info), "write link info");
ioWriteFlush(serverWriteIo);
TEST_RESULT_STR(strPtr(strNewBuf(serverWrite)), ".l\n.0\n.null\n.0\n.null\n.0\n.0\n.\"../\"\n", "check result");
TEST_RESULT_STR_Z(strNewBuf(serverWrite), ".l\n.0\n.null\n.0\n.null\n.0\n.0\n.\"../\"\n", "check result");
bufUsedSet(serverWrite, 0);
@ -253,7 +253,7 @@ testRun(void)
varLstAdd(paramList, varNewBool(false));
TEST_RESULT_BOOL(storageRemoteProtocol(PROTOCOL_COMMAND_STORAGE_INFO_STR, paramList, server), true, "protocol list");
TEST_RESULT_STR(strPtr(strNewBuf(serverWrite)), "{\"out\":false}\n", "check result");
TEST_RESULT_STR_Z(strNewBuf(serverWrite), "{\"out\":false}\n", "check result");
bufUsedSet(serverWrite, 0);
@ -265,8 +265,8 @@ testRun(void)
varLstAdd(paramList, varNewBool(false));
TEST_RESULT_BOOL(storageRemoteProtocol(PROTOCOL_COMMAND_STORAGE_INFO_STR, paramList, server), true, "protocol list");
TEST_RESULT_STR(
strPtr(strNewBuf(serverWrite)),
TEST_RESULT_STR_Z(
strNewBuf(serverWrite),
hrnReplaceKey(
"{\"out\":true}\n"
".f\n.{[user-id]}\n.\"{[user]}\"\n.{[group-id]}\n.\"{[group]}\"\n.416\n.1555160001\n.6\n"
@ -324,8 +324,8 @@ testRun(void)
varLstAdd(paramList, varNewStrZ(hrnReplaceKey("{[path]}/repo")));
TEST_RESULT_BOOL(storageRemoteProtocol(PROTOCOL_COMMAND_STORAGE_INFO_LIST_STR, paramList, server), true, "call protocol");
TEST_RESULT_STR(
strPtr(strNewBuf(serverWrite)),
TEST_RESULT_STR_Z(
strNewBuf(serverWrite),
hrnReplaceKey(
".\".\"\n.p\n.{[user-id]}\n.\"{[user]}\"\n.{[group-id]}\n.\"{[group]}\"\n.488\n.1555160000\n"
".\"test\"\n.f\n.{[user-id]}\n.\"{[user]}\"\n.{[group-id]}\n.\"{[group]}\"\n.416\n.1555160001\n.6\n"
@ -348,11 +348,11 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
storagePathCreateP(storageTest, strNew("repo/testy"));
TEST_RESULT_STR(strPtr(strLstJoin(storageListP(storageRemote, NULL), ",")), "testy" , "list path");
TEST_RESULT_STR_Z(strLstJoin(storageListP(storageRemote, NULL), ","), "testy" , "list path");
storagePathCreateP(storageTest, strNew("repo/testy2\""));
TEST_RESULT_STR(
strPtr(strLstJoin(strLstSort(storageListP(storageRemote, strNewFmt("%s/repo", testPath())), sortOrderAsc), ",")),
TEST_RESULT_STR_Z(
strLstJoin(strLstSort(storageListP(storageRemote, strNewFmt("%s/repo", testPath())), sortOrderAsc), ","),
"testy,testy2\"" , "list 2 paths");
// Check protocol function directly
@ -362,7 +362,7 @@ testRun(void)
varLstAdd(paramList, varNewStr(strNew("^testy$")));
TEST_RESULT_BOOL(storageRemoteProtocol(PROTOCOL_COMMAND_STORAGE_LIST_STR, paramList, server), true, "protocol list");
TEST_RESULT_STR(strPtr(strNewBuf(serverWrite)), "{\"out\":[\"testy\"]}\n", "check result");
TEST_RESULT_STR_Z(strNewBuf(serverWrite), "{\"out\":[\"testy\"]}\n", "check result");
bufUsedSet(serverWrite, 0);
}
@ -430,7 +430,7 @@ testRun(void)
TEST_RESULT_BOOL(
storageRemoteProtocol(PROTOCOL_COMMAND_STORAGE_OPEN_READ_STR, paramList, server), true,
"protocol open read (missing)");
TEST_RESULT_STR(strPtr(strNewBuf(serverWrite)), "{\"out\":false}\n", "check result");
TEST_RESULT_STR_Z(strNewBuf(serverWrite), "{\"out\":false}\n", "check result");
bufUsedSet(serverWrite, 0);
@ -456,8 +456,8 @@ testRun(void)
TEST_RESULT_BOOL(
storageRemoteProtocol(PROTOCOL_COMMAND_STORAGE_OPEN_READ_STR, paramList, server), true, "protocol open read");
TEST_RESULT_STR(
strPtr(strNewBuf(serverWrite)),
TEST_RESULT_STR_Z(
strNewBuf(serverWrite),
"{\"out\":true}\n"
"BRBLOCK4\n"
"TESTBRBLOCK4\n"
@ -485,8 +485,8 @@ testRun(void)
TEST_RESULT_BOOL(
storageRemoteProtocol(PROTOCOL_COMMAND_STORAGE_OPEN_READ_STR, paramList, server), true, "protocol open read (sink)");
TEST_RESULT_STR(
strPtr(strNewBuf(serverWrite)),
TEST_RESULT_STR_Z(
strNewBuf(serverWrite),
"{\"out\":true}\n"
"BRBLOCK0\n"
"{\"out\":{\"buffer\":null,\"hash\":\"bbbcf2c59433f68f22376cd2439d6cd309378df6\",\"sink\":null,\"size\":8}}\n",
@ -536,7 +536,7 @@ testRun(void)
TEST_RESULT_BOOL(storageWriteCreatePath(write), true, "path will be created");
TEST_RESULT_UINT(storageWriteModeFile(write), STORAGE_MODE_FILE_DEFAULT, "file mode is default");
TEST_RESULT_UINT(storageWriteModePath(write), STORAGE_MODE_PATH_DEFAULT, "path mode is default");
TEST_RESULT_STR(strPtr(storageWriteName(write)), hrnReplaceKey("{[path]}/repo/test.txt"), "check file name");
TEST_RESULT_STR_Z(storageWriteName(write), hrnReplaceKey("{[path]}/repo/test.txt"), "check file name");
TEST_RESULT_BOOL(storageWriteSyncFile(write), true, "file is synced");
TEST_RESULT_BOOL(storageWriteSyncPath(write), true, "path is synced");
@ -601,14 +601,14 @@ testRun(void)
TEST_RESULT_BOOL(
storageRemoteProtocol(PROTOCOL_COMMAND_STORAGE_OPEN_WRITE_STR, paramList, server), true, "protocol open write");
TEST_RESULT_STR(
strPtr(strNewBuf(serverWrite)),
TEST_RESULT_STR_Z(
strNewBuf(serverWrite),
"{}\n"
"{\"out\":{\"buffer\":null,\"size\":18}}\n",
"{\"out\":{\"buffer\":null,\"size\":18}}\n",
"check result");
TEST_RESULT_STR(
strPtr(strNewBuf(storageGetP(storageNewReadP(storageTest, strNew("repo/test3.txt"))))), "ABC123456789012345",
TEST_RESULT_STR_Z(
strNewBuf(storageGetP(storageNewReadP(storageTest, strNew("repo/test3.txt")))), "ABC123456789012345",
"check file");
bufUsedSet(serverWrite, 0);
@ -632,18 +632,17 @@ testRun(void)
TEST_RESULT_BOOL(
storageRemoteProtocol(PROTOCOL_COMMAND_STORAGE_OPEN_WRITE_STR, paramList, server), true, "protocol open write");
TEST_RESULT_STR(
strPtr(strNewBuf(serverWrite)),
TEST_RESULT_STR_Z(
strNewBuf(serverWrite),
"{}\n"
"{}\n",
"{}\n",
"check result");
bufUsedSet(serverWrite, 0);
ioBufferSizeSet(8192);
TEST_RESULT_STR(
strPtr(strNewBuf(storageGetP(storageNewReadP(storageTest, strNew("repo/test4.txt.pgbackrest.tmp"))))), "",
"check file");
TEST_RESULT_STR_Z(
strNewBuf(storageGetP(storageNewReadP(storageTest, strNew("repo/test4.txt.pgbackrest.tmp")))), "", "check file");
}
// *****************************************************************************************************************************
@ -663,7 +662,7 @@ testRun(void)
TEST_RESULT_BOOL(
storageRemoteProtocol(PROTOCOL_COMMAND_STORAGE_PATH_EXISTS_STR, paramList, server), true, "protocol path exists");
TEST_RESULT_STR(strPtr(strNewBuf(serverWrite)), "{\"out\":false}\n", "check result");
TEST_RESULT_STR_Z(strNewBuf(serverWrite), "{\"out\":false}\n", "check result");
bufUsedSet(serverWrite, 0);
}
@ -722,7 +721,7 @@ testRun(void)
TEST_ASSIGN(info, storageInfoP(storageTest, strNewFmt("repo/%s", strPtr(path))), " get path info");
TEST_RESULT_BOOL(info.exists, true, " path exists");
TEST_RESULT_INT(info.mode, 0777, " mode is set");
TEST_RESULT_STR(strPtr(strNewBuf(serverWrite)), "{}\n", " check result");
TEST_RESULT_STR_Z(strNewBuf(serverWrite), "{}\n", " check result");
bufUsedSet(serverWrite, 0);
}
@ -750,7 +749,7 @@ testRun(void)
TEST_RESULT_BOOL(
storageRemoteProtocol(PROTOCOL_COMMAND_STORAGE_PATH_REMOVE_STR, paramList, server), true,
" protocol path remove missing");
TEST_RESULT_STR(strPtr(strNewBuf(serverWrite)), "{\"out\":false}\n", " check result");
TEST_RESULT_STR_Z(strNewBuf(serverWrite), "{\"out\":false}\n", " check result");
bufUsedSet(serverWrite, 0);
@ -762,7 +761,7 @@ testRun(void)
storageRemoteProtocol(PROTOCOL_COMMAND_STORAGE_PATH_REMOVE_STR, paramList, server), true,
" protocol path recurse remove");
TEST_RESULT_BOOL(storagePathExistsP(storageTest, strNewFmt("repo/%s", strPtr(path))), false, " recurse path removed");
TEST_RESULT_STR(strPtr(strNewBuf(serverWrite)), "{\"out\":true}\n", " check result");
TEST_RESULT_STR_Z(strNewBuf(serverWrite), "{\"out\":true}\n", " check result");
bufUsedSet(serverWrite, 0);
}
@ -802,7 +801,7 @@ testRun(void)
TEST_RESULT_BOOL(
storageRemoteProtocol(PROTOCOL_COMMAND_STORAGE_REMOVE_STR, paramList, server), true,
"protocol file remove - no error on missing");
TEST_RESULT_STR(strPtr(strNewBuf(serverWrite)), "{}\n", " check result");
TEST_RESULT_STR_Z(strNewBuf(serverWrite), "{}\n", " check result");
bufUsedSet(serverWrite, 0);
// Write the file to the repo via the remote and test the protocol
@ -811,7 +810,7 @@ testRun(void)
storageRemoteProtocol(PROTOCOL_COMMAND_STORAGE_REMOVE_STR, paramList, server), true,
"protocol file remove");
TEST_RESULT_BOOL(storageExistsP(storageTest, strNewFmt("repo/%s", strPtr(file))), false, " confirm file removed");
TEST_RESULT_STR(strPtr(strNewBuf(serverWrite)), "{}\n", " check result");
TEST_RESULT_STR_Z(strNewBuf(serverWrite), "{}\n", " check result");
bufUsedSet(serverWrite, 0);
}
@ -835,7 +834,7 @@ testRun(void)
TEST_RESULT_BOOL(
storageRemoteProtocol(PROTOCOL_COMMAND_STORAGE_PATH_SYNC_STR, paramList, server), true,
"protocol path sync");
TEST_RESULT_STR(strPtr(strNewBuf(serverWrite)), "{}\n", " check result");
TEST_RESULT_STR_Z(strNewBuf(serverWrite), "{}\n", " check result");
bufUsedSet(serverWrite, 0);
paramList = varLstNew();

View File

@ -536,15 +536,13 @@ testRun(void)
Storage *storage = NULL;
TEST_ASSIGN(storage, storageRepoGet(strNew(STORAGE_TYPE_S3), false), "get S3 repo storage");
TEST_RESULT_STR(strPtr(storage->path), strPtr(path), " check path");
TEST_RESULT_STR(strPtr(((StorageS3 *)storage->driver)->bucket), strPtr(bucket), " check bucket");
TEST_RESULT_STR(strPtr(((StorageS3 *)storage->driver)->region), strPtr(region), " check region");
TEST_RESULT_STR(storage->path, path, " check path");
TEST_RESULT_STR(((StorageS3 *)storage->driver)->bucket, bucket, " check bucket");
TEST_RESULT_STR(((StorageS3 *)storage->driver)->region, region, " check region");
TEST_RESULT_STR(
strPtr(((StorageS3 *)storage->driver)->bucketEndpoint), strPtr(strNewFmt("%s.%s", strPtr(bucket), strPtr(endPoint))),
" check host");
TEST_RESULT_STR(strPtr(((StorageS3 *)storage->driver)->accessKey), strPtr(accessKey), " check access key");
TEST_RESULT_STR(
strPtr(((StorageS3 *)storage->driver)->secretAccessKey), strPtr(secretAccessKey), " check secret access key");
((StorageS3 *)storage->driver)->bucketEndpoint, strNewFmt("%s.%s", strPtr(bucket), strPtr(endPoint)), " check host");
TEST_RESULT_STR(((StorageS3 *)storage->driver)->accessKey, accessKey, " check access key");
TEST_RESULT_STR(((StorageS3 *)storage->driver)->secretAccessKey, secretAccessKey, " check secret access key");
TEST_RESULT_PTR(((StorageS3 *)storage->driver)->securityToken, NULL, " check security token");
TEST_RESULT_BOOL(storageFeature(storage, storageFeaturePath), false, " check path feature");
TEST_RESULT_BOOL(storageFeature(storage, storageFeatureCompress), false, " check compress feature");
@ -567,17 +565,14 @@ testRun(void)
harnessCfgLoad(cfgCmdArchiveGet, argList);
TEST_ASSIGN(storage, storageRepoGet(strNew(STORAGE_TYPE_S3), false), "get S3 repo storage with options");
TEST_RESULT_STR(strPtr(((StorageS3 *)storage->driver)->bucket), strPtr(bucket), " check bucket");
TEST_RESULT_STR(strPtr(((StorageS3 *)storage->driver)->region), strPtr(region), " check region");
TEST_RESULT_STR(((StorageS3 *)storage->driver)->bucket, bucket, " check bucket");
TEST_RESULT_STR(((StorageS3 *)storage->driver)->region, region, " check region");
TEST_RESULT_STR(
strPtr(((StorageS3 *)storage->driver)->bucketEndpoint), strPtr(strNewFmt("%s.%s", strPtr(bucket), strPtr(endPoint))),
" check host");
((StorageS3 *)storage->driver)->bucketEndpoint, strNewFmt("%s.%s", strPtr(bucket), strPtr(endPoint)), " check host");
TEST_RESULT_UINT(((StorageS3 *)storage->driver)->port, 443, " check port");
TEST_RESULT_STR(strPtr(((StorageS3 *)storage->driver)->accessKey), strPtr(accessKey), " check access key");
TEST_RESULT_STR(
strPtr(((StorageS3 *)storage->driver)->secretAccessKey), strPtr(secretAccessKey), " check secret access key");
TEST_RESULT_STR(
strPtr(((StorageS3 *)storage->driver)->securityToken), strPtr(securityToken), " check security token");
TEST_RESULT_STR(((StorageS3 *)storage->driver)->accessKey, accessKey, " check access key");
TEST_RESULT_STR(((StorageS3 *)storage->driver)->secretAccessKey, secretAccessKey, " check secret access key");
TEST_RESULT_STR(((StorageS3 *)storage->driver)->securityToken, securityToken, " check security token");
// Add a port to the endpoint
// -------------------------------------------------------------------------------------------------------------------------
@ -596,17 +591,14 @@ testRun(void)
harnessCfgLoad(cfgCmdArchiveGet, argList);
TEST_ASSIGN(storage, storageRepoGet(strNew(STORAGE_TYPE_S3), false), "get S3 repo storage with options");
TEST_RESULT_STR(strPtr(((StorageS3 *)storage->driver)->bucket), strPtr(bucket), " check bucket");
TEST_RESULT_STR(strPtr(((StorageS3 *)storage->driver)->region), strPtr(region), " check region");
TEST_RESULT_STR(((StorageS3 *)storage->driver)->bucket, bucket, " check bucket");
TEST_RESULT_STR(((StorageS3 *)storage->driver)->region, region, " check region");
TEST_RESULT_STR(
strPtr(((StorageS3 *)storage->driver)->bucketEndpoint), strPtr(strNewFmt("%s.%s", strPtr(bucket), strPtr(endPoint))),
" check host");
((StorageS3 *)storage->driver)->bucketEndpoint, strNewFmt("%s.%s", strPtr(bucket), strPtr(endPoint)), " check host");
TEST_RESULT_UINT(((StorageS3 *)storage->driver)->port, 999, " check port");
TEST_RESULT_STR(strPtr(((StorageS3 *)storage->driver)->accessKey), strPtr(accessKey), " check access key");
TEST_RESULT_STR(
strPtr(((StorageS3 *)storage->driver)->secretAccessKey), strPtr(secretAccessKey), " check secret access key");
TEST_RESULT_STR(
strPtr(((StorageS3 *)storage->driver)->securityToken), strPtr(securityToken), " check security token");
TEST_RESULT_STR(((StorageS3 *)storage->driver)->accessKey, accessKey, " check access key");
TEST_RESULT_STR(((StorageS3 *)storage->driver)->secretAccessKey, secretAccessKey, " check secret access key");
TEST_RESULT_STR(((StorageS3 *)storage->driver)->securityToken, securityToken, " check security token");
// Also add port to the host
// -------------------------------------------------------------------------------------------------------------------------
@ -626,17 +618,14 @@ testRun(void)
harnessCfgLoad(cfgCmdArchiveGet, argList);
TEST_ASSIGN(storage, storageRepoGet(strNew(STORAGE_TYPE_S3), false), "get S3 repo storage with options");
TEST_RESULT_STR(strPtr(((StorageS3 *)storage->driver)->bucket), strPtr(bucket), " check bucket");
TEST_RESULT_STR(strPtr(((StorageS3 *)storage->driver)->region), strPtr(region), " check region");
TEST_RESULT_STR(((StorageS3 *)storage->driver)->bucket, bucket, " check bucket");
TEST_RESULT_STR(((StorageS3 *)storage->driver)->region, region, " check region");
TEST_RESULT_STR(
strPtr(((StorageS3 *)storage->driver)->bucketEndpoint), strPtr(strNewFmt("%s.%s", strPtr(bucket), strPtr(endPoint))),
" check host");
((StorageS3 *)storage->driver)->bucketEndpoint, strNewFmt("%s.%s", strPtr(bucket), strPtr(endPoint)), " check host");
TEST_RESULT_UINT(((StorageS3 *)storage->driver)->port, 7777, " check port");
TEST_RESULT_STR(strPtr(((StorageS3 *)storage->driver)->accessKey), strPtr(accessKey), " check access key");
TEST_RESULT_STR(
strPtr(((StorageS3 *)storage->driver)->secretAccessKey), strPtr(secretAccessKey), " check secret access key");
TEST_RESULT_STR(
strPtr(((StorageS3 *)storage->driver)->securityToken), strPtr(securityToken), " check security token");
TEST_RESULT_STR(((StorageS3 *)storage->driver)->accessKey, accessKey, " check access key");
TEST_RESULT_STR(((StorageS3 *)storage->driver)->secretAccessKey, secretAccessKey, " check secret access key");
TEST_RESULT_STR(((StorageS3 *)storage->driver)->securityToken, securityToken, " check security token");
// Use the port option to override both
// -------------------------------------------------------------------------------------------------------------------------
@ -657,23 +646,20 @@ testRun(void)
harnessCfgLoad(cfgCmdArchiveGet, argList);
TEST_ASSIGN(storage, storageRepoGet(strNew(STORAGE_TYPE_S3), false), "get S3 repo storage with options");
TEST_RESULT_STR(strPtr(((StorageS3 *)storage->driver)->bucket), strPtr(bucket), " check bucket");
TEST_RESULT_STR(strPtr(((StorageS3 *)storage->driver)->region), strPtr(region), " check region");
TEST_RESULT_STR(((StorageS3 *)storage->driver)->bucket, bucket, " check bucket");
TEST_RESULT_STR(((StorageS3 *)storage->driver)->region, region, " check region");
TEST_RESULT_STR(
strPtr(((StorageS3 *)storage->driver)->bucketEndpoint), strPtr(strNewFmt("%s.%s", strPtr(bucket), strPtr(endPoint))),
" check host");
((StorageS3 *)storage->driver)->bucketEndpoint, strNewFmt("%s.%s", strPtr(bucket), strPtr(endPoint)), " check host");
TEST_RESULT_UINT(((StorageS3 *)storage->driver)->port, 9001, " check port");
TEST_RESULT_STR(strPtr(((StorageS3 *)storage->driver)->accessKey), strPtr(accessKey), " check access key");
TEST_RESULT_STR(
strPtr(((StorageS3 *)storage->driver)->secretAccessKey), strPtr(secretAccessKey), " check secret access key");
TEST_RESULT_STR(
strPtr(((StorageS3 *)storage->driver)->securityToken), strPtr(securityToken), " check security token");
TEST_RESULT_STR(((StorageS3 *)storage->driver)->accessKey, accessKey, " check access key");
TEST_RESULT_STR(((StorageS3 *)storage->driver)->secretAccessKey, secretAccessKey, " check secret access key");
TEST_RESULT_STR(((StorageS3 *)storage->driver)->securityToken, securityToken, " check security token");
}
// *****************************************************************************************************************************
if (testBegin("storageS3DateTime() and storageS3Auth()"))
{
TEST_RESULT_STR(strPtr(storageS3DateTime(1491267845)), "20170404T010405Z", "static date");
TEST_RESULT_STR_Z(storageS3DateTime(1491267845), "20170404T010405Z", "static date");
// -------------------------------------------------------------------------------------------------------------------------
StorageS3 *driver = (StorageS3 *)storageDriver(
@ -689,8 +675,8 @@ testRun(void)
TEST_RESULT_VOID(
storageS3Auth(driver, strNew("GET"), strNew("/"), query, strNew("20170606T121212Z"), header, HASH_TYPE_SHA256_ZERO_STR),
"generate authorization");
TEST_RESULT_STR(
strPtr(httpHeaderGet(header, strNew("authorization"))),
TEST_RESULT_STR_Z(
httpHeaderGet(header, strNew("authorization")),
"AWS4-HMAC-SHA256 Credential=AKIAIOSFODNN7EXAMPLE/20170606/us-east-1/s3/aws4_request,"
"SignedHeaders=host;x-amz-content-sha256;x-amz-date,"
"Signature=cb03bf1d575c1f8904dabf0e573990375340ab293ef7ad18d049fc1338fd89b3",
@ -702,8 +688,8 @@ testRun(void)
TEST_RESULT_VOID(
storageS3Auth(driver, strNew("GET"), strNew("/"), query, strNew("20170606T121212Z"), header, HASH_TYPE_SHA256_ZERO_STR),
"generate authorization");
TEST_RESULT_STR(
strPtr(httpHeaderGet(header, strNew("authorization"))),
TEST_RESULT_STR_Z(
httpHeaderGet(header, strNew("authorization")),
"AWS4-HMAC-SHA256 Credential=AKIAIOSFODNN7EXAMPLE/20170606/us-east-1/s3/aws4_request,"
"SignedHeaders=host;x-amz-content-sha256;x-amz-date,"
"Signature=cb03bf1d575c1f8904dabf0e573990375340ab293ef7ad18d049fc1338fd89b3",
@ -714,8 +700,8 @@ testRun(void)
TEST_RESULT_VOID(
storageS3Auth(driver, strNew("GET"), strNew("/"), query, strNew("20180814T080808Z"), header, HASH_TYPE_SHA256_ZERO_STR),
" generate authorization");
TEST_RESULT_STR(
strPtr(httpHeaderGet(header, strNew("authorization"))),
TEST_RESULT_STR_Z(
httpHeaderGet(header, strNew("authorization")),
"AWS4-HMAC-SHA256 Credential=AKIAIOSFODNN7EXAMPLE/20180814/us-east-1/s3/aws4_request,"
"SignedHeaders=host;x-amz-content-sha256;x-amz-date,"
"Signature=d0fa9c36426eb94cdbaf287a7872c7a3b6c913f523163d0d7debba0758e36f49",
@ -732,8 +718,8 @@ testRun(void)
TEST_RESULT_VOID(
storageS3Auth(driver, strNew("GET"), strNew("/"), query, strNew("20170606T121212Z"), header, HASH_TYPE_SHA256_ZERO_STR),
"generate authorization");
TEST_RESULT_STR(
strPtr(httpHeaderGet(header, strNew("authorization"))),
TEST_RESULT_STR_Z(
httpHeaderGet(header, strNew("authorization")),
"AWS4-HMAC-SHA256 Credential=AKIAIOSFODNN7EXAMPLE/20170606/us-east-1/s3/aws4_request,"
"SignedHeaders=host;x-amz-content-sha256;x-amz-date;x-amz-security-token,"
"Signature=c12565bf5d7e0ef623f76d66e09e5431aebef803f6a25a01c586525f17e474a3",
@ -760,15 +746,13 @@ testRun(void)
TEST_ERROR(
storageGetP(storageNewReadP(s3, strNew("file.txt"))), FileMissingError,
"unable to open '/file.txt': No such file or directory");
TEST_RESULT_STR(
strPtr(strNewBuf(storageGetP(storageNewReadP(s3, strNew("file.txt"))))), "this is a sample file",
"get file");
TEST_RESULT_STR(strPtr(strNewBuf(storageGetP(storageNewReadP(s3, strNew("file0.txt"))))), "", "get zero-length file");
TEST_RESULT_STR_Z(strNewBuf(storageGetP(storageNewReadP(s3, strNew("file.txt")))), "this is a sample file", "get file");
TEST_RESULT_STR_Z(strNewBuf(storageGetP(storageNewReadP(s3, strNew("file0.txt")))), "", "get zero-length file");
StorageRead *read = NULL;
TEST_ASSIGN(read, storageNewReadP(s3, strNew("file.txt"), .ignoreMissing = true), "new read file");
TEST_RESULT_BOOL(storageReadIgnoreMissing(read), true, " check ignore missing");
TEST_RESULT_STR(strPtr(storageReadName(read)), "/file.txt", " check name");
TEST_RESULT_STR_Z(storageReadName(read), "/file.txt", " check name");
TEST_ERROR(
ioReadOpen(storageReadIo(read)), ProtocolError,
@ -797,7 +781,7 @@ testRun(void)
TEST_RESULT_BOOL(storageWriteCreatePath(write), true, "path will be created");
TEST_RESULT_UINT(storageWriteModeFile(write), 0, "file mode is 0");
TEST_RESULT_UINT(storageWriteModePath(write), 0, "path mode is 0");
TEST_RESULT_STR(strPtr(storageWriteName(write)), "/file.txt", "check file name");
TEST_RESULT_STR_Z(storageWriteName(write), "/file.txt", "check file name");
TEST_RESULT_BOOL(storageWriteSyncFile(write), true, "file is synced");
TEST_RESULT_BOOL(storageWriteSyncPath(write), true, "path is synced");
@ -844,10 +828,10 @@ testRun(void)
storageInfoListP(s3, strNew("/path/to"), testStorageInfoListCallback, (void *)memContextCurrent()), "info list files");
TEST_RESULT_UINT(testStorageInfoListSize, 2, " file and path returned");
TEST_RESULT_STR(strPtr(testStorageInfoList[0].name), "test_path", " check name");
TEST_RESULT_STR_Z(testStorageInfoList[0].name, "test_path", " check name");
TEST_RESULT_UINT(testStorageInfoList[0].size, 0, " check size");
TEST_RESULT_UINT(testStorageInfoList[0].type, storageTypePath, " check type");
TEST_RESULT_STR(strPtr(testStorageInfoList[1].name), "test_file", " check name");
TEST_RESULT_STR_Z(testStorageInfoList[1].name, "test_file", " check name");
TEST_RESULT_UINT(testStorageInfoList[1].size, 787, " check size");
TEST_RESULT_UINT(testStorageInfoList[1].type, storageTypeFile, " check type");
@ -896,15 +880,15 @@ testRun(void)
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><Error><Code>RequestTimeTooSkewed</Code>"
"<Message>The difference between the request time and the current time is too large.</Message></Error>");
TEST_RESULT_STR(strPtr(strLstJoin(storageListP(s3, strNew("/")), ",")), "path1,test1.txt", "list a file/path in root");
TEST_RESULT_STR(
strPtr(strLstJoin(storageListP(s3, strNew("/"), .expression = strNew("^test.*$")), ",")), "test1.txt",
TEST_RESULT_STR_Z(strLstJoin(storageListP(s3, strNew("/")), ","), "path1,test1.txt", "list a file/path in root");
TEST_RESULT_STR_Z(
strLstJoin(storageListP(s3, strNew("/"), .expression = strNew("^test.*$")), ","), "test1.txt",
"list a file in root with expression");
TEST_RESULT_STR(
strPtr(strLstJoin(storageListP(s3, strNew("/path/to")), ",")),
TEST_RESULT_STR_Z(
strLstJoin(storageListP(s3, strNew("/path/to")), ","),
"path1,test1.txt,test2.txt,path2,test3.txt", "list files with continuation");
TEST_RESULT_STR(
strPtr(strLstJoin(storageListP(s3, strNew("/path/to"), .expression = strNew("^test(1|3)")), ",")),
TEST_RESULT_STR_Z(
strLstJoin(storageListP(s3, strNew("/path/to"), .expression = strNew("^test(1|3)")), ","),
"test1.path,test1.txt,test3.txt", "list files with expression");
// storageDriverPathRemove()