1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-04-21 11:57:01 +02:00

Add bufNewZ() to Buffer object.

This constructor creates a Buffer object directly from a zero-terminated string.  The old way was to create a String object first, then convert that to a Buffer using bufNewStr().

Updated in all places that used the old pattern.
This commit is contained in:
David Steele 2018-09-26 18:46:52 +01:00
parent d038b9a029
commit 51484a008f
11 changed files with 200 additions and 171 deletions

View File

@ -90,6 +90,10 @@
<p>Add helper for repository storage.</p> <p>Add helper for repository storage.</p>
</release-item> </release-item>
<release-item>
<p>Add <code>bufNewZ()</code> to <code>Buffer</code> object.</p>
</release-item>
<release-item> <release-item>
<release-item-contributor-list> <release-item-contributor-list>
<release-item-contributor id="cynthia.shang"/> <release-item-contributor id="cynthia.shang"/>

View File

@ -89,6 +89,26 @@ bufNewStr(const String *string)
FUNCTION_TEST_RESULT(BUFFER, this); FUNCTION_TEST_RESULT(BUFFER, this);
} }
/***********************************************************************************************************************************
Create a new buffer from a zero-terminated string
***********************************************************************************************************************************/
Buffer *
bufNewZ(const char *string)
{
FUNCTION_TEST_BEGIN();
FUNCTION_TEST_PARAM(STRINGZ, string);
FUNCTION_TEST_ASSERT(string != NULL);
FUNCTION_TEST_END();
// Create object and copy string
Buffer *this = bufNew(strlen(string));
memcpy(this->buffer, string, strlen(string));
this->used = this->size;
FUNCTION_TEST_RESULT(BUFFER, this);
}
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Append the contents of another buffer Append the contents of another buffer
***********************************************************************************************************************************/ ***********************************************************************************************************************************/

View File

@ -18,6 +18,7 @@ Functions
Buffer *bufNew(size_t size); Buffer *bufNew(size_t size);
Buffer *bufNewC(size_t size, const void *buffer); Buffer *bufNewC(size_t size, const void *buffer);
Buffer *bufNewStr(const String *string); Buffer *bufNewStr(const String *string);
Buffer *bufNewZ(const char *string);
Buffer *bufCat(Buffer *this, const Buffer *cat); Buffer *bufCat(Buffer *this, const Buffer *cat);
Buffer *bufCatC(Buffer *this, const unsigned char *cat, size_t catOffset, size_t catSize); Buffer *bufCatC(Buffer *this, const unsigned char *cat, size_t catOffset, size_t catSize);

View File

