From 8fa055942e52bf5d34d81dd1ae9bd157077746c3 Mon Sep 17 00:00:00 2001 From: xia-liyun Date: Wed, 8 Sep 2021 13:09:11 +0800 Subject: [PATCH] format code:zhanghanlin9@huawei.com Signed-off-by: xia-liyun Change-Id: I9923661a13f8e3858759e71a5b4238afcdfc6222 --- security_lite/permission_posix.zip | 3 - .../permission_posix/pms/src/ActsPMSTest.h | 48 ++-- .../pms/src/ActsPMSUpdatePermissionTest.cpp | 212 +++++++++--------- 3 files changed, 134 insertions(+), 129 deletions(-) delete mode 100644 security_lite/permission_posix.zip diff --git a/security_lite/permission_posix.zip b/security_lite/permission_posix.zip deleted file mode 100644 index 6d6ca2517..000000000 --- a/security_lite/permission_posix.zip +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:cbd3be7f60b952be577fe590fe5478f00eff1aa234a9971b82abd0ca288802dd -size 70322 diff --git a/security_lite/permission_posix/pms/src/ActsPMSTest.h b/security_lite/permission_posix/pms/src/ActsPMSTest.h index 55d650fe2..d8d925552 100755 --- a/security_lite/permission_posix/pms/src/ActsPMSTest.h +++ b/security_lite/permission_posix/pms/src/ActsPMSTest.h @@ -38,20 +38,20 @@ #include "service.h" #include "samgr_lite.h" -#define TEST_APP_ID "com.permission.test" -#define TEST_APP_ID2 "com.permission.test2" -#define SUBTEST_APP_ID "com.permission.subtest" -#define TEST_APP_SHORT "a" -#define TEST_APP_LONG "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" -#define TEST_APP_PATH "/storage/app/etc/permissions/com.permission.test" -#define TEST_APP_INVALID "com.permission.!@#$%^&*()_+" -#define TEST_APP_NOT_EXIST "com.permission.onetwothree" -#define PERMISSION_UNDEFINED "ohos.permission.TEST" -#define PERMISSION_TOOLONG "ohos.permission.balabalabalabalabalabalabalabalabalabala" -#define PERMISSION_EMPTY "" -#define PERMISSION_UNSUPPORTED "!@#$%^&*()_+" -#define ETC_PREFIX "/storage/app/etc" -#define PERMISSION_PREFIX "/storage/app/etc/permissions" +const char[] TEST_APP_ID = "com.permission.test"; +const char[] TEST_APP_ID2 = "com.permission.test2"; +const char[] SUBTEST_APP_ID = "com.permission.subtest"; +const char[] TEST_APP_SHORT = "a"; +const char[] TEST_APP_LONG = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; +const char[] TEST_APP_PATH = "/storage/app/etc/permissions/com.permission.test"; +const char[] TEST_APP_INVALID = "com.permission.!@#$%^&*()_+"; +const char[] TEST_APP_NOT_EXIST = "com.permission.onetwothree"; +const char[] PERMISSION_UNDEFINED = "ohos.permission.TEST"; +const char[] PERMISSION_TOOLONG = "ohos.permission.balabalabalabalabalabalabalabalabalabala"; +const char[] PERMISSION_EMPTY = ""; +const char[] PERMISSION_UNSUPPORTED = "!@#$%^&*()_+"; +const char[] ETC_PREFIX = "/storage/app/etc"; +const char[] PERMISSION_PREFIX = "/storage/app/etc/permissions"; const int SLEEP_TIME = 5; const int TEST_TASKID = 1000; @@ -67,22 +67,22 @@ const int MAX_PID = 0x7fffffff; const int MIN_PID = 0; const int ABNORMAL_PKG_NUM = 5; const int DIR_MODE = 777; -const int FLAG_NOT_EXIST=123; -const int PERFORMANCE_RUN_TIMES=10000; -const int MILLISECOND=1000; +const int FLAG_NOT_EXIST = 123; +const int PERFORMANCE_RUN_TIMES = 10000; +const int MILLISECOND = 1000; -int IsUserGrant(const char* pname); +int IsUserGrant(const char *pname); -int CheckPermData(const PermissionTrans* pt, const PermissionSaved* ps, - const PermissionSaved* pre, int len, int plen); +int CheckPermData(const PermissionTrans *pt, const PermissionSaved *ps, + const PermissionSaved *pre, int len, int plen); -void ClrPers(PermissionSaved* &permissions); +void ClrPers(PermissionSaved *&permissions); -void CheckAppPermission(const char *identifier, int expRet, int expNum, const PermissionTrans* installPers, - const PermissionSaved* lastPers = nullptr, int lastLen = 0); +void CheckAppPermission(const char *identifier, int expRet, int expNum, const PermissionTrans *installPers, + const PermissionSaved *lastPers = nullptr, int lastLen = 0); void SubTestWithoutCheck(const char *identifier, int taskID); void CreateAppDir(void); -#endif // XTS_HITS_TOKEN_API_EXPECT_H \ No newline at end of file +#endif // XTS_HITS_TOKEN_API_EXPECT_H \ No newline at end of file diff --git a/security_lite/permission_posix/pms/src/ActsPMSUpdatePermissionTest.cpp b/security_lite/permission_posix/pms/src/ActsPMSUpdatePermissionTest.cpp index aa44afe76..143970fd2 100644 --- a/security_lite/permission_posix/pms/src/ActsPMSUpdatePermissionTest.cpp +++ b/security_lite/permission_posix/pms/src/ActsPMSUpdatePermissionTest.cpp @@ -14,7 +14,7 @@ */ #include "ActsPMSTest.h" -#include +#include using namespace std; using namespace testing::ext; @@ -68,13 +68,14 @@ static PermissionTrans g_systemPers[] = { }, }; -class ActsPMSUpdatePermissionTest:public testing::Test{ +class ActsPMSUpdatePermissionTest : public testing::Test +{ protected: static void SetUpTestCase(void) { CreateAppDir(); IUnknown *iUnknown = SAMGR_GetInstance()->GetFeatureApi(PERMISSION_SERVICE, PERM_INNER); - iUnknown->QueryInterface(iUnknown, DEFAULT_VERSION, (void **) &g_interface); + iUnknown->QueryInterface(iUnknown, DEFAULT_VERSION, (void **)&g_interface); setuid(0); } static void TearDownTestCase(void) {} @@ -92,8 +93,8 @@ protected: long GetCurrentTimeMillis() { struct timeval current; - gettimeofday(¤t,NULL); - return current.tv_sec*MILLISECOND+current.tv_usec/MILLISECOND; + gettimeofday(¤t, NULL); + return current.tv_sec * MILLISECOND + current.tv_usec / MILLISECOND; } /** @@ -105,22 +106,23 @@ HWTEST_F(ActsPMSUpdatePermissionTest, testSecPMUpdatePMFlags_001, Function | Med { SaveOrUpdatePermissions(TEST_APP_ID, g_systemPers, SYS_PERM_NUM, FIRST_INSTALL); - PermissionSaved *permissions=NULL; - int permNum=0; - int ret=g_interface->QueryPermission(TEST_APP_ID,&permissions,&permNum); - EXPECT_EQ(ret,PERM_ERRORCODE_SUCCESS)<<"query ret="<