summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngo Huerner <ingo.huerner@xse.de>2014-07-07 15:55:20 +0200
committerIngo Huerner <ingo.huerner@xse.de>2014-07-07 15:55:20 +0200
commit4680fad3bd70ee363838ceb74c0259e5718be3fa (patch)
treef4b5a79d56237ce179226ec39f914a9dfc8e6702
parentb13802972ee82370c33a14150e480220761cac75 (diff)
downloadpersistence-client-library-4680fad3bd70ee363838ceb74c0259e5718be3fa.tar.gz
Implemented backup blacklist for files
-rw-r--r--src/persistence_client_library.c13
-rw-r--r--src/persistence_client_library_backup_filelist.c64
-rw-r--r--src/persistence_client_library_data_organization.c7
-rw-r--r--src/persistence_client_library_data_organization.h15
-rw-r--r--src/persistence_client_library_file.c58
-rw-r--r--src/persistence_client_library_handle.c5
-rw-r--r--src/persistence_client_library_handle.h3
-rw-r--r--src/persistence_client_library_prct_access.c4
-rw-r--r--test/data/PAS_data.tar.gzbin5291 -> 5843 bytes
-rw-r--r--test/persistence_client_library_test.c103
10 files changed, 200 insertions, 72 deletions
diff --git a/src/persistence_client_library.c b/src/persistence_client_library.c
index 93e2339..2bc2608 100644
--- a/src/persistence_client_library.c
+++ b/src/persistence_client_library.c
@@ -70,8 +70,7 @@ int pclInitLibrary(const char* appName, int shutdownMode)
/// environment variable for max key value data
const char *pDataSize = getenv("PERS_MAX_KEY_VAL_DATA_SIZE");
- /// blacklist path environment variable
- const char *pBlacklistPath = getenv("PERS_BLACKLIST_PATH");
+ char blacklistPath[DbPathMaxLen] = {0};
#if USE_FILECACHE
DLT_LOG(gPclDLTContext, DLT_LOG_INFO, DLT_STRING("Using the filecache!!!"));
@@ -85,14 +84,12 @@ int pclInitLibrary(const char* appName, int shutdownMode)
gMaxKeyValDataSize = atoi(pDataSize);
}
- if(pBlacklistPath == NULL)
- {
- pBlacklistPath = "/etc/pclBackupBlacklist.txt"; // default path
- }
+ // Assemble backup blacklist path
+ sprintf(blacklistPath, "%s%s/%s", CACHEPREFIX, appName, gBackupFilename);
- if(readBlacklistConfigFile(pBlacklistPath) == -1)
+ if(readBlacklistConfigFile(blacklistPath) == -1)
{
- DLT_LOG(gPclDLTContext, DLT_LOG_WARN, DLT_STRING("pclInitLibrary -> failed to access blacklist:"), DLT_STRING(pBlacklistPath));
+ DLT_LOG(gPclDLTContext, DLT_LOG_WARN, DLT_STRING("pclInitLibrary -> failed to access blacklist:"), DLT_STRING(blacklistPath));
}
if(setup_dbus_mainloop() == -1)
diff --git a/src/persistence_client_library_backup_filelist.c b/src/persistence_client_library_backup_filelist.c
index 11312f7..7b596dc 100644
--- a/src/persistence_client_library_backup_filelist.c
+++ b/src/persistence_client_library_backup_filelist.c
@@ -100,10 +100,8 @@ static void fillFileBackupCharTokenArray()
static void createAndStoreFileNames()
{
- int i= 0, j =0;
- char path[128];
- const char* gFilePostFix = ".pers";
- const char* gKeyPathFormat = "/%s/%s/%s/%s/%s%s";
+ int i= 0;
+ char path[128] = {0};
key_value_s* item;
// creat new tree
@@ -111,32 +109,30 @@ static void createAndStoreFileNames()
if(gRb_tree_bl != NULL)
{
-
- for(i=0; i<128; i++)
- {
- // assemble path
- snprintf(path, 128, gKeyPathFormat, gpTokenArray[j+2], // storage type
- gpTokenArray[j+3], // policy id
- gpTokenArray[j+4], // profileID
- gpTokenArray[j], // application id
- gpTokenArray[j+1], // filename
- gFilePostFix); // file postfix
-
- // asign key and value to the rbtree item
- item = malloc(sizeof(key_value_s));
- if(item != NULL)
- {
- item->key = pclCrc32(0, (unsigned char*)path, strlen(path));
- // we don't need the path name here, we just need to know that this key is available in the tree
- item->value = "";
- jsw_rbinsert(gRb_tree_bl, item);
- free(item);
- }
- j+=5;
- if(gpTokenArray[j] == NULL)
- {
- break;
- }
+ while( i < TOKENARRAYSIZE )
+ {
+ if(gpTokenArray[i+1] != 0 )
+ {
+ memset(path, 0, sizeof(path));
+ snprintf(path, 128, "%s", gpTokenArray[i]); // storage type
+
+ // asign key and value to the rbtree item
+ item = malloc(sizeof(key_value_s));
+ if(item != NULL)
+ {
+ //printf("createAndStoreFileNames => path: %s\n", path);
+ item->key = pclCrc32(0, (unsigned char*)path, strlen(path));
+ // we don't need the path name here, we just need to know that this key is available in the tree
+ item->value = "";
+ jsw_rbinsert(gRb_tree_bl, item);
+ free(item);
+ }
+ i+=1;
+ }
+ else
+ {
+ break;
+ }
}
}
@@ -153,7 +149,6 @@ int readBlacklistConfigFile(const char* filename)
if(filename != NULL)
{
-
memset(&buffer, 0, sizeof(buffer));
status = stat(filename, &buffer);
if(status != -1)
@@ -212,7 +207,7 @@ int readBlacklistConfigFile(const char* filename)
int need_backup_key(unsigned int key)
{
- int rval = 1;
+ int rval = CREATE_BACKUP;
key_value_s* item = NULL;
key_value_s* foundItem = NULL;
@@ -223,7 +218,7 @@ int need_backup_key(unsigned int key)
foundItem = (key_value_s*)jsw_rbfind(gRb_tree_bl, item);
if(foundItem != NULL)
{
- rval = 0;
+ rval = DONT_CREATE_BACKUP;
}
free(item);
}
@@ -232,8 +227,7 @@ int need_backup_key(unsigned int key)
if(item!=NULL)
free(item);
- rval = -1;
- DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("need_backup_key ==> item or gRb_tree_bl is NULL"));
+ rval = CREATE_BACKUP;
}
return rval;
diff --git a/src/persistence_client_library_data_organization.c b/src/persistence_client_library_data_organization.c
index 0723f75..c2d26f5 100644
--- a/src/persistence_client_library_data_organization.c
+++ b/src/persistence_client_library_data_organization.c
@@ -23,12 +23,6 @@
#include <stdlib.h>
-// define PERS_ORG_ROOT_PATH comes form persistence common object
-
-/// cached path location
-#define CACHEPREFIX PERS_ORG_ROOT_PATH "/mnt-c/"
-/// write through path location
-#define WTPREFIX PERS_ORG_ROOT_PATH "/mnt-wt/"
/// path for the backup location
const char* gBackupPrefix = PERS_ORG_ROOT_PATH "/mnt-backup/";
@@ -72,6 +66,7 @@ const char* gSharedPublicWtPathKey = WTPREFIX "%s/shared_public%s";
// path prefix for local cached files: /Data/mnt_c/<appId>/<user>/<seat>/<resource>
const char* gLocalCacheFilePath = CACHEPREFIX "%s"PERS_ORG_USER_FOLDER_NAME_"%d"PERS_ORG_SEAT_FOLDER_NAME_"%d/%s";
+const char* gBackupFilename = "BackupFileList.info";
const char* gChangeSignal = "PersistenceResChange";
const char* gDeleteSignal = "PersistenceResDelete";
diff --git a/src/persistence_client_library_data_organization.h b/src/persistence_client_library_data_organization.h
index 1efb88a..7e0fa72 100644
--- a/src/persistence_client_library_data_organization.h
+++ b/src/persistence_client_library_data_organization.h
@@ -109,6 +109,10 @@ typedef enum _PersNotifyRegPolicy_e
/// constant definitions
enum _PersistenceConstantDef
{
+ /// flag to identify if a backup should NOT be created
+ DONT_CREATE_BACKUP = 0,
+ /// flag to identify if a backup should be created
+ CREATE_BACKUP = 1,
/// flag to identify that resource a not file
ResIsNoFile = 0,
/// flag to identify that resource a file
@@ -191,6 +195,14 @@ enum _PersistenceConstantDef
defaultMaxKeyValDataSize = PERS_DB_MAX_SIZE_KEY_DATA
};
+
+// define PERS_ORG_ROOT_PATH comes form persistence common object
+
+/// cached path location
+#define CACHEPREFIX PERS_ORG_ROOT_PATH "/mnt-c/"
+/// write through path location
+#define WTPREFIX PERS_ORG_ROOT_PATH "/mnt-wt/"
+
/// path for the backup location
extern const char* gBackupPrefix;
/// backup filename postfix
@@ -232,6 +244,9 @@ extern const char* gSharedPublicWtPathKey;
/// path prefix for local cached files: /Data/mnt_c/&lt;appId&gt;/&lt;user&gt;/&gt;userno&gt;/&lt;seat&gt;/&gt;seatno&gt;/&lt;resource&gt;
extern const char* gLocalCacheFilePath;
+// backup blacklist filename
+extern const char* gBackupFilename;
+
/// application id
extern char gAppId[MaxAppNameLen];
diff --git a/src/persistence_client_library_file.c b/src/persistence_client_library_file.c
index 3f4cb32..c2d20e7 100644
--- a/src/persistence_client_library_file.c
+++ b/src/persistence_client_library_file.c
@@ -46,6 +46,28 @@
int pclFileGetDefaultData(int handle, const char* resource_id, int policy);
+char* get_raw_string(char* dbKey)
+{
+ char* keyPtr = NULL;
+ int cnt = 0, i = 0;
+
+ for(i=0; i<DbKeyMaxLen; i++)
+ {
+ if(dbKey[i] == '/')
+ {
+ cnt++;
+ }
+
+ if(cnt >= 5) // stop after the 5th '/' has been found
+ {
+ break;
+ }
+ keyPtr = dbKey+i;
+ }
+ return ++keyPtr;
+}
+
+
int pclFileClose(int fd)
{
int rval = EPERS_NOT_INITIALIZED;
@@ -139,7 +161,6 @@ void* pclFileMapData(void* addr, long size, long offset, int fd)
}
-
int pclFileOpen(unsigned int ldbid, const char* resource_id, unsigned int user_no, unsigned int seat_no)
{
int handle = EPERS_NOT_INITIALIZED;
@@ -147,12 +168,13 @@ int pclFileOpen(unsigned int ldbid, const char* resource_id, unsigned int user_n
if(gPclInitialized >= PCLinitialized)
{
int shared_DB = 0;
+ int wantBackup = 1;
PersistenceInfo_s dbContext;
- char dbKey[DbKeyMaxLen] = {0}; // database key
- char dbPath[DbPathMaxLen] = {0}; // database location
+ char dbKey[DbKeyMaxLen] = {0}; // database key
+ char dbPath[DbPathMaxLen] = {0}; // database location
char backupPath[DbPathMaxLen] = {0}; // backup file
- char csumPath[DbPathMaxLen] = {0}; // checksum file
+ char csumPath[DbPathMaxLen] = {0}; // checksum file
//DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclFileOpen: "), DLT_INT(ldbid), DLT_STRING(resource_id) );
@@ -188,8 +210,9 @@ int pclFileOpen(unsigned int ldbid, const char* resource_id, unsigned int user_n
// file will be opened writable, so check about data consistency
if( (dbContext.configKey.permission != PersistencePermission_ReadOnly)
- && pclBackupNeeded(dbPath) )
+ && (pclBackupNeeded(get_raw_string(dbKey)) == CREATE_BACKUP))
{
+ wantBackup = 0;
if((handle = pclVerifyConsistency(dbPath, backupPath, csumPath, flags)) == -1)
{
DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("pclFileOpen: error => file inconsistent, recovery N O T possible!"));
@@ -198,7 +221,11 @@ int pclFileOpen(unsigned int ldbid, const char* resource_id, unsigned int user_n
}
else
{
- DLT_LOG(gPclDLTContext, DLT_LOG_INFO, DLT_STRING("pclFileOpen: No Backup => file is read only OR is in blacklist!"));
+ if(dbContext.configKey.permission == PersistencePermission_ReadOnly)
+ DLT_LOG(gPclDLTContext, DLT_LOG_INFO, DLT_STRING("pclFileOpen: No Backup => file is READ ONLY!"), DLT_STRING(dbKey));
+ else
+ DLT_LOG(gPclDLTContext, DLT_LOG_INFO, DLT_STRING("pclFileOpen: No Backup => file is in backup blacklist!"), DLT_STRING(dbKey));
+
}
#if USE_FILECACHE
@@ -234,8 +261,9 @@ int pclFileOpen(unsigned int ldbid, const char* resource_id, unsigned int user_n
if(dbContext.configKey.permission != PersistencePermission_ReadOnly)
{
- if(set_file_handle_data(handle, dbContext.configKey.permission, 0 /*backupCreated*/, backupPath, csumPath, NULL) != -1)
+ if(set_file_handle_data(handle, dbContext.configKey.permission, backupPath, csumPath, NULL) != -1)
{
+ set_file_backup_status(handle, wantBackup);
__sync_fetch_and_add(&gOpenFdArray[handle], FileOpen); // set open flag
}
else
@@ -254,9 +282,9 @@ int pclFileOpen(unsigned int ldbid, const char* resource_id, unsigned int user_n
if(handle != -1)
{
-
- if(set_file_handle_data(handle, PersistencePermission_ReadWrite, 0 /*backupCreated*/, backupPath, csumPath, NULL) != -1)
+ if(set_file_handle_data(handle, PersistencePermission_ReadWrite, backupPath, csumPath, NULL) != -1)
{
+ set_file_backup_status(handle, 1);
__sync_fetch_and_add(&gOpenFdArray[handle], FileOpen); // set open flag
}
else
@@ -432,6 +460,7 @@ int pclFileWriteData(int fd, const void * buffer, int buffer_size)
}
else
{
+ DLT_LOG(gPclDLTContext, DLT_LOG_INFO, DLT_STRING("pclFileWriteData: Failed to write ==> read only file!"), DLT_STRING(get_file_backup_path(fd)));
size = EPERS_RESOURCE_READ_ONLY;
}
}
@@ -481,14 +510,14 @@ int pclFileCreatePath(unsigned int ldbid, const char* resource_id, unsigned int
// file will be opened writable, so check about data consistency
if( dbContext.configKey.permission != PersistencePermission_ReadOnly
- && pclBackupNeeded(dbPath) )
+ && pclBackupNeeded( get_raw_string(dbPath)) == CREATE_BACKUP)
{
snprintf(backupPath, DbPathMaxLen-1, "%s%s", dbPath, gBackupPostfix);
snprintf(csumPath, DbPathMaxLen-1, "%s%s", dbPath, gBackupCsPostfix);
if((handle = pclVerifyConsistency(dbPath, backupPath, csumPath, flags)) == -1)
{
- DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("pclFileOpen: error => file inconsistent, recovery N O T possible!"));
+ DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("pclFileCreatePath: error => file inconsistent, recovery N O T possible!"));
return -1;
}
// we don't need the file handle here
@@ -496,6 +525,10 @@ int pclFileCreatePath(unsigned int ldbid, const char* resource_id, unsigned int
if(handle > 0)
close(handle);
}
+ else
+ {
+ DLT_LOG(gPclDLTContext, DLT_LOG_INFO, DLT_STRING("pclFileCreatePath: No Backup => read only OR in blacklist!"), DLT_STRING(dbKey));
+ }
handle = get_persistence_handle_idx();
@@ -672,6 +705,5 @@ int pclFileGetDefaultData(int handle, const char* resource_id, int policy)
}
return rval;
-}// getDefault
-
+}
diff --git a/src/persistence_client_library_handle.c b/src/persistence_client_library_handle.c
index bcb4e23..aac4a71 100644
--- a/src/persistence_client_library_handle.c
+++ b/src/persistence_client_library_handle.c
@@ -183,8 +183,7 @@ void clear_key_handle_array(int idx)
}
-int set_file_handle_data(int idx, PersistencePermission_e permission, int backupCreated,
- const char* backup, const char* csumPath, char* filePath)
+int set_file_handle_data(int idx, PersistencePermission_e permission, const char* backup, const char* csumPath, char* filePath)
{
int rval = 0;
@@ -194,7 +193,7 @@ int set_file_handle_data(int idx, PersistencePermission_e permission, int backup
{
strcpy(gFileHandleArray[idx].backupPath, backup);
strcpy(gFileHandleArray[idx].csumPath, csumPath);
- gFileHandleArray[idx].backupCreated = backupCreated;
+ gFileHandleArray[idx].backupCreated = 0; // set to 0 by default
gFileHandleArray[idx].permission = permission;
gFileHandleArray[idx].filePath = filePath; // check to do if this works
}
diff --git a/src/persistence_client_library_handle.h b/src/persistence_client_library_handle.h
index 5bd82cb..d4d1260 100644
--- a/src/persistence_client_library_handle.h
+++ b/src/persistence_client_library_handle.h
@@ -140,8 +140,7 @@ void clear_key_handle_array(int idx);
* @param filePath the path to the file
*
*/
-int set_file_handle_data(int idx, PersistencePermission_e permission, int backupCreated,
- const char* backup, const char* csumPath, char* filePath);
+int set_file_handle_data(int idx, PersistencePermission_e permission, const char* backup, const char* csumPath, char* filePath);
/**
diff --git a/src/persistence_client_library_prct_access.c b/src/persistence_client_library_prct_access.c
index a53dad3..dcbcbea 100644
--- a/src/persistence_client_library_prct_access.c
+++ b/src/persistence_client_library_prct_access.c
@@ -50,7 +50,6 @@ typedef enum _PersistenceRCT_e
} PersistenceRCT_e;
-
PersistenceRCT_e get_table_id(int ldbid, int* groupId)
{
PersistenceRCT_e rctType = PersistenceRCT_LastEntry;
@@ -92,7 +91,7 @@ void invalidate_resource_cfg_table(int i)
gResource_table[i] = -1;
}
-// status: OK
+
int get_resource_cfg_table(PersistenceRCT_e rct, int group)
{
int arrayIdx = 0;
@@ -226,7 +225,6 @@ int get_db_context(PersistenceInfo_s* dbContext, const char* resource_id, unsign
-// status: OK
int get_db_path_and_key(PersistenceInfo_s* dbContext, const char* resource_id, char dbKey[], char dbPath[])
{
int storePolicy = PersistenceStorage_LastEntry;
diff --git a/test/data/PAS_data.tar.gz b/test/data/PAS_data.tar.gz
index ea68d6c..b3c9879 100644
--- a/test/data/PAS_data.tar.gz
+++ b/test/data/PAS_data.tar.gz
Binary files differ
diff --git a/test/persistence_client_library_test.c b/test/persistence_client_library_test.c
index 12d4761..be5bbe9 100644
--- a/test/persistence_client_library_test.c
+++ b/test/persistence_client_library_test.c
@@ -58,6 +58,7 @@ char* gWriteRecoveryTestData = "This is the data to recover: /Data/mnt-c/lt-pers
char* gRecovChecksum = "608a3b5d"; // generated with http://www.tools4noobs.com/online_php_functions/crc32/
+
void data_teardown(void)
{
printf("* * * tear down * * *\n"); // nothing
@@ -575,6 +576,38 @@ END_TEST
+// creat blacklist file, if this does not exist
+void data_setupBlacklist(void)
+{
+
+/// backup info
+char gBackupInfo[] = {
+"/media/doNotBackupMe.txt_START\n\
+/media/doNotBackupMe_01.txt\n\
+/media/doNotBackupMe_02.txt\n\
+/media/doNotBackupMe_03.txt\n\
+/media/doNotBackupMe_04.txt\n\
+/media/iDontWantDoBeBackuped_01.txt\n\
+/media/iDontWantDoBeBackuped_02.txt\n\
+/media/iDontWantDoBeBackuped_03.txt\n\
+/media/iDontWantDoBeBackuped_04.txt\n\
+/media/iDontWantDoBeBackuped_05.txt_END\n"
+};
+
+ const char* backupBlacklist = "/Data/mnt-c/lt-persistence_client_library_test/BackupFileList.info";
+
+ if(access(backupBlacklist, F_OK) == -1)
+ {
+ int handle = open(backupBlacklist, O_CREAT|O_RDWR|O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
+
+ write(handle, gBackupInfo, strlen(gBackupInfo));
+ close(handle);
+ }
+
+ printf("Finished: ==> data_setupBlacklist\n");
+}
+
+
/*
* Test the file interface:
* - open file
@@ -592,15 +625,18 @@ START_TEST(test_DataFile)
X_TEST_REPORT_TYPE(GOOD);
int fd = 0, i = 0, idx = 0;
- int size = 0, ret = 0;
+ int size = 0, ret = 0, avail = 100;
int writeSize = 16*1024;
+ int fdArray[10] = {0};
unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
unsigned char buffer[READ_SIZE] = {0};
+ unsigned char wBuffer[READ_SIZE] = {0};
const char* refBuffer = "/Data/mnt-wt/lt-persistence_client_library_test/user/1/seat/1/media";
char* writeBuffer;
char* fileMap = NULL;
+ printf("test_DataFile ==> S T A R T\n");
ret = pclInitLibrary(gTheAppId, shutdownReg);
x_fail_unless(ret <= 1, "Failed to init PCL");
#if 1
@@ -675,6 +711,66 @@ START_TEST(test_DataFile)
ret = pclFileClose(fd);
x_fail_unless(ret == 0, "Failed to close file");
+
+ // test backup blacklist functionality
+ fdArray[0] = pclFileOpen(0xFF, "media/doNotBackupMe.txt_START", 1, 1);
+ fdArray[1] = pclFileOpen(0xFF, "media/doNotBackupMe.txt_START", 1, 2);
+ fdArray[2] = pclFileOpen(0xFF, "media/doNotBackupMe.txt_START", 20, 10);
+ fdArray[3] = pclFileOpen(0xFF, "media/doNotBackupMe.txt_START", 200, 100);
+
+ fdArray[4] = pclFileOpen(0xFF, "media/doNotBackupMe_01.txt", 2, 1);
+ fdArray[5] = pclFileOpen(0xFF, "media/doNotBackupMe_02.txt", 2, 1);
+ fdArray[6] = pclFileOpen(0xFF, "media/doNotBackupMe_03.txt", 2, 1);
+ fdArray[7] = pclFileOpen(0xFF, "media/doNotBackupMe_04.txt", 2, 1);
+
+ fdArray[8] = pclFileOpen(0xFF, "media/iDontWantDoBeBackuped_04.txt", 2, 1);
+ fdArray[9] = pclFileOpen(0xFF, "media/iDontWantDoBeBackuped_05.txt_END", 2, 1);
+
+ for(i=0; i<10; i++)
+ {
+ snprintf( (char*)wBuffer, 1024, "Test - %d", i);
+ pclFileWriteData(fdArray[i], wBuffer, strlen( (char*)wBuffer));
+ }
+
+ //
+ // test if backup blacklist works correctly
+ //
+ avail = access("/Data/mnt-backup/lt-persistence_client_library_test/user/1/seat/1/media/doNotBackupMe.txt_START~", F_OK);
+ x_fail_unless(avail == -1, "1. Failed backup => backup available, but should not");
+
+
+ avail = access("/Data/mnt-backup/lt-persistence_client_library_test/user/1/seat/2/media/doNotBackupMe.txt_START~", F_OK);
+ x_fail_unless(avail == -1, "2. Failed backup => backup available, but should not");
+
+ avail = access("/Data/mnt-backup/lt-persistence_client_library_test/user/20/seat/10/media/doNotBackupMe.txt_START~", F_OK);
+ x_fail_unless(avail == -1, "3. Failed backup => backup available, but should not");
+
+ avail = access("/Data/mnt-backup/lt-persistence_client_library_test/user/200/seat/100/media/doNotBackupMe.txt_START~", F_OK);
+ x_fail_unless(avail == -1, "4. Failed backup => backup available, but should not");
+
+ avail = access("/Data/mnt-backup/lt-persistence_client_library_test/user/2/seat/1/media/doNotBackupMe_01.txt~", F_OK);
+ x_fail_unless(avail == -1, "5. Failed backup => backup available, but should not");
+
+ avail = access("/Data/mnt-backup/lt-persistence_client_library_test/user/2/seat/1/media/doNotBackupMe_02.txt~", F_OK);
+ x_fail_unless(avail == -1, "6. Failed backup => backup available, but should not");
+
+ avail = access("/Data/mnt-backup/lt-persistence_client_library_test/user/2/seat/1/media/doNotBackupMe_03.txt~", F_OK);
+ x_fail_unless(avail == -1, "7. Failed backup => backup available, but should not");
+
+ avail = access("/Data/mnt-backup/lt-persistence_client_library_test/user/2/seat/1/media/doNotBackupMe_04.txt~", F_OK);
+ x_fail_unless(avail == -1, "8. Failed backup => backup available, but should not");
+
+ avail = access("/Data/mnt-backup/lt-persistence_client_library_test/user/2/seat/1/media/iDontWantDoBeBackuped_04.txt~", F_OK);
+ x_fail_unless(avail == -1, "9. Failed backup => backup available, but should not");
+
+ avail = access("/Data/mnt-backup/lt-persistence_client_library_test/user/2/seat/1/media/iDontWantDoBeBackuped_05.txt_END~", F_OK);
+ x_fail_unless(avail == -1, "10. Failed backup => backup available, but should not");
+
+ for(i=0; i<10; i++)
+ {
+ pclFileClose(fdArray[i]);
+ }
+
free(writeBuffer);
#endif
pclDeinitLibrary();
@@ -737,6 +833,7 @@ START_TEST(test_DataFileBackupCreation)
// verify the backup creation:
handle = open(path, O_RDWR);
+ printf("Path: %s | handle: %d\n", path, handle);
x_fail_unless(handle != -1, "Could not open file ==> failed to access backup file");
rval = read(handle, rBuffer, 1024);
@@ -870,7 +967,6 @@ START_TEST(test_DataHandle)
// test multiple handles
handleArray[0] = pclFileOpen(0xFF, "media/mediaDB_write_01.db", 1, 1);
- printf("** **** **** **** ** handleArray[0] => %d\n", handleArray[0]);
x_fail_unless(handle1 != -1, "Could not open file ==> /media/mediaDB_write_01.db");
handleArray[1] = pclFileOpen(0xFF, "media/mediaDB_write_02.db", 1, 1);
@@ -1332,8 +1428,11 @@ static Suite * persistencyClientLib_suite()
suite_add_tcase(s, tc_ReadConfDefault);
suite_add_tcase(s, tc_persDataFile);
+ tcase_add_checked_fixture(tc_persDataFile, data_setupBlacklist, data_teardown);
+
suite_add_tcase(s, tc_persDataFileBackupCreation);
tcase_add_checked_fixture(tc_persDataFileBackupCreation, data_setupBackup, data_teardown);
+
suite_add_tcase(s, tc_persDataFileRecovery);
tcase_add_checked_fixture(tc_persDataFileRecovery, data_setupRecovery, data_teardown);