@ -48,20 +48,20 @@ testRun(void)
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
storagePutNP( storagePutNP(
storageNewWriteNP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s.ok", strPtr(segment))), storageNewWriteNP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s.ok", strPtr(segment))),
bufNewStr(strNew(BOGUS_STR))); bufNewZ(BOGUS_STR));
TEST_ERROR( TEST_ERROR(
archiveAsyncStatus(archiveModePush, segment, false), FormatError, archiveAsyncStatus(archiveModePush, segment, false), FormatError,
"000000010000000100000001.ok content must have at least two lines"); "000000010000000100000001.ok content must have at least two lines");
storagePutNP( storagePutNP(
storageNewWriteNP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s.ok", strPtr(segment))), storageNewWriteNP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s.ok", strPtr(segment))),
bufNewStr(strNew(BOGUS_STR "\n"))); bufNewZ(BOGUS_STR "\n"));
TEST_ERROR( TEST_ERROR(
archiveAsyncStatus(archiveModePush, segment, false), FormatError, "000000010000000100000001.ok message must be > 0"); archiveAsyncStatus(archiveModePush, segment, false), FormatError, "000000010000000100000001.ok message must be > 0");
storagePutNP( storagePutNP(
storageNewWriteNP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s.ok", strPtr(segment))), storageNewWriteNP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s.ok", strPtr(segment))),
bufNewStr(strNew(BOGUS_STR "\nmessage"))); bufNewZ(BOGUS_STR "\nmessage"));
TEST_ERROR(archiveAsyncStatus(archiveModePush, segment, false), FormatError, "unable to convert string 'BOGUS' to int"); TEST_ERROR(archiveAsyncStatus(archiveModePush, segment, false), FormatError, "unable to convert string 'BOGUS' to int");
storagePutNP(storageNewWriteNP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s.ok", strPtr(segment))), NULL); storagePutNP(storageNewWriteNP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s.ok", strPtr(segment))), NULL);
@ -69,21 +69,20 @@ testRun(void)
storagePutNP( storagePutNP(
storageNewWriteNP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s.ok", strPtr(segment))), storageNewWriteNP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s.ok", strPtr(segment))),
bufNewStr(strNew("0\nwarning"))); bufNewZ("0\nwarning"));
TEST_RESULT_BOOL(archiveAsyncStatus(archiveModePush, segment, false), true, "ok file with warning"); TEST_RESULT_BOOL(archiveAsyncStatus(archiveModePush, segment, false), true, "ok file with warning");
harnessLogResult("P00 WARN: warning"); harnessLogResult("P00 WARN: warning");
storagePutNP( storagePutNP(
storageNewWriteNP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s.ok", strPtr(segment))), storageNewWriteNP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s.ok", strPtr(segment))),
bufNewStr(strNew("25\nerror"))); bufNewZ("25\nerror"));
TEST_RESULT_BOOL(archiveAsyncStatus(archiveModePush, segment, false), true, "error status renamed to ok"); TEST_RESULT_BOOL(archiveAsyncStatus(archiveModePush, segment, false), true, "error status renamed to ok");
harnessLogResult( harnessLogResult(
"P00 WARN: WAL segment '000000010000000100000001' was not pushed due to error [25] and was manually skipped: error"); "P00 WARN: WAL segment '000000010000000100000001' was not pushed due to error [25] and was manually skipped: error");
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
storagePutNP( storagePutNP(
storageNewWriteNP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s.error", strPtr(segment))), storageNewWriteNP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s.error", strPtr(segment))), bufNew(0));
bufNewStr(strNew("")));
TEST_ERROR( TEST_ERROR(
archiveAsyncStatus(archiveModePush, segment, false), AssertError, archiveAsyncStatus(archiveModePush, segment, false), AssertError,
strPtr( strPtr(
@ -97,7 +96,7 @@ testRun(void)
storagePutNP( storagePutNP(
storageNewWriteNP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s.error", strPtr(segment))), storageNewWriteNP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_OUT "/%s.error", strPtr(segment))),
bufNewStr(strNew("25\nmessage"))); bufNewZ("25\nmessage"));
TEST_ERROR(archiveAsyncStatus(archiveModePush, segment, true), AssertError, "message"); TEST_ERROR(archiveAsyncStatus(archiveModePush, segment, true), AssertError, "message");
TEST_RESULT_BOOL(archiveAsyncStatus(archiveModePush, segment, false), false, "suppress error"); TEST_RESULT_BOOL(archiveAsyncStatus(archiveModePush, segment, false), false, "suppress error");

View File

@ -41,15 +41,14 @@ testRun(void)
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
storagePutNP( storagePutNP(
storageNewWriteNP(storageTest, strNew("repo/archive/test1/archive.info")), storageNewWriteNP(storageTest, strNew("repo/archive/test1/archive.info")),
bufNewStr( bufNewZ(
strNew( "[backrest]\n"
"[backrest]\n" "backrest-checksum=\"0a415a03fa3faccb4ac171759895478469e9e19e\"\n"
"backrest-checksum=\"0a415a03fa3faccb4ac171759895478469e9e19e\"\n" "backrest-format=5\n"
"backrest-format=5\n" "backrest-version=\"2.06\"\n"
"backrest-version=\"2.06\"\n" "\n"
"\n" "[db:history]\n"
"[db:history]\n" "1={\"db-id\":5555555555555555555,\"db-version\":\"9.4\"}\n"));
"1={\"db-id\":5555555555555555555,\"db-version\":\"9.4\"}\n")));
TEST_ERROR( TEST_ERROR(
archiveGetCheck(strNew("876543218765432187654321")), ArchiveMismatchError, archiveGetCheck(strNew("876543218765432187654321")), ArchiveMismatchError,
@ -59,18 +58,17 @@ testRun(void)
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
storagePutNP( storagePutNP(
storageNewWriteNP(storageTest, strNew("repo/archive/test1/archive.info")), storageNewWriteNP(storageTest, strNew("repo/archive/test1/archive.info")),
bufNewStr( bufNewZ(
strNew( "[backrest]\n"
"[backrest]\n" "backrest-checksum=\"f7617b5c4c9f212f40b9bc3d8ec7f97edbbf96af\"\n"
"backrest-checksum=\"f7617b5c4c9f212f40b9bc3d8ec7f97edbbf96af\"\n" "backrest-format=5\n"
"backrest-format=5\n" "backrest-version=\"2.06\"\n"
"backrest-version=\"2.06\"\n" "\n"
"\n" "[db:history]\n"
"[db:history]\n" "1={\"db-id\":5555555555555555555,\"db-version\":\"9.4\"}\n"
"1={\"db-id\":5555555555555555555,\"db-version\":\"9.4\"}\n" "2={\"db-id\":18072658121562454734,\"db-version\":\"10\"}\n"
"2={\"db-id\":18072658121562454734,\"db-version\":\"10\"}\n" "3={\"db-id\":18072658121562454734,\"db-version\":\"9.6\"}\n"
"3={\"db-id\":18072658121562454734,\"db-version\":\"9.6\"}\n" "4={\"db-id\":18072658121562454734,\"db-version\":\"10\"}"));
"4={\"db-id\":18072658121562454734,\"db-version\":\"10\"}")));
TEST_RESULT_PTR(archiveGetCheck(strNew("876543218765432187654321")), NULL, "no segment found"); TEST_RESULT_PTR(archiveGetCheck(strNew("876543218765432187654321")), NULL, "no segment found");
@ -129,15 +127,14 @@ testRun(void)
// Create archive.info // Create archive.info
storagePutNP( storagePutNP(
storageNewWriteNP(storageTest, strNew("repo/archive/test1/archive.info")), storageNewWriteNP(storageTest, strNew("repo/archive/test1/archive.info")),
bufNewStr( bufNewZ(
strNew( "[backrest]\n"
"[backrest]\n" "backrest-checksum=\"8a041a4128eaa2c08a23dd1f04934627795946ff\"\n"
"backrest-checksum=\"8a041a4128eaa2c08a23dd1f04934627795946ff\"\n" "backrest-format=5\n"
"backrest-format=5\n" "backrest-version=\"2.06\"\n"
"backrest-version=\"2.06\"\n" "\n"
"\n" "[db:history]\n"
"[db:history]\n" "1={\"db-id\":18072658121562454734,\"db-version\":\"10\"}"));
"1={\"db-id\":18072658121562454734,\"db-version\":\"10\"}")));
// Nothing to copy // Nothing to copy
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
@ -242,7 +239,7 @@ testRun(void)
walSegmentSize = 1024 * 1024; walSegmentSize = 1024 * 1024;
queueSize = walSegmentSize * 5; queueSize = walSegmentSize * 5;
storagePutNP(storageNewWriteNP(storageSpoolWrite(), strNew(STORAGE_SPOOL_ARCHIVE_IN "/junk")), bufNewStr(strNew("JUNK"))); storagePutNP(storageNewWriteNP(storageSpoolWrite(), strNew(STORAGE_SPOOL_ARCHIVE_IN "/junk")), bufNewZ("JUNK"));
storagePutNP( storagePutNP(
storageNewWriteNP( storageNewWriteNP(
storageSpoolWrite(), strNew(STORAGE_SPOOL_ARCHIVE_IN "/000000010000000A00000FFE")), walSegmentBuffer); storageSpoolWrite(), strNew(STORAGE_SPOOL_ARCHIVE_IN "/000000010000000A00000FFE")), walSegmentBuffer);
@ -368,7 +365,7 @@ testRun(void)
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
storagePutNP( storagePutNP(
storageNewWriteNP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_IN "/%s", strPtr(walSegment))), storageNewWriteNP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_IN "/%s", strPtr(walSegment))),
bufNewStr(strNew("SHOULD-BE-A-REAL-WAL-FILE"))); bufNewZ("SHOULD-BE-A-REAL-WAL-FILE"));
TEST_RESULT_VOID(cmdArchiveGet(), "successful get"); TEST_RESULT_VOID(cmdArchiveGet(), "successful get");
harnessLogResult("P00 INFO: found 000000010000000100000001 in the archive"); harnessLogResult("P00 INFO: found 000000010000000100000001 in the archive");
@ -385,10 +382,10 @@ testRun(void)
storagePutNP( storagePutNP(
storageNewWriteNP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_IN "/%s", strPtr(walSegment))), storageNewWriteNP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_IN "/%s", strPtr(walSegment))),
bufNewStr(strNew("SHOULD-BE-A-REAL-WAL-FILE"))); bufNewZ("SHOULD-BE-A-REAL-WAL-FILE"));
storagePutNP( storagePutNP(
storageNewWriteNP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_IN "/%s", strPtr(walSegment2))), storageNewWriteNP(storageSpoolWrite(), strNewFmt(STORAGE_SPOOL_ARCHIVE_IN "/%s", strPtr(walSegment2))),
bufNewStr(strNew("SHOULD-BE-A-REAL-WAL-FILE"))); bufNewZ("SHOULD-BE-A-REAL-WAL-FILE"));
TEST_RESULT_VOID(cmdArchiveGet(), "successful get"); TEST_RESULT_VOID(cmdArchiveGet(), "successful get");
harnessLogResult("P00 INFO: found 000000010000000100000001 in the archive"); harnessLogResult("P00 INFO: found 000000010000000100000001 in the archive");

