diff --git a/test/src/common/harnessStorage.c b/test/src/common/harnessStorage.c index b8570eb22..1a96d1295 100644 --- a/test/src/common/harnessStorage.c +++ b/test/src/common/harnessStorage.c @@ -361,6 +361,32 @@ hrnStorageMove( hrnTestResultEnd(); } +/**********************************************************************************************************************************/ +void +hrnStorageCopy( + const Storage *const storageSource, const char *const fileSource, const Storage *const storageDest, const char *const fileDest, + HrnStorageCopyParam param) +{ + hrnTestResultBegin(__func__, false); + + ASSERT(storageSource != NULL); + ASSERT(fileSource != NULL); + ASSERT(storageDest != NULL); + ASSERT(fileDest != NULL); + + const String *const fileSourceStr = storagePathP(storageSource, STR(fileSource)); + const String *const fileDestStr = storagePathP(storageDest, STR(fileDest)); + + printf("copy '%s' to '%s'", strZ(fileSourceStr), strZ(fileDestStr)); + + hrnTestResultComment(param.comment); + + // Copy the file + storageCopyP(storageNewReadP(storageSource, fileSourceStr), storageNewWriteP(storageDest, fileDestStr)); + + hrnTestResultEnd(); +} + /**********************************************************************************************************************************/ void hrnStoragePut( diff --git a/test/src/common/harnessStorage.h b/test/src/common/harnessStorage.h index 9684f1284..aeac7c9d9 100644 --- a/test/src/common/harnessStorage.h +++ b/test/src/common/harnessStorage.h @@ -120,6 +120,27 @@ typedef struct HrnStorageMoveParam void hrnStorageMove( const Storage *const storage, const char *const fileSource, const char *const fileDest, HrnStorageMoveParam param); +/*********************************************************************************************************************************** +Copy a file +***********************************************************************************************************************************/ +typedef struct HrnStorageCopyParam +{ + VAR_PARAM_HEADER; + const char *comment; // Comment +} HrnStorageCopyParam; + +#define HRN_STORAGE_COPY(storageSource, fileSource, storageDest, fileDest, ...) \ + do \ + { \ + hrnTestLogPrefix(__LINE__); \ + hrnStorageCopy(storageSource, fileSource, storageDest, fileDest, (HrnStorageCopyParam){VAR_PARAM_INIT, __VA_ARGS__}); \ + } \ + while (0) + +void hrnStorageCopy( + const Storage *const storageSource, const char *const fileSource, const Storage *const storageDest, const char *const fileDest, + HrnStorageCopyParam param); + /*********************************************************************************************************************************** Create a path ***********************************************************************************************************************************/