2 * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
5 * @file security_server_tests_clean_env.cpp
6 * @author Zbigniew Jasinski (z.jasinski@samsung.com)
8 * @brief Functions to prepare clean env for tests.
15 #include <service_manager.h>
17 int restart_security_server() {
18 ServiceManager serviceManager("security-server.service");
19 serviceManager.restartService();
24 static int nftw_rmdir_contents(const char *fpath, const struct stat * /*sb*/,
25 int tflag, struct FTW *ftwbuf)
29 else if (tflag == FTW_DP && ftwbuf->level != 0)
36 * This function should be called at the begining of every SS test, so all the tests
37 * are independent of each other.
39 int reset_security_server()
41 const char* path = "/opt/data/security-server/";
42 const int max_descriptors = 10; //max number of open file descriptors by nftw function
44 // Clear /opt/data/security-server/ directory
45 if (access(path, F_OK) == 0) {
46 if (nftw(path, &nftw_rmdir_contents, max_descriptors, FTW_DEPTH) == -1) {
52 restart_security_server();