View File

@ -60,7 +60,7 @@ testRun(void)
storagePathRemoveNP(storageTest, strNewFmt("%s/db/archive_status", testPath())); storagePathRemoveNP(storageTest, strNewFmt("%s/db/archive_status", testPath()));
String *errorFile = storagePathNP(storageSpool(), strNew(STORAGE_SPOOL_ARCHIVE_OUT "/000000010000000100000001.error")); String *errorFile = storagePathNP(storageSpool(), strNew(STORAGE_SPOOL_ARCHIVE_OUT "/000000010000000100000001.error"));
storagePutNP(storageNewWriteNP(storageSpoolWrite(), errorFile), bufNewStr(strNew("25\n" BOGUS_STR))); storagePutNP(storageNewWriteNP(storageSpoolWrite(), errorFile), bufNewZ("25\n" BOGUS_STR));
TEST_ERROR(cmdArchivePush(), AssertError, BOGUS_STR); TEST_ERROR(cmdArchivePush(), AssertError, BOGUS_STR);
@ -69,8 +69,7 @@ testRun(void)
// Write out a valid ok file and test for success // Write out a valid ok file and test for success
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
storagePutNP( storagePutNP(
storageNewWriteNP(storageSpoolWrite(), strNew(STORAGE_SPOOL_ARCHIVE_OUT "/000000010000000100000001.ok")), storageNewWriteNP(storageSpoolWrite(), strNew(STORAGE_SPOOL_ARCHIVE_OUT "/000000010000000100000001.ok")), bufNew(0));
bufNewStr(strNew("")));
TEST_RESULT_VOID(cmdArchivePush(), "successful push"); TEST_RESULT_VOID(cmdArchivePush(), "successful push");
harnessLogResult("P00 INFO: pushed WAL segment 000000010000000100000001 asynchronously"); harnessLogResult("P00 INFO: pushed WAL segment 000000010000000100000001 asynchronously");

View File

