!939 disable 静态库的cfi check,这个静态库只是为了测试使用,正式版本不带上

Merge pull request !939 from CheerfulRicky/master
This commit is contained in:
openharmony_ci 2024-04-30 04:46:13 +00:00 committed by Gitee
commit 68ce04950b
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
8 changed files with 36 additions and 35 deletions

View File

@ -178,7 +178,8 @@ __attribute__((no_sanitize("cfi"))) int32_t CommonEvent::SubscribeCommonEvent(
}
}
int32_t CommonEvent::UnSubscribeCommonEvent(const std::shared_ptr<CommonEventSubscriber> &subscriber)
__attribute__((no_sanitize("cfi"))) int32_t CommonEvent::UnSubscribeCommonEvent(
const std::shared_ptr<CommonEventSubscriber> &subscriber)
{
HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__);
EVENT_LOGD("enter");

View File

@ -412,7 +412,7 @@ HWTEST_F(CommonEventSubscribeTest, CommonEventSubscribe_012, TestSize.Level1)
* SubFunction: Subscribe common event
* FunctionPoints: test is ready
* EnvConditions: system run normally
* CaseDescription: 1. ready fail because runner is null
* CaseDescription: 1. ready true because handler is null but ThreadMode is not handler
*/
HWTEST_F(CommonEventSubscribeTest, CommonEventSubscribe_014, TestSize.Level1)
{
@ -426,7 +426,7 @@ HWTEST_F(CommonEventSubscribeTest, CommonEventSubscribe_014, TestSize.Level1)
bool result = commonEventListener.IsReady();
EXPECT_EQ(false, result);
EXPECT_EQ(true, result);
}
/*
@ -435,12 +435,13 @@ HWTEST_F(CommonEventSubscribeTest, CommonEventSubscribe_014, TestSize.Level1)
* SubFunction: Subscribe common event
* FunctionPoints: test is ready
* EnvConditions: system run normally
* CaseDescription: 1. ready fail because handler is null
* CaseDescription: 1. ready fail because handler is null and threadMode is handler
*/
HWTEST_F(CommonEventSubscribeTest, CommonEventSubscribe_015, TestSize.Level1)
{
MatchingSkills matchingSkills;
CommonEventSubscribeInfo subscribeInfo(matchingSkills);
subscribeInfo.SetThreadMode(CommonEventSubscribeInfo::HANDLER);
std::shared_ptr<CommonEventSubscribeInfo> commonEventSubscribeInfo =
std::make_shared<CommonEventSubscribeInfo>(subscribeInfo);
std::shared_ptr<SubscriberTest> subscriber = std::make_shared<SubscriberTest>(subscribeInfo);
@ -627,7 +628,8 @@ HWTEST_F(CommonEventSubscribeTest, CommonEventSubscriber_001, TestSize.Level1)
subscriber->SetAsyncCommonEventResult(nullptr);
EXPECT_EQ(subscriber->CheckSynchronous(), false);
bool result = subscriber->SetCode(1);
const int code = 1;
bool result = subscriber->SetCode(code);
EXPECT_EQ(result, false);
}
@ -665,7 +667,7 @@ HWTEST_F(CommonEventSubscribeTest, CommonEventSubscriber_003, TestSize.Level1)
subscriber->SetAsyncCommonEventResult(nullptr);
EXPECT_EQ(subscriber->CheckSynchronous(), false);
std::string data = "this is data";
const std::string data = "this is data";
bool result = subscriber->SetData(data);
EXPECT_EQ(result, false);
}
@ -705,8 +707,8 @@ HWTEST_F(CommonEventSubscribeTest, CommonEventSubscriber_005, TestSize.Level1)
subscriber->SetAsyncCommonEventResult(nullptr);
EXPECT_EQ(subscriber->CheckSynchronous(), false);
int32_t code = 1;
std::string data = "this is data";
const int32_t code = 1;
const std::string data = "this is data";
bool result = subscriber->SetCodeAndData(code, data);
EXPECT_EQ(result, false);
}

View File

