Skip to content
Permalink
Browse files

Add harnessInfoChecksum/Z() to ease creation of test info files.

  • Loading branch information...
dwsteele committed Apr 23, 2019
1 parent aebac47 commit f41112a4634421071d80686ae19042c652576cb3
@@ -74,6 +74,14 @@
</release-item>
</release-development-list>
</release-core-list>

<release-test-list>
<release-development-list>
<release-item>
<p>Add <code>harnessInfoChecksum/Z()</code> to ease creation of test info files.</p>
</release-item>
</release-development-list>
</release-test-list>
</release>

<release date="2019-04-18" version="2.13" title="Bug Fixes">
@@ -0,0 +1,55 @@
/***********************************************************************************************************************************
Harness for Loading Test Configurations
***********************************************************************************************************************************/
#include "common/harnessDebug.h"
#include "common/harnessInfo.h"

#include "common/io/bufferWrite.h"
#include "common/type/json.h"
#include "info/info.h"
#include "version.h"

/***********************************************************************************************************************************
Load a test configuration without any side effects
There's no need to open log files, acquire locks, reset log levels, etc.
***********************************************************************************************************************************/
Buffer *
harnessInfoChecksum(const String *info)
{
FUNCTION_HARNESS_BEGIN();
FUNCTION_HARNESS_PARAM(STRING, info);
FUNCTION_HARNESS_END();

Buffer *result = NULL;

MEM_CONTEXT_TEMP_BEGIN()
{
// Load data into an ini file
Ini *ini = iniNew();
iniParse(ini, info);

// Add header and checksum values
iniSet(ini, STRDEF("backrest"), STRDEF("backrest-version"), jsonFromStr(STRDEF(PROJECT_VERSION)));
iniSet(ini, STRDEF("backrest"), STRDEF("backrest-format"), jsonFromUInt(REPOSITORY_FORMAT));
iniSet(ini, STRDEF("backrest"), STRDEF("backrest-checksum"), jsonFromStr(infoHash(ini)));

// Write to a buffer
result = bufNew(0);
iniSave(ini, ioBufferWriteIo(ioBufferWriteNew(result)));
bufMove(result, MEM_CONTEXT_OLD());
}
MEM_CONTEXT_TEMP_END();

FUNCTION_HARNESS_RESULT(BUFFER, result);
}

Buffer *
harnessInfoChecksumZ(const char *info)
{
FUNCTION_HARNESS_BEGIN();
FUNCTION_HARNESS_PARAM(STRINGZ, info);
FUNCTION_HARNESS_END();

FUNCTION_HARNESS_RESULT(BUFFER, harnessInfoChecksum(STRDEF(info)));
}
@@ -0,0 +1,10 @@
/***********************************************************************************************************************************
Harness for Generating Test Info Files
***********************************************************************************************************************************/
#include "common/type/buffer.h"

/***********************************************************************************************************************************
Functions
***********************************************************************************************************************************/
Buffer *harnessInfoChecksum(const String *info);
Buffer *harnessInfoChecksumZ(const char *info);
@@ -1,16 +1,17 @@
/***********************************************************************************************************************************
Test Archive Get Command
***********************************************************************************************************************************/
#include "postgres/interface.h"
#include "postgres/version.h"

#include "common/compress/gzip/compress.h"
#include "common/harnessConfig.h"
#include "common/harnessFork.h"
#include "common/io/bufferRead.h"
#include "common/io/bufferWrite.h"
#include "postgres/interface.h"
#include "postgres/version.h"
#include "storage/driver/posix/storage.h"

#include "common/harnessInfo.h"