@ -21,7 +21,7 @@ static size_t
testIoRead(void *driver, Buffer *buffer) testIoRead(void *driver, Buffer *buffer)
{ {
ASSERT(driver == (void *)999); ASSERT(driver == (void *)999);
bufCat(buffer, bufNewStr(strNew("Z"))); bufCat(buffer, bufNewZ("Z"));
return 1; return 1;
} }
@ -251,7 +251,7 @@ testRun(void)
IoBufferRead *bufferRead = NULL; IoBufferRead *bufferRead = NULL;
ioBufferSizeSet(2); ioBufferSizeSet(2);
buffer = bufNew(2); buffer = bufNew(2);
Buffer *bufferOriginal = bufNewStr(strNew("123")); Buffer *bufferOriginal = bufNewZ("123");
MEM_CONTEXT_TEMP_BEGIN() MEM_CONTEXT_TEMP_BEGIN()
{ {
@ -332,7 +332,7 @@ testRun(void)
TEST_RESULT_VOID(ioWriteOpen(write), " open io object"); TEST_RESULT_VOID(ioWriteOpen(write), " open io object");
TEST_RESULT_BOOL(testIoWriteOpenCalled, true, " check io object open"); TEST_RESULT_BOOL(testIoWriteOpenCalled, true, " check io object open");
TEST_RESULT_VOID(ioWrite(write, bufNewStr(strNew("ABC"))), " write 3 bytes"); TEST_RESULT_VOID(ioWrite(write, bufNewZ("ABC")), " write 3 bytes");
TEST_RESULT_VOID(ioWriteClose(write), " close io object"); TEST_RESULT_VOID(ioWriteClose(write), " close io object");
TEST_RESULT_BOOL(testIoWriteCloseCalled, true, " check io object closed"); TEST_RESULT_BOOL(testIoWriteCloseCalled, true, " check io object closed");
@ -359,12 +359,12 @@ testRun(void)
TEST_RESULT_VOID(ioWriteFilterGroupSet(ioBufferWriteIo(bufferWrite), filterGroup), " add filter group to write io"); TEST_RESULT_VOID(ioWriteFilterGroupSet(ioBufferWriteIo(bufferWrite), filterGroup), " add filter group to write io");
TEST_RESULT_VOID(ioWriteOpen(ioBufferWriteIo(bufferWrite)), " open buffer write object"); TEST_RESULT_VOID(ioWriteOpen(ioBufferWriteIo(bufferWrite)), " open buffer write object");
TEST_RESULT_VOID(ioWrite(ioBufferWriteIo(bufferWrite), bufNewStr(strNew("ABC"))), " write 3 bytes"); TEST_RESULT_VOID(ioWrite(ioBufferWriteIo(bufferWrite), bufNewZ("ABC")), " write 3 bytes");
TEST_RESULT_VOID(ioWrite(ioBufferWriteIo(bufferWrite), bufNewStr(strNew(""))), " write 0 bytes"); TEST_RESULT_VOID(ioWrite(ioBufferWriteIo(bufferWrite), bufNew(0)), " write 0 bytes");
TEST_RESULT_VOID(ioWrite(ioBufferWriteIo(bufferWrite), NULL), " write 0 bytes"); TEST_RESULT_VOID(ioWrite(ioBufferWriteIo(bufferWrite), NULL), " write 0 bytes");
TEST_RESULT_STR(strPtr(strNewBuf(buffer)), "AABBCC", " check write"); TEST_RESULT_STR(strPtr(strNewBuf(buffer)), "AABBCC", " check write");
TEST_RESULT_VOID(ioWrite(ioBufferWriteIo(bufferWrite), bufNewStr(strNew("12345"))), " write 4 bytes"); TEST_RESULT_VOID(ioWrite(ioBufferWriteIo(bufferWrite), bufNewZ("12345")), " write 4 bytes");
TEST_RESULT_STR(strPtr(strNewBuf(buffer)), "AABBCC112233445", " check write"); TEST_RESULT_STR(strPtr(strNewBuf(buffer)), "AABBCC112233445", " check write");
TEST_RESULT_VOID(ioWriteClose(ioBufferWriteIo(bufferWrite)), " close buffer write object"); TEST_RESULT_VOID(ioWriteClose(ioBufferWriteIo(bufferWrite)), " close buffer write object");

View File

@ -11,7 +11,7 @@ testRun(void)
FUNCTION_HARNESS_VOID(); FUNCTION_HARNESS_VOID();
// ***************************************************************************************************************************** // *****************************************************************************************************************************
if (testBegin("bufNew(), bugNewC, bufNewStr(), bufMove(), bufSize(), bufPtr(), and bufFree()")) if (testBegin("bufNew(), bugNewC, bufNewStr(), bufNewZ(), bufMove(), bufSize(), bufPtr(), and bufFree()"))
{ {
Buffer *buffer = NULL; Buffer *buffer = NULL;
@ -28,6 +28,9 @@ testRun(void)
TEST_ASSIGN(buffer, bufNewStr(strNew("TEST-STR")), "new buffer from string"); TEST_ASSIGN(buffer, bufNewStr(strNew("TEST-STR")), "new buffer from string");
TEST_RESULT_BOOL(memcmp(bufPtr(buffer), "TEST-STR", 8) == 0, true, "check buffer"); TEST_RESULT_BOOL(memcmp(bufPtr(buffer), "TEST-STR", 8) == 0, true, "check buffer");
TEST_ASSIGN(buffer, bufNewZ("TEST-STRZ"), "new buffer from zero-terminated string");
TEST_RESULT_BOOL(memcmp(bufPtr(buffer), "TEST-STRZ", 9) == 0, true, "check buffer");
TEST_RESULT_VOID(bufFree(buffer), "free buffer"); TEST_RESULT_VOID(bufFree(buffer), "free buffer");
TEST_RESULT_VOID(bufFree(bufNew(0)), "free empty buffer"); TEST_RESULT_VOID(bufFree(bufNew(0)), "free empty buffer");
TEST_RESULT_VOID(bufFree(NULL), "free null buffer"); TEST_RESULT_VOID(bufFree(NULL), "free null buffer");
@ -104,26 +107,26 @@ testRun(void)
// ***************************************************************************************************************************** // *****************************************************************************************************************************
if (testBegin("bufEq()")) if (testBegin("bufEq()"))
{ {
TEST_RESULT_BOOL(bufEq(bufNewStr(strNew("123")), bufNewStr(strNew("1234"))), false, "buffer sizes not equal"); TEST_RESULT_BOOL(bufEq(bufNewZ("123"), bufNewZ("1234")), false, "buffer sizes not equal");
TEST_RESULT_BOOL(bufEq(bufNewStr(strNew("321")), bufNewStr(strNew("123"))), false, "buffer sizes equal"); TEST_RESULT_BOOL(bufEq(bufNewZ("321"), bufNewZ("123")), false, "buffer sizes equal");
TEST_RESULT_BOOL(bufEq(bufNewStr(strNew("123")), bufNewStr(strNew("123"))), true, "buffers equal"); TEST_RESULT_BOOL(bufEq(bufNewZ("123"), bufNewZ("123")), true, "buffers equal");
} }
// ***************************************************************************************************************************** // *****************************************************************************************************************************
if (testBegin("bufCat*()")) if (testBegin("bufCat*()"))
{ {
TEST_RESULT_STR(strPtr(strNewBuf(bufCat(bufNewStr(strNew("123")), NULL))), "123", "cat null buffer"); TEST_RESULT_STR(strPtr(strNewBuf(bufCat(bufNewZ("123"), NULL))), "123", "cat null buffer");
TEST_RESULT_STR(strPtr(strNewBuf(bufCat(bufNewStr(strNew("123")), bufNew(0)))), "123", "cat empty buffer"); TEST_RESULT_STR(strPtr(strNewBuf(bufCat(bufNewZ("123"), bufNew(0)))), "123", "cat empty buffer");
TEST_RESULT_STR(strPtr(strNewBuf(bufCat(bufNewStr(strNew("123")), bufNewStr(strNew("ABC"))))), "123ABC", "cat buffer"); TEST_RESULT_STR(strPtr(strNewBuf(bufCat(bufNewZ("123"), bufNewZ("ABC")))), "123ABC", "cat buffer");
TEST_RESULT_STR(strPtr(strNewBuf(bufCatSub(bufNewStr(strNew("123")), NULL, 0, 0))), "123", "cat sub null buffer"); TEST_RESULT_STR(strPtr(strNewBuf(bufCatSub(bufNewZ("123"), NULL, 0, 0))), "123", "cat sub null buffer");
TEST_RESULT_STR(strPtr(strNewBuf(bufCatSub(bufNewStr(strNew("123")), bufNew(0), 0, 0))), "123", "cat sub empty buffer"); TEST_RESULT_STR(strPtr(strNewBuf(bufCatSub(bufNewZ("123"), bufNew(0), 0, 0))), "123", "cat sub empty buffer");
TEST_RESULT_STR( TEST_RESULT_STR(
strPtr(strNewBuf(bufCatSub(bufNewStr(strNew("123")), bufNewStr(strNew("ABC")), 1, 2))), "123BC", "cat sub buffer"); strPtr(strNewBuf(bufCatSub(bufNewZ("123"), bufNewZ("ABC"), 1, 2))), "123BC", "cat sub buffer");
Buffer *buffer = NULL; Buffer *buffer = NULL;
TEST_ASSIGN(buffer, bufNew(2), "new buffer with space"); TEST_ASSIGN(buffer, bufNew(2), "new buffer with space");
TEST_RESULT_STR(strPtr(strNewBuf(bufCat(buffer, bufNewStr(strNew("AB"))))), "AB", "cat buffer with space"); TEST_RESULT_STR(strPtr(strNewBuf(bufCat(buffer, bufNewZ("AB")))), "AB", "cat buffer with space");
} }
// ***************************************************************************************************************************** // *****************************************************************************************************************************

View File

@ -64,41 +64,40 @@ testRun(void)
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP)); strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
storagePut( storagePut(
storageNewWriteNP(storageLocalWrite(), configFile), bufNewStr( storageNewWriteNP(storageLocalWrite(), configFile),
strNew( bufNewZ(
"[global]\n" "[global]\n"
"compress-level=3\n" "compress-level=3\n"
"spool-path=/path/to/spool\n"))); "spool-path=/path/to/spool\n"));
storagePut( storagePut(
storageNewWriteNP( storageNewWriteNP(storageLocalWrite(), strNewFmt("%s/global-backup.conf", strPtr(configIncludePath))),
storageLocalWrite(), strNewFmt("%s/global-backup.conf", strPtr(configIncludePath))), bufNewStr( bufNewZ(
strNew( "[global:backup]\n"
"[global:backup]\n" "repo1-hardlink=y\n"
"repo1-hardlink=y\n" "bogus=bogus\n"
"bogus=bogus\n" "no-compress=y\n"
"no-compress=y\n" "reset-compress=y\n"
"reset-compress=y\n" "archive-copy=y\n"
"archive-copy=y\n" "online=y\n"
"online=y\n" "pg1-path=/not/path/to/db\n"
"pg1-path=/not/path/to/db\n" "backup-standby=y\n"
"backup-standby=y\n" "buffer-size=65536\n"));
"buffer-size=65536\n")));
storagePut( storagePut(
storageNewWriteNP(storageLocalWrite(), strNewFmt("%s/db-backup.conf", strPtr(configIncludePath))), bufNewStr( storageNewWriteNP(storageLocalWrite(), strNewFmt("%s/db-backup.conf", strPtr(configIncludePath))),
strNew( bufNewZ(
"[db:backup]\n" "[db:backup]\n"
"compress=n\n" "compress=n\n"
"recovery-option=a=b\n"))); "recovery-option=a=b\n"));
storagePut( storagePut(
storageNewWriteNP(storageLocalWrite(), strNewFmt("%s/stanza.db.conf", strPtr(configIncludePath))), bufNewStr( storageNewWriteNP(storageLocalWrite(), strNewFmt("%s/stanza.db.conf", strPtr(configIncludePath))),
strNew( bufNewZ(
"[db]\n" "[db]\n"
"pg1-host=db\n" "pg1-host=db\n"
"pg1-path=/path/to/db\n" "pg1-path=/path/to/db\n"
"recovery-option=c=d\n"))); "recovery-option=c=d\n"));
TEST_RESULT_VOID( TEST_RESULT_VOID(
configParse(strLstSize(argList), strLstPtr(argList), false), TEST_COMMAND_BACKUP " command with config-include"); configParse(strLstSize(argList), strLstPtr(argList), false), TEST_COMMAND_BACKUP " command with config-include");
@ -225,11 +224,10 @@ testRun(void)
mkdir(strPtr(strPath(oldConfigDefault)), 0750); mkdir(strPtr(strPath(oldConfigDefault)), 0750);
storagePut( storagePut(
storageNewWriteNP( storageNewWriteNP(storageLocalWrite(), oldConfigDefault),
storageLocalWrite(), oldConfigDefault), bufNewStr( bufNewZ(
strNew( "[global:backup]\n"
"[global:backup]\n" "buffer-size=65536\n"));
"buffer-size=65536\n")));
// Pass actual location of config files as "default" - not setting valueList above, so these are the only possible values // Pass actual location of config files as "default" - not setting valueList above, so these are the only possible values
// to choose. // to choose.
@ -907,10 +905,11 @@ testRun(void)
strLstAdd(argList, strNewFmt("--config=%s", strPtr(configFile))); strLstAdd(argList, strNewFmt("--config=%s", strPtr(configFile)));
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP)); strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
storagePutNP(storageNewWriteNP(storageLocalWrite(), configFile), bufNewStr(strNew( storagePutNP(
"[global]\n" storageNewWriteNP(storageLocalWrite(), configFile),
"compress=bogus\n" bufNewZ(
))); "[global]\n"
"compress=bogus\n"));
TEST_ERROR(configParse( TEST_ERROR(configParse(
strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError, strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
@ -923,10 +922,11 @@ testRun(void)
strLstAdd(argList, strNewFmt("--config=%s", strPtr(configFile))); strLstAdd(argList, strNewFmt("--config=%s", strPtr(configFile)));
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP)); strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
storagePutNP(storageNewWriteNP(storageLocalWrite(), configFile), bufNewStr(strNew( storagePutNP(
"[global]\n" storageNewWriteNP(storageLocalWrite(), configFile),
"compress=\n" bufNewZ(
))); "[global]\n"
"compress=\n"));
TEST_ERROR(configParse( TEST_ERROR(configParse(
strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError, strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
@ -939,11 +939,12 @@ testRun(void)
strLstAdd(argList, strNewFmt("--config=%s", strPtr(configFile))); strLstAdd(argList, strNewFmt("--config=%s", strPtr(configFile)));
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP)); strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
storagePutNP(storageNewWriteNP(storageLocalWrite(), configFile), bufNewStr(strNew( storagePutNP(
"[db]\n" storageNewWriteNP(storageLocalWrite(), configFile),
"pg1-path=/path/to/db\n" bufNewZ(
"db-path=/also/path/to/db\n" "[db]\n"
))); "pg1-path=/path/to/db\n"
"db-path=/also/path/to/db\n"));
TEST_ERROR(configParse( TEST_ERROR(configParse(
strLstSize(argList), strLstPtr(argList), false), OptionInvalidError, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
@ -956,11 +957,12 @@ testRun(void)
strLstAdd(argList, strNewFmt("--config=%s", strPtr(configFile))); strLstAdd(argList, strNewFmt("--config=%s", strPtr(configFile)));
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP)); strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
storagePutNP(storageNewWriteNP(storageLocalWrite(), configFile), bufNewStr(strNew( storagePutNP(
"[db]\n" storageNewWriteNP(storageLocalWrite(), configFile),
"pg1-path=/path/to/db\n" bufNewZ(
"pg1-path=/also/path/to/db\n" "[db]\n"
))); "pg1-path=/path/to/db\n"
"pg1-path=/also/path/to/db\n"));
TEST_ERROR(configParse(strLstSize(argList), strLstPtr(argList), false), TEST_ERROR(configParse(strLstSize(argList), strLstPtr(argList), false),
OptionInvalidError, OptionInvalidError,
@ -1082,32 +1084,33 @@ testRun(void)
setenv("PGBACKREST_START_FAST", "n", true); setenv("PGBACKREST_START_FAST", "n", true);
setenv("PGBACKREST_PG1_SOCKET_PATH", "/path/to/socket", true); setenv("PGBACKREST_PG1_SOCKET_PATH", "/path/to/socket", true);
storagePutNP(storageNewWriteNP(storageLocalWrite(), configFile), bufNewStr(strNew( storagePutNP(
"[global]\n" storageNewWriteNP(storageLocalWrite(), configFile),
"compress-level=3\n" bufNewZ(
"spool-path=/path/to/spool\n" "[global]\n"
"\n" "compress-level=3\n"
"[global:backup]\n" "spool-path=/path/to/spool\n"
"repo1-hardlink=y\n" "\n"
"bogus=bogus\n" "[global:backup]\n"
"no-compress=y\n" "repo1-hardlink=y\n"
"reset-compress=y\n" "bogus=bogus\n"
"archive-copy=y\n" "no-compress=y\n"
"start-fast=y\n" "reset-compress=y\n"
"online=y\n" "archive-copy=y\n"
"pg1-path=/not/path/to/db\n" "start-fast=y\n"
"backup-standby=y\n" "online=y\n"
"buffer-size=65536\n" "pg1-path=/not/path/to/db\n"
"\n" "backup-standby=y\n"
"[db:backup]\n" "buffer-size=65536\n"
"compress=n\n" "\n"
"recovery-option=a=b\n" "[db:backup]\n"
"\n" "compress=n\n"
"[db]\n" "recovery-option=a=b\n"
"pg1-host=db\n" "\n"
"pg1-path=/path/to/db\n" "[db]\n"
"recovery-option=c=d\n" "pg1-host=db\n"
))); "pg1-path=/path/to/db\n"
"recovery-option=c=d\n"));
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), TEST_COMMAND_BACKUP " command"); TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), TEST_COMMAND_BACKUP " command");
harnessLogResult( harnessLogResult(
@ -1162,10 +1165,11 @@ testRun(void)
strLstAdd(argList, strNew("--buffer-size=2MB")); strLstAdd(argList, strNew("--buffer-size=2MB"));
strLstAdd(argList, strNew("archive-push")); strLstAdd(argList, strNew("archive-push"));
storagePutNP(storageNewWriteNP(storageLocalWrite(), configFile), bufNewStr(strNew( storagePutNP(
"[global]\n" storageNewWriteNP(storageLocalWrite(), configFile),
"spool-path=/path/to/spool\n" bufNewZ(
))); "[global]\n"
"spool-path=/path/to/spool\n"));
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "archive-push command"); TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "archive-push command");
@ -1235,14 +1239,15 @@ testRun(void)
strLstAdd(argList, strNew("--stanza=db")); strLstAdd(argList, strNew("--stanza=db"));
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE)); strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
storagePutNP(storageNewWriteNP(storageLocalWrite(), configFile), bufNewStr(strNew( storagePutNP(
"[global:restore]\n" storageNewWriteNP(storageLocalWrite(), configFile),
"recovery-option=f=g\n" bufNewZ(
"recovery-option=hijk=l\n" "[global:restore]\n"
"\n" "recovery-option=f=g\n"
"[db]\n" "recovery-option=hijk=l\n"
"pg1-path=/path/to/db\n" "\n"
))); "[db]\n"
"pg1-path=/path/to/db\n"));
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), TEST_COMMAND_RESTORE " command"); TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), TEST_COMMAND_RESTORE " command");
@ -1280,13 +1285,14 @@ testRun(void)
strLstAdd(argList, strNewFmt("--config=%s", strPtr(configFile))); strLstAdd(argList, strNewFmt("--config=%s", strPtr(configFile)));
strLstAdd(argList, strNew("info")); strLstAdd(argList, strNew("info"));
storagePutNP(storageNewWriteNP(storageLocalWrite(), configFile), bufNewStr(strNew( storagePutNP(
"[global]\n" storageNewWriteNP(storageLocalWrite(), configFile),
"repo1-path=/path/to/repo\n" bufNewZ(
"\n" "[global]\n"
"[db]\n" "repo1-path=/path/to/repo\n"
"repo1-path=/not/the/path\n" "\n"
))); "[db]\n"
"repo1-path=/not/the/path\n"));
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "info command"); 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(strPtr(cfgOptionStr(cfgOptRepoPath)), "/path/to/repo", "check repo1-path option");