@ -131,14 +131,6 @@ ohos_shared_library("cesfwk_services") {
# Note: Just for test
ohos_static_library("cesfwk_services_static") {
sanitize = {
integer_overflow = true
ubsan = true
boundary_sanitize = true
cfi = true
cfi_cross_dso = true
debug = false
}
cflags_cc = []
sources = cesfwk_services_sources

View File

@ -578,7 +578,7 @@ HWTEST_F(AbilityManagerHelperTest, AbilityManagerHelper_0300, Level1)
Want want;
CommonEventData event;
sptr<IRemoteObject> callerToken = nullptr;
int32_t userId = 1;
const int32_t userId = 1;
EXPECT_EQ(-1, abilityManagerHelper.ConnectAbility(want, event, callerToken, userId));
GTEST_LOG_(INFO) << "AbilityManagerHelper_0300 end";
}

View File

@ -115,7 +115,7 @@ HWTEST_F(BundleManagerHelperTest, BundleManagerHelper_0500, Level1)
GTEST_LOG_(INFO) << "BundleManagerHelper_0500 start";
BundleManagerHelper bundleManagerHelper;
bundleManagerHelper.sptrBundleMgr_ = nullptr;
uid_t uid = 1;
const uid_t uid = 1;
EXPECT_EQ("", bundleManagerHelper.GetBundleName(uid));
GTEST_LOG_(INFO) << "BundleManagerHelper_0500 end";
}
@ -131,7 +131,7 @@ HWTEST_F(BundleManagerHelperTest, BundleManagerHelper_0600, Level1)
BundleManagerHelper bundleManagerHelper;
bundleManagerHelper.sptrBundleMgr_ = nullptr;
std::vector<AppExecFwk::ExtensionAbilityInfo> extensionInfos;
int32_t userId = 1;
const int32_t userId = 1;
EXPECT_EQ(false, bundleManagerHelper.QueryExtensionInfos(extensionInfos, userId));
GTEST_LOG_(INFO) << "BundleManagerHelper_0600 end";
}
@ -193,7 +193,7 @@ HWTEST_F(BundleManagerHelperTest, BundleManagerHelper_1000, Level1)
GTEST_LOG_(INFO) << "BundleManagerHelper_1000 start";
BundleManagerHelper bundleManagerHelper;
bundleManagerHelper.sptrBundleMgr_ = nullptr;
uid_t uid = 1;
const uid_t uid = 1;
EXPECT_EQ(false, bundleManagerHelper.CheckIsSystemAppByUid(uid));
GTEST_LOG_(INFO) << "BundleManagerHelper_1000 end";
}
@ -209,7 +209,7 @@ HWTEST_F(BundleManagerHelperTest, BundleManagerHelper_1100, Level1)
BundleManagerHelper bundleManagerHelper;
bundleManagerHelper.sptrBundleMgr_ = nullptr;
std::string bundleName = "aa";
int32_t userId = 1;
const int32_t userId = 1;
EXPECT_EQ(false, bundleManagerHelper.CheckIsSystemAppByBundleName(bundleName, userId));
GTEST_LOG_(INFO) << "BundleManagerHelper_1100 end";
}

View File

@ -58,7 +58,7 @@ void CommonEventManagerServiceAbilityTest::TearDown(void)
HWTEST_F(CommonEventManagerServiceAbilityTest, CommonEventManagerServiceAbility_0100, Level1)
{
GTEST_LOG_(INFO) << "CommonEventManagerServiceAbility_0100 start";
int32_t systemAbilityId = 1;
const int32_t systemAbilityId = 1;
bool runOnCreate = true;
std::shared_ptr<CommonEventManagerServiceAbility> commonEventManagerServiceAbility =
std::make_shared<CommonEventManagerServiceAbility>(systemAbilityId, runOnCreate);
@ -76,7 +76,7 @@ HWTEST_F(CommonEventManagerServiceAbilityTest, CommonEventManagerServiceAbility_
HWTEST_F(CommonEventManagerServiceAbilityTest, CommonEventManagerServiceAbility_0200, Level1)
{
GTEST_LOG_(INFO) << "CommonEventManagerServiceAbility_0200 start";
int32_t systemAbilityId = 1;
const int32_t systemAbilityId = 1;
bool runOnCreate = true;
std::shared_ptr<CommonEventManagerServiceAbility> commonEventManagerServiceAbility =
std::make_shared<CommonEventManagerServiceAbility>(systemAbilityId, runOnCreate);
@ -95,7 +95,7 @@ HWTEST_F(CommonEventManagerServiceAbilityTest, CommonEventManagerServiceAbility_
HWTEST_F(CommonEventManagerServiceAbilityTest, CommonEventManagerServiceAbility_0300, Level1)
{
GTEST_LOG_(INFO) << "CommonEventManagerServiceAbility_0300 start";
int32_t systemAbilityId = 1;
const int32_t systemAbilityId = 1;
bool runOnCreate = true;
std::shared_ptr<CommonEventManagerServiceAbility> commonEventManagerServiceAbility =
std::make_shared<CommonEventManagerServiceAbility>(systemAbilityId, runOnCreate);

View File

@ -644,8 +644,10 @@ HWTEST_F(CommonEventSubscribeUnitTest, CommonEventSubscribeUnitTest_0300, Functi
struct tm curTime {0};
OHOS::Security::AccessToken::AccessTokenID tokenID = 0;
InnerCommonEventManager innerCommonEventManager;
const pid_t pid = 0;
const uid_t uid = 0;
EXPECT_TRUE(innerCommonEventManager.SubscribeCommonEvent(
subscribeInfo, commonEventListenerPtr, curTime, 0, 0, tokenID, ""));
subscribeInfo, commonEventListenerPtr, curTime, pid, uid, tokenID, ""));
}
/*
@ -670,8 +672,10 @@ HWTEST_F(CommonEventSubscribeUnitTest, CommonEventSubscribeUnitTest_0400, Functi
struct tm curTime {0};
OHOS::Security::AccessToken::AccessTokenID tokenID = 0;
InnerCommonEventManager innerCommonEventManager;
const pid_t pid = 0;
const uid_t uid = 0;
EXPECT_FALSE(innerCommonEventManager.SubscribeCommonEvent(
subscribeInfo, commonEventListenerPtr, curTime, 0, 0, tokenID, ""));
subscribeInfo, commonEventListenerPtr, curTime, pid, uid, tokenID, ""));
}
/*
@ -693,7 +697,9 @@ HWTEST_F(CommonEventSubscribeUnitTest, CommonEventSubscribeUnitTest_0500, Functi
struct tm curTime {0};
OHOS::Security::AccessToken::AccessTokenID tokenID = 0;
InnerCommonEventManager innerCommonEventManager;
EXPECT_FALSE(innerCommonEventManager.SubscribeCommonEvent(subscribeInfo, sp, curTime, 0, 0, tokenID, ""));
const pid_t pid = 0;
const uid_t uid = 0;
EXPECT_FALSE(innerCommonEventManager.SubscribeCommonEvent(subscribeInfo, sp, curTime, pid, uid, tokenID, ""));
}
/*
@ -951,7 +957,7 @@ HWTEST_F(CommonEventSubscribeUnitTest, AbilityManagerHelper_0002, Function | Med
// make common event data
CommonEventData event;
OHOS::sptr<OHOS::IRemoteObject> callerToken(nullptr);
int32_t userId = 1;
const int32_t userId = 1;
AbilityManagerHelper abilityManagerHelper;
abilityManagerHelper.abilityMgr_ = new (std::nothrow) TestAbilityMgr();
int result = abilityManagerHelper.ConnectAbility(want, event, callerToken, userId);
@ -967,7 +973,7 @@ HWTEST_F(CommonEventSubscribeUnitTest, AbilityManagerHelper_0002, Function | Med
HWTEST_F(CommonEventSubscribeUnitTest, BundleManagerHelper_0001, Function | MediumTest | Level1)
{
std::vector<OHOS::AppExecFwk::ExtensionAbilityInfo> extensionInfos;
int32_t userId = 3;
const int32_t userId = 3;
BundleManagerHelper bundleManagerHelper;
bundleManagerHelper.QueryExtensionInfos(extensionInfos, userId);
}
@ -1003,9 +1009,9 @@ HWTEST_F(CommonEventSubscribeUnitTest, CommonEventManagerService_0001, Function
// make publish info
CommonEventPublishInfo publishinfo;
OHOS::sptr<OHOS::IRemoteObject> commonEventListener(nullptr);
uid_t uid = 1;
int32_t userId = 1;
int32_t tokenId = 0;
const uid_t uid = 1;
const int32_t userId = 1;
const int32_t tokenId = 0;
CommonEventManagerService commonEventManagerService;
bool result = commonEventManagerService.PublishCommonEvent(event, publishinfo, commonEventListener, uid,
tokenId, userId);
@ -1022,7 +1028,7 @@ HWTEST_F(CommonEventSubscribeUnitTest, CommonEventManagerService_0002, Function
{
uint8_t dumpType = 1;
std::string event = "Event";
int32_t userId =2;
const int32_t userId =2;
std::vector<std::string> state;
CommonEventManagerService commonEventManagerService;
bool result = commonEventManagerService.DumpState(dumpType, event, userId, state);

View File

@ -115,7 +115,7 @@ HWTEST_F(SubscriberDeathRecipientTest, SubscriberDeathRecipient_0100, Level1)
GTEST_LOG_(INFO) << "SubscriberDeathRecipient_0100 start";
std::shared_ptr<SubscriberDeathRecipient> subscriberDeathRecipient = std::make_shared<SubscriberDeathRecipient>();
ASSERT_NE(nullptr, subscriberDeathRecipient);
wptr<MockIRemoteObject> remote = nullptr;
const wptr<MockIRemoteObject> remote = nullptr;
subscriberDeathRecipient->OnRemoteDied(remote);
GTEST_LOG_(INFO) << "SubscriberDeathRecipient_0100 end";
}
@ -131,7 +131,7 @@ HWTEST_F(SubscriberDeathRecipientTest, SubscriberDeathRecipient_0200, Level1)
SubscriberDeathRecipient subscriberDeathRecipient;
sptr<MockIRemoteObject> sptrDeath = new (std::nothrow) MockIRemoteObject();
ASSERT_NE(nullptr, sptrDeath);
wptr<MockIRemoteObject> remote = sptrDeath;
const wptr<MockIRemoteObject> remote = sptrDeath;
subscriberDeathRecipient.OnRemoteDied(remote);
GTEST_LOG_(INFO) << "SubscriberDeathRecipient_0200 end";
}