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"
53 #include <summary_collector.h>
54 #include <smack_access.h>
56 IMPLEMENT_SAFE_SINGLETON(DPL::Log::LogSystem);
57 #include <security_server_tests_common.h>
58 #include <tests_common.h>
60 /*Number of calls in a single test*/
61 #define NUMBER_OF_CALLS (5)
62 #define MICROSECS_PER_SEC (1000000)
63 /* number of miliseconds, process will be suspended for multiplications of this quantum */
64 #define QUANTUM (10000)
65 /*Strings used in tests*/
66 /*name of existing user group on test device like "tel_gprs"*/
67 #define EXISTING_GROUP_NAME "telephony_makecall"
68 /*below labels should not be used in the system*/
69 #define M60_OBJECT_LABEL "tc060MeasurerLabel"
70 #define M60_SUBJECT_LABEL "tc060Subject"
71 #define M70_OBJECT_LABEL "tc070MeasurerLabel"
72 #define M70_SUBJECT_LABEL "tc070Subject"
73 #define M160_CUSTOMER_LABEL "my_customer_label"
74 #define M170_OBJECT_LABEL "myObject"
77 void securityClientEnableLogSystem(void) {
78 DPL::Log::LogSystemSingleton::Instance().SetTag("SEC_SRV_API_SPEED");
82 /** Store statistics from a set of function calls
84 struct readwrite_stats
86 timeval current_start_time; /*of last API call*/
87 timeval current_end_time; /*of last API call*/
88 int number_of_calls; /*till now*/
89 double total_duration; /*of all API calls*/
90 double average_duration;
91 double minimal_duration; /*minimum of averages*/
92 double maximal_duration; /*maximum of averages*/
95 /*Auxiliary functions*/
97 /**Sleep for the given time
100 @return 0 on success, -1 on error if process woken earlier
102 int my_nanosecsleep(long nanoseconds) {
104 sleep_spec.tv_sec = 0;
105 sleep_spec.tv_nsec = nanoseconds;
106 return nanosleep(&sleep_spec, NULL);
109 /**Read from pipe descriptor to buffer; retries if less than count bytes were read.
111 @param buf start of buffer
112 @param count number of bytes read
113 @return number of bytes read (count)
115 int my_pipe_read(int fd, void *buf, size_t count) {
117 ssize_t rest = count;
120 RUNNER_ASSERT_MSG_BT(0 < (s = TEMP_FAILURE_RETRY(read(fd, ((char*)buf) + readf, rest))), "Error in read from pipe");
127 /**Write from buffer to a pipe ; retries if less than count bytes were written.
129 @param buf start of buffer
130 @param count number of bytes to write
131 @return number of bytes written (count)
133 int my_pipe_write(int fd, void *buf, size_t count) {
135 ssize_t rest = count;
138 RUNNER_ASSERT_MSG_BT(0 <= (s = TEMP_FAILURE_RETRY(write(fd, ((char*)buf) + writef, rest))), "Error in write to pipe");
146 /** Check whether there was connection error during function call (Security Server API) based on exit code
147 @param result_code the exit code of a function
148 @return -1 if the function result code indicated network error, 0 otherwise
150 int communication_succeeded(int result_code) {
153 case SECURITY_SERVER_API_ERROR_NO_SUCH_SERVICE:
154 case SECURITY_SERVER_API_ERROR_SOCKET:
155 case SECURITY_SERVER_API_ERROR_BAD_REQUEST:
156 case SECURITY_SERVER_API_ERROR_BAD_RESPONSE:
163 /** Returns current system time (wrapper for standard system function)
164 @return current system time
166 timeval my_gettime() {
168 int res = gettimeofday(&t, NULL);
169 RUNNER_ASSERT_MSG_BT(res == 0, "gettimeofday() returned error value: " << res);
173 /** Return a difference between two times (wrapper for standard system function)
178 timeval my_timersub(timeval t1, timeval t2) {
180 timersub(&t1, &t2, &result);
184 double timeval_to_microsecs(timeval t) {
185 return ((double)t.tv_sec * (double)MICROSECS_PER_SEC) + ((double)t.tv_usec);
188 /** Initialize statistics at the beginning of a TEST_CASE
189 @param stats [in/out] statistics to be initialized
191 void initialize_stats(readwrite_stats *stats) {
192 stats->number_of_calls = 0;
193 stats->total_duration = 0.0;
194 stats->average_duration = 0.0;
195 stats->minimal_duration = DBL_MAX;
196 stats->maximal_duration = 0.0;
199 /** Save time at the beginning of a RUN
200 @param stats [in/out] statistics
202 void start_stats_update(readwrite_stats *stats) {
203 stats->current_start_time = my_gettime();
204 //LogDebug("start_stats_update at: %ld.%06ld\n", stats->current_start_time.tv_sec, stats->current_start_time.tv_usec);
207 /** Save time at the end of a RUN and updates the statistics (current_end_time, number_of_calls, total_duration, minimal_duration, maximal_duration)
208 @param stats [in/out] statistics
210 void end_stats_update(readwrite_stats *stats) {
211 stats->current_end_time = my_gettime();
212 double current_duration = timeval_to_microsecs(my_timersub(stats->current_end_time, stats->current_start_time));
213 stats->total_duration += current_duration;
214 stats->number_of_calls += 1;
215 if (current_duration < stats->minimal_duration)
216 (stats->minimal_duration) = current_duration;
217 if (current_duration > stats->maximal_duration)
218 (stats->maximal_duration) = current_duration;
221 /** Updates the statistics (average_duration, number_of_new_calls, total_duration, minimal_duration, maximal_duration)
222 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.
223 @param stats [in/out] statistics
224 @param number_of_new_calls number of function calls in the RUN
225 @param current_duration (total) of number_of_new calls
227 void stats_update(readwrite_stats *stats, int number_of_new_calls, double current_duration) {
228 if (number_of_new_calls > 0) {
229 double current_average = (double)current_duration / (double)number_of_new_calls;
230 stats->average_duration = (double)((stats->total_duration) / (stats->number_of_calls));
231 stats->total_duration += current_duration;
232 stats->number_of_calls += number_of_new_calls;
233 if (current_average < stats->minimal_duration)
234 (stats->minimal_duration) = current_average;
235 if (current_average > stats->maximal_duration)
236 (stats->maximal_duration) = current_average;
239 LogDebug("stats_update called after zero successful function calls \n");
242 /** Calculate the average time and calculates statistics taken by a single function call.
243 Called at the end of a TEST_CASE.
244 @param stats [in/out] statistics
245 @param function_name of the function called in tests (to be printed)
247 void finish_stats(readwrite_stats *stats, const char* function_name) {
248 if ((stats->number_of_calls) > 0) {
249 stats->average_duration = (double)((stats->total_duration) / (stats->number_of_calls));
250 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);
253 LogDebug("No function call succeeded\n");
256 void closesockfdptr(int* sockfd_ptr)
260 typedef std::unique_ptr<int, std::function<void(int*)> > SockFDUniquePtr;
263 RUNNER_TEST_GROUP_INIT(SECURITY_SERVER_API_SPEED_MEASURER)
266 * test: Tests the tests
267 * 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.
269 RUNNER_TEST(m000_security_server_test_the_tests) {
271 readwrite_stats stats;
272 double expected_min_min = QUANTUM;
273 double expected_min_max = 1.5 * expected_min_min;
274 double expected_avarage_min = (((double)(NUMBER_OF_CALLS + 1)) / 2.0) * expected_min_min;
275 double expected_avarage_max = 1.5 * expected_avarage_min;
276 double expected_max_min = ((double)(NUMBER_OF_CALLS)) * expected_min_min;
277 double expected_max_max = 1.5 * expected_max_min;
278 initialize_stats(&stats);
279 for (int i=0; i < NUMBER_OF_CALLS; i++) {
280 start_stats_update(&stats);
281 ret = my_nanosecsleep((long) ((i+1)*QUANTUM*1000));
282 RUNNER_ASSERT_MSG_BT(ret == 0, "system sleep function returned premature wake-up; ret = " << ret);
283 end_stats_update(&stats);
285 finish_stats(&stats, "my_nanosecsleep");
286 RUNNER_ASSERT_MSG_BT((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);
287 RUNNER_ASSERT_MSG_BT((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);
288 RUNNER_ASSERT_MSG_BT((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);
292 * measurer: Fails only on connection error.
294 RUNNER_TEST(m010_security_server_security_server_get_gid) {
296 readwrite_stats stats;
297 initialize_stats(&stats);
298 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
299 start_stats_update(&stats);
300 ret = security_server_get_gid(EXISTING_GROUP_NAME);
301 RUNNER_ASSERT_MSG_BT(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
302 end_stats_update(&stats);
304 finish_stats(&stats, "security_server_get_gid");
308 * measurer: Fails only on connection error.
310 RUNNER_TEST(m030_security_server_request_cookie) {
313 cookie_size = security_server_get_cookie_size();
314 char cookie[cookie_size];
315 readwrite_stats stats;
316 initialize_stats(&stats);
317 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
318 start_stats_update(&stats);
319 ret = security_server_request_cookie(cookie, cookie_size);
320 RUNNER_ASSERT_MSG_BT(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
321 end_stats_update(&stats);
323 finish_stats(&stats, "security_server_request_cookie");
327 * measurer: Fails only on connection error.
328 * Create new processes and measures times of first calls of security_server_request_cookie in them
331 RUNNER_MULTIPROCESS_TEST(m031_security_server_request_cookie_first_time_only) {
334 cookie_size = security_server_get_cookie_size();
335 char cookie[cookie_size];
336 readwrite_stats stats;
341 double duration_of_calls;
342 /*initialize pipes - one pipe for one child process*/
343 RUNNER_ASSERT_MSG_BT(0 == pipe(pipefd), "error in pipe");
344 initialize_stats(&stats);
345 for (int i = 0; i < NUMBER_OF_CALLS; i++) {
346 RUNNER_ASSERT_MSG_BT(-1 != (cpid = fork()), "error in fork #i = " << i);
347 if (cpid == 0) { /* Child*/
348 close(pipefd[0]); /* Close unused read end */
351 start_time = my_gettime();
352 ret = security_server_request_cookie(cookie, cookie_size);
353 end_time = my_gettime();
354 if (communication_succeeded(ret) == 0) {
356 duration_of_calls = timeval_to_microsecs(my_timersub(end_time, start_time));
361 duration_of_calls = 0.0;
363 RUNNER_ASSERT_MSG_BT(my_pipe_write(pipefd[1], &number_of_calls, sizeof(number_of_calls)) == sizeof(number_of_calls), "error in write number of calls to pipe");
364 RUNNER_ASSERT_MSG_BT(my_pipe_write(pipefd[1], &duration_of_calls, sizeof(duration_of_calls)) == sizeof(duration_of_calls), "error in write duration of calls to pipe");
369 RUNNER_ASSERT_MSG_BT(my_pipe_read(pipefd[0], &number_of_calls, sizeof(number_of_calls)) == sizeof(number_of_calls), "error in read number of calls to pipe");
370 RUNNER_ASSERT_MSG_BT(my_pipe_read(pipefd[0], &duration_of_calls, sizeof(duration_of_calls)) == sizeof(duration_of_calls), "error in read duration of calls to pipe");
372 RUNNER_ASSERT_MSG_BT(number_of_calls > 0, "commmunication error");
373 stats_update(&stats, number_of_calls, duration_of_calls);
377 close(pipefd[1]); /* Close parent descriptors */
382 * measurer: Fails only on connection error.
384 RUNNER_TEST(m040_security_server_get_cookie_size) {
386 readwrite_stats stats;
387 initialize_stats(&stats);
388 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
389 start_stats_update(&stats);
390 cookie_size = security_server_get_cookie_size();
391 RUNNER_ASSERT_MSG_BT(cookie_size > 0, "cookie_size = " << cookie_size);
392 end_stats_update(&stats);
394 finish_stats(&stats, "security_server_get_cookie_size");
398 * measurer: Fails only on connection error.
400 RUNNER_TEST(m050_security_server_check_privilege) {
402 readwrite_stats stats;
403 initialize_stats(&stats);
404 const char *existing_group_name = EXISTING_GROUP_NAME;
407 // we use existing group name for the measurment, however this is not neccessary
408 call_gid = security_server_get_gid(existing_group_name);
409 cookie_size = security_server_get_cookie_size();
410 char recved_cookie[cookie_size];
411 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
412 start_stats_update(&stats);
413 ret = security_server_check_privilege(recved_cookie, (gid_t)call_gid);
414 RUNNER_ASSERT_MSG_BT(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
415 end_stats_update(&stats);
417 finish_stats(&stats, "security_server_check_privilege");
420 void testSecurityServerCheckPrivilegeByCookie(bool smack) {
421 const char *object_label = M60_OBJECT_LABEL;
422 const char *access_rights = "r";
423 const char *access_rights_ext = "rw";
424 const char *subject_label = M60_SUBJECT_LABEL;
426 readwrite_stats stats;
427 initialize_stats(&stats);
430 SmackAccess smackAccess;
431 smackAccess.add(subject_label, object_label, access_rights);
433 RUNNER_ASSERT_MSG_BT(0 == (ret = smack_set_label_for_self(subject_label)),
434 "Error in smack_set_label_for_self(); ret = " << ret);
437 Cookie cookie = getCookieFromSS();
439 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
440 start_stats_update(&stats);
441 /*odd(i) - ask for possessed privileges, even(i) ask for not possessed privileges */
443 ret = security_server_check_privilege_by_cookie(
448 ret = security_server_check_privilege_by_cookie(
453 RUNNER_ASSERT_MSG_BT(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
454 end_stats_update(&stats);
456 finish_stats(&stats, "security_server_check_privilege_by_cookie");
460 * measurer: Fails only on connection error.
463 RUNNER_TEST_SMACK(m060_security_server_check_privilege_by_cookie_smack) {
464 testSecurityServerCheckPrivilegeByCookie(true);
467 RUNNER_TEST_NOSMACK(m060_security_server_check_privilege_by_cookie_nosmack) {
468 testSecurityServerCheckPrivilegeByCookie(false);
471 void testSecurityServerCheckPrivilegeBySockfd(bool smack) {
472 const char *object_label = M70_OBJECT_LABEL;
473 const char *access_rights = "r";
474 const char *access_rights_ext = "rw";
475 const char *subject_label = M70_SUBJECT_LABEL;
477 readwrite_stats stats;
478 initialize_stats(&stats);
481 SmackAccess smackAccess;
482 smackAccess.add(subject_label, object_label, access_rights);
487 RUNNER_ASSERT_BT(-1 != pid);
490 int sockfd = create_new_socket();
491 RUNNER_ASSERT_MSG_BT(sockfd >= 0, "create_new_socket() failed");
493 SockFDUniquePtr sockfd_ptr(&sockfd, closesockfdptr);
496 RUNNER_ASSERT_MSG_BT(0 == smack_set_label_for_self(subject_label), "child label " << subject_label << " not set");
498 RUNNER_ASSERT_MSG_BT(listen(sockfd, 5) >= 0, "child listen failed");
500 struct sockaddr_un client_addr;
501 socklen_t client_len = sizeof(client_addr);
503 RUNNER_ASSERT_MSG_BT((csockfd = accept(sockfd,(struct sockaddr*)&client_addr, &client_len)) > 0, "child accept failed");
511 int sockfd = connect_to_testserver();
512 RUNNER_ASSERT_MSG_BT(sockfd >= 0, "connect_to_testserver() failed");
514 SockFDUniquePtr sockfd_ptr(&sockfd, closesockfdptr);
516 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
517 start_stats_update(&stats);
518 /*odd(i) - ask for possessed privileges, even(i) ask for not possessed privileges */
520 ret = security_server_check_privilege_by_sockfd(
525 ret = security_server_check_privilege_by_sockfd(
529 RUNNER_ASSERT_MSG_BT(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
530 end_stats_update(&stats);
533 finish_stats(&stats, "check_privilege_by_sockfd");
538 * measurer: Fails only on connection error.
541 RUNNER_MULTIPROCESS_TEST_SMACK(m070_security_server_check_privilege_by_sockfd_smack) {
542 testSecurityServerCheckPrivilegeBySockfd(true);
545 RUNNER_MULTIPROCESS_TEST_NOSMACK(m070_security_server_check_privilege_by_sockfd_nosmack) {
546 testSecurityServerCheckPrivilegeBySockfd(false);
550 * measurer: Fails only on connection error.
552 RUNNER_TEST(m080_security_server_get_cookie_pid) {
555 cookie_size = security_server_get_cookie_size();
556 char cookie[cookie_size];
557 ret = security_server_request_cookie(cookie, cookie_size);
558 RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "security_server_request_cookie failed; ret = " << ret);
559 readwrite_stats stats;
560 initialize_stats(&stats);
561 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
562 start_stats_update(&stats);
563 ret = security_server_get_cookie_pid(cookie);
564 RUNNER_ASSERT_MSG_BT(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
565 end_stats_update(&stats);
567 finish_stats(&stats, "security_server_request_cookie");
571 * measurer: Fails only on connection error.
573 RUNNER_TEST(m090_security_server_is_pwd_valid) {
575 unsigned int attempt, max_attempt, expire_sec;
576 readwrite_stats stats;
577 initialize_stats(&stats);
578 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
579 start_stats_update(&stats);
580 ret = security_server_is_pwd_valid(&attempt, &max_attempt, &expire_sec);
581 RUNNER_ASSERT_MSG_BT(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
582 end_stats_update(&stats);
584 finish_stats(&stats, "security_server_is_pwd_valid");
588 * measurer: Fails only on connection error.
590 RUNNER_TEST(m100_security_server_set_pwd) {
592 readwrite_stats stats;
593 initialize_stats(&stats);
594 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
595 start_stats_update(&stats);
596 ret = security_server_set_pwd("this_is_current_pwd", "this_is_new_pwd", 20, 365);
597 RUNNER_ASSERT_MSG_BT(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
598 end_stats_update(&stats);
600 finish_stats(&stats, "security_server_set_pwd");
604 * measurer: Fails only on connection error.
606 RUNNER_TEST(m110_security_server_set_pwd_validity) {
608 readwrite_stats stats;
609 initialize_stats(&stats);
610 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
611 start_stats_update(&stats);
612 ret = security_server_set_pwd_validity(2);
613 RUNNER_ASSERT_MSG_BT(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
614 end_stats_update(&stats);
616 finish_stats(&stats, "security_server_set_pwd_validity");
620 * measurer: Fails only on connection error.
622 RUNNER_TEST(m120_security_server_set_pwd_max_challenge) {
624 readwrite_stats stats;
625 initialize_stats(&stats);
626 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
627 start_stats_update(&stats);
628 ret = security_server_set_pwd_max_challenge(3);
629 RUNNER_ASSERT_MSG_BT(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
630 end_stats_update(&stats);
632 finish_stats(&stats, "security_server_set_pwd_max_challenge");
636 * measurer: Fails only on connection error.
638 RUNNER_TEST(m130_security_server_reset_pwd) {
640 readwrite_stats stats;
641 initialize_stats(&stats);
642 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
643 start_stats_update(&stats);
644 ret = security_server_reset_pwd("apud", 1, 2);
645 RUNNER_ASSERT_MSG_BT(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
646 end_stats_update(&stats);
648 finish_stats(&stats, "security_server_reset_pwd");
652 * measurer: Fails only on connection error.
654 RUNNER_TEST(m140_security_server_chk_pwd) {
656 unsigned int attempt, max_attempt, expire_sec;
657 readwrite_stats stats;
658 initialize_stats(&stats);
659 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
660 start_stats_update(&stats);
661 ret = security_server_chk_pwd("is_this_password", &attempt, &max_attempt, &expire_sec);
662 RUNNER_ASSERT_MSG_BT(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
663 end_stats_update(&stats);
665 finish_stats(&stats, "security_server_chk_pwd");
669 * measurer: Fails only on connection error.
671 RUNNER_TEST(m150_security_server_set_pwd_history) {
673 readwrite_stats stats;
674 initialize_stats(&stats);
675 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
676 start_stats_update(&stats);
677 ret = security_server_set_pwd_history(100);
678 RUNNER_ASSERT_MSG_BT(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
679 end_stats_update(&stats);
681 finish_stats(&stats, "security_server_set_pwd_history");
685 * measurer: Fails only on connection error.
687 RUNNER_TEST(m160_security_server_app_give_access) {
689 readwrite_stats stats;
690 initialize_stats(&stats);
691 const char* customer_label = M160_CUSTOMER_LABEL;
692 int customer_pid = getpid();
693 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
694 start_stats_update(&stats);
695 ret = security_server_app_give_access(customer_label, customer_pid);
696 RUNNER_ASSERT_MSG_BT(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
697 end_stats_update(&stats);
699 finish_stats(&stats, "security_server_app_give_access");
703 * measurer: Fails only on connection error.
705 RUNNER_TEST(m170_security_server_check_privilege_by_pid) {
708 readwrite_stats stats;
709 initialize_stats(&stats);
711 const char *object = M170_OBJECT_LABEL;
712 const char *access_rights = "rw";
713 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
714 start_stats_update(&stats);
715 ret = security_server_check_privilege_by_pid(pid, object, access_rights);
716 RUNNER_ASSERT_MSG_BT(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
717 end_stats_update(&stats);
719 finish_stats(&stats, "security_server_check_privilege_by_pid");
723 int main(int argc, char *argv[])
725 SummaryCollector::Register();
726 securityClientEnableLogSystem();
727 DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);