2 * Copyright (c) 2014 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/singleton.h>
33 #include <dpl/singleton_safe_impl.h>
34 #include <dpl/test/test_runner.h>
35 #include <dpl/test/test_runner_child.h>
36 #include <dpl/test/test_runner_multiprocess.h>
40 #include <security-server.h>
43 #include <sys/smack.h>
44 #include <sys/socket.h>
46 #include <sys/types.h>
51 #include "security_server_mockup.h"
52 #include <smack_access.h>
54 IMPLEMENT_SAFE_SINGLETON(DPL::Log::LogSystem);
55 #include <security_server_tests_common.h>
56 #include <tests_common.h>
58 /*Number of calls in a single test*/
59 #define NUMBER_OF_CALLS (5)
60 #define MICROSECS_PER_SEC (1000000)
61 /* number of miliseconds, process will be suspended for multiplications of this quantum */
62 #define QUANTUM (10000)
63 /*Strings used in tests*/
64 /*name of existing user group on test device like "tel_gprs"*/
65 #define EXISTING_GROUP_NAME "telephony_makecall"
66 /*below labels should not be used in the system*/
67 #define M60_OBJECT_LABEL "tc060MeasurerLabel"
68 #define M60_SUBJECT_LABEL "tc060Subject"
69 #define M70_OBJECT_LABEL "tc070MeasurerLabel"
70 #define M70_SUBJECT_LABEL "tc070Subject"
71 #define M160_CUSTOMER_LABEL "my_customer_label"
72 #define M170_OBJECT_LABEL "myObject"
75 void securityClientEnableLogSystem(void) {
76 DPL::Log::LogSystemSingleton::Instance().SetTag("SEC_SRV_API_SPEED");
80 /** Store statistics from a set of function calls
82 struct readwrite_stats
84 timeval current_start_time; /*of last API call*/
85 timeval current_end_time; /*of last API call*/
86 int number_of_calls; /*till now*/
87 double total_duration; /*of all API calls*/
88 double average_duration;
89 double minimal_duration; /*minimum of averages*/
90 double maximal_duration; /*maximum of averages*/
93 /*Auxiliary functions*/
95 /**Sleep for the given time
98 @return 0 on success, -1 on error if process woken earlier
100 int my_nanosecsleep(long nanoseconds) {
102 sleep_spec.tv_sec = 0;
103 sleep_spec.tv_nsec = nanoseconds;
104 return nanosleep(&sleep_spec, nullptr);
107 /**Read from pipe descriptor to buffer; retries if less than count bytes were read.
109 @param buf start of buffer
110 @param count number of bytes read
111 @return number of bytes read (count)
113 int my_pipe_read(int fd, void *buf, size_t count) {
115 ssize_t rest = count;
118 RUNNER_ASSERT_ERRNO_MSG(0 < (s = TEMP_FAILURE_RETRY(read(fd, ((char*)buf) + readf, rest))),
119 "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_ERRNO_MSG(0 <= (s = TEMP_FAILURE_RETRY(write(fd, ((char*)buf) + writef, rest))),
138 "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, nullptr);
169 RUNNER_ASSERT_ERRNO_MSG(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");
257 RUNNER_TEST_GROUP_INIT(SECURITY_SERVER_API_SPEED_MEASURER)
260 * test: Tests the tests
261 * 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.
263 RUNNER_TEST(m000_security_server_test_the_tests) {
265 readwrite_stats stats;
266 double expected_min_min = QUANTUM;
267 double expected_min_max = 1.5 * expected_min_min;
268 double expected_avarage_min = (((double)(NUMBER_OF_CALLS + 1)) / 2.0) * expected_min_min;
269 double expected_avarage_max = 1.5 * expected_avarage_min;
270 double expected_max_min = ((double)(NUMBER_OF_CALLS)) * expected_min_min;
271 double expected_max_max = 1.5 * expected_max_min;
272 initialize_stats(&stats);
273 for (int i=0; i < NUMBER_OF_CALLS; i++) {
274 start_stats_update(&stats);
275 ret = my_nanosecsleep((long) ((i+1)*QUANTUM*1000));
276 RUNNER_ASSERT_MSG(ret == 0, "system sleep function returned premature wake-up; ret = " << ret);
277 end_stats_update(&stats);
279 finish_stats(&stats, "my_nanosecsleep");
280 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);
281 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);
282 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);
286 * measurer: Fails only on connection error.
288 RUNNER_TEST(m010_security_server_security_server_get_gid) {
290 readwrite_stats stats;
291 initialize_stats(&stats);
292 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
293 start_stats_update(&stats);
294 ret = security_server_get_gid(EXISTING_GROUP_NAME);
295 RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
296 end_stats_update(&stats);
298 finish_stats(&stats, "security_server_get_gid");
302 * measurer: Fails only on connection error.
304 RUNNER_TEST(m030_security_server_request_cookie) {
307 cookie_size = security_server_get_cookie_size();
308 char cookie[cookie_size];
309 readwrite_stats stats;
310 initialize_stats(&stats);
311 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
312 start_stats_update(&stats);
313 ret = security_server_request_cookie(cookie, cookie_size);
314 RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
315 end_stats_update(&stats);
317 finish_stats(&stats, "security_server_request_cookie");
321 * measurer: Fails only on connection error.
322 * Create new processes and measures times of first calls of security_server_request_cookie in them
325 RUNNER_MULTIPROCESS_TEST(m031_security_server_request_cookie_first_time_only) {
328 cookie_size = security_server_get_cookie_size();
329 char cookie[cookie_size];
330 readwrite_stats stats;
335 double duration_of_calls;
336 /*initialize pipes - one pipe for one child process*/
337 RUNNER_ASSERT_ERRNO_MSG(0 == pipe(pipefd), "error in pipe");
338 initialize_stats(&stats);
339 for (int i = 0; i < NUMBER_OF_CALLS; i++) {
340 RUNNER_ASSERT_ERRNO_MSG(-1 != (cpid = fork()), "error in fork #i = " << i);
341 if (cpid == 0) { /* Child*/
342 close(pipefd[0]); /* Close unused read end */
345 start_time = my_gettime();
346 ret = security_server_request_cookie(cookie, cookie_size);
347 end_time = my_gettime();
348 if (communication_succeeded(ret) == 0) {
350 duration_of_calls = timeval_to_microsecs(my_timersub(end_time, start_time));
355 duration_of_calls = 0.0;
357 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");
358 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");
363 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");
364 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");
366 RUNNER_ASSERT_MSG(number_of_calls > 0, "commmunication error");
367 stats_update(&stats, number_of_calls, duration_of_calls);
371 close(pipefd[1]); /* Close parent descriptors */
376 * measurer: Fails only on connection error.
378 RUNNER_TEST(m040_security_server_get_cookie_size) {
380 readwrite_stats stats;
381 initialize_stats(&stats);
382 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
383 start_stats_update(&stats);
384 cookie_size = security_server_get_cookie_size();
385 RUNNER_ASSERT_MSG(cookie_size > 0, "cookie_size = " << cookie_size);
386 end_stats_update(&stats);
388 finish_stats(&stats, "security_server_get_cookie_size");
392 * measurer: Fails only on connection error.
394 RUNNER_TEST(m050_security_server_check_privilege) {
396 readwrite_stats stats;
397 initialize_stats(&stats);
398 const char *existing_group_name = EXISTING_GROUP_NAME;
401 // we use existing group name for the measurment, however this is not neccessary
402 call_gid = security_server_get_gid(existing_group_name);
403 cookie_size = security_server_get_cookie_size();
404 char recved_cookie[cookie_size];
405 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
406 start_stats_update(&stats);
407 ret = security_server_check_privilege(recved_cookie, (gid_t)call_gid);
408 RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
409 end_stats_update(&stats);
411 finish_stats(&stats, "security_server_check_privilege");
414 void testSecurityServerCheckPrivilegeByCookie(bool smack) {
415 const char *object_label = M60_OBJECT_LABEL;
416 const char *access_rights = "r";
417 const char *access_rights_ext = "rw";
418 const char *subject_label = M60_SUBJECT_LABEL;
420 readwrite_stats stats;
421 initialize_stats(&stats);
424 SmackAccess smackAccess;
425 smackAccess.add(subject_label, object_label, access_rights);
427 RUNNER_ASSERT_MSG(0 == (ret = smack_set_label_for_self(subject_label)),
428 "Error in smack_set_label_for_self(); ret = " << ret);
431 Cookie cookie = getCookieFromSS();
433 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
434 start_stats_update(&stats);
435 /*odd(i) - ask for possessed privileges, even(i) ask for not possessed privileges */
437 ret = security_server_check_privilege_by_cookie(
442 ret = security_server_check_privilege_by_cookie(
447 RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
448 end_stats_update(&stats);
450 finish_stats(&stats, "security_server_check_privilege_by_cookie");
454 * measurer: Fails only on connection error.
457 RUNNER_TEST_SMACK(m060_security_server_check_privilege_by_cookie_smack) {
458 RUNNER_IGNORED_MSG("security_server_check_privilege_by_cookie is temporarily disabled: always returns success");
459 testSecurityServerCheckPrivilegeByCookie(true);
462 RUNNER_TEST_NOSMACK(m060_security_server_check_privilege_by_cookie_nosmack) {
463 RUNNER_IGNORED_MSG("security_server_check_privilege_by_cookie is temporarily disabled: always returns success");
464 testSecurityServerCheckPrivilegeByCookie(false);
467 void testSecurityServerCheckPrivilegeBySockfd(bool smack) {
468 const char *object_label = M70_OBJECT_LABEL;
469 const char *access_rights = "r";
470 const char *access_rights_ext = "rw";
471 const char *subject_label = M70_SUBJECT_LABEL;
473 readwrite_stats stats;
474 initialize_stats(&stats);
477 SmackAccess smackAccess;
478 smackAccess.add(subject_label, object_label, access_rights);
483 RUNNER_ASSERT_ERRNO(-1 != pid);
486 int sockfd = create_new_socket();
487 RUNNER_ASSERT_MSG(sockfd >= 0, "create_new_socket() failed");
489 SockUniquePtr sockfd_ptr(&sockfd);
492 RUNNER_ASSERT_MSG(0 == smack_set_label_for_self(subject_label), "child label " << subject_label << " not set");
494 RUNNER_ASSERT_ERRNO_MSG(listen(sockfd, 5) >= 0, "child listen failed");
496 struct sockaddr_un client_addr;
497 socklen_t client_len = sizeof(client_addr);
499 RUNNER_ASSERT_ERRNO_MSG((csockfd = accept(sockfd,(struct sockaddr*)&client_addr, &client_len)) > 0,
500 "child accept failed");
508 int sockfd = connect_to_testserver();
509 RUNNER_ASSERT_MSG(sockfd >= 0, "connect_to_testserver() failed");
511 SockUniquePtr sockfd_ptr(&sockfd);
513 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
514 start_stats_update(&stats);
515 /*odd(i) - ask for possessed privileges, even(i) ask for not possessed privileges */
517 ret = security_server_check_privilege_by_sockfd(
522 ret = security_server_check_privilege_by_sockfd(
526 RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
527 end_stats_update(&stats);
530 finish_stats(&stats, "check_privilege_by_sockfd");
535 * measurer: Fails only on connection error.
538 RUNNER_MULTIPROCESS_TEST_SMACK(m070_security_server_check_privilege_by_sockfd_smack) {
539 RUNNER_IGNORED_MSG("security_server_check_privilege_by_sockfd is temporarily disabled: always returns success");
540 testSecurityServerCheckPrivilegeBySockfd(true);
543 RUNNER_MULTIPROCESS_TEST_NOSMACK(m070_security_server_check_privilege_by_sockfd_nosmack) {
544 RUNNER_IGNORED_MSG("security_server_check_privilege_by_sockfd is temporarily disabled: always returns success");
545 testSecurityServerCheckPrivilegeBySockfd(false);
549 * measurer: Fails only on connection error.
551 RUNNER_TEST(m080_security_server_get_cookie_pid) {
554 cookie_size = security_server_get_cookie_size();
555 char cookie[cookie_size];
556 ret = security_server_request_cookie(cookie, cookie_size);
557 RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "security_server_request_cookie failed; ret = " << ret);
558 readwrite_stats stats;
559 initialize_stats(&stats);
560 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
561 start_stats_update(&stats);
562 ret = security_server_get_cookie_pid(cookie);
563 RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
564 end_stats_update(&stats);
566 finish_stats(&stats, "security_server_request_cookie");
570 * measurer: Fails only on connection error.
572 RUNNER_TEST(m090_security_server_is_pwd_valid) {
574 unsigned int attempt, max_attempt, expire_sec;
575 readwrite_stats stats;
576 initialize_stats(&stats);
577 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
578 start_stats_update(&stats);
579 ret = security_server_is_pwd_valid(&attempt, &max_attempt, &expire_sec);
580 RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
581 end_stats_update(&stats);
583 finish_stats(&stats, "security_server_is_pwd_valid");
587 * measurer: Fails only on connection error.
589 RUNNER_TEST(m100_security_server_set_pwd) {
591 readwrite_stats stats;
592 initialize_stats(&stats);
593 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
594 start_stats_update(&stats);
595 ret = security_server_set_pwd("this_is_current_pwd", "this_is_new_pwd", 20, 365);
596 RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
597 end_stats_update(&stats);
599 finish_stats(&stats, "security_server_set_pwd");
603 * measurer: Fails only on connection error.
605 RUNNER_TEST(m110_security_server_set_pwd_validity) {
607 readwrite_stats stats;
608 initialize_stats(&stats);
609 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
610 start_stats_update(&stats);
611 ret = security_server_set_pwd_validity(2);
612 RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
613 end_stats_update(&stats);
615 finish_stats(&stats, "security_server_set_pwd_validity");
619 * measurer: Fails only on connection error.
621 RUNNER_TEST(m120_security_server_set_pwd_max_challenge) {
623 readwrite_stats stats;
624 initialize_stats(&stats);
625 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
626 start_stats_update(&stats);
627 ret = security_server_set_pwd_max_challenge(3);
628 RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
629 end_stats_update(&stats);
631 finish_stats(&stats, "security_server_set_pwd_max_challenge");
635 * measurer: Fails only on connection error.
637 RUNNER_TEST(m130_security_server_reset_pwd) {
639 readwrite_stats stats;
640 initialize_stats(&stats);
641 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
642 start_stats_update(&stats);
643 ret = security_server_reset_pwd("apud", 1, 2);
644 RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
645 end_stats_update(&stats);
647 finish_stats(&stats, "security_server_reset_pwd");
651 * measurer: Fails only on connection error.
653 RUNNER_TEST(m140_security_server_chk_pwd) {
655 unsigned int attempt, max_attempt, expire_sec;
656 readwrite_stats stats;
657 initialize_stats(&stats);
658 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
659 start_stats_update(&stats);
660 ret = security_server_chk_pwd("is_this_password", &attempt, &max_attempt, &expire_sec);
661 RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
662 end_stats_update(&stats);
664 finish_stats(&stats, "security_server_chk_pwd");
668 * measurer: Fails only on connection error.
670 RUNNER_TEST(m150_security_server_set_pwd_history) {
672 readwrite_stats stats;
673 initialize_stats(&stats);
674 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
675 start_stats_update(&stats);
676 ret = security_server_set_pwd_history(100);
677 RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
678 end_stats_update(&stats);
680 finish_stats(&stats, "security_server_set_pwd_history");
684 * measurer: Fails only on connection error.
686 RUNNER_TEST(m160_security_server_app_give_access) {
688 readwrite_stats stats;
689 initialize_stats(&stats);
690 const char* customer_label = M160_CUSTOMER_LABEL;
691 int customer_pid = getpid();
692 for (int i = 1; i <= NUMBER_OF_CALLS; i++) {
693 start_stats_update(&stats);
694 ret = security_server_app_give_access(customer_label, customer_pid);
695 RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret);
696 end_stats_update(&stats);
698 finish_stats(&stats, "security_server_app_give_access");
702 * measurer: Fails only on connection error.
704 RUNNER_TEST(m170_security_server_check_privilege_by_pid) {
706 RUNNER_IGNORED_MSG("security_server_check_privilege_by_pid is temporarily disabled: always returns success");
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(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 securityClientEnableLogSystem();
726 DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);