1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-03-03 14:52:21 +02:00

Move storageHelperFree() to storageHelper test harness.

This function was only used for testing so move into a test harness.
This commit is contained in:
David Steele 2022-12-31 13:14:27 +07:00
parent 8b218158ae
commit 2332ce8ffc
6 changed files with 48 additions and 19 deletions

View File

@ -567,17 +567,3 @@ storageSpoolWrite(void)
FUNCTION_TEST_RETURN_CONST(STORAGE, storageHelper.storageSpoolWrite);
}
/**********************************************************************************************************************************/
void
storageHelperFree(void)
{
FUNCTION_TEST_VOID();
if (storageHelper.memContext != NULL)
memContextFree(storageHelper.memContext);
storageHelper = (struct StorageHelperLocal){.memContext = NULL, .helperList = storageHelper.helperList};
FUNCTION_TEST_RETURN_VOID();
}

View File

@ -62,8 +62,4 @@ const Storage *storageRepoWrite(void);
const Storage *storageSpool(void);
const Storage *storageSpoolWrite(void);
// Free all storage helper objects. This should be done on any config load to ensure that stanza changes are honored. ?? Currently
// this is only done in testing, but in the future it will likely be done in production as well.
void storageHelperFree(void);
#endif

View File

@ -389,6 +389,10 @@ unit:
- name: lock
total: 3
harness: config
harness:
name: storageHelper
shim:
storage/helper: ~
coverage:
- common/lock

View File

@ -19,6 +19,7 @@ Harness for Loading Test Configurations
#include "common/harnessDebug.h"
#include "common/harnessLog.h"
#include "common/harnessTest.h"
#include "common/harnessStorageHelper.h"
/**********************************************************************************************************************************/
void
@ -73,7 +74,7 @@ hrnCfgLoad(ConfigCommand commandId, const StringList *argListParam, const HrnCfg
}
// Free objects in storage helper
storageHelperFree();
hrnStorageHelperFree();
// Parse config
configParse(storageLocal(), strLstSize(argList), strLstPtr(argList), false);

View File

@ -0,0 +1,25 @@
/***********************************************************************************************************************************
Storage Helper Test Harness
***********************************************************************************************************************************/
#include "build.auto.h"
#include "common/harnessStorageHelper.h"
/***********************************************************************************************************************************
Include shimmed C modules
***********************************************************************************************************************************/
{[SHIM_MODULE]}
/**********************************************************************************************************************************/
void
hrnStorageHelperFree(void)
{
FUNCTION_TEST_VOID();
if (storageHelper.memContext != NULL)
memContextFree(storageHelper.memContext);
storageHelper = (struct StorageHelperLocal){.memContext = NULL, .helperList = storageHelper.helperList};
FUNCTION_TEST_RETURN_VOID();
}

View File

@ -0,0 +1,17 @@
/***********************************************************************************************************************************
Storage Helper Test Harness
Helper functions for testing the storage helper.
***********************************************************************************************************************************/
#ifndef TEST_COMMON_HARNESS_STORAGE_HELPER_H
#define TEST_COMMON_HARNESS_STORAGE_HELPER_H
#include "storage/helper.h"
/***********************************************************************************************************************************
Functions
***********************************************************************************************************************************/
// Free all storage helper objects. This should be done on any config load to ensure that stanza changes are honored.
void hrnStorageHelperFree(void);
#endif