/***********************************************************************************************************************************
Test Run
***********************************************************************************************************************************/
@@ -53,12 +54,7 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
storagePutNP(
storageNewWriteNP(storageTest, strNew("repo/archive/test1/archive.info")),
BUFSTRDEF(
"[backrest]\n"
"backrest-checksum=\"806471e1481804dc3ddf8dc6f1da7c34939420a8\"\n"
"backrest-format=5\n"
"backrest-version=\"2.06\"\n"
"\n"
harnessInfoChecksumZ(
"[db]\n"
"db-id=1\n"
"\n"
@@ -73,12 +69,7 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
storagePutNP(
storageNewWriteNP(storageTest, strNew("repo/archive/test1/archive.info")),
BUFSTRDEF(
"[backrest]\n"
"backrest-checksum=\"4120e2a5c3918a480af951fb99bee7dc091f080a\"\n"
"backrest-format=5\n"
"backrest-version=\"2.06\"\n"
"\n"
harnessInfoChecksumZ(
"[db]\n"
"db-id=3\n"
"\n"
@@ -151,12 +142,7 @@ testRun(void)
// Create archive.info
storagePutNP(
storageNewWriteNP(storageTest, strNew("repo/archive/test1/archive.info")),
BUFSTRDEF(
"[backrest]\n"
"backrest-checksum=\"bf9d69c6131e906898511432b4445335f377b12b\"\n"
"backrest-format=5\n"
"backrest-version=\"2.06\"\n"
"\n"
harnessInfoChecksumZ(
"[db]\n"
"db-id=1\n"
"\n"
@@ -208,12 +194,7 @@ testRun(void)

storagePutNP(
infoWrite,
BUFSTRDEF(
"[backrest]\n"
"backrest-checksum=\"5e4bf8cafff30b488c01574411e858c7866df4a2\"\n"
"backrest-format=5\n"
"backrest-version=\"2.06\"\n"
"\n"
harnessInfoChecksumZ(
"[cipher]\n"
"cipher-pass=\"worstpassphraseever\"\n"
"\n"
@@ -372,12 +353,7 @@ testRun(void)

storagePutNP(
storageNewWriteNP(storageTest, strNew("repo/archive/test2/archive.info")),
BUFSTRDEF(
"[backrest]\n"
"backrest-checksum=\"398aa38312ce69e3625b2ecfb4dfc6387e5ce7d3\"\n"
"backrest-format=5\n"
"backrest-version=\"2.11\"\n"
"\n"
harnessInfoChecksumZ(
"[db]\n"
"db-id=1\n"
"\n"
@@ -11,6 +11,7 @@ Test Archive Push Command

#include "common/harnessConfig.h"
#include "common/harnessFork.h"
#include "common/harnessInfo.h"

/***********************************************************************************************************************************
Test Run
@@ -128,12 +129,7 @@ testRun(void)
// Create incorrect archive info
storagePutNP(
storageNewWriteNP(storageTest, strNew("repo/archive/test/archive.info")),
BUFSTRDEF(
"[backrest]\n"
"backrest-checksum=\"806471e1481804dc3ddf8dc6f1da7c34939420a8\"\n"
"backrest-format=5\n"
"backrest-version=\"2.06\"\n"
"\n"
harnessInfoChecksumZ(
"[db]\n"
"db-id=1\n"
"\n"
@@ -148,12 +144,7 @@ testRun(void)
// Fix the version
storagePutNP(
storageNewWriteNP(storageTest, strNew("repo/archive/test/archive.info")),
BUFSTRDEF(
"[backrest]\n"
"backrest-checksum=\"4656aad82fa16a5d87b1aed36cb8a20c2707b9f9\"\n"
"backrest-format=5\n"
"backrest-version=\"2.08\"\n"
"\n"
harnessInfoChecksumZ(
"[db]\n"
"db-id=1\n"
"\n"
@@ -168,12 +159,7 @@ testRun(void)
// Fix archive info
storagePutNP(
storageNewWriteNP(storageTest, strNew("repo/archive/test/archive.info")),
BUFSTRDEF(
"[backrest]\n"
"backrest-checksum=\"724b21c26c64f4c25567a11eb222c18766cbec00\"\n"
"backrest-format=5\n"
"backrest-version=\"2.11\"\n"
"\n"
harnessInfoChecksumZ(
"[db]\n"
"db-id=1\n"
"\n"
@@ -227,12 +213,7 @@ testRun(void)

storagePutNP(
storageNewWriteNP(storageTest, strNew("repo/archive/test/archive.info")),
BUFSTRDEF(
"[backrest]\n"
"backrest-checksum=\"f5c9e17258db65e8d22609e23d1e99985d6bb063\"\n"
"backrest-format=5\n"
"backrest-version=\"2.12\"\n"
"\n"
harnessInfoChecksumZ(
"[db]\n"
"db-id=1\n"
"\n"
@@ -401,12 +382,7 @@ testRun(void)

storagePutNP(
infoWrite,
BUFSTRDEF(
"[backrest]\n"
"backrest-checksum=\"4ce1b0e8f7132e3b5193a9c385f2d039dd75062f\"\n"
"backrest-format=5\n"
"backrest-version=\"2.12\"\n"
"\n"
harnessInfoChecksumZ(
"[cipher]\n"
"cipher-pass=\"badsubpassphrase\"\n"
"\n"
@@ -482,12 +458,7 @@ testRun(void)

storagePutNP(
storageNewWriteNP(storageTest, strNew("repo/archive/test/archive.info")),
BUFSTRDEF(
"[backrest]\n"
"backrest-checksum=\"d12be58a906afa894c34f49ac9cbb6b968efc5a4\"\n"
"backrest-format=5\n"
"backrest-version=\"2.12\"\n"
"\n"
harnessInfoChecksumZ(
"[db]\n"
"db-id=1\n"
"\n"
Oops, something went wrong.

0 comments on commit f41112a

Please sign in to comment.
You can’t perform that action at this time.