2 * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
4 * Contact: Bumjin Im <bj.im@samsung.com>
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License
20 * @file security_server_measurer_API_speed.cpp
21 * @author Radoslaw Bartosiak (radoslaw.bartosiak@samsung.com)
23 * @brief Log security server API functions average execution times and some aproximation of maximal and minimal execution time.
24 * @details The functions are run at least NUMBER_OF_CALLS times (time is measured at the beginning and at the end, the difference is taken as the execution time).
25 * @details One test case for one function of security-server. Test pass always when there was no connection error (API calls themselves may fail).
26 * @details Measured times are logged using DLP testing framework logging functions. Calls each API function many times to take the average.
27 * @details This file contains TEST_CASEs. Each TEST_CASE consist of one or more RUNs, each RUN consist of one or more function calls.
28 * @details Each test case contains RUNs of one function only. The time is being measured before & after each run.
31 #include <dpl/log/log.h>
32 #include <dpl/serialization.h>
33 #include <dpl/singleton.h>
34 #include <dpl/singleton_safe_impl.h>
35 #include <dpl/test/test_runner.h>
36 #include <dpl/test/test_runner_child.h>
37 #include <dpl/test/test_runner_multiprocess.h>
41 #include <security-server.h>
44 #include <sys/smack.h>
45 #include <sys/socket.h>
47 #include <sys/types.h>
52 #include "security_server_mockup.h"
54 /*Number of calls in a single test*/
55 #define NUMBER_OF_CALLS (5)
56 #define MICROSECS_PER_SEC (1000000)
57 /*the constant is defined in security-server-common.h, not accessable to the outside world*/
58 #define SECURITY_SERVER_MAX_OBJ_NAME (30)
59 /* number of miliseconds, process will be suspended for multiplications of this quantum */
60 #define QUANTUM (10000)
61 /*Strings used in tests*/
62 /*name of existing user group on test device like "tel_gprs"*/
63 #define EXISTING_GROUP_NAME "telephony_makecall"
64 /*below labels should not be used in the system*/
65 #define M60_OBJECT_LABEL "tc060MeasurerLabel"
66 #define M60_SUBJECT_LABEL "tc060Subject"
67 #define M70_OBJECT_LABEL "tc070MeasurerLabel"
68 #define M70_SUBJECT_LABEL "tc070Subject"
69 #define M160_CUSTOMER_LABEL "my_customer_label"
70 #define M170_OBJECT_LABEL "myObject"
73 IMPLEMENT_SAFE_SINGLETON(DPL::Log::LogSystem);
76 void securityClientEnableLogSystem(void) {
77 DPL::Log::LogSystemSingleton::Instance().SetTag("SEC_SRV_API_SPEED");
81 /** Store statistics from a set of function calls
83 struct readwrite_stats
85 timeval current_start_time; /*of last API call*/
86 timeval current_end_time; /*of last API call*/
87 int number_of_calls; /*till now*/
88 double total_duration; /*of all API calls*/
89 double average_duration;
90 double minimal_duration; /*minimum of averages*/
91 double maximal_duration; /*maximum of averages*/
94 /*Auxiliary functions*/
96 /**Sleep for the given time
99 @return 0 on success, -1 on error if process woken earlier
101 int my_nanosecsleep(long nanoseconds) {
103 sleep_spec.tv_sec = 0;
104 sleep_spec.tv_nsec = nanoseconds;
105 return nanosleep(&sleep_spec, NULL);
108 /**Read from pipe descriptor to buffer; retries if less than count bytes were read.
110 @param buf start of buffer
111 @param count number of bytes read
112 @return number of bytes read (count)
114 int my_pipe_read(int fd, void *buf, size_t count) {
116 ssize_t rest = count;
119 RUNNER_ASSERT_MSG(0 < (s = TEMP_FAILURE_RETRY(read(fd, ((char*)buf) + readf, rest))), "Error in read from pipe");
126 /**Write from buffer to a pipe ; retries if less than count bytes were written.
128 @param buf start of buffer
129 @param count number of bytes to write
130 @return number of bytes written (count)
132 int my_pipe_write(int fd, void *buf, size_t count) {
134 ssize_t rest = count;
137 RUNNER_ASSERT_MSG(0 <= (s = TEMP_FAILURE_RETRY(write(fd, ((char*)buf) + writef, rest))), "Error in write to pipe");
145 /** Check whether there was connection error during function call (Security Server API) based on exit code
146 @param result_code the exit code of a function
147 @return -1 if the function result code indicated network error, 0 otherwise
149 int communication_succeeded(int result_code) {
150 if ((result_code == SECURITY_SERVER_API_ERROR_SOCKET) ||
151 (result_code == SECURITY_SERVER_API_ERROR_SEND_FAILED) ||
152 (result_code == SECURITY_SERVER_API_ERROR_RECV_FAILED))
158 /** Returns current system time (wrapper for standard system function)
159 @return current system time
161 timeval my_gettime() {
163 int res = gettimeofday(&t, NULL);
164 RUNNER_ASSERT_MSG(res == 0, "gettimeofday() returned error value: " << res);
168 /** Return a difference between two times (wrapper for standard system function)
173 timeval my_timersub(timeval t1, timeval t2) {
175 timersub(&t1, &t2, &result);
179 double timeval_to_secs(timeval t) {
180 return ((double)t.tv_sec) + (t.tv_usec / (double)MICROSECS_PER_SEC);
183 double timeval_to_microsecs(timeval t) {
184 return ((double)t.tv_sec * (double)MICROSECS_PER_SEC) + ((double)t.tv_usec);
187 timeval secs_to_timeval(double s) {
189 t.tv_sec = (time_t)s;
190 t.tv_usec = (__suseconds_t) ((s - (double)t.tv_sec) * MICROSECS_PER_SEC);
194 /** Initialize statistics at the beginning of a TEST_CASE
195 @param stats [in/out] statistics to be initialized
197 void initialize_stats(readwrite_stats *stats) {
198 stats->number_of_calls = 0;
199 stats->total_duration = 0.0;
200 stats->average_duration = 0.0;
201 stats->minimal_duration = DBL_MAX;
202 stats->maximal_duration = 0.0;
205 /** Save time at the beginning of a RUN
206 @param stats [in/out] statistics
208 void start_stats_update(readwrite_stats *stats) {
209 stats->current_start_time = my_gettime();
210 //LogDebug("start_stats_update at: %ld.%06ld\n", stats->current_start_time.tv_sec, stats->current_start_time.tv_usec);
213 /** Save time at the end of a RUN and updates the statistics (current_end_time, number_of_calls, total_duration, minimal_duration, maximal_duration)
214 @param stats [in/out] statistics
216 void end_stats_update(readwrite_stats *stats) {
217 stats->current_end_time = my_gettime();
218 double current_duration = timeval_to_microsecs(my_timersub(stats->current_end_time, stats->current_start_time));
219 stats->total_duration += current_duration;
220 stats->number_of_calls += 1;
221 if (current_duration < stats->minimal_duration)
222 (stats->minimal_duration) = current_duration;
223 if (current_duration > stats->maximal_duration)
224 (stats->maximal_duration) = current_duration;
227 /** Updates the statistics (average_duration, number_of_new_calls, total_duration, minimal_duration, maximal_duration)
228 Function is used instead of start_stats_update and end_stats_update (e.g when current_duration and number_of_new_calls are reported by child process.
229 @param stats [in/out] statistics
230 @param number_of_new_calls number of function calls in the RUN
231 @param current_duration (total) of number_of_new calls
233 void stats_update(readwrite_stats *stats, int number_of_new_calls, double current_duration) {
234 if (number_of_new_calls > 0) {
235 double current_average = (double)current_duration / (double)number_of_new_calls;
236 stats->average_duration = (double)((stats->total_duration) / (stats->number_of_calls));
237 stats->total_duration += current_duration;
238 stats->number_of_calls += number_of_new_calls;
239 if (current_average < stats->minimal_duration)
240 (stats->minimal_duration) = current_average;
241 if (current_average > stats->maximal_duration)
242 (stats->maximal_duration) = current_average;
245 LogDebug("stats_update called after zero successful function calls \n");
248 /** Calculate the average time and calculates statistics taken by a single function call.
249 Called at the end of a TEST_CASE.
250 @param stats [in/out] statistics
251 @param function_name of the function called in tests (to be printed)
253 void finish_stats(readwrite_stats *stats, const char* function_name) {
254 if ((stats->number_of_calls) > 0) {
255 stats->average_duration = (double)((stats->total_duration) / (stats->number_of_calls));
256 printf("The approx (min, max, avg) execution times for function:\n%s are: \n---(%'.2fus, %'.2fus, %'.2fus)\n", function_name, stats->minimal_duration, stats->maximal_duration, stats->average_duration);
259 LogDebug("No function call succeeded\n");
262 void closesockfdptr(int* sockfd_ptr)
266 typedef std::unique_ptr<int, std::function<void(int*)> > SockFDUniquePtr;
269 RUNNER_TEST_GROUP_INIT(SECURITY_SERVER_API_SPEED_MEASURER)
272 * test: Tests the tests
273 * expected: The minimum shall be about (QUANTUM) = 10^-2s = 10000 us, max about (NUMBER_OF_CALLS*QUANTUM) = 5*10^-2s = 50000us, avg (average) about (0.5*NUMBER_OF_CALLS+1*QUANTUM)=3*10^-2s = 30000us. Max is no more than 50% bigger than minimum.
275 RUNNER_TEST(m000_security_server_test_the_tests) {
277 readwrite_stats stats;
278 double expected_min_min = QUANTUM;
279 double expected_min_max = 1.5 * expected_min_min;
280 double expected_avarage_min = (((double)(NUMBER_OF_CALLS + 1)) / 2.0) * expected_min_min;
281 double expected_avarage_max = 1.5 * expected_avarage_min;
282 double expected_max_min = ((double)(NUMBER_OF_CALLS)) * expected_min_min;
283 double expected_max_max = 1.5 * expected_max_min;
284 initialize_stats(&stats);
285 for (int i=0; i < NUMBER_OF_CALLS; i++) {
286 start_stats_update(&stats);
287 ret = my_nanosecsleep((long) ((i+1)*QUANTUM*1000));
288 RUNNER_ASSERT_MSG(ret == 0, "system sleep function returned premature wake-up; ret = " << ret);
289 end_stats_update(&stats);
291 finish_stats(&stats, "my_nanosecsleep");
292 RUNNER_ASSERT_MSG((stats.average_duration>expected_avarage_min) && (stats.average_duration<expected_avarage_max), "Avarage time is suspicious - check the issue; stats.average_duration=" << stats.average_duration);
293 RUNNER_ASSERT_MSG((stats.minimal_duration>expected_min_min) && (stats.minimal_duration<expected_min_max), "Minimal time is suspicious - check the issue; stats.minimal_duration=" << stats.minimal_duration);
294 RUNNER_ASSERT_MSG((stats.maximal_duration>expected_max_min) && (stats.maximal_duration<expected_max_max), "Maximal time is suspicious - check the issue; stats.maximal_duration=" << stats.maximal_duration);
298 * measurer: Fails only on connection error.
300 RUNNER_TEST(m010_security_server_security_server_get_gid) {
302 readwrite_stats stats;
303 initialize_stats(&stats);
304 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
305 start_stats_update(&stats);
306 ret = security_server_get_gid(EXISTING_GROUP_NAME);
307 RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
308 end_stats_update(&stats);
310 finish_stats(&stats, "security_server_get_gid");
314 * measurer: Fails only on connection error.
316 RUNNER_TEST(m030_security_server_request_cookie) {
319 cookie_size = security_server_get_cookie_size();
320 char cookie[cookie_size];
321 readwrite_stats stats;
322 initialize_stats(&stats);
323 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
324 start_stats_update(&stats);
325 ret = security_server_request_cookie(cookie, cookie_size);
326 RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
327 end_stats_update(&stats);
329 finish_stats(&stats, "security_server_request_cookie");
333 * measurer: Fails only on connection error.
334 * Create new processes and measures times of first calls of security_server_request_cookie in them
337 RUNNER_MULTIPROCESS_TEST(m031_security_server_request_cookie_first_time_only) {
340 cookie_size = security_server_get_cookie_size();
341 char cookie[cookie_size];
342 readwrite_stats stats;
347 double duration_of_calls;
348 /*initialize pipes - one pipe for one child process*/
349 RUNNER_ASSERT_MSG(0 == pipe(pipefd), "error in pipe");
350 initialize_stats(&stats);
351 for (int i = 0; i < NUMBER_OF_CALLS; i++) {
352 RUNNER_ASSERT_MSG(-1 != (cpid = fork()), "error in fork #i = " << i);
353 if (cpid == 0) { /* Child*/
354 close(pipefd[0]); /* Close unused read end */
357 start_time = my_gettime();
358 ret = security_server_request_cookie(cookie, cookie_size);
359 end_time = my_gettime();
360 if (communication_succeeded(ret) == 0) {
362 duration_of_calls = timeval_to_microsecs(my_timersub(end_time, start_time));
367 duration_of_calls = 0.0;
369 RUNNER_ASSERT_MSG(my_pipe_write(pipefd[1], &number_of_calls, sizeof(number_of_calls)) == sizeof(number_of_calls), "error in write number of calls to pipe");
370 RUNNER_ASSERT_MSG(my_pipe_write(pipefd[1], &duration_of_calls, sizeof(duration_of_calls)) == sizeof(duration_of_calls), "error in write duration of calls to pipe");
375 RUNNER_ASSERT_MSG(my_pipe_read(pipefd[0], &number_of_calls, sizeof(number_of_calls)) == sizeof(number_of_calls), "error in read number of calls to pipe");
376 RUNNER_ASSERT_MSG(my_pipe_read(pipefd[0], &duration_of_calls, sizeof(duration_of_calls)) == sizeof(duration_of_calls), "error in read duration of calls to pipe");
378 RUNNER_ASSERT_MSG(number_of_calls > 0, "commmunication error");
379 stats_update(&stats, number_of_calls, duration_of_calls);
383 close(pipefd[1]); /* Close parent descriptors */
388 * measurer: Fails only on connection error.
390 RUNNER_TEST(m040_security_server_get_cookie_size) {
392 readwrite_stats stats;
393 initialize_stats(&stats);
394 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
395 start_stats_update(&stats);
396 cookie_size = security_server_get_cookie_size();
397 RUNNER_ASSERT_MSG(cookie_size > 0, "cookie_size = " << cookie_size);
398 end_stats_update(&stats);
400 finish_stats(&stats, "security_server_get_cookie_size");
404 * measurer: Fails only on connection error.
406 RUNNER_TEST(m050_security_server_check_privilege) {
408 readwrite_stats stats;
409 initialize_stats(&stats);
410 const char *existing_group_name = EXISTING_GROUP_NAME;
413 // we use existing group name for the measurment, however this is not neccessary
414 call_gid = security_server_get_gid(existing_group_name);
415 cookie_size = security_server_get_cookie_size();
416 char recved_cookie[cookie_size];
417 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
418 start_stats_update(&stats);
419 ret = security_server_check_privilege(recved_cookie, (gid_t)call_gid);
420 RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
421 end_stats_update(&stats);
423 finish_stats(&stats, "security_server_check_privilege");
427 * measurer: Fails only on connection error.
430 RUNNER_TEST(m060_security_server_check_privilege_by_cookie) {
432 cookie_size = security_server_get_cookie_size();
433 char cookie[cookie_size];
434 const char *object_label = M60_OBJECT_LABEL;
435 const char *access_rights = "r";
436 const char *access_rights_ext = "rw";
437 const char *subject_label = M60_SUBJECT_LABEL;
438 smack_accesses *handle;
440 readwrite_stats stats;
441 initialize_stats(&stats);
442 RUNNER_ASSERT_MSG(-1 != system("touch /opt/home/root/pid_cycle"),
443 "Cannot prepare environment for test.");
444 RUNNER_ASSERT_MSG(0 == smack_set_label_for_self(subject_label),
445 "Cannot prepare environment for test.");
446 RUNNER_ASSERT_MSG(0 == (ret = smack_accesses_new(&handle)), "Error in smack_accesses_new()");
447 RUNNER_ASSERT_MSG(0 == smack_accesses_add(handle,
450 access_rights), "Error in smack_accesses_add()" );
451 RUNNER_ASSERT_MSG(0 == (ret = smack_accesses_apply(handle)), "Error in smack_accesses_apply(); ret = " << ret);
452 smack_accesses_free(handle);
453 RUNNER_ASSERT_MSG(0 == (ret = smack_set_label_for_self(subject_label)), "Error in smack_set_label_for_self(); ret = " << ret);
454 RUNNER_ASSERT_MSG(SECURITY_SERVER_API_SUCCESS == security_server_request_cookie(cookie, cookie_size), "Error in security_server_request_cookie()");
455 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
456 start_stats_update(&stats);
457 /*odd(i) - ask for possessed privileges, even(i) ask for not possessed privileges */
459 ret = security_server_check_privilege_by_cookie(
464 ret = security_server_check_privilege_by_cookie(
469 RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
470 end_stats_update(&stats);
472 finish_stats(&stats, "security_server_check_privilege_by_cookie");
476 * measurer: Fails only on connection error.
479 RUNNER_MULTIPROCESS_TEST(m070_security_server_check_privilege_by_sockfd) {
480 const char *object_label = M70_OBJECT_LABEL;
481 const char *access_rights = "r";
482 const char *access_rights_ext = "rw";
483 const char *subject_label = M70_SUBJECT_LABEL;
485 readwrite_stats stats;
486 initialize_stats(&stats);
487 smack_accesses *handle;
488 RUNNER_ASSERT(0 == smack_accesses_new(&handle));
489 RUNNER_ASSERT(0 == smack_accesses_add(handle,
493 RUNNER_ASSERT(0 == smack_accesses_apply(handle));
494 smack_accesses_free(handle);
496 RUNNER_ASSERT(-1 != pid);
499 int sockfd = create_new_socket();
500 RUNNER_ASSERT_MSG(sockfd >= 0, "create_new_socket() failed");
502 SockFDUniquePtr sockfd_ptr(&sockfd, closesockfdptr);
504 RUNNER_ASSERT_MSG(0 == smack_set_label_for_self(subject_label), "child label " << subject_label << " not set");
506 RUNNER_ASSERT_MSG(listen(sockfd, 5) >= 0, "child listen failed");
508 struct sockaddr_un client_addr;
509 socklen_t client_len = sizeof(client_addr);
511 RUNNER_ASSERT_MSG((csockfd = accept(sockfd,(struct sockaddr*)&client_addr, &client_len)) > 0, "child accept failed");
519 int sockfd = connect_to_testserver();
520 RUNNER_ASSERT_MSG(sockfd >= 0, "connect_to_testserver() failed");
522 SockFDUniquePtr sockfd_ptr(&sockfd, closesockfdptr);
524 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
525 start_stats_update(&stats);
526 /*odd(i) - ask for possessed privileges, even(i) ask for not possessed privileges */
528 ret = security_server_check_privilege_by_sockfd(
533 ret = security_server_check_privilege_by_sockfd(
537 RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
538 end_stats_update(&stats);
541 finish_stats(&stats, "check_privilege_by_sockfd");
546 * measurer: Fails only on connection error.
548 RUNNER_TEST(m080_security_server_get_cookie_pid) {
551 cookie_size = security_server_get_cookie_size();
552 char cookie[cookie_size];
553 ret = security_server_request_cookie(cookie, cookie_size);
554 RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "security_server_request_cookie failed; ret = " << ret);
555 readwrite_stats stats;
556 initialize_stats(&stats);
557 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
558 start_stats_update(&stats);
559 ret = security_server_get_cookie_pid(cookie);
560 RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
561 end_stats_update(&stats);
563 finish_stats(&stats, "security_server_request_cookie");
567 * measurer: Fails only on connection error.
569 RUNNER_TEST(m090_security_server_is_pwd_valid) {
571 unsigned int attempt, max_attempt, expire_sec;
572 readwrite_stats stats;
573 initialize_stats(&stats);
574 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
575 start_stats_update(&stats);
576 ret = security_server_is_pwd_valid(&attempt, &max_attempt, &expire_sec);
577 RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
578 end_stats_update(&stats);
580 finish_stats(&stats, "security_server_is_pwd_valid");
584 * measurer: Fails only on connection error.
586 RUNNER_TEST(m100_security_server_set_pwd) {
588 readwrite_stats stats;
589 initialize_stats(&stats);
590 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
591 start_stats_update(&stats);
592 ret = security_server_set_pwd("this_is_current_pwd", "this_is_new_pwd", 20, 365);
593 RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
594 end_stats_update(&stats);
596 finish_stats(&stats, "security_server_set_pwd");
600 * measurer: Fails only on connection error.
602 RUNNER_TEST(m110_security_server_set_pwd_validity) {
604 readwrite_stats stats;
605 initialize_stats(&stats);
606 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
607 start_stats_update(&stats);
608 ret = security_server_set_pwd_validity(2);
609 RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
610 end_stats_update(&stats);
612 finish_stats(&stats, "security_server_set_pwd_validity");
616 * measurer: Fails only on connection error.
618 RUNNER_TEST(m120_security_server_set_pwd_max_challenge) {
620 readwrite_stats stats;
621 initialize_stats(&stats);
622 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
623 start_stats_update(&stats);
624 ret = security_server_set_pwd_max_challenge(3);
625 RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
626 end_stats_update(&stats);
628 finish_stats(&stats, "security_server_set_pwd_max_challenge");
632 * measurer: Fails only on connection error.
634 RUNNER_TEST(m130_security_server_reset_pwd) {
636 readwrite_stats stats;
637 initialize_stats(&stats);
638 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
639 start_stats_update(&stats);
640 ret = security_server_reset_pwd("apud", 1, 2);
641 RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
642 end_stats_update(&stats);
644 finish_stats(&stats, "security_server_reset_pwd");
648 * measurer: Fails only on connection error.
650 RUNNER_TEST(m140_security_server_chk_pwd) {
652 unsigned int attempt, max_attempt, expire_sec;
653 readwrite_stats stats;
654 initialize_stats(&stats);
655 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
656 start_stats_update(&stats);
657 ret = security_server_chk_pwd("is_this_password", &attempt, &max_attempt, &expire_sec);
658 RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
659 end_stats_update(&stats);
661 finish_stats(&stats, "security_server_chk_pwd");
665 * measurer: Fails only on connection error.
667 RUNNER_TEST(m150_security_server_set_pwd_history) {
669 readwrite_stats stats;
670 initialize_stats(&stats);
671 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
672 start_stats_update(&stats);
673 ret = security_server_set_pwd_history(100);
674 RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
675 end_stats_update(&stats);
677 finish_stats(&stats, "security_server_set_pwd_history");
681 * measurer: Fails only on connection error.
683 RUNNER_TEST(m160_security_server_app_give_access) {
685 readwrite_stats stats;
686 initialize_stats(&stats);
687 const char* customer_label = M160_CUSTOMER_LABEL;
688 int customer_pid = getpid();
689 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
690 start_stats_update(&stats);
691 ret = security_server_app_give_access(customer_label, customer_pid);
692 RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
693 end_stats_update(&stats);
695 finish_stats(&stats, "security_server_app_give_access");
699 * measurer: Fails only on connection error.
701 RUNNER_TEST(m170_security_server_check_privilege_by_pid) {
704 readwrite_stats stats;
705 initialize_stats(&stats);
707 const char *object = M170_OBJECT_LABEL;
708 const char *access_rights = "rw";
709 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
710 start_stats_update(&stats);
711 ret = security_server_check_privilege_by_pid(pid, object, access_rights);
712 RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
713 end_stats_update(&stats);
715 finish_stats(&stats, "security_server_check_privilege_by_pid");
719 int main(int argc, char *argv[])
721 securityClientEnableLogSystem();
722 DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);