View File

@ -34,9 +34,9 @@ testRun(void)
TEST_ASSIGN(hashFilter, cryptoHashFilter(hash), "create sha1 hash"); TEST_ASSIGN(hashFilter, cryptoHashFilter(hash), "create sha1 hash");
TEST_RESULT_VOID(cryptoHashProcessC(hash, (const unsigned char *)"1", 1), " add 1"); TEST_RESULT_VOID(cryptoHashProcessC(hash, (const unsigned char *)"1", 1), " add 1");
TEST_RESULT_VOID(cryptoHashProcessStr(hash, strNew("2")), " add 2"); TEST_RESULT_VOID(cryptoHashProcessStr(hash, strNew("2")), " add 2");
TEST_RESULT_VOID(ioFilterProcessIn(hashFilter, bufNewStr(strNew("3"))), " add 3"); TEST_RESULT_VOID(ioFilterProcessIn(hashFilter, bufNewZ("3")), " add 3");
TEST_RESULT_VOID(ioFilterProcessIn(hashFilter, bufNewStr(strNew("4"))), " add 4"); TEST_RESULT_VOID(ioFilterProcessIn(hashFilter, bufNewZ("4")), " add 4");
TEST_RESULT_VOID(ioFilterProcessIn(hashFilter, bufNewStr(strNew("5"))), " add 5"); TEST_RESULT_VOID(ioFilterProcessIn(hashFilter, bufNewZ("5")), " add 5");
TEST_RESULT_STR( TEST_RESULT_STR(
strPtr(varStr(ioFilterResult(hashFilter))), "8cb2237d0679ca88db6464eac60da96345513964", " check small hash"); strPtr(varStr(ioFilterResult(hashFilter))), "8cb2237d0679ca88db6464eac60da96345513964", " check small hash");
@ -57,7 +57,7 @@ testRun(void)
if (testBegin("cryptoHashOne*()")) if (testBegin("cryptoHashOne*()"))
{ {
TEST_RESULT_STR( TEST_RESULT_STR(
strPtr(cryptoHashOne(strNew(HASH_TYPE_SHA1), bufNewStr(strNew("12345")))), "8cb2237d0679ca88db6464eac60da96345513964", strPtr(cryptoHashOne(strNew(HASH_TYPE_SHA1), bufNewZ("12345"))), "8cb2237d0679ca88db6464eac60da96345513964",
" check small hash"); " check small hash");
TEST_RESULT_STR( TEST_RESULT_STR(
strPtr(cryptoHashOneStr(strNew(HASH_TYPE_SHA1), strNew("12345"))), "8cb2237d0679ca88db6464eac60da96345513964", strPtr(cryptoHashOneStr(strNew(HASH_TYPE_SHA1), strNew("12345"))), "8cb2237d0679ca88db6464eac60da96345513964",

View File

@ -198,7 +198,7 @@ testRun(void)
TEST_RESULT_INT(info.mode, 0770, " check mode"); TEST_RESULT_INT(info.mode, 0770, " check mode");
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
Buffer *buffer = bufNewStr(strNew("TESTFILE")); Buffer *buffer = bufNewZ("TESTFILE");
TEST_RESULT_VOID(storagePutNP(storageNewWriteNP(storageTest, fileName), buffer), "put test file"); TEST_RESULT_VOID(storagePutNP(storageNewWriteNP(storageTest, fileName), buffer), "put test file");
TEST_ASSIGN(info, storageInfoNP(storageTest, fileName), "get file info"); TEST_ASSIGN(info, storageInfoNP(storageTest, fileName), "get file info");
@ -254,13 +254,13 @@ testRun(void)
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_VOID( TEST_RESULT_VOID(
storagePutNP(storageNewWriteNP(storageTest, strNew("aaa.txt")), bufNewStr(strNew("aaa"))), "write aaa.text"); storagePutNP(storageNewWriteNP(storageTest, strNew("aaa.txt")), bufNewZ("aaa")), "write aaa.text");
TEST_RESULT_STR( TEST_RESULT_STR(
strPtr(strLstJoin(storageListNP(storageTest, NULL), ", ")), "aaa.txt, noperm", strPtr(strLstJoin(storageListNP(storageTest, NULL), ", ")), "aaa.txt, noperm",
"dir list"); "dir list");
TEST_RESULT_VOID( TEST_RESULT_VOID(
storagePutNP(storageNewWriteNP(storageTest, strNew("bbb.txt")), bufNewStr(strNew("bbb"))), "write bbb.text"); storagePutNP(storageNewWriteNP(storageTest, strNew("bbb.txt")), bufNewZ("bbb")), "write bbb.text");
TEST_RESULT_STR( TEST_RESULT_STR(
strPtr(strLstJoin(storageListP(storageTest, NULL, .expression = strNew("^bbb")), ", ")), "bbb.txt", "dir list"); strPtr(strLstJoin(storageListP(storageTest, NULL, .expression = strNew("^bbb")), ", ")), "bbb.txt", "dir list");
} }
@ -284,7 +284,7 @@ testRun(void)
TEST_RESULT_BOOL(storageCopyNP(source, destination), false, "copy and ignore missing file"); TEST_RESULT_BOOL(storageCopyNP(source, destination), false, "copy and ignore missing file");
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
Buffer *expectedBuffer = bufNewStr(strNew("TESTFILE\n")); Buffer *expectedBuffer = bufNewZ("TESTFILE\n");
TEST_RESULT_VOID(storagePutNP(storageNewWriteNP(storageTest, sourceFile), expectedBuffer), "write source file"); TEST_RESULT_VOID(storagePutNP(storageNewWriteNP(storageTest, sourceFile), expectedBuffer), "write source file");
source = storageNewReadNP(storageTest, sourceFile); source = storageNewReadNP(storageTest, sourceFile);
@ -319,7 +319,7 @@ testRun(void)
"unable to move '%s' to '%s': [13] Permission denied", strPtr(fileNoPerm), strPtr(destinationFile)); "unable to move '%s' to '%s': [13] Permission denied", strPtr(fileNoPerm), strPtr(destinationFile));
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
Buffer *buffer = bufNewStr(strNew("TESTFILE")); Buffer *buffer = bufNewZ("TESTFILE");
storagePutNP(storageNewWriteNP(storageTest, sourceFile), buffer); storagePutNP(storageNewWriteNP(storageTest, sourceFile), buffer);
source = storageNewReadNP(storageTest, sourceFile); source = storageNewReadNP(storageTest, sourceFile);
@ -604,7 +604,7 @@ testRun(void)
TEST_RESULT_BOOL(storageExistsNP(storageTest, emptyFile), true, "check empty file exists"); TEST_RESULT_BOOL(storageExistsNP(storageTest, emptyFile), true, "check empty file exists");
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
Buffer *buffer = bufNewStr(strNew("TESTFILE\n")); Buffer *buffer = bufNewZ("TESTFILE\n");
TEST_RESULT_VOID( TEST_RESULT_VOID(
storagePutNP(storageNewWriteNP(storageTest, strNewFmt("%s/test.txt", testPath())), buffer), "put test file"); storagePutNP(storageNewWriteNP(storageTest, strNewFmt("%s/test.txt", testPath())), buffer), "put test file");
@ -695,7 +695,7 @@ testRun(void)
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
Buffer *outBuffer = bufNew(2); Buffer *outBuffer = bufNew(2);
Buffer *expectedBuffer = bufNewStr(strNew("TESTFILE\n")); Buffer *expectedBuffer = bufNewZ("TESTFILE\n");
TEST_RESULT_VOID(storagePutNP(storageNewWriteNP(storageTest, fileName), expectedBuffer), "write test file"); TEST_RESULT_VOID(storagePutNP(storageNewWriteNP(storageTest, fileName), expectedBuffer), "write test file");
TEST_ASSIGN(file, storageNewReadNP(storageTest, fileName), "new read file"); TEST_ASSIGN(file, storageNewReadNP(storageTest, fileName), "new read file");
@ -805,7 +805,7 @@ testRun(void)
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
String *fileTmp = strNewFmt("%s.pgbackrest.tmp", strPtr(fileName)); String *fileTmp = strNewFmt("%s.pgbackrest.tmp", strPtr(fileName));
ioBufferSizeSet(10); ioBufferSizeSet(10);
Buffer *buffer = bufNewStr(strNew("TESTFILE\n")); Buffer *buffer = bufNewZ("TESTFILE\n");
TEST_ASSIGN(file, storageNewWriteNP(storageTest, fileName), "new write file"); TEST_ASSIGN(file, storageNewWriteNP(storageTest, fileName), "new write file");
TEST_RESULT_STR(strPtr(storageFileWriteName(file)), strPtr(fileName), " check file name"); TEST_RESULT_STR(strPtr(storageFileWriteName(file)), strPtr(fileName), " check file name");