diff options
author | Ingo Huerner <ingo_huerner@mentor.com> | 2015-07-22 13:00:17 +0200 |
---|---|---|
committer | Ingo Huerner <ingo_huerner@mentor.com> | 2015-07-22 13:00:17 +0200 |
commit | 8a48058aefa98d3041bd9801107218a24f70056e (patch) | |
tree | 74cb3f663e3ab3c7b4a994a6a5956a48da599d53 /test | |
parent | 4b503da99c6b04ad21a197dafe6e7243187c7c7e (diff) | |
download | persistence-client-library-8a48058aefa98d3041bd9801107218a24f70056e.tar.gz |
Extended tests for writing shared data
Diffstat (limited to 'test')
-rw-r--r-- | test/persistence_client_library_dbus_test.c | 44 | ||||
-rw-r--r-- | test/persistence_client_library_test.c | 42 |
2 files changed, 81 insertions, 5 deletions
diff --git a/test/persistence_client_library_dbus_test.c b/test/persistence_client_library_dbus_test.c index d6bd472..ad3b9db 100644 --- a/test/persistence_client_library_dbus_test.c +++ b/test/persistence_client_library_dbus_test.c @@ -20,15 +20,26 @@ #include "../include/persistence_client_library_file.h" #include "../include/persistence_client_library_error_def.h" +#include "../src/rbtree.h" +#include "../src/persistence_client_library_tree_helper.h" + #include <stdio.h> +#include <stdlib.h> +#include <pthread.h> #include <dlt.h> #include <dlt_common.h> +#define READ_BUFFER_SIZE 124 + +pthread_mutex_t gMtx = PTHREAD_MUTEX_INITIALIZER; + + + int myChangeCallback(pclNotification_s * notifyStruct) { - printf(" ==> * - * myChangeCallback * - *\n"); + printf(" ==> * - *** myChangeCallback *** - *\n"); printf("Notification received ==> lbid: %d | resource_id: %s | seat: %d | user: %d | status: %d \n", notifyStruct->ldbid, notifyStruct->resource_id, @@ -36,17 +47,22 @@ int myChangeCallback(pclNotification_s * notifyStruct) notifyStruct->user_no, notifyStruct->pclKeyNotify_Status ); - printf(" <== * - * myChangeCallback * - *\n"); + pthread_mutex_unlock(&gMtx); + + printf(" <== * - *** myChangeCallback *** - *\n"); return 1; } + int main(int argc, char *argv[]) { - int ret = 0; + int ret = 0, i = 0; unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL; + unsigned char readBuffer[READ_BUFFER_SIZE] = {0}; + (void)argc; (void)argv; @@ -57,11 +73,13 @@ int main(int argc, char *argv[]) ret = pclInitLibrary("lt-persistence_client_library_test", shutdownReg); printf("pclInitLibrary: %d\n", ret); - printf("Press a key to end application\n"); ret = pclKeyHandleOpen(PCL_LDBID_LOCAL, "posHandle/last_position", 0, 0); printf("Register for change notification\n"); ret = pclKeyRegisterNotifyOnChange(0x20, "links/last_link2", 2/*user_no*/, 1/*seat_no*/, &myChangeCallback); + + +#if 0 ret = pclKeyRegisterNotifyOnChange(0x20, "links/last_link3", 3/*user_no*/, 2/*seat_no*/, &myChangeCallback); ret = pclKeyRegisterNotifyOnChange(0x20, "links/last_link4", 4/*user_no*/, 1/*seat_no*/, &myChangeCallback); @@ -72,7 +90,6 @@ int main(int argc, char *argv[]) ret = pclKeyRegisterNotifyOnChange(PCL_LDBID_LOCAL, "key_70", 1/*user_no*/, 2/*seat_no*/, &myChangeCallback); printf("Reg => key_70: %d\n", ret); - printf("Press enter to unregister to notifications\n"); getchar(); @@ -100,6 +117,23 @@ int main(int argc, char *argv[]) getchar(); sleep(2); + +#else + + + + while(i<18) + { + memset(readBuffer, 0, READ_BUFFER_SIZE); + pthread_mutex_lock(&gMtx); + + pclKeyReadData(0x20, "links/last_link2", 2, 1, readBuffer, READ_BUFFER_SIZE); + printf("%d - Read value of resource \"links/last_link2\" = %s \n\n\n", i++, readBuffer); + } + +#endif + + pclDeinitLibrary(); diff --git a/test/persistence_client_library_test.c b/test/persistence_client_library_test.c index 7382ab4..d0fc252 100644 --- a/test/persistence_client_library_test.c +++ b/test/persistence_client_library_test.c @@ -1821,6 +1821,8 @@ void runTestSequence(const char* resourceID) rval = pclFileClose(fd2); fail_unless(rval == 0, "Could not close file ==> dataLoc/file.txt"); } + + START_TEST(test_FileTest) { int i = 0; @@ -1921,6 +1923,37 @@ START_TEST(test_InvalidPluginfConf) } END_TEST + +START_TEST(test_SharedData) +{ + int ret = 0; + ret = pclKeyWriteData(0x20, "links/last_link2", 2, 1, (unsigned char*)"Test notify shared data___1111", strlen("Test notify shared data___1111")); + fail_unless(ret == (int)strlen("Test notify shared data___1111"), "Wrong write size"); + + sleep(1); + + ret = pclKeyWriteData(0x20, "links/last_link2", 2, 1, (unsigned char*)"Test notify shared data___2211", strlen("Test notify shared data___2211")); + fail_unless(ret == (int)strlen("Test notify shared data___2211"), "Wrong write size"); + + sleep(1); + + ret = pclKeyWriteData(0x20, "links/last_link2", 2, 1, (unsigned char*)"Test notify shared data___3311", strlen("Test notify shared data___3311")); + fail_unless(ret == (int)strlen("Test notify shared data___3311"), "Wrong write size"); + + sleep(1); + + ret = pclKeyWriteData(0x20, "links/last_link2", 2, 1, (unsigned char*)"Test notify shared data___4411", strlen("Test notify shared data___4411")); + fail_unless(ret == (int)strlen("Test notify shared data___4411"), "Wrong write size"); + + sleep(1); + + ret = pclKeyWriteData(0x20, "links/last_link2", 2, 1, (unsigned char*)"Test notify shared data___5511", strlen("Test notify shared data___5511")); + fail_unless(ret == (int)strlen("Test notify shared data___5511"), "Wrong write size"); +} +END_TEST + + + static Suite * persistencyClientLib_suite() { const char* testSuiteName = "Persistency_client_library"; @@ -2046,6 +2079,12 @@ static Suite * persistencyClientLib_suite() TCase * tc_InvalidPluginfConf = tcase_create("InvalidPluginfConf"); tcase_add_test(tc_InvalidPluginfConf, test_InvalidPluginfConf); + TCase * tc_SharedData = tcase_create("SharedData"); + tcase_add_test(tc_SharedData, test_SharedData); + tcase_set_timeout(tc_SharedData, 10); + + + suite_add_tcase(s, tc_persSetData); tcase_add_checked_fixture(tc_persSetData, data_setup, data_teardown); @@ -2138,6 +2177,9 @@ static Suite * persistencyClientLib_suite() tcase_set_timeout(tc_LC_DbusInterface, 8); #endif + suite_add_tcase(s, tc_SharedData); + tcase_add_checked_fixture(tc_SharedData, data_setup, data_teardown); + return s; } |