diff options
author | Ingo Huerner <ingo.huerner@xse.de> | 2014-06-24 17:43:13 +0200 |
---|---|---|
committer | Ingo Huerner <ingo.huerner@xse.de> | 2014-06-24 17:43:13 +0200 |
commit | e80d06d26005c2ad166711e592e1c70bad1d2048 (patch) | |
tree | e5c1aba33a10fbba0a4d1b0c9b497b0ddd844088 | |
parent | 5130ea993302082e52a790b828fd2935f9fe49b0 (diff) | |
download | persistence-client-library-e80d06d26005c2ad166711e592e1c70bad1d2048.tar.gz |
Added test plugins and plugin tests
-rw-r--r-- | config/pclCustomLibConfigFile.cfg | 6 | ||||
-rw-r--r-- | test/Makefile.am | 38 | ||||
-rw-r--r-- | test/persistence_client_library_dbus_test.c | 2 | ||||
-rw-r--r-- | test/persistence_client_library_test.c | 2 | ||||
-rw-r--r-- | test/persistence_test_customlib.c | 302 |
5 files changed, 348 insertions, 2 deletions
diff --git a/config/pclCustomLibConfigFile.cfg b/config/pclCustomLibConfigFile.cfg index e69de29..20727dc 100644 --- a/config/pclCustomLibConfigFile.cfg +++ b/config/pclCustomLibConfigFile.cfg @@ -0,0 +1,6 @@ +hwinfo /usr/local/lib/libhwinfoperscustom.so init async +secure /usr/local/lib/libsecureperscustom.so init sync +custom3 /usr/local/lib/libcustom3perscustom.so od sync +emergency /usr/local/lib/libemergencyperscustom.so od async +early /usr/local/lib/libearlyperscustom.so od sync +custom2 /usr/local/lib/libcustom2perscustom.so init sync
\ No newline at end of file diff --git a/test/Makefile.am b/test/Makefile.am index 6264d76..b9a33d3 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -32,3 +32,41 @@ persistence_lifeCycle_mockup_SOURCES = persistence_lifeCycle_mockup.c persistence_lifeCycle_mockup_LDADD = $(DEPS_LIBS) TESTS=persistence_client_library_test + + + +lib_LTLIBRARIES = libearlyperscustom.la +libearlyperscustom_la_SOURCES = persistence_test_customlib.c +libearlyperscustom_la_LDFLAGS = -avoid-version -module -shared -export-dynamic $(LDFLAGS) +libearlyperscustom_la_CFLAGS = -DLIBIDENT='"early"' + +lib_LTLIBRARIES += libsecureperscustom.la +libsecureperscustom_la_SOURCES = persistence_test_customlib.c +libsecureperscustom_la_LDFLAGS = -avoid-version -module -shared -export-dynamic $(LDFLAGS) +libsecureperscustom_la_CFLAGS = -DLIBIDENT='"secure"' + + +lib_LTLIBRARIES += libhwinfoperscustom.la +libhwinfoperscustom_la_SOURCES = persistence_test_customlib.c +libhwinfoperscustom_la_LDFLAGS = -avoid-version -module -shared -export-dynamic $(LDFLAGS) +libhwinfoperscustom_la_CFLAGS = -DLIBIDENT='"hwinfo"' + +lib_LTLIBRARIES += libcustom1perscustom.la +libcustom1perscustom_la_SOURCES = persistence_test_customlib.c +libcustom1perscustom_la_LDFLAGS = -avoid-version -module -shared -export-dynamic $(LDFLAGS) +libcustom1perscustom_la_CFLAGS = -DLIBIDENT='"custom1"' + +lib_LTLIBRARIES += libemergencyperscustom.la +libemergencyperscustom_la_SOURCES = persistence_test_customlib.c +libemergencyperscustom_la_LDFLAGS = -avoid-version -module -shared -export-dynamic $(LDFLAGS) +libemergencyperscustom_la_CFLAGS = -DLIBIDENT='"emergency"' + +lib_LTLIBRARIES += libcustom2perscustom.la +libcustom2perscustom_la_SOURCES = persistence_test_customlib.c +libcustom2perscustom_la_LDFLAGS = -avoid-version -module -shared -export-dynamic $(LDFLAGS) +libcustom2perscustom_la_CFLAGS = -DLIBIDENT='"custom2"' + +lib_LTLIBRARIES += libcustom3perscustom.la +libcustom3perscustom_la_SOURCES = persistence_test_customlib.c +libcustom3perscustom_la_LDFLAGS = -avoid-version -module -shared -export-dynamic $(LDFLAGS) +libcustom3perscustom_la_CFLAGS = -DLIBIDENT='"custom3"' diff --git a/test/persistence_client_library_dbus_test.c b/test/persistence_client_library_dbus_test.c index 21e15e8..3fd0130 100644 --- a/test/persistence_client_library_dbus_test.c +++ b/test/persistence_client_library_dbus_test.c @@ -51,7 +51,7 @@ int main(int argc, char *argv[]) /// debug log and trace (DLT) setup DLT_REGISTER_APP("noty","tests the persistence client library"); - ret = pclInitLibrary("lt-persistence_client_library_dbus_test", shutdownReg); + ret = pclInitLibrary("lt-persistence_client_library_test", shutdownReg); printf("pclInitLibrary: %d\n", ret); printf("Press a key to end application\n"); diff --git a/test/persistence_client_library_test.c b/test/persistence_client_library_test.c index 9f82fda..794c044 100644 --- a/test/persistence_client_library_test.c +++ b/test/persistence_client_library_test.c @@ -1336,7 +1336,7 @@ static Suite * persistencyClientLib_suite() suite_add_tcase(s, tc_NegHandle); suite_add_tcase(s, tc_InitDeinit); - //suite_add_tcase(s, tc_Plugin); // activate only if the plugins are available + suite_add_tcase(s, tc_Plugin); return s; } diff --git a/test/persistence_test_customlib.c b/test/persistence_test_customlib.c new file mode 100644 index 0000000..50694d1 --- /dev/null +++ b/test/persistence_test_customlib.c @@ -0,0 +1,302 @@ +/****************************************************************************** + * Project Persistency + * (c) copyright 2012 + * Company XS Embedded GmbH + *****************************************************************************/ +/****************************************************************************** + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE + OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ + /** + * @file persistenceCustomLib_Demo.c + * @ingroup Persistency client library + * @author Ingo Huerner + * @brief Demo implementation of the persistence custom client library + * @see + */ + + +#include <stdio.h> +#include <string.h> + +#include "../include/persistence_client_custom.h" + +/** + * @brief close the given handle + * + * @param handle the handle to close + * + * @return positive value: successfully closed; negative value: error + */ +// OK +int plugin_handle_close(int handle) +{ + int rval = 99; + + //printf("* * * * * plugin_close- handle: %d!\n", handle); + + return rval; +} + + +/** + * @brief delete data + * + * @param path the path to the data to delete + * + * @return positive value: delete success; negative value: error + */ +// OK +int plugin_delete_data(const char* path) +{ + int rval = 99; + + //printf("* * * * * plugin_delete_data - path: %s!\n", path); + + return rval; +} + + +/** + * @brief get data + * + * @param handle the handle returned from open + * @param buffer the buffer to store data + * @param size the number of bytes to get data + * + * @return positive value: size data read in bytes; negative value: error + */ +// OK +int plugin_handle_get_data(int handle, char* buffer, int size) +{ + int strSize = 99; + //printf("plugin_handle_get_data: %s\n", LIBIDENT); + + return snprintf(buffer, size, "Custom plugin -> plugin_get_data_handle: %s!", LIBIDENT); +} +/** + * @brief get data + * + * @param buffer the buffer to store data + * @param size the number of bytes to get data + * + * @return positive value: size data read in bytes; negative value: error + */ +// OK +int plugin_get_data(const char* path, char* buffer, int size) +{ + int strSize = 99; + + //printf("Custom plugin -> plugin_get_data: %s!\n", LIBIDENT); + + return snprintf(buffer, size, "Custom plugin -> plugin_get_data: %s!", LIBIDENT); +} + + + +/** + * @brief initialize plugin + * + * @return positive value: init success; negative value: error + */ +// OK +int plugin_init() +{ + int rval = 99; + + //printf("* * * * * plugin_init sync => %s!\n", LIBIDENT); + + return rval; +} + +int plugin_init_async(plugin_callback_async_t pfInitCompletedCB) +{ + int rval = -1; + + //printf("* * * * * plugin_init_async => %s!\n", LIBIDENT); + + return rval; +} + + +/** + * @brief deinitialize plugin + * + * @return positive value: init success; negative value: error + */ +// OK +int plugin_deinit() +{ + int rval = 99; + + //printf("* * * * * plugin_deinit: %s!\n", LIBIDENT); + + return rval; +} + + + + +/** + * @brief open a resource + * + * @param path the path to the resource to open + * @param flag open flags + * @param mode the open mode + * + * @return positive value: handle; negative value: error + */ +// OK +int plugin_handle_open(const char* path, int flag, int mode) +{ + int rval = 100; + + //printf("* * * * * plugin_open - path: %s | flag: %d | mode: %d | plugin: %s!\n", path, flag, mode, LIBIDENT); + + return rval; +} + + +/** + * @brief set data + * + * @param handle the handle given by open + * @param buffer the data to write + * @param size the number of bytes to write + * + * @return positive size data set; negative value: error + */ +// OK +int plugin_handle_set_data(int handle, char* buffer, int size) +{ + int rval = 99; + + //printf("* * * * * plugin_handle_set_data: %s!\n", LIBIDENT); + + return rval; +} +/** + * @brief set data + * + * @param buffer the data to write + * @param size the number of bytes to write + * + * @return positive size data set; negative value: error + */ +// OK +int plugin_set_data(const char* path, char* buffer, int size) +{ + int rval = 99; + + //printf("* * * * * plugin_set_data: %s!\n", LIBIDENT); + + return rval; +} + + +/** + * @brief typdef of callback function prototype + * + * @param status status identifier + * @param dataPtr data + */ +typedef int (*plugin_callback_t) (int status, void* dataPtr); + + +/** + * @brief registercallback for status notifications + * + * @param pFunct the callback + * + * @return positive value: register success; negative value error + */ +int plugin_get_status_notification_clbk(plugin_callback_t pFunct) +{ + int rval = 99; + + //printf("* * * * * plugin_get_status_notification_clbk: %s!\n", LIBIDENT); + + return rval; +} + + +int plugin_handle_get_size(int handle) +{ + int rval = 99; + + //printf("* * * * * plugin_get_size_handle: %d | %s!\n", handle, LIBIDENT); + + return rval; +} + +// OK +int plugin_get_size(const char* path) +{ + int rval = 99; + + //printf("* * * * * plugin_get_size: %s | %s!\n", path, LIBIDENT); + + return rval; +} + + +// OK +int plugin_create_backup(const char* backup_id) +{ + int rval = -1; + + printf("* * * * * plugin_create_backup: backup_id %s | %s!\n", backup_id, LIBIDENT); + + return rval; +} + +// OK +int plugin_restore_backup(const char* backup_id) +{ + int rval = -1; + + printf("* * * * * plugin_restore_backup: backup_id %s | %s!\n", backup_id, LIBIDENT); + + return rval; + +} + +// OK +int plugin_get_backup(char* backup_id, int size) +{ + int rval = -1; + + printf("* * * * * plugin_get_backup: backup_id %s\n", backup_id); + + return rval; +} + + +int plugin_clear_all_data(void) +{ + printf("plugin_clear_all_data\n"); +} + + +int plugin_sync(void) +{ + printf("plugin_sync\n"); +} + + + |