diff --git a/cfi_blocklist.txt b/cfi_blocklist.txt new file mode 100644 index 0000000000000000000000000000000000000000..a3472a91fe29c4eed9d69f24e954189592374f8a --- /dev/null +++ b/cfi_blocklist.txt @@ -0,0 +1,33 @@ +# Copyright (C) 2022-2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +[cfi] +type:*OHOS::Parcel* +type:*OHOS::RefBase* +type:*OHOS::MessageParcel* +type:*OHOS::IRemoteObject* +type:*OHOS::IRemoteBroker* +type:*OHOS::IRemoteProxy* +type:*OHOS::BrokerRegistration* +type:*OHOS::BrokerDelegator* +type:*OHOS::BrokerCreator* +type:*OHOS::ISystemAbilityManager* +type:*OHOS::ThreadPool* +type:*OHOS::IPCSkeleton* +type:*OHOS::Security::AccessToken::AccessTokenKit* +type:*OHOS::AAFwk::SystemAbilityManagerClient* +type:*OHOS::SystemAbility* +type:*OHOS::AppExecFwk* +type:*OHOS::AAFwk::AbilityConnectionStub* +src:*third_party/googletest/googlemock/include/gmock/* +src:*third_party/googletest/googletest/include/gtest/* \ No newline at end of file diff --git a/services/backup_sa/src/module_ipc/svc_backup_connection.cpp b/services/backup_sa/src/module_ipc/svc_backup_connection.cpp index 4da0013a62d861206b00f93f6127185f819632c2..c11b00efbe87abe0972ae02a761614468d24e77b 100644 --- a/services/backup_sa/src/module_ipc/svc_backup_connection.cpp +++ b/services/backup_sa/src/module_ipc/svc_backup_connection.cpp @@ -33,7 +33,7 @@ void SvcBackupConnection::OnAbilityConnectDone(const AppExecFwk::ElementName &el HILOGE("Failed to ability connect done, remote is nullptr"); return; } - backupProxy_ = iface_cast(remoteObject); + backupProxy_ = iface_cast(remoteObject); if (backupProxy_ == nullptr) { HILOGE("Failed to ability connect done, backupProxy_ is nullptr"); return; diff --git a/tests/mock/module_ipc/app_gallery_dispose_proxy_mock.cpp b/tests/mock/module_ipc/app_gallery_dispose_proxy_mock.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ca6ce6a2b7e11cfd5a49f7080a3dec499b23e8d4 --- /dev/null +++ b/tests/mock/module_ipc/app_gallery_dispose_proxy_mock.cpp @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "module_app_gallery/app_gallery_dispose_proxy.h" + +#include +#include + +#include "message_parcel.h" +#include "want.h" + +#include "module_app_gallery/app_gallery_service_connection.h" + +namespace OHOS::FileManagement::Backup { +using namespace std; + +AppGalleryDisposeProxy::AppGalleryDisposeProxy() +{ + GTEST_LOG_(INFO) << "AppGalleryDisposeProxy is OK"; +} + +AppGalleryDisposeProxy::~AppGalleryDisposeProxy() +{ + GTEST_LOG_(INFO) << "~AppGalleryDisposeProxy is OK"; +} + +sptr AppGalleryDisposeProxy::GetInstance() +{ + return new AppGalleryDisposeProxy; +} + +DisposeErr AppGalleryDisposeProxy::StartBackup(const std::string &bundleName) +{ + return DoDispose(bundleName, DisposeOperation::START_BACKUP); +} + +DisposeErr AppGalleryDisposeProxy::EndBackup(const std::string &bundleName) +{ + return DoDispose(bundleName, DisposeOperation::END_BACKUP); +} + +DisposeErr AppGalleryDisposeProxy::StartRestore(const std::string &bundleName) +{ + return DoDispose(bundleName, DisposeOperation::START_RESTORE); +} + +DisposeErr AppGalleryDisposeProxy::EndRestore(const std::string &bundleName) +{ + return DoDispose(bundleName, DisposeOperation::END_RESTORE); +} + +DisposeErr AppGalleryDisposeProxy::DoDispose(const std::string &bundleName, DisposeOperation disposeOperation) +{ + return DisposeErr::OK; +} + +} // namespace OHOS::FileManagement::Backup diff --git a/tests/mock/module_ipc/svc_backup_connection_mock.cpp b/tests/mock/module_ipc/svc_backup_connection_mock.cpp index ead43d40dc5d45dee8cf1813ce6a912e52befaca..68cbd81b83a2ca244d83e9363c3ca3c52e441da9 100644 --- a/tests/mock/module_ipc/svc_backup_connection_mock.cpp +++ b/tests/mock/module_ipc/svc_backup_connection_mock.cpp @@ -32,7 +32,7 @@ void SvcBackupConnection::OnAbilityConnectDone(const AppExecFwk::ElementName &el int resultCode) { isConnected_.store(true); - backupProxy_ = iface_cast(remoteObject); + backupProxy_ = iface_cast(remoteObject); string bundleName = ""; callConnDone_(move(bundleName)); } diff --git a/tests/unittests/backup_api/backup_impl/BUILD.gn b/tests/unittests/backup_api/backup_impl/BUILD.gn index 478b257385da8d135f602df1103ec7f0c89b7ede..5f28f599ae17e10316bf72ad5ecb9b85cfcdff18 100644 --- a/tests/unittests/backup_api/backup_impl/BUILD.gn +++ b/tests/unittests/backup_api/backup_impl/BUILD.gn @@ -76,6 +76,7 @@ ohos_unittest("backup_sa_impl_test") { cfi = true cfi_cross_dso = true debug = false + blocklist = "${path_backup}/cfi_blocklist.txt" } use_exceptions = true diff --git a/tests/unittests/backup_sa/module_ipc/BUILD.gn b/tests/unittests/backup_sa/module_ipc/BUILD.gn index 849e366f535a4eaa952b3a764014a2ae686f0c1a..fa9f7762e399834d446187e54994db395dba8cee 100644 --- a/tests/unittests/backup_sa/module_ipc/BUILD.gn +++ b/tests/unittests/backup_sa/module_ipc/BUILD.gn @@ -18,6 +18,7 @@ ohos_unittest("module_ipc_test") { module_out_path = path_module_out_tests sources = [ + "${path_backup_mock}/timer/timer_mock.cpp", "service_reverse_proxy_test.cpp", "service_stub_test.cpp", "svc_backup_connection_test.cpp", @@ -50,6 +51,13 @@ ohos_unittest("module_ipc_test") { "storage_service:storage_manager_sa_proxy", ] + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + blocklist = "${path_backup}/cfi_blocklist.txt" + } + use_exceptions = true } @@ -58,7 +66,8 @@ ohos_unittest("backup_service_test") { sources = [ "${path_backup_mock}/accesstoken/accesstoken_kit_mock.cpp", - "${path_backup}/services/backup_sa/src/module_app_gallery/app_gallery_dispose_proxy.cpp", + "${path_backup_mock}/module_ipc/app_gallery_dispose_proxy_mock.cpp", + "${path_backup_mock}/timer/timer_mock.cpp", "${path_backup}/services/backup_sa/src/module_ipc/service.cpp", "${path_backup}/services/backup_sa/src/module_ipc/svc_restore_deps_manager.cpp", "service_test.cpp", @@ -96,6 +105,13 @@ ohos_unittest("backup_service_test") { "storage_service:storage_manager_sa_proxy", ] + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + blocklist = "${path_backup}/cfi_blocklist.txt" + } + use_exceptions = true }