diff --git a/data_share/interfaces/inner_api/common/BUILD.gn b/data_share/interfaces/inner_api/common/BUILD.gn index 95bd8587cc580c9015b0896f69842794e43e991b..ace184d0d86be12aaf86d0bad2862875f02e1237 100644 --- a/data_share/interfaces/inner_api/common/BUILD.gn +++ b/data_share/interfaces/inner_api/common/BUILD.gn @@ -52,6 +52,7 @@ ohos_shared_library("datashare_common") { public_deps = [] configs = [ ":ability_config" ] + version_script = "libdatashare_common.map" external_deps = [ "ability_base:zuri", diff --git a/data_share/interfaces/inner_api/common/libdatashare_common.map b/data_share/interfaces/inner_api/common/libdatashare_common.map new file mode 100644 index 0000000000000000000000000000000000000000..fc3862c64291f4bb3d301ec5db2e7f09b603cf6f --- /dev/null +++ b/data_share/interfaces/inner_api/common/libdatashare_common.map @@ -0,0 +1,27 @@ +# 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. + +1.0 { + global: + *DataShareAbsPredicates*; + *DataShareJSUtils*; + *DataSharePredicates*; + *DataShareResultSet*; + *DataShareValueObject*; + *DataShareValuesBucket*; + *Error*; + *ISharedResultSet*; + *ITypesUtils*; + local: + *; +}; \ No newline at end of file diff --git a/data_share/test/native/BUILD.gn b/data_share/test/native/BUILD.gn index 360be1d7484d61ab550de6b67760bf742811145b..722b949d3f6e6567258673a3a19a98726e35f630 100644 --- a/data_share/test/native/BUILD.gn +++ b/data_share/test/native/BUILD.gn @@ -16,8 +16,14 @@ import("//foundation/multimedia/media_library/media_library.gni") group("unittest") { testonly = true + deps = [] - deps = [ ":NativeDataShareTest" ] + deps += [ + ":NativeDataShareTest", + ":SlientAccessTest", + "resource/datashare_ext_bundle:datashare_ext", + "resource/ohos_test:copy_ohos_test", + ] } ohos_unittest("NativeDataShareTest") { @@ -74,3 +80,38 @@ ohos_unittest("NativeDataShareTest") { "samgr:samgr_proxy", ] } + +ohos_unittest("SlientAccessTest") { + module_out_path = "data_share/native_datashare" + + include_dirs = [ + "//base/security/access_token/frameworks/common/include", + "//base/hiviewdfx/hilog/interfaces/native/innerkits/include", + "//foundation/aafwk/standard/interfaces/innerkits/uri/include", + "//commonlibrary/c_utils/base/include", + "//utils/system/safwk/native/include", + "//foundation/communication/ipc/interfaces/innerkits/ipc_core/include", + ] + + sources = [ "./unittest/mediadatashare_test/src/slientaccess_test.cpp" ] + + deps = [ + "${ABILITY_RUNTIME_INNER_API_PATH}/ability_manager:ability_manager", + "${ABILITY_RUNTIME_PATH}/frameworks/native/ability/native:abilitykit_native", + "//base/security/access_token/interfaces/innerkits/token_setproc:libtoken_setproc", + ] + + external_deps = [ + "ability_base:want", + "ability_base:zuri", + "access_token:libaccesstoken_sdk", + "access_token:libnativetoken", + "c_utils:utils", + "data_share:datashare_common", + "data_share:datashare_consumer", + "hilog_native:libhilog", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + ] +} diff --git a/data_share/test/native/resource/datashare_ext_bundle/AppScope/app.json b/data_share/test/native/resource/datashare_ext_bundle/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..8ec8c76abea7eadca2f91c81cc1d3d7675e4ec0b --- /dev/null +++ b/data_share/test/native/resource/datashare_ext_bundle/AppScope/app.json @@ -0,0 +1,13 @@ +{ + "app": { + "bundleName": "com.acts.datasharetest", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "distributedNotificationEnabled": true, + "minAPIVersion": 9, + "targetAPIVersion": 9 + } +} diff --git a/data_share/test/native/resource/datashare_ext_bundle/AppScope/resources/base/element/string.json b/data_share/test/native/resource/datashare_ext_bundle/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..740e505afa0f81910681f96281493a3cf118388e --- /dev/null +++ b/data_share/test/native/resource/datashare_ext_bundle/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "datasharetest" + } + ] +} diff --git a/data_share/test/native/resource/datashare_ext_bundle/AppScope/resources/base/media/app_icon.png b/data_share/test/native/resource/datashare_ext_bundle/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/data_share/test/native/resource/datashare_ext_bundle/AppScope/resources/base/media/app_icon.png differ diff --git a/data_share/test/native/resource/datashare_ext_bundle/BUILD.gn b/data_share/test/native/resource/datashare_ext_bundle/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..53a887a6be55ec7de64e88b1895cb5f499a4d6e7 --- /dev/null +++ b/data_share/test/native/resource/datashare_ext_bundle/BUILD.gn @@ -0,0 +1,45 @@ +# Copyright (c) 2022 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. + +import("//build/ohos.gni") + +ohos_hap("datashare_ext") { + hap_profile = "entry/src/main/module.json" + hap_name = "datashare_ext" + subsystem_name = "distributeddatamgr" + part_name = "data_share" + final_hap_path = "$root_out_dir/tests/unittest/data_share/resource/datashare_ext_bundle/${hap_name}.hap" + testonly = true + deps = [ + ":datashare_ext_ets_assets", + ":datashare_ext_ets_resources", + ] + certificate_profile = "signature/openharmony_sx.p7b" +} + +ohos_js_assets("datashare_ext_ets_assets") { + ets2abc = true + source_dir = "entry/src/main/ets" + hap_profile = "entry/src/main/module.json" +} + +ohos_app_scope("datashare_ext_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_resources("datashare_ext_ets_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":datashare_ext_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/data_share/test/native/resource/datashare_ext_bundle/entry/src/main/ets/Application/MyAbilityStage.ts b/data_share/test/native/resource/datashare_ext_bundle/entry/src/main/ets/Application/MyAbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..9ee1aa9fbe29ab663a8171935457969972573fca --- /dev/null +++ b/data_share/test/native/resource/datashare_ext_bundle/entry/src/main/ets/Application/MyAbilityStage.ts @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2022 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. + */ + +import AbilityStage from "@ohos.app.ability.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/data_share/test/native/resource/datashare_ext_bundle/entry/src/main/ets/DataShareExtAbility/DataShareExtAbility.ts b/data_share/test/native/resource/datashare_ext_bundle/entry/src/main/ets/DataShareExtAbility/DataShareExtAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..5072d1205172ae2de25e645be6149833a00e15a0 --- /dev/null +++ b/data_share/test/native/resource/datashare_ext_bundle/entry/src/main/ets/DataShareExtAbility/DataShareExtAbility.ts @@ -0,0 +1,192 @@ +/* + * Copyright (c) 2022 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. + */ + +import Extension from '@ohos.application.DataShareExtensionAbility' +import rdb from '@ohos.data.relationalStore'; +import rpc from '@ohos.rpc'; + +let DB_NAME = "DB00.db"; +let TBL_NAME = "TBL00"; +let DDL_TBL_CREATE = "CREATE TABLE IF NOT EXISTS " ++ TBL_NAME ++ " (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)"; + +let rdbStore; + +export default class +extends Extension { + async onCreate(want, callback) { + console.log('[ttt] [DataShareTest] <> DataShareExtAbility onCreate, want:' + want.abilityName); + console.log("[ttt] [DataShareTest] DataShareExtAbility onCreate this.context.databaseDir:" + this.context.databaseDir); + // @ts-ignore + rdbStore = await rdb.getRdbStore(this.context, { name: DB_NAME, securityLevel: rdb.SecurityLevel.S1 }); + console.log('[ttt] [DataShareTest] <> DataShareExtAbility getRdbStore done'); + await rdbStore.executeSql(DDL_TBL_CREATE, []); + console.log('[ttt] [DataShareTest] <> DataShareExtAbility executeSql done'); + let err = {"code":0}; + callback(err); + console.log('[ttt] [DataShareTest] <> DataShareExtAbility onCreate end'); + } + + async getFileTypes(uri: string, mimeTypeFilter: string, callback) { + console.info('[ttt] [DataShareTest] <> [getFileTypes] enter'); + let ret = new Array("type01", "type00", "type03"); + console.info('[ttt] [DataShareTest] <> [getFileTypes] leave, ret:' + ret); + let err = {"code":0}; + await callback(err,ret); + return ret; + } + + async openFile(uri: string, mode: string, callback) { + console.info('[ttt] [DataShareTest] <> [openFile] enter'); + let ret = 12345; + let err = {"code":0}; + await callback(err,ret); + console.info('[ttt] [DataShareTest] <> [openFile] leave, ret:' + ret); + } + + async insert(uri, value, callback) { + console.info('[ttt] [DataShareTest] <> [insert] enter'); + if (value == null) { + console.info('[ttt] [DataShareTest] <> [insert] invalid valueBuckets'); + return; + } + + console.info('[ttt] [DataShareTest] <> [insert] getCallingTokenId:' + rpc.IPCSkeleton.getCallingTokenId()); + console.info('[ttt] [DataShareTest] <> [insert] value = ' + value); + console.info('[ttt] [DataShareTest] <> [insert] value = ' + JSON.stringify(value)); + await rdbStore.insert(TBL_NAME, value, function (err, ret) { + console.info('[ttt] [DataShareTest] <> [insert] callback ret:' + ret); + + if (callback != undefined) { + callback(err, ret); + } + }); + console.info('[ttt] [DataShareTest] <> [insert] leave'); + } + + async update(uri, predicates, value, callback) { + console.info('[ttt] [DataShareTest] <> [update] enter'); + if (predicates == null || predicates == undefined) { + console.info('[ttt] [DataShareTest] <> [update] invalid predicates'); + return; + } + console.info('[ttt] [DataShareTest] <> [update] values = ' + value); + console.info('[ttt] [DataShareTest] <> [update] values = ' + JSON.stringify(value)); + console.info('[ttt] [DataShareTest] <> [update] predicates = ' + predicates); + console.info('[ttt] [DataShareTest] <> [update] predicates = ' + JSON.stringify(predicates)); + try { + await rdbStore.update(TBL_NAME,value, predicates, function (err, ret) { + console.info('[ttt] [DataShareTest] <> [update] callback ret:' + ret); + console.info('[ttt] [DataShareTest] <> [update] callback err:' + err); + if (callback != undefined) { + callback(err, ret); + } + }); + } catch (err) { + console.error('[ttt] [DataShareTest] <> [update] error' + err); + } + console.info('[ttt] [DataShareTest] <> [update] leave'); + } + + async delete(uri, predicates, callback) { + console.info('[ttt] [DataShareTest] <> [delete] enter'); + if (predicates == null || predicates == undefined) { + console.info('[ttt] [DataShareTest] <> [delete] invalid predicates'); + return; + } + console.info('[ttt] [DataShareTest] <> [delete] predicates = ' + predicates); + console.info('[ttt] [DataShareTest] <> [delete] predicates = ' + JSON.stringify(predicates)); + try { + await rdbStore.delete(TBL_NAME,predicates, function (err, ret) { + console.info('[ttt] [DataShareTest] <> [delete] ret:' + ret); + if (callback != undefined) { + callback(err, ret); + } + }); + } catch (err) { + console.error('[ttt] [DataShareTest] <> [delete] error' + err); + } + console.info('[ttt] [DataShareTest] <> [delete] leave'); + } + + async query(uri, predicates, columns, callback) { + console.info('[ttt] [DataShareTest] <> [query] enter'); + if (predicates == null || predicates == undefined) { + console.info('[ttt] [DataShareTest] <> [query] invalid predicates'); + } + console.info('[ttt] [DataShareTest] <> [query] values = ' + columns); + console.info('[ttt] [DataShareTest] <> [query] values = ' + JSON.stringify(columns)); + console.info('[ttt] [DataShareTest] <> [query] predicates = ' + predicates); + console.info('[ttt] [DataShareTest] <> [query] predicates = ' + JSON.stringify(predicates)); + try { + await rdbStore.query(TBL_NAME, predicates, columns, function (err, resultSet) { + console.info('[ttt] [DataShareTest] <> [query] ret: ' + resultSet); + if (resultSet != undefined) { + console.info('[ttt] [DataShareTest] <> [query] resultSet.rowCount: ' + resultSet.rowCount); + } + if (callback != undefined) { + callback(err, resultSet); + } + }); + } catch (err) { + console.error('[ttt] [DataShareTest] <> [query] error' + err); + } + console.info('[ttt] [DataShareTest] <> [query] leave'); + } + + async getType(uri: string,callback) { + console.info('[ttt] [DataShareTest] <> [getType] enter'); + let ret = "image"; + console.info('[ttt] [DataShareTest] <> [getType] leave, ret:' + ret); + let err = {"code":0}; + await callback(err,ret); + return ret; + } + + async batchInsert(uri: string, valueBuckets, callback) { + console.info('[ttt] [DataShareTest] <> [batchInsert] enter'); + if (valueBuckets == null || valueBuckets.length == undefined) { + console.info('[ttt] [DataShareTest] <> [batchInsert] invalid valueBuckets'); + return; + } + console.info('[ttt] [DataShareTest] <> [batchInsert] valueBuckets.length:' + valueBuckets.length); + let resultNum = valueBuckets.length + await rdbStore.batchinsert(TBL_NAME, valueBuckets, function (err, ret) { + console.info('[ttt] [DataShareTest] <> [batchInsert] callback ret:' + ret); + if (callback != undefined) { + callback(err, ret); + } + }); + + console.info('[ttt] [DataShareTest] <> [batchInsert] leave'); + } + + async normalizeUri(uri: string, callback) { + console.info('[ttt] [DataShareTest] <> [normalizeUri] enter'); + let ret = "normalize+" + uri; + let err = {"code":0}; + await callback(err, ret); + console.info('[ttt] [DataShareTest] <> [normalizeUri] leave, ret:' + ret); + } + + async denormalizeUri(uri: string, callback) { + console.info('[ttt] [DataShareTest] <> [denormalizeUri] enter'); + let ret = "denormalize+" + uri; + let err = {"code":0}; + await callback(err, ret); + console.info('[ttt] [DataShareTest] <> [denormalizeUri] leave, ret:' + ret); + } +}; \ No newline at end of file diff --git a/data_share/test/native/resource/datashare_ext_bundle/entry/src/main/ets/MainAbility/MainAbility.ts b/data_share/test/native/resource/datashare_ext_bundle/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..57457c2ba26d771683fe7dc3d3888d12e7b8c5d2 --- /dev/null +++ b/data_share/test/native/resource/datashare_ext_bundle/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,252 @@ +/* + * Copyright (c) 2022 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. + */ + +import Ability from '@ohos.app.ability.UIAbility' +import dataShare from '@ohos.data.dataShare' +import dataSharePredicates from '@ohos.data.dataSharePredicates' + +let dseUri = ("datashare:///com.acts.datasharetest"); +let uri = ("datashare://com.acts.datasharetest/entry/DB00/TBL00?Proxy=true"); + +export function onCallback() { + console.info("[ttt] [DataShareTest] <> **** Observer on callback ****"); +} + +export function offCallback() { + console.info("[ttt] [DataShareTest] <> **** Observer off callback ****"); +} + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("[ttt] [DataShareTest] <> MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("[ttt] [DataShareTest] <> MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[ttt] [DataShareTest] <> MainAbility onWindowStageCreate") + globalThis.abilityContext = this.context; + console.log("[ttt] [DataShareTest] <> MainAbility this.context.databaseDir:" + this.context.databaseDir); + globalThis.connectDataShareExtAbility = (async () => { + console.log("[ttt] [DataShareTest] <> connectDataShareExtAbility begin"); + globalThis.dsHelper = await dataShare.createDataShareHelper(this.context, dseUri); + console.log("[ttt] [DataShareTest] <> connectDataShareExtAbility end"); + }) + + globalThis.disconnectDataShareExtAbility = (async () => { + console.log("[ttt] [DataShareTest] <> disconnectDataShareExtAbility begin"); + globalThis.dsHelper = null; + console.log("[ttt] [DataShareTest] <> disconnectDataShareExtAbility end"); + }) + + globalThis.on = (async () => { + console.log("[ttt] [DataShareTest] <> on begin"); + if (globalThis.dsHelper == null) { + console.log("[ttt] [DataShareTest] <> on end, DSHelper is null"); + return; + } + await globalThis.dsHelper.on("dataChange", uri, onCallback); + console.log("[ttt] [DataShareTest] <> on end"); + }) + + globalThis.off = (async () => { + console.log("[ttt] [DataShareTest] <> off begin"); + if (globalThis.dsHelper == null) { + console.log("[ttt] [DataShareTest] <> off end, DSHelper is null"); + return; + } + await globalThis.dsHelper.off("dataChange", uri); + await globalThis.dsHelper.off("dataChange", uri, offCallback); + console.log("[ttt] [DataShareTest] <> off end"); + }) + + globalThis.openFile = (async () => { + console.log("[ttt] [DataShareTest] <> openFile begin"); + if (globalThis.dsHelper == null) { + console.log("[ttt] [DataShareTest] <> openFile end, DSHelper is null"); + return; + } + let result = await globalThis.dsHelper.openFile(dseUri, "rw"); + console.log("[ttt] [DataShareTest] <> openFile end, result:" + result); + return result; + }) + + globalThis.query = (async () => { + console.log("[ttt] [DataShareTest] <> query begin"); + let da = new dataSharePredicates.DataSharePredicates(); + if (da == null || da == undefined) { + console.log("[ttt] [DataShareTest] <> da is null or undefined"); + return; + } + let count = 0; + if (globalThis.dsHelper == null) { + console.log("[ttt] [DataShareTest] <> query end, DSHelper is null"); + return; + } + da.equalTo("name", "ZhangSan"); + let result = await globalThis.dsHelper.query(dseUri, da, ["*"]); + if (result != undefined) { + count = result.rowCount; + } + console.log("[ttt] [DataShareTest] <> query end, count:" + count); + return count; + }) + + globalThis.insert = (async () => { + console.log("[ttt] [DataShareTest] <> insert begin"); + if (globalThis.dsHelper == null) { + console.log("[ttt] [DataShareTest] <> insert end, DSHelper is null"); + return; + } + let vb = {"name":"ZhangSan", "age": 21} + + console.log("[ttt] [DataShareTest] <> insert vb:" + JSON.stringify(vb)); + let ret = await globalThis.dsHelper.insert(dseUri, vb); + await console.log("[ttt] [DataShareTest] <> insert end, ret:" + ret); + return ret; + }) + + globalThis.update = (async () => { + console.log("[ttt] [DataShareTest] <> update begin"); + if (globalThis.dsHelper == null) { + console.log("[ttt] [DataShareTest] <> update end, DSHelper is null"); + return; + } + console.log("[ttt] [DataShareTest] <> update begin RPF666"); + let da = new dataSharePredicates.DataSharePredicates(); + console.log("[ttt] [DataShareTest] <> update begin RPF777"); + if (da == null || da == undefined) { + console.log("[ttt] [DataShareTest] <> da is null or undefined"); + return; + } + da.equalTo("name", "ZhangSan"); + + let ret = await globalThis.dsHelper.update(dseUri, da, {"name":"ZhangSan", "age":31}); + console.log("[ttt] [DataShareTest] <> update end, result:" + ret); + return ret; + }) + + globalThis.delete = (async () => { + console.log("[ttt] [DataShareTest] <> delete begin"); + if (globalThis.dsHelper == null) { + console.log("[ttt] [DataShareTest] <> delete end, DSHelper is null"); + return; + } + let da = new dataSharePredicates.DataSharePredicates(); + if (da == null || da == undefined) { + console.log("[ttt] [DataShareTest] <> da is null or undefined"); + return; + } + da.equalTo("name", "ZhangSan"); + let ret = await globalThis.dsHelper.delete(dseUri, da); + console.log("[ttt] [DataShareTest] <> delete end, result:" + ret); + return ret; + }) + + globalThis.batchInsert = (async () => { + console.log("[ttt] [DataShareTest] <> batchInsert begin"); + if (globalThis.dsHelper == null) { + console.log("[ttt] [DataShareTest] <> batchInsert end, DSHelper is null"); + return; + } + let ar = new Uint8Array([1,2,3,4,5,6]); + let arr = new Uint8Array([4,5,6,7]); + let people = new Array( + {"name": "LiSi", "age": 41, "Binary": ar}, + {"name": "WangWu", "age": 21, "Binary": arr}, + {"name": "ZhaoLiu", "age": 61, "Binary": arr}); + let ret = await globalThis.dsHelper.batchInsert(dseUri, people); + console.log("[ttt] [DataShareTest] <> batchInsert end, result:" + ret); + return ret; + }) + + globalThis.notifyChange = (async () => { + console.log("[ttt] [DataShareTest] <> notifyChange begin"); + if (globalThis.dsHelper == null) { + console.log("[ttt] [DataShareTest] <> notifyChange end, DSHelper is null"); + return; + } + await globalThis.dsHelper.notifyChange(dseUri); + console.log("[ttt] [DataShareTest] <> notifyChange end"); + }) + + globalThis.getType = (async () => { + console.log("[ttt] [DataShareTest] <> getType begin"); + if (globalThis.dsHelper == null) { + console.log("[ttt] [DataShareTest] <> getType end, DSHelper is null"); + return; + } + let result = await globalThis.dsHelper.getType(dseUri); + console.log("[ttt] [DataShareTest] <> getType end, result:" + result); + return result; + }) + + globalThis.getFileTypes = (async () => { + console.log("[ttt] [DataShareTest] <> getFileTypes begin"); + if (globalThis.dsHelper == null) { + console.log("[ttt] [DataShareTest] <> getFileTypes end, DSHelper is null"); + return; + } + let result = await globalThis.dsHelper.getFileTypes(dseUri, "image/*"); + console.log("[ttt] [DataShareTest] <> getFileTypes end, result:" + result); + return result; + }) + + globalThis.normalizeUri = (async () => { + console.log("[ttt] [DataShareTest] <> normalizeUri begin"); + if (globalThis.dsHelper == null) { + console.log("[ttt] [DataShareTest] <> normalizeUri end, DSHelper is null"); + return; + } + let result = await globalThis.dsHelper.normalizeUri(dseUri); + console.log("[ttt] [DataShareTest] <> normalizeUri end, result:" + result); + return result; + }) + + globalThis.denormalizeUri = (async () => { + console.log("[ttt] [DataShareTest] <> denormalizeUri begin"); + if (globalThis.dsHelper == null) { + console.log("[ttt] [DataShareTest] <> denormalizeUri end, DSHelper is null"); + return; + } + let result = await globalThis.dsHelper.denormalizeUri(dseUri); + console.log("[ttt] [DataShareTest] <> denormalizeUri end, result:" + result); + return result; + }) + + windowStage.setUIContent(this.context, "pages/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[ttt] [DataShareTest] <> MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[ttt] [DataShareTest] <> MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[ttt] [DataShareTest] <> MainAbility onBackground") + } +}; \ No newline at end of file diff --git a/data_share/test/native/resource/datashare_ext_bundle/entry/src/main/ets/pages/index.ets b/data_share/test/native/resource/datashare_ext_bundle/entry/src/main/ets/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..6323faaf90672dce585c7aadbdda3675f13dd6ad --- /dev/null +++ b/data_share/test/native/resource/datashare_ext_bundle/entry/src/main/ets/pages/index.ets @@ -0,0 +1,341 @@ +/* + * Copyright (c) 2022 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. + */ + +import dataShare from '@ohos.data.dataShare' +import dataSharePredicates from '@ohos.data.dataSharePredicates' + +@Entry +@Component +struct Index { + @State message: string = "Main thread message filed" + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('DataShare Extension Ability Test') + .fontSize(25) + .fontWeight(FontWeight.Bold) + + Text(`${this.message}`) + .fontSize(30) + .height('15%') + .width('100%') + .textAlign(TextAlign.Center) + + Row() { + Button() { + Text('Connect') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .width('45%') + .height('8%') + .backgroundColor('#0ddffb') + .onClick(async () => { + console.info('[ttt] [DataShareTest] <> Connect onclick enter') + this.message = 'Connect onclick' + await globalThis.connectDataShareExtAbility() + console.info('[ttt] [DataShareTest] <> Connect onclick leave') + }) + + Button() { + Text('Disconnect') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .width('45%') + .height('8%') + .backgroundColor('#0ddffb') + .onClick(async () => { + console.info('[ttt] [DataShareTest] <> Disconnect onclick enter') + this.message = 'Disconnect onclick' + await globalThis.disconnectDataShareExtAbility() + console.info('[ttt] [DataShareTest] <> Disconnect onclick leave') + }) + } + + Row() { + Button() { + Text('On') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .width('25%') + .height('8%') + .backgroundColor('#0ddffb') + .onClick(async () => { + console.info('[ttt] [DataShareTest] <> On onclick enter') + this.message = '~ On onclick' + try { + await globalThis.on(); + } catch (err) { + console.error('[ttt] [DataAbilityTest] Observer on catch(err)====>:' + err); + } + console.info('[ttt] [DataShareTest] <> On onclick leave') + }) + + Button() { + Text('Off') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .width('25%') + .height('8%') + .backgroundColor('#0ddffb') + .onClick(async () => { + console.info('[ttt] [DataShareTest] <> Off onclick enter') + this.message = '~ Off onclick' + try { + await globalThis.off(); + } catch (err) { + console.error('[ttt] [DataAbilityTest] Observer Off catch(err)====>:' + err); + } + console.info('[ttt] [DataShareTest] <> Off onclick leave') + }) + + Button() { + Text('OpenFile') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .width('40%') + .height('8%') + .backgroundColor('#0ddffb') + .onClick(async () => { + console.info('[ttt] [DataShareTest] <> OpenFile onclick enter') + this.message = 'OpenFile onclick' + let ret = await globalThis.openFile() + this.message += "\n\n Test Result: " + ret; + console.info('[ttt] [DataShareTest] <> OpenFile onclick leave') + }) + } + + Row() { + Button() { + Text('Query') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .width('45%') + .height('8%') + .backgroundColor('#0ddffb') + .onClick(async () => { + console.info('[ttt] [DataShareTest] <> Query onclick enter') + this.message = 'Query onclick' + let ret = await globalThis.query() + this.message += "\n\n Test Result: " + ret; + console.info('[ttt] [DataShareTest] <> Query onclick leave') + }) + + Button() { + Text('Insert') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .width('45%') + .height('8%') + .backgroundColor('#0ddffb') + .onClick(async () => { + console.info('[ttt] [DataShareTest] <> Insert onclick enter') + this.message = 'Insert onclick' + let ret = await globalThis.insert() + this.message += "\n\n Test Result: " + ret; + console.info('[ttt] [DataShareTest] <> Insert onclick leave') + }) + } + + Row() { + Button() { + Text('Update') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .width('45%') + .height('8%') + .backgroundColor('#0ddffb') + .onClick(async () => { + console.info('[ttt] [DataShareTest] <> Update onclick enter') + this.message = 'Update onclick' + let ret = await globalThis.update() + this.message += "\n\n Test Result: " + ret; + console.info('[ttt] [DataShareTest] <> Update onclick leave') + }) + + Button() { + Text('Delete') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .width('45%') + .height('8%') + .backgroundColor('#0ddffb') + .onClick(async () => { + console.info('[ttt] [DataShareTest] <> Delete onclick enter') + this.message = 'Delete onclick' + let ret = await globalThis.delete() + this.message += "\n\n Test Result: " + ret; + console.info('[ttt] [DataShareTest] <> Delete onclick leave') + }) + } + + Row() { + Button() { + Text('BatchInsert') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .width('45%') + .height('8%') + .backgroundColor('#0ddffb') + .onClick(async () => { + console.info('[ttt] [DataShareTest] <> BatchInsert onclick enter') + this.message = 'BatchInsert onclick' + let ret = await globalThis.batchInsert() + this.message += "\n\n Test Result: " + ret; + console.info('[ttt] [DataShareTest] <> BatchInsert onclick leave') + }) + + Button() { + Text('NotifyChange') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .width('45%') + .height('8%') + .backgroundColor('#0ddffb') + .onClick(async () => { + console.info('[ttt] [DataShareTest] <> NotifyChange onclick enter') + this.message = 'NotifyChange onclick' + await globalThis.notifyChange() + console.info('[ttt] [DataShareTest] <> NotifyChange onclick leave') + }) + } + + Row() { + Button() { + Text('GetType') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .width('45%') + .height('8%') + .backgroundColor('#0ddffb') + .onClick(async () => { + console.info('[ttt] [DataShareTest] <> GetType onclick enter') + this.message = 'GetType onclick' + let ret = await globalThis.getType() + this.message += "\n\n Test Result: " + ret; + console.info('[ttt] [DataShareTest] <> GetType onclick leave') + }) + + Button() { + Text('GetFileTypes') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .width('45%') + .height('8%') + .backgroundColor('#0ddffb') + .onClick(async () => { + console.info('[ttt] [DataShareTest] <> GetFileTypes onclick enter') + this.message = 'GetFileTypes onclick' + let ret = await globalThis.getFileTypes() + this.message += "\n\n Test Result: " + ret; + console.info('[ttt] [DataShareTest] <> GetFileTypes onclick leave') + }) + } + + Row() { + Button() { + Text('NormalizeUri') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .width('45%') + .height('8%') + .backgroundColor('#0ddffb') + .onClick(async () => { + console.info('[ttt] [DataShareTest] <> NormalizeUri onclick enter') + this.message = 'NormalizeUri onclick' + let ret = await globalThis.normalizeUri() + this.message += "\n\n Test Result: " + ret; + console.info('[ttt] [DataShareTest] <> NormalizeUri onclick leave') + }) + + Button() { + Text('DenormalizeUri') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .width('45%') + .height('8%') + .backgroundColor('#0ddffb') + .onClick(async () => { + console.info('[ttt] [DataShareTest] <> DenormalizeUri onclick enter') + this.message = 'DenormalizeUri onclick' + let ret = await globalThis.denormalizeUri() + this.message += "\n\n Test Result: " + ret; + console.info('[ttt] [DataShareTest] <> DenormalizeUri onclick leave') + }) + } + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/data_share/test/native/resource/datashare_ext_bundle/entry/src/main/module.json b/data_share/test/native/resource/datashare_ext_bundle/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..d510285dabdf3e59140c06dbf9bcf0d601853c4a --- /dev/null +++ b/data_share/test/native/resource/datashare_ext_bundle/entry/src/main/module.json @@ -0,0 +1,50 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "srcEntrance": "./ets/Application/MyAbilityStage.ts", + "description": "$string:entry_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:white", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "srcEntrance": "./ets/DataShareExtAbility/DataShareExtAbility.ts", + "name": "DataShareExtAbility", + "icon": "$media:icon", + "description": "$string:description_datashareextability", + "type": "dataShare", + "uri": "datashare://com.acts.datasharetest", + "visible": true + } + ] + } +} \ No newline at end of file diff --git a/data_share/test/native/resource/datashare_ext_bundle/entry/src/main/resources/base/element/color.json b/data_share/test/native/resource/datashare_ext_bundle/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..1bbc9aa9617e97c45440e1d3d66afc1154837012 --- /dev/null +++ b/data_share/test/native/resource/datashare_ext_bundle/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "white", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/data_share/test/native/resource/datashare_ext_bundle/entry/src/main/resources/base/element/string.json b/data_share/test/native/resource/datashare_ext_bundle/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..222eb589c8710beebac1dc5937b21715d620a245 --- /dev/null +++ b/data_share/test/native/resource/datashare_ext_bundle/entry/src/main/resources/base/element/string.json @@ -0,0 +1,28 @@ +{ + "string": [ + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "DataShareTest" + }, + { + "name": "description_application", + "value": "DataShareTest" + }, + { + "name": "app_name", + "value": "DataShareTest" + }, + { + "name": "description_datashareextability", + "value": "description_datashareextability" + } + ] +} \ No newline at end of file diff --git a/data_share/test/native/resource/datashare_ext_bundle/entry/src/main/resources/base/media/icon.png b/data_share/test/native/resource/datashare_ext_bundle/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/data_share/test/native/resource/datashare_ext_bundle/entry/src/main/resources/base/media/icon.png differ diff --git a/data_share/test/native/resource/datashare_ext_bundle/entry/src/main/resources/base/profile/main_pages.json b/data_share/test/native/resource/datashare_ext_bundle/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..feec276e105eeb8d621c20aaf838f318b0a94150 --- /dev/null +++ b/data_share/test/native/resource/datashare_ext_bundle/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/index" + ] +} diff --git a/data_share/test/native/resource/datashare_ext_bundle/signature/openharmony_sx.p7b b/data_share/test/native/resource/datashare_ext_bundle/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..7989f037e9d8820e2a4889a27c66b2f7782010f6 Binary files /dev/null and b/data_share/test/native/resource/datashare_ext_bundle/signature/openharmony_sx.p7b differ diff --git a/data_share/test/native/resource/ohos_test/BUILD.gn b/data_share/test/native/resource/ohos_test/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..e30cf901c8a8c22560b03fe76fee66afb1eac201 --- /dev/null +++ b/data_share/test/native/resource/ohos_test/BUILD.gn @@ -0,0 +1,22 @@ +# Copyright (c) 2022 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. + +import("//build/ohos.gni") + +ohos_copy("copy_ohos_test") { + sources = [ "./ohos_test.xml" ] + outputs = [ "$root_out_dir/tests/unittest/data_share/resource/ohos_test.xml" ] + + subsystem_name = "distributeddatamgr" + part_name = "data_share" +} diff --git a/data_share/test/native/resource/ohos_test/ohos_test.xml b/data_share/test/native/resource/ohos_test/ohos_test.xml new file mode 100644 index 0000000000000000000000000000000000000000..3308e64b9074ef8a15ed4521322cb154d2c78480 --- /dev/null +++ b/data_share/test/native/resource/ohos_test/ohos_test.xml @@ -0,0 +1,26 @@ + + + + + + + + + + \ No newline at end of file diff --git a/data_share/test/native/unittest/mediadatashare_test/src/slientaccess_test.cpp b/data_share/test/native/unittest/mediadatashare_test/src/slientaccess_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..45dd14d5030d533c1ccd9572ec94239f969f3080 --- /dev/null +++ b/data_share/test/native/unittest/mediadatashare_test/src/slientaccess_test.cpp @@ -0,0 +1,182 @@ +/* + * Copyright (C) 2021-2022 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 +#include + +#include "accesstoken_kit.h" +#include "datashare_helper.h" +#include "datashare_log.h" +#include "hap_token_info.h" +#include "iservice_registry.h" +#include "system_ability_definition.h" +#include "token_setproc.h" + +namespace OHOS { +namespace DataShare { +using namespace testing::ext; +using namespace OHOS::Security::AccessToken; +constexpr int STORAGE_MANAGER_MANAGER_ID = 5003; +std::string DATA_SHARE_URI = "datashare:///com.acts.datasharetest"; +std::string SLIENT_ACCESS_URI = "datashare:///com.acts.datasharetest/entry/DB00/TBL00?Proxy=true"; +std::string TBL_STU_NAME = "name"; +std::string TBL_STU_AGE = "age"; +std::shared_ptr g_slientAccessHelper; + +class SlientAccessTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); +}; + +std::shared_ptr CreateDataShareHelper(int32_t systemAbilityId, std::string uri) +{ + LOG_INFO("CreateDataShareHelper start"); + auto saManager = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (saManager == nullptr) { + LOG_ERROR("GetSystemAbilityManager get samgr failed."); + return nullptr; + } + auto remoteObj = saManager->GetSystemAbility(systemAbilityId); + while (remoteObj == nullptr) { + LOG_ERROR("GetSystemAbility service failed."); + return nullptr; + } + return DataShare::DataShareHelper::Creator(remoteObj, uri); +} + +void SlientAccessTest::SetUpTestCase(void) +{ + LOG_INFO("SetUpTestCase invoked"); + auto dataShareHelper = CreateDataShareHelper(STORAGE_MANAGER_MANAGER_ID, DATA_SHARE_URI); + ASSERT_TRUE(dataShareHelper != nullptr); + int sleepTime = 3; + sleep(sleepTime); + + HapInfoParams info = { + .userID = 100, + .bundleName = "ohos.datashareclienttest.demo", + .instIndex = 0, + .appIDDesc = "ohos.datashareclienttest.demo" + }; + HapPolicyParams policy = { + .apl = APL_NORMAL, + .domain = "test.domain", + .permList = { + { + .permissionName = "ohos.permission.test", + .bundleName = "ohos.datashareclienttest.demo", + .grantMode = 1, + .availableLevel = APL_NORMAL, + .label = "label", + .labelId = 1, + .description = "ohos.datashareclienttest.demo", + .descriptionId = 1 + } + }, + .permStateList = { + { + .permissionName = "ohos.permission.test", + .isGeneral = true, + .resDeviceID = { "local" }, + .grantStatus = { PermissionState::PERMISSION_GRANTED }, + .grantFlags = { 1 } + } + } + }; + AccessTokenKit::AllocHapToken(info, policy); + auto testTokenId = Security::AccessToken::AccessTokenKit::GetHapTokenID( + info.userID, info.bundleName, info.instIndex); + SetSelfTokenID(testTokenId); + + g_slientAccessHelper = CreateDataShareHelper(STORAGE_MANAGER_MANAGER_ID, SLIENT_ACCESS_URI); + ASSERT_TRUE(g_slientAccessHelper != nullptr); + LOG_INFO("SetUpTestCase end"); +} + +void SlientAccessTest::TearDownTestCase(void) +{ + auto tokenId = AccessTokenKit::GetHapTokenID(100, "ohos.datashareclienttest.demo", 0); + AccessTokenKit::DeleteToken(tokenId); +} + +void SlientAccessTest::SetUp(void) {} +void SlientAccessTest::TearDown(void) {} + +HWTEST_F(SlientAccessTest, SlientAccess_Insert_Test_001, TestSize.Level0) +{ + LOG_INFO("SlientAccess_Insert_Test_001::Start"); + auto helper = g_slientAccessHelper; + Uri uri(SLIENT_ACCESS_URI); + DataShare::DataShareValuesBucket valuesBucket; + std::string value = "lisi"; + valuesBucket.Put(TBL_STU_NAME, value); + int age = 25; + valuesBucket.Put(TBL_STU_AGE, age); + + int retVal = helper->Insert(uri, valuesBucket); + EXPECT_EQ((retVal > 0), true); + LOG_INFO("SlientAccess_Insert_Test_001::End"); +} + +HWTEST_F(SlientAccessTest, SlientAccess_Update_Test_001, TestSize.Level0) +{ + LOG_INFO("SlientAccess_Update_Test_001::Start"); + auto helper = g_slientAccessHelper; + Uri uri(SLIENT_ACCESS_URI); + DataShare::DataShareValuesBucket valuesBucket; + int value = 50; + valuesBucket.Put(TBL_STU_AGE, value); + DataShare::DataSharePredicates predicates; + std::string selections = TBL_STU_NAME + " = 'lisi'"; + predicates.SetWhereClause(selections); + int retVal = helper->Update(uri, predicates, valuesBucket); + EXPECT_EQ((retVal > 0), true); + LOG_INFO("SlientAccess_Update_Test_001::End"); +} + +HWTEST_F(SlientAccessTest, SlientAccess_Query_Test_001, TestSize.Level0) +{ + LOG_INFO("SlientAccess_Query_Test_001::Start"); + auto helper = g_slientAccessHelper; + Uri uri(SLIENT_ACCESS_URI); + DataShare::DataSharePredicates predicates; + predicates.EqualTo(TBL_STU_NAME, "lisi"); + vector columns; + auto resultSet = helper->Query(uri, predicates, columns); + int result = 0; + if (resultSet != nullptr) { + resultSet->GetRowCount(result); + } + EXPECT_EQ(result, 1); + LOG_INFO("SlientAccess_Query_Test_001::End"); +} + +HWTEST_F(SlientAccessTest, SlientAccess_Delete_Test_001, TestSize.Level0) +{ + LOG_INFO("SlientAccess_Delete_Test_001::Start"); + auto helper = g_slientAccessHelper; + Uri uri(SLIENT_ACCESS_URI); + + DataShare::DataSharePredicates deletePredicates; + std::string selections = TBL_STU_NAME + " = 'lisi'"; + deletePredicates.SetWhereClause(selections); + int retVal = helper->Delete(uri, deletePredicates); + EXPECT_EQ((retVal > 0), true); + LOG_INFO("SlientAccess_Delete_Test_001::End"); +} +} // namespace DataShare +} // namespace OHOS \ No newline at end of file diff --git a/datamgr_service/BUILD.gn b/datamgr_service/BUILD.gn index 2a6d0268c46e7c0cefea3d387dffb1402ecdeaec..8c8a8314278b10bf36860556da7c0c3251338b51 100644 --- a/datamgr_service/BUILD.gn +++ b/datamgr_service/BUILD.gn @@ -19,7 +19,6 @@ group("build_native_test") { "services/distributeddataservice/app/test:unittest", "services/distributeddataservice/framework/test:unittest", "services/distributeddataservice/service/test:unittest", - "services/distributeddataservice/test:moduletest", ] } diff --git a/datamgr_service/services/distributeddataservice/adapter/account/src/account_delegate_normal_impl.cpp b/datamgr_service/services/distributeddataservice/adapter/account/src/account_delegate_normal_impl.cpp index ddca36ad14699b3cb748468dfb1f8a1995144489..042beb6c4643ff9740449a6fc4f28da6279706cb 100644 --- a/datamgr_service/services/distributeddataservice/adapter/account/src/account_delegate_normal_impl.cpp +++ b/datamgr_service/services/distributeddataservice/adapter/account/src/account_delegate_normal_impl.cpp @@ -31,7 +31,7 @@ namespace DistributedKv { using namespace OHOS::EventFwk; using namespace OHOS::AAFwk; using namespace OHOS::DistributedData; -using namespace Security::AccessToken; +using namespace Security::AccessToken;6 //AccountDelegate::BaseInstance AccountDelegate::getInstance_ = AccountDelegateNormalImpl::GetBaseInstance; AccountDelegate *AccountDelegateNormalImpl::GetBaseInstance() { diff --git a/datamgr_service/services/distributeddataservice/app/src/checker/bundle_checker.cpp b/datamgr_service/services/distributeddataservice/app/src/checker/bundle_checker.cpp index 6b1f36c0fe8252492a8f834c56a13264b29f518d..557c99900c50b0bcac7b067d332ee225030660aa 100644 --- a/datamgr_service/services/distributeddataservice/app/src/checker/bundle_checker.cpp +++ b/datamgr_service/services/distributeddataservice/app/src/checker/bundle_checker.cpp @@ -55,7 +55,7 @@ std::string BundleChecker::GetAppId(const CheckerManager::StoreInfo &info) ZLOGE("token:0x%{public}x, result:%{public}d", info.tokenId, result); return ""; } - if (tokenInfo.bundleName != info.bundleName) { + if (!info.bundleName.empty() && tokenInfo.bundleName != info.bundleName) { ZLOGE("bundlename:%{public}s <-> %{public}s", info.bundleName.c_str(), tokenInfo.bundleName.c_str()); return ""; } diff --git a/datamgr_service/services/distributeddataservice/service/kvdb/kvdb_service_impl.cpp b/datamgr_service/services/distributeddataservice/service/kvdb/kvdb_service_impl.cpp index f6ee81d4aaf5177835e9fad468281f95f86118ce..6e19c96a6d5fea542814a9f10e500afaedeaa2b0 100644 --- a/datamgr_service/services/distributeddataservice/service/kvdb/kvdb_service_impl.cpp +++ b/datamgr_service/services/distributeddataservice/service/kvdb/kvdb_service_impl.cpp @@ -39,6 +39,7 @@ #include "utils/anonymous.h" #include "utils/constant.h" #include "utils/converter.h" +#include "utils/crypto.h" namespace OHOS::DistributedKv { using namespace OHOS::DistributedData; using namespace OHOS::AppDistributedKv; @@ -350,6 +351,36 @@ Status KVDBServiceImpl::GetBackupPassword(const AppId &appId, const StoreId &sto return (BackupManager::GetInstance().GetPassWord(metaData, password)) ? SUCCESS : ERROR; } +KVDBService::DevBrief KVDBServiceImpl::GetLocalDevice() +{ + DevBrief brief; + CheckerManager::StoreInfo storeInfo; + storeInfo.tokenId = IPCSkeleton::GetCallingTokenID(); + storeInfo.uid = IPCSkeleton::GetCallingPid(); + auto appId = CheckerManager::GetInstance().GetAppId(storeInfo); + auto device = DMAdapter::GetInstance().GetLocalDevice(); + brief.networkId = std::move(device.networkId); + brief.uuid = Crypto::Sha256(appId + "_" + device.uuid); + return brief; +} + +std::vector KVDBServiceImpl::GetRemoteDevices() +{ + std::vector briefs; + CheckerManager::StoreInfo storeInfo; + storeInfo.tokenId = IPCSkeleton::GetCallingTokenID(); + storeInfo.uid = IPCSkeleton::GetCallingPid(); + auto appId = CheckerManager::GetInstance().GetAppId(storeInfo); + auto devices = DMAdapter::GetInstance().GetRemoteDevices(); + for (const auto &device : devices) { + DevBrief brief; + brief.networkId = std::move(device.networkId); + brief.uuid = Crypto::Sha256(appId + "_" + device.uuid); + briefs.push_back(std::move(brief)); + } + return briefs; +} + Status KVDBServiceImpl::BeforeCreate(const AppId &appId, const StoreId &storeId, const Options &options) { ZLOGD("appId:%{public}s storeId:%{public}s to export data", appId.appId.c_str(), storeId.storeId.c_str()); @@ -709,7 +740,7 @@ Status KVDBServiceImpl::ConvertDbStatus(DBStatus status) const case DBStatus::TIME_OUT: return Status::TIME_OUT; case DBStatus::OVER_MAX_LIMITS: - return Status::OVER_MAX_SUBSCRIBE_LIMITS; + return Status::OVER_MAX_LIMITS; case DBStatus::EKEYREVOKED_ERROR: // fallthrough case DBStatus::SECURITY_OPTION_CHECK_ERROR: return Status::SECURITY_LEVEL_ERROR; diff --git a/datamgr_service/services/distributeddataservice/service/kvdb/kvdb_service_impl.h b/datamgr_service/services/distributeddataservice/service/kvdb/kvdb_service_impl.h index c2aecdd74b0956d89f6e6f2ee4698408f7ac6223..72dddfc472b4dbe3ee883f840d90ae1ad62fbeeb 100644 --- a/datamgr_service/services/distributeddataservice/service/kvdb/kvdb_service_impl.h +++ b/datamgr_service/services/distributeddataservice/service/kvdb/kvdb_service_impl.h @@ -53,6 +53,8 @@ public: Status Subscribe(const AppId &appId, const StoreId &storeId, sptr observer) override; Status Unsubscribe(const AppId &appId, const StoreId &storeId, sptr observer) override; Status GetBackupPassword(const AppId &appId, const StoreId &storeId, std::vector &password) override; + DevBrief GetLocalDevice() override; + std::vector GetRemoteDevices() override; int32_t OnAppExit(pid_t uid, pid_t pid, uint32_t tokenId, const std::string &appId) override; int32_t ResolveAutoLaunch(const std::string &identifier, DBLaunchParam ¶m) override; diff --git a/datamgr_service/services/distributeddataservice/service/kvdb/kvdb_service_stub.cpp b/datamgr_service/services/distributeddataservice/service/kvdb/kvdb_service_stub.cpp index 61fdde59d2b3d0c3df0b738173138307d6a6a7ec..95e333dc2fd5dae97b6e19c61d104d7b6e689624 100644 --- a/datamgr_service/services/distributeddataservice/service/kvdb/kvdb_service_stub.cpp +++ b/datamgr_service/services/distributeddataservice/service/kvdb/kvdb_service_stub.cpp @@ -40,6 +40,8 @@ const KVDBServiceStub::Handler KVDBServiceStub::HANDLERS[TRANS_BUTT] = { &KVDBServiceStub::OnSubscribe, &KVDBServiceStub::OnUnsubscribe, &KVDBServiceStub::OnGetBackupPassword, + &KVDBServiceStub::OnGetLocalDevice, + &KVDBServiceStub::OnGetRemoteDevices, }; int KVDBServiceStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply) @@ -59,6 +61,9 @@ int KVDBServiceStub::OnRemoteRequest(uint32_t code, MessageParcel &data, Message AppId appId; StoreId storeId; + if (TRANS_NO_APPID_BEGIN <= code && code <= TRANS_NO_APPID_END) { + return (this->*HANDLERS[code])(appId, storeId, data, reply); + } if (!ITypesUtil::Unmarshal(data, appId, storeId)) { ZLOGE("Unmarshal appId:%{public}s storeId:%{public}s", appId.appId.c_str(), storeId.storeId.c_str()); return IPC_STUB_INVALID_DATA_ERR; @@ -220,6 +225,34 @@ int32_t KVDBServiceStub::OnGetSyncParam( return ERR_NONE; } +int32_t KVDBServiceStub::OnGetLocalDevice( + const AppId &appId, const StoreId &storeId, MessageParcel &data, MessageParcel &reply) +{ + (void)appId; + (void)storeId; + int32_t status = SUCCESS; + auto brief = GetLocalDevice(); + if (!ITypesUtil::Marshal(reply, status, brief)) { + ZLOGE("Marshal device brief:{%{public}u, %{public}u}", brief.networkId.empty(), brief.uuid.empty()); + return IPC_STUB_WRITE_PARCEL_ERR; + } + return ERR_NONE; +} + +int32_t KVDBServiceStub::OnGetRemoteDevices( + const AppId &appId, const StoreId &storeId, MessageParcel &data, MessageParcel &reply) +{ + (void)appId; + (void)storeId; + int32_t status = SUCCESS; + auto briefs = GetRemoteDevices(); + if (!ITypesUtil::Marshal(reply, status, briefs)) { + ZLOGE("Marshal device brief:%{public}zu", briefs.size()); + return IPC_STUB_WRITE_PARCEL_ERR; + } + return ERR_NONE; +} + int32_t KVDBServiceStub::OnEnableCap( const AppId &appId, const StoreId &storeId, MessageParcel &data, MessageParcel &reply) { diff --git a/datamgr_service/services/distributeddataservice/service/kvdb/kvdb_service_stub.h b/datamgr_service/services/distributeddataservice/service/kvdb/kvdb_service_stub.h index ab0bacc494d2e6df8019b6a077d2e563102f7c99..8b5f8b9003c52b4b4aaa896e5b32d57808e1ef0c 100644 --- a/datamgr_service/services/distributeddataservice/service/kvdb/kvdb_service_stub.h +++ b/datamgr_service/services/distributeddataservice/service/kvdb/kvdb_service_stub.h @@ -43,6 +43,8 @@ private: int32_t OnSubscribe(const AppId &appId, const StoreId &storeId, MessageParcel &data, MessageParcel &reply); int32_t OnUnsubscribe(const AppId &appId, const StoreId &storeId, MessageParcel &data, MessageParcel &reply); int32_t OnGetBackupPassword(const AppId &appId, const StoreId &storeId, MessageParcel &data, MessageParcel &reply); + int32_t OnGetLocalDevice(const AppId &appId, const StoreId &storeId, MessageParcel &data, MessageParcel &reply); + int32_t OnGetRemoteDevices(const AppId &appId, const StoreId &storeId, MessageParcel &data, MessageParcel &reply); static const Handler HANDLERS[TRANS_BUTT]; }; } // namespace OHOS::DistributedKv diff --git a/datamgr_service/services/distributeddataservice/test/BUILD.gn b/datamgr_service/services/distributeddataservice/test/BUILD.gn index ae66f36b5de7b9aafba2b06a659ad90edb2ecfb3..b36942961b761f7f9708e8cbbca2ee86b6b2b83e 100644 --- a/datamgr_service/services/distributeddataservice/test/BUILD.gn +++ b/datamgr_service/services/distributeddataservice/test/BUILD.gn @@ -12,701 +12,6 @@ # limitations under the License. import("//build/test.gni") -module_output_path = "datamgr_service/distributeddb" - -mul_sources = [ - "common/distributeddb/src/auto_launch_callback.cpp", - "common/distributeddb/src/delegate_callback.cpp", - "common/distributeddb/src/delegate_kv_mgr_callback.cpp", - "common/distributeddb/src/distributed_test_tools.cpp", - "common/distributeddb/src/kv_store_observer_impl.cpp", - "common/distributeddb/src/kv_store_snapshot_callback.cpp", -] - -############################################################################### -config("module_private_config") { - visibility = [ ":*" ] - - include_dirs = [ - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/include", - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/include", - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src", - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver", - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite", - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/include", - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/include", - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src", - "../adapter/include/communicator", - "//developtools/liblog", - "common/distributeddb/include", - "moduletest/common/distributeddb/include", - "//commonlibrary/c_utils/base/include", - "//third_party/sqlite/include", - "//foundation/distributeddatamgr/kv_store/interfaces/innerkits/distributeddata/include", - "//third_party/openssl/include/", - ] - - defines = [ - "_LARGEFILE64_SOURCE", - "_FILE_OFFSET_BITS=64", - "SQLITE_HAS_CODEC", - "USE_SQLITE_SYMBOLS", - "USING_HILOG_LOGGER", - "TESTCASES_USING_GTEST_EXT", - "OMIT_JSON", - "LOW_LEVEL_MEM_DEV", - "RELEASE_MODE_V2", - "RELEASE_MODE_V3", - "OMIT_MULTI_VER", - ] - ldflags = [ "-Wl,--exclude-libs,ALL" ] -} - -##############################moduletest########################################## -ohos_moduletest("DistributeddbKvTransactionTest") { - module_out_path = module_output_path - - sources = [ - "common/distributeddb/src/distributed_test_sysinfo.cpp", - "common/distributeddb/src/distributeddb_data_generator.cpp", - "moduletest/common/distributeddb/src/distributed_crud_transaction_tools.cpp", - "moduletest/common/distributeddb/src/distributeddb_kv_transaction_test.cpp", - ] - sources += mul_sources - configs = [ ":module_private_config" ] - - deps = [ - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", - "//third_party/googletest:gtest_main", - "//third_party/openssl:libcrypto_shared", - "//third_party/sqlite:sqlite", - ] - external_deps = [ - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - ] - part_name = "datamgr_service" -} - -ohos_moduletest("DistributeddbKvTransactionPerfTest") { - module_out_path = module_output_path - - sources = [ - "common/distributeddb/src/distributed_test_sysinfo.cpp", - "common/distributeddb/src/distributeddb_data_generator.cpp", - "moduletest/common/distributeddb/src/distributed_crud_transaction_tools.cpp", - "moduletest/common/distributeddb/src/distributeddb_kv_transaction_perf_test.cpp", - ] - sources += mul_sources - configs = [ ":module_private_config" ] - - deps = [ - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", - "//third_party/googletest:gtest_main", - "//third_party/openssl:libcrypto_shared", - "//third_party/sqlite:sqlite", - ] - external_deps = [ - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - ] - part_name = "datamgr_service" -} -ohos_moduletest("DistributeddbKvConcurrencyCrudTest") { - module_out_path = module_output_path - - sources = [ - "common/distributeddb/src/distributed_test_sysinfo.cpp", - "common/distributeddb/src/distributeddb_data_generator.cpp", - "moduletest/common/distributeddb/src/distributeddb_kv_concurrency_crud_test.cpp", - ] - sources += mul_sources - configs = [ ":module_private_config" ] - - deps = [ - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", - "//third_party/googletest:gtest_main", - "//third_party/openssl:libcrypto_shared", - "//third_party/sqlite:sqlite", - ] - external_deps = [ - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - ] - part_name = "datamgr_service" -} -ohos_moduletest("DistributeddbKvBatchCrudTest") { - module_out_path = module_output_path - - sources = [ - "common/distributeddb/src/distributed_test_sysinfo.cpp", - "common/distributeddb/src/distributeddb_data_generator.cpp", - "moduletest/common/distributeddb/src/distributeddb_kv_batch_crud_test.cpp", - ] - sources += mul_sources - configs = [ ":module_private_config" ] - - deps = [ - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", - "//third_party/googletest:gtest_main", - "//third_party/openssl:libcrypto_shared", - "//third_party/sqlite:sqlite", - ] - external_deps = [ - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - ] - part_name = "datamgr_service" -} -ohos_moduletest("DistributeddbKvCreateTest") { - module_out_path = module_output_path - - sources = [ - "common/distributeddb/src/distributed_test_sysinfo.cpp", - "common/distributeddb/src/distributeddb_data_generator.cpp", - "moduletest/common/distributeddb/src/distributeddb_kv_create_test.cpp", - ] - sources += mul_sources - configs = [ ":module_private_config" ] - - deps = [ - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", - "//third_party/googletest:gtest_main", - "//third_party/openssl:libcrypto_shared", - "//third_party/sqlite:sqlite", - ] - external_deps = [ - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - ] - part_name = "datamgr_service" -} -ohos_moduletest("DistributeddbKvCrudTest") { - module_out_path = module_output_path - - sources = [ - "common/distributeddb/src/distributed_test_sysinfo.cpp", - "common/distributeddb/src/distributeddb_data_generator.cpp", - "moduletest/common/distributeddb/src/distributeddb_kv_crud_test.cpp", - ] - sources += mul_sources - configs = [ ":module_private_config" ] - - deps = [ - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", - "//third_party/googletest:gtest_main", - "//third_party/openssl:libcrypto_shared", - "//third_party/sqlite:sqlite", - ] - external_deps = [ - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - ] - part_name = "datamgr_service" -} -ohos_moduletest("DistributeddbKvObserverTest") { - module_out_path = module_output_path - - sources = [ - "common/distributeddb/src/distributed_test_sysinfo.cpp", - "common/distributeddb/src/distributeddb_data_generator.cpp", - "moduletest/common/distributeddb/src/distributeddb_kv_observer_test.cpp", - ] - sources += mul_sources - configs = [ ":module_private_config" ] - - deps = [ - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", - "//third_party/googletest:gtest_main", - "//third_party/openssl:libcrypto_shared", - "//third_party/sqlite:sqlite", - ] - external_deps = [ - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - ] - part_name = "datamgr_service" -} -ohos_moduletest("DistributeddbKvObserverSnapTest") { - module_out_path = module_output_path - - sources = [ - "common/distributeddb/src/distributed_test_sysinfo.cpp", - "common/distributeddb/src/distributeddb_data_generator.cpp", - "moduletest/common/distributeddb/src/distributeddb_kv_observer_snap_test.cpp", - ] - sources += mul_sources - configs = [ ":module_private_config" ] - - deps = [ - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", - "//third_party/googletest:gtest_main", - "//third_party/openssl:libcrypto_shared", - "//third_party/sqlite:sqlite", - ] - external_deps = [ - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - ] - part_name = "datamgr_service" -} - -ohos_moduletest("DistributeddbKvBackupTest") { - module_out_path = module_output_path - sources = [ - "common/distributeddb/src/distributeddb_constant.cpp", - "common/distributeddb/src/distributeddb_data_generator.cpp", - "moduletest/common/distributeddb/src/distributeddb_kv_backup_test.cpp", - ] - sources += mul_sources - configs = [ ":module_private_config" ] - deps = [ - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", - "//third_party/googletest:gtest_main", - "//third_party/openssl:libcrypto_shared", - "//third_party/sqlite:sqlite", - ] - external_deps = [ - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - ] - part_name = "datamgr_service" -} - -ohos_moduletest("DistributeddbKvRealdelTest") { - module_out_path = module_output_path - sources = [ - "common/distributeddb/src/distributeddb_constant.cpp", - "common/distributeddb/src/distributeddb_data_generator.cpp", - "moduletest/common/distributeddb/src/distributeddb_kv_realdel_test.cpp", - ] - sources += mul_sources - configs = [ ":module_private_config" ] - - deps = [ - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", - "//third_party/googletest:gtest_main", - "//third_party/openssl:libcrypto_shared", - "//third_party/sqlite:sqlite", - ] - external_deps = [ - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - ] - part_name = "datamgr_service" -} - -ohos_moduletest("DistributeddbNbCreateTest") { - module_out_path = module_output_path - - sources = [ - "common/distributeddb/src/distributeddb_constant.cpp", - "common/distributeddb/src/distributeddb_data_generator.cpp", - "common/distributeddb/src/distributeddb_nb_test_tools.cpp", - "moduletest/common/distributeddb/src/distributeddb_nb_create_test.cpp", - ] - sources += mul_sources - configs = [ ":module_private_config" ] - - deps = [ - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", - "//third_party/googletest:gtest_main", - "//third_party/openssl:libcrypto_shared", - "//third_party/sqlite:sqlite", - ] - external_deps = [ - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - ] - part_name = "datamgr_service" -} -ohos_moduletest("DistributeddbNbCrudTest") { - module_out_path = module_output_path - - sources = [ - "common/distributeddb/src/distributeddb_constant.cpp", - "common/distributeddb/src/distributeddb_data_generator.cpp", - "common/distributeddb/src/distributeddb_nb_test_tools.cpp", - "moduletest/common/distributeddb/src/distributeddb_nb_crud_test.cpp", - ] - sources += mul_sources - configs = [ ":module_private_config" ] - - deps = [ - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", - "//third_party/googletest:gtest_main", - "//third_party/openssl:libcrypto_shared", - "//third_party/sqlite:sqlite", - ] - external_deps = [ - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - ] - part_name = "datamgr_service" -} -ohos_moduletest("DistributeddbNbObserverTest") { - module_out_path = module_output_path - - sources = [ - "common/distributeddb/src/distributeddb_constant.cpp", - "common/distributeddb/src/distributeddb_data_generator.cpp", - "common/distributeddb/src/distributeddb_nb_test_tools.cpp", - "moduletest/common/distributeddb/src/distributeddb_nb_observer_test.cpp", - ] - sources += mul_sources - configs = [ ":module_private_config" ] - - deps = [ - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", - "//third_party/googletest:gtest_main", - "//third_party/openssl:libcrypto_shared", - "//third_party/sqlite:sqlite", - ] - external_deps = [ - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - ] - part_name = "datamgr_service" -} - -ohos_moduletest("DistributeddbNbCursorTest") { - module_out_path = module_output_path - - sources = [ - "common/distributeddb/src/distributeddb_constant.cpp", - "common/distributeddb/src/distributeddb_data_generator.cpp", - "common/distributeddb/src/distributeddb_nb_test_tools.cpp", - "moduletest/common/distributeddb/src/distributeddb_nb_cursor_test.cpp", - "moduletest/common/distributeddb/src/distributeddb_nb_cursor_testcase.cpp", - ] - sources += mul_sources - configs = [ ":module_private_config" ] - - deps = [ - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", - "//third_party/googletest:gtest_main", - "//third_party/openssl:libcrypto_shared", - "//third_party/sqlite:sqlite", - ] - external_deps = [ - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - ] - part_name = "datamgr_service" -} - -ohos_moduletest("DistributeddbNbBackupTest") { - module_out_path = module_output_path - - sources = [ - "common/distributeddb/src/distributeddb_constant.cpp", - "common/distributeddb/src/distributeddb_data_generator.cpp", - "common/distributeddb/src/distributeddb_nb_test_tools.cpp", - "moduletest/common/distributeddb/src/distributeddb_nb_backup_test.cpp", - ] - sources += mul_sources - configs = [ ":module_private_config" ] - - deps = [ - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", - "//third_party/googletest:gtest_main", - "//third_party/openssl:libcrypto_shared", - "//third_party/sqlite:sqlite", - ] - - external_deps = [ - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - ] - part_name = "datamgr_service" -} - -ohos_moduletest("DistributeddbNbBatchCrudTest") { - module_out_path = module_output_path - - sources = [ - "common/distributeddb/src/distributeddb_constant.cpp", - "common/distributeddb/src/distributeddb_data_generator.cpp", - "common/distributeddb/src/distributeddb_nb_test_tools.cpp", - "moduletest/common/distributeddb/src/distributeddb_nb_batch_crud_test.cpp", - ] - sources += mul_sources - configs = [ ":module_private_config" ] - - deps = [ - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", - "//third_party/googletest:gtest_main", - "//third_party/openssl:libcrypto_shared", - "//third_party/sqlite:sqlite", - ] - external_deps = [ - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - ] - part_name = "datamgr_service" -} - -ohos_moduletest("DistributeddbNbLocalBatchCrudTest") { - module_out_path = module_output_path - - sources = [ - "common/distributeddb/src/distributeddb_constant.cpp", - "common/distributeddb/src/distributeddb_data_generator.cpp", - "common/distributeddb/src/distributeddb_nb_test_tools.cpp", - "moduletest/common/distributeddb/src/distributeddb_nb_local_batch_crud_test.cpp", - ] - sources += mul_sources - configs = [ ":module_private_config" ] - - deps = [ - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", - "//third_party/googletest:gtest_main", - "//third_party/openssl:libcrypto_shared", - "//third_party/sqlite:sqlite", - ] - external_deps = [ - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - ] - part_name = "datamgr_service" -} - -ohos_moduletest("DistributeddbNbSchemaDbTest") { - module_out_path = module_output_path - - sources = [ - "common/distributeddb/src/distributeddb_constant.cpp", - "common/distributeddb/src/distributeddb_data_generator.cpp", - "common/distributeddb/src/distributeddb_nb_test_tools.cpp", - "moduletest/common/distributeddb/src/distributeddb_nb_schema_test.cpp", - ] - sources += mul_sources - configs = [ ":module_private_config" ] - deps = [ - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", - "//third_party/googletest:gtest_main", - "//third_party/openssl:libcrypto_shared", - "//third_party/sqlite:sqlite", - ] - external_deps = [ - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - ] - part_name = "datamgr_service" -} - -ohos_moduletest("DistributeddbNbPredicateQueryTest") { - module_out_path = module_output_path - - sources = [ - "common/distributeddb/src/distributeddb_constant.cpp", - "common/distributeddb/src/distributeddb_data_generator.cpp", - "common/distributeddb/src/distributeddb_nb_test_tools.cpp", - "moduletest/common/distributeddb/src/distributeddb_nb_predicate_query_test.cpp", - ] - sources += mul_sources - configs = [ ":module_private_config" ] - - deps = [ - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", - "//third_party/googletest:gtest_main", - "//third_party/openssl:libcrypto_shared", - "//third_party/sqlite:sqlite", - ] - external_deps = [ - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - ] - part_name = "datamgr_service" -} - -ohos_moduletest("DistributeddbNbPredicateQueryExpandTest") { - module_out_path = module_output_path - sources = [ - "common/distributeddb/src/distributeddb_constant.cpp", - "common/distributeddb/src/distributeddb_data_generator.cpp", - "common/distributeddb/src/distributeddb_nb_test_tools.cpp", - "common/distributeddb/src/distributeddb_schema_test_tools.cpp", - "moduletest/common/distributeddb/src/distributeddb_nb_predicate_query_expand_test.cpp", - ] - sources += mul_sources - configs = [ ":module_private_config" ] - - deps = [ - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", - "//third_party/googletest:gtest_main", - "//third_party/openssl:libcrypto_shared", - "//third_party/sqlite:sqlite", - ] - external_deps = [ - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - ] - part_name = "datamgr_service" -} - -ohos_moduletest("DistributeddbNbAutolaunchTest") { - module_out_path = module_output_path - sources = [ - "common/distributeddb/src/distributeddb_constant.cpp", - "common/distributeddb/src/distributeddb_data_generator.cpp", - "common/distributeddb/src/distributeddb_nb_test_tools.cpp", - "common/distributeddb/src/distributeddb_schema_test_tools.cpp", - "moduletest/common/distributeddb/src/distributeddb_nb_autolaunch_test.cpp", - ] - sources += mul_sources - configs = [ ":module_private_config" ] - - deps = [ - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", - "//third_party/googletest:gtest_main", - "//third_party/openssl:libcrypto_shared", - "//third_party/sqlite:sqlite", - ] - external_deps = [ - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - ] - part_name = "datamgr_service" -} - -ohos_moduletest("DistributedbNbDbDamageTest") { - module_out_path = module_output_path - sources = [ - "common/distributeddb/src/distributeddb_constant.cpp", - "common/distributeddb/src/distributeddb_data_generator.cpp", - "common/distributeddb/src/distributeddb_nb_test_tools.cpp", - "common/distributeddb/src/distributeddb_schema_test_tools.cpp", - "moduletest/common/distributeddb/src/distributeddb_nb_db_damage_test.cpp", - ] - sources += mul_sources - configs = [ ":module_private_config" ] - - deps = [ - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", - "//third_party/googletest:gtest_main", - "//third_party/openssl:libcrypto_shared", - "//third_party/sqlite:sqlite", - ] - external_deps = [ - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - ] - part_name = "datamgr_service" -} - -ohos_moduletest("DistributeddbNbCrudPowerTest") { - module_out_path = module_output_path - sources = [ - "common/distributeddb/src/distributeddb_constant.cpp", - "common/distributeddb/src/distributeddb_data_generator.cpp", - "common/distributeddb/src/distributeddb_nb_test_tools.cpp", - "common/distributeddb/src/distributeddb_schema_test_tools.cpp", - "moduletest/common/distributeddb/src/distributeddb_nb_crud_power_test.cpp", - ] - sources += mul_sources - configs = [ ":module_private_config" ] - - deps = [ - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", - "//third_party/googletest:gtest_main", - "//third_party/openssl:libcrypto_shared", - "//third_party/sqlite:sqlite", - ] - external_deps = [ - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - ] - part_name = "datamgr_service" -} - -ohos_moduletest("DistributeddbNbSchemaTest") { - module_out_path = module_output_path - sources = [ - "common/distributeddb/src/distributeddb_constant.cpp", - "common/distributeddb/src/distributeddb_data_generator.cpp", - "common/distributeddb/src/distributeddb_nb_test_tools.cpp", - "common/distributeddb/src/distributeddb_schema_test_tools.cpp", - "moduletest/common/distributeddb/src/distributeddb_nb_schema_test.cpp", - ] - sources += mul_sources - configs = [ ":module_private_config" ] - - deps = [ - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", - "//third_party/googletest:gtest_main", - "//third_party/openssl:libcrypto_shared", - "//third_party/sqlite:sqlite", - ] - external_deps = [ - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - ] - part_name = "datamgr_service" -} - -ohos_moduletest("DistributeddbNbSchemaUpgradeTest") { - module_out_path = module_output_path - sources = [ - "common/distributeddb/src/distributeddb_constant.cpp", - "common/distributeddb/src/distributeddb_data_generator.cpp", - "common/distributeddb/src/distributeddb_nb_test_tools.cpp", - "common/distributeddb/src/distributeddb_schema_test_tools.cpp", - "moduletest/common/distributeddb/src/distributeddb_nb_schema_upgrade_test.cpp", - ] - sources += mul_sources - configs = [ ":module_private_config" ] - - deps = [ - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", - "//third_party/googletest:gtest_main", - "//third_party/openssl:libcrypto_shared", - "//third_party/sqlite:sqlite", - ] - external_deps = [ - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - ] - part_name = "datamgr_service" -} - -############################################################################### -group("moduletest") { - testonly = true - deps = [ - "//third_party/googletest:gmock", - "//third_party/googletest:gtest_main", - "//third_party/sqlite:sqlite", - ] - - deps += [ - ":DistributedbNbDbDamageTest", - ":DistributeddbKvBackupTest", - ":DistributeddbKvBatchCrudTest", - ":DistributeddbKvConcurrencyCrudTest", - ":DistributeddbKvCreateTest", - ":DistributeddbKvCrudTest", - ":DistributeddbKvObserverSnapTest", - ":DistributeddbKvObserverTest", - ":DistributeddbKvRealdelTest", - ":DistributeddbKvTransactionPerfTest", - ":DistributeddbKvTransactionTest", - ":DistributeddbNbAutolaunchTest", - ":DistributeddbNbBackupTest", - ":DistributeddbNbBatchCrudTest", - ":DistributeddbNbCreateTest", - ":DistributeddbNbCrudPowerTest", - ":DistributeddbNbCrudTest", - ":DistributeddbNbCursorTest", - ":DistributeddbNbLocalBatchCrudTest", - ":DistributeddbNbObserverTest", - ":DistributeddbNbPredicateQueryExpandTest", - ":DistributeddbNbPredicateQueryTest", - ":DistributeddbNbSchemaTest", - ":DistributeddbNbSchemaUpgradeTest", - ] -} - ############################################################################### group("fuzztest") { diff --git a/kv_store/frameworks/innerkitsimpl/distributeddatafwk/src/distributed_kv_data_manager.cpp b/kv_store/frameworks/innerkitsimpl/distributeddatafwk/src/distributed_kv_data_manager.cpp index 8a4db228cdfbd406f00cc60b2bf99fddb9920eeb..c3a3485aa6ebf3d7a466c2b56ef0ec51fe7a8730 100644 --- a/kv_store/frameworks/innerkitsimpl/distributeddatafwk/src/distributed_kv_data_manager.cpp +++ b/kv_store/frameworks/innerkitsimpl/distributeddatafwk/src/distributed_kv_data_manager.cpp @@ -168,26 +168,26 @@ void DistributedKvDataManager::UnRegisterKvStoreServiceDeathRecipient( Status DistributedKvDataManager::GetLocalDevice(DeviceInfo &localDevice) { - auto dvInfo = DevManager::GetInstance().GetLocalDevice(); - if (dvInfo.networkId.empty()) { + auto devInfo = DevManager::GetInstance().GetLocalDevice(); + if (devInfo.networkId.empty()) { ZLOGE("deviceId empty!"); return Status::ERROR; } - localDevice.deviceId = dvInfo.networkId; - localDevice.deviceName = dvInfo.deviceName; - localDevice.deviceType = dvInfo.deviceType; + localDevice.deviceId = devInfo.networkId; return Status::SUCCESS; } Status DistributedKvDataManager::GetDeviceList(std::vector &deviceInfoList, DeviceFilterStrategy strategy) { - auto dvInfos = DevManager::GetInstance().GetRemoteDevices(); - for (const auto &info : dvInfos) { + auto devInfos = DevManager::GetInstance().GetRemoteDevices(); + for (const auto &info : devInfos) { if (info.networkId.empty()) { ZLOGW("deviceId empty!"); continue; } - DeviceInfo devInfo = { info.networkId, info.deviceName, info.deviceType }; + DeviceInfo devInfo = { + .deviceId = info.networkId, + }; deviceInfoList.emplace_back(devInfo); } ZLOGI("strategy is:%{public}d", strategy); diff --git a/kv_store/frameworks/innerkitsimpl/distributeddatafwk/test/unittest/distributed_kv_data_manager_test.cpp b/kv_store/frameworks/innerkitsimpl/distributeddatafwk/test/unittest/distributed_kv_data_manager_test.cpp index 5bc33a0aa9fdd5f67b3a2112f896d4852e831cf8..15ac2f5b21c7ded32289aa9aadf8fb6c07072e30 100644 --- a/kv_store/frameworks/innerkitsimpl/distributeddatafwk/test/unittest/distributed_kv_data_manager_test.cpp +++ b/kv_store/frameworks/innerkitsimpl/distributeddatafwk/test/unittest/distributed_kv_data_manager_test.cpp @@ -743,15 +743,15 @@ HWTEST_F(DistributedKvDataManagerTest, UnRegisterKvStoreServiceDeathRecipient001 * @tc.require: * @tc.author: zuojiangjiang */ -HWTEST_F(DistributedKvDataManagerTest, GetLocalDevice001, TestSize.Level1) +HWTEST_F(DistributedKvDataManagerTest, GetLocalDevice, TestSize.Level1) { - ZLOGI("GetLocalDevice001 begin."); - DeviceInfo dvInfo; - Status status = manager.GetLocalDevice(dvInfo); + ZLOGI("GetLocalDevice begin."); + DeviceInfo devInfo; + Status status = manager.GetLocalDevice(devInfo); EXPECT_EQ(status, Status::SUCCESS); - EXPECT_EQ(dvInfo.deviceId.empty(), false); - EXPECT_EQ(dvInfo.deviceName.empty(), false); - EXPECT_EQ(dvInfo.deviceType.empty(), false); + EXPECT_EQ(devInfo.deviceId.empty(), false); + EXPECT_EQ(devInfo.deviceName.empty(), true); + EXPECT_EQ(devInfo.deviceType.empty(), true); } /** @@ -761,11 +761,11 @@ HWTEST_F(DistributedKvDataManagerTest, GetLocalDevice001, TestSize.Level1) * @tc.require: * @tc.author: zuojiangjiang */ -HWTEST_F(DistributedKvDataManagerTest, GetDeviceList001, TestSize.Level1) +HWTEST_F(DistributedKvDataManagerTest, GetDeviceList, TestSize.Level1) { - ZLOGI("GetDeviceList001 begin."); - std::vector dvInfos; - Status status = manager.GetDeviceList(dvInfos, DeviceFilterStrategy::NO_FILTER); + ZLOGI("GetDeviceList begin."); + std::vector devInfos; + Status status = manager.GetDeviceList(devInfos, DeviceFilterStrategy::NO_FILTER); EXPECT_EQ(status, Status::SUCCESS); } @@ -776,9 +776,9 @@ HWTEST_F(DistributedKvDataManagerTest, GetDeviceList001, TestSize.Level1) * @tc.require: * @tc.author: zuojiangjiang */ -HWTEST_F(DistributedKvDataManagerTest, WatchDeviceChange001, TestSize.Level1) +HWTEST_F(DistributedKvDataManagerTest, WatchDeviceChange, TestSize.Level1) { - ZLOGI("GetDeviceList001 begin."); + ZLOGI("GetDeviceList begin."); std::shared_ptr observer = nullptr; Status status = manager.StartWatchDeviceChange(observer); EXPECT_EQ(status, Status::SUCCESS); diff --git a/kv_store/frameworks/innerkitsimpl/kvdb/include/backup_manager.h b/kv_store/frameworks/innerkitsimpl/kvdb/include/backup_manager.h index 9eea87e3001c112b7c177b4d1b3e260281656e05..494443877cf37db1734ea4a15da63e49dbf9a622 100644 --- a/kv_store/frameworks/innerkitsimpl/kvdb/include/backup_manager.h +++ b/kv_store/frameworks/innerkitsimpl/kvdb/include/backup_manager.h @@ -26,6 +26,7 @@ namespace OHOS::DistributedKv { class BackupManager { public: using DBStore = DistributedDB::KvStoreNbDelegate; + using DBPassword = DistributedKv::SecurityManager::DBPassword; struct ResidueInfo { size_t tmpBackupSize; size_t tmpKeySize; @@ -59,7 +60,7 @@ private: void CleanTmpData(const std::string &name); StoreUtil::FileInfo GetBackupFileInfo(const std::string &name, const std::string &baseDir, const std::string &storeId); - SecurityManager::DBPassword GetRestorePassword(const std::string &name, const std::string &baseDir, + DBPassword GetRestorePassword(const std::string &name, const std::string &baseDir, const std::string &appId, const std::string &storeId); bool HaveResidueFile(const std::vector &files); bool HaveResidueKey(const std::vector &files, std::string storeId); diff --git a/kv_store/frameworks/innerkitsimpl/kvdb/include/dev_manager.h b/kv_store/frameworks/innerkitsimpl/kvdb/include/dev_manager.h index c6e18d9cdb9ac2960a1ed473299b121046030c7f..d04cf321267daa64d14626c85a1a03332d671684 100644 --- a/kv_store/frameworks/innerkitsimpl/kvdb/include/dev_manager.h +++ b/kv_store/frameworks/innerkitsimpl/kvdb/include/dev_manager.h @@ -24,14 +24,13 @@ public: static constexpr size_t MAX_ID_LEN = 64; struct DetailInfo { std::string uuid; - std::string udid; std::string networkId; std::string deviceName; std::string deviceType; }; static DevManager &GetInstance(); - std::string ToUUID(const std::string &networkId) const; - std::string ToNetworkId(const std::string &uuid) const; + std::string ToUUID(const std::string &networkId); + std::string ToNetworkId(const std::string &uuid); const DetailInfo &GetLocalDevice(); std::vector GetRemoteDevices() const; class Observer { @@ -55,6 +54,8 @@ private: void OnChanged(const std::string &networkId); void OnReady(const std::string &networkId); void RegisterDevCallback(); + void UpdateBucket(); + DetailInfo GetDevInfoFromBucket(const std::string &id); int32_t Init(); std::function Retry(); diff --git a/kv_store/frameworks/innerkitsimpl/kvdb/include/kv_types_util.h b/kv_store/frameworks/innerkitsimpl/kvdb/include/kv_types_util.h index b81432e466e08c61135c8bf67ac7c36c79e85706..1a0211b598e2a130e67e8d973b5e1b667b11a9e5 100644 --- a/kv_store/frameworks/innerkitsimpl/kvdb/include/kv_types_util.h +++ b/kv_store/frameworks/innerkitsimpl/kvdb/include/kv_types_util.h @@ -16,6 +16,7 @@ #ifndef OHOS_DISTRIBUTED_DATA_FRAMEWORKS_KVDB_KV_TYPES_UTIL_H #define OHOS_DISTRIBUTED_DATA_FRAMEWORKS_KVDB_KV_TYPES_UTIL_H #include "change_notification.h" +#include "kvdb_service.h" #include "itypes_util.h" #include "types.h" namespace OHOS::ITypesUtil { @@ -28,8 +29,8 @@ using StoreId = DistributedKv::StoreId; using DeviceInfo = DistributedKv::DeviceInfo; using ChangeNotification = DistributedKv::ChangeNotification; using Options = DistributedKv::Options; -using Options = DistributedKv::Options; using SyncPolicy = DistributedKv::SyncPolicy; +using DevBrief = DistributedKv::KVDBService::DevBrief; template<> API_EXPORT bool Marshalling(const Blob &input, MessageParcel &data); template<> @@ -70,6 +71,11 @@ API_EXPORT bool Marshalling(const SyncPolicy &input, MessageParcel &data); template<> API_EXPORT bool Unmarshalling(SyncPolicy &output, MessageParcel &data); +template<> +API_EXPORT bool Marshalling(const DevBrief &input, MessageParcel &data); +template<> +API_EXPORT bool Unmarshalling(DevBrief &output, MessageParcel &data); + int64_t GetTotalSize(const std::vector &entries); int64_t GetTotalSize(const std::vector &entries); } // namespace OHOS::ITypesUtil diff --git a/kv_store/frameworks/innerkitsimpl/kvdb/include/kvdb_service.h b/kv_store/frameworks/innerkitsimpl/kvdb/include/kvdb_service.h index 3332366ec47b07dbc77d8439faa67fab368e7e58..74af08fbfad879815cf8eb389cb7c83e11d66a66 100644 --- a/kv_store/frameworks/innerkitsimpl/kvdb/include/kvdb_service.h +++ b/kv_store/frameworks/innerkitsimpl/kvdb/include/kvdb_service.h @@ -33,6 +33,10 @@ public: std::vector devices; std::string query; }; + struct DevBrief { + std::string uuid; + std::string networkId; + }; DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.DistributedKv.KVFeature"); API_EXPORT KVDBService() = default; @@ -59,6 +63,8 @@ public: virtual Status Unsubscribe(const AppId &appId, const StoreId &storeId, sptr observer) = 0; virtual Status GetBackupPassword( const AppId &appId, const StoreId &storeId, std::vector &password) = 0; + virtual DevBrief GetLocalDevice() = 0; + virtual std::vector GetRemoteDevices() = 0; protected: enum TransId : int32_t { @@ -80,7 +86,11 @@ protected: TRANS_SUB, TRANS_UNSUB, TRANS_GET_PASSWORD, - TRANS_BUTT, + TRANS_NO_APPID_BEGIN, + TRANS_GET_LOCAL_DEVICE = TRANS_NO_APPID_BEGIN, + TRANS_GET_REMOTE_DEVICES, + TRANS_NO_APPID_END, + TRANS_BUTT = TRANS_NO_APPID_END, }; }; } // namespace OHOS::DistributedKv diff --git a/kv_store/frameworks/innerkitsimpl/kvdb/include/kvdb_service_client.h b/kv_store/frameworks/innerkitsimpl/kvdb/include/kvdb_service_client.h index 94adb55561963498c423e79cef4042ae73ceb4ce..b38c055a8fc4011af087389df79a9b0335777985 100644 --- a/kv_store/frameworks/innerkitsimpl/kvdb/include/kvdb_service_client.h +++ b/kv_store/frameworks/innerkitsimpl/kvdb/include/kvdb_service_client.h @@ -48,6 +48,8 @@ public: Status Subscribe(const AppId &appId, const StoreId &storeId, sptr observer) override; Status Unsubscribe(const AppId &appId, const StoreId &storeId, sptr observer) override; Status GetBackupPassword(const AppId &appId, const StoreId &storeId, std::vector &password) override; + DevBrief GetLocalDevice() override; + std::vector GetRemoteDevices() override; sptr GetSyncAgent(const AppId &appId); protected: diff --git a/kv_store/frameworks/innerkitsimpl/kvdb/include/security_manager.h b/kv_store/frameworks/innerkitsimpl/kvdb/include/security_manager.h index 5d3e93498f753b8cb8e1df3395a480a5bcec6d34..81458ae2602005ab0cc7bda692b9ff9e1a83205e 100644 --- a/kv_store/frameworks/innerkitsimpl/kvdb/include/security_manager.h +++ b/kv_store/frameworks/innerkitsimpl/kvdb/include/security_manager.h @@ -15,15 +15,42 @@ #ifndef OHOS_DISTRIBUTED_DATA_FRAMEWORKS_KVDB_SECURITY_MANAGER_H #define OHOS_DISTRIBUTED_DATA_FRAMEWORKS_KVDB_SECURITY_MANAGER_H #include + +#include "kv_store_delegate_manager.h" +#include "kv_store_nb_delegate.h" #include "types.h" #include "types_export.h" namespace OHOS::DistributedKv { class SecurityManager { public: - using DBPassword = DistributedDB::CipherPassword; + struct DBPassword { + bool isKeyOutdated = false; + DistributedDB::CipherPassword password; + size_t GetSize() const + { + return password.GetSize(); + } + const uint8_t *GetData() const + { + return password.GetData(); + } + int SetValue(const uint8_t *inputData, size_t inputSize) + { + return password.SetValue(inputData, inputSize); + } + bool IsValid() + { + return password.GetSize() != 0; + } + int Clear() + { + return password.Clear(); + } + }; + static SecurityManager &GetInstance(); DBPassword GetDBPassword(const std::string &name, const std::string &path, bool needCreate = false); - bool SaveDBPassword(const std::string &name, const std::string &path, const DBPassword &key); + bool SaveDBPassword(const std::string &name, const std::string &path, const DistributedDB::CipherPassword &key); void DelDBPassword(const std::string &name, const std::string &path); private: @@ -31,18 +58,20 @@ private: static constexpr const char *HKS_BLOB_TYPE_NONCE = "Z5s0Bo571KoqwIi6"; static constexpr const char *HKS_BLOB_TYPE_AAD = "distributeddata_client"; static constexpr int KEY_SIZE = 32; + static constexpr int HOURS_PER_YEAR = (24 * 365); SecurityManager(); ~SecurityManager(); - std::vector Random(int32_t len); - std::vector LoadKeyFromFile(const std::string &name, const std::string &path); + std::vector LoadKeyFromFile(const std::string &name, const std::string &path, bool &isOutdated); bool SaveKeyToFile(const std::string &name, const std::string &path, std::vector &key); + std::vector Random(int32_t len); + bool IsKeyOutdated(const std::vector &date); int32_t GenerateRootKey(); int32_t CheckRootKey(); bool Retry(); std::vector Encrypt(const std::vector &key); bool Decrypt(std::vector &source, std::vector &key); - + std::vector vecRootKeyAlias_{}; std::vector vecNonce_{}; std::vector vecAad_{}; diff --git a/kv_store/frameworks/innerkitsimpl/kvdb/include/single_store_impl.h b/kv_store/frameworks/innerkitsimpl/kvdb/include/single_store_impl.h index f9e1b76c54632032455c4ee7368a34652cf4b067..00bfeb3a409b10e431f36d3fba62968080d911e0 100644 --- a/kv_store/frameworks/innerkitsimpl/kvdb/include/single_store_impl.h +++ b/kv_store/frameworks/innerkitsimpl/kvdb/include/single_store_impl.h @@ -95,6 +95,7 @@ private: static constexpr size_t MAX_OBSERVER_SIZE = 8; Status GetResultSet(const DBQuery &query, std::shared_ptr &resultSet) const; Status GetEntries(const DBQuery &query, std::vector &entries) const; + Status RetryWithCheckPoint(std::function lambda); std::function BridgeReleaser(); Status DoSync(const SyncInfo &syncInfo, std::shared_ptr observer); void DoAutoSync(); diff --git a/kv_store/frameworks/innerkitsimpl/kvdb/include/store_factory.h b/kv_store/frameworks/innerkitsimpl/kvdb/include/store_factory.h index 730fa7800a73717a7ea79701b9b65ab65dbb2810..b305ec0ba8804c65be56a64a47cb78935d5b631c 100644 --- a/kv_store/frameworks/innerkitsimpl/kvdb/include/store_factory.h +++ b/kv_store/frameworks/innerkitsimpl/kvdb/include/store_factory.h @@ -16,9 +16,11 @@ #ifndef OHOS_DISTRIBUTED_DATA_FRAMEWORKS_KVDB_STORE_FACTORY_H #define OHOS_DISTRIBUTED_DATA_FRAMEWORKS_KVDB_STORE_FACTORY_H #include + #include "concurrent_map.h" #include "convertor.h" #include "kv_store_delegate_manager.h" +#include "security_manager.h" #include "single_store_impl.h" namespace OHOS::DistributedKv { class StoreFactory { @@ -33,11 +35,25 @@ private: using DBManager = DistributedDB::KvStoreDelegateManager; using DBOption = DistributedDB::KvStoreNbDelegate::Option; using DBStore = DistributedDB::KvStoreNbDelegate; - using DBPassword = DistributedDB::CipherPassword; + using DBStatus = DistributedDB::DBStatus; + using DBPassword = DistributedKv::SecurityManager::DBPassword; + + static constexpr int REKEY_TIMES = 3; + static constexpr const char *REKEY_NEW = ".new"; + static constexpr uint64_t MAX_WAL_SIZE = 200 * 1024 * 1024; // the max size of WAL is 200MB StoreFactory(); std::shared_ptr GetDBManager(const std::string &path, const AppId &appId); - DBOption GetDBOption(const Options &options, const DBPassword &password) const; + DBOption GetDBOption(const Options &options, const DBPassword &dbPassword) const; + void ReKey(const std::string &storeId, const std::string &path, DBPassword &dbPassword, + std::shared_ptr dbManager, const Options &options); + Status RekeyRecover(const std::string &storeId, const std::string &path, DBPassword &dbPassword, + std::shared_ptr dbManager, const Options &options); + bool ExecuteRekey(const std::string &storeId, const std::string &path, DBPassword &dbPassword, DBStore *dbStore); + Status IsPwdValid(const std::string &storeId, std::shared_ptr dbManager, const Options &options, + DBPassword &dbPassword); + void UpdateKeyFile(const std::string &storeId, const std::string &path); + Status SetDbConfig(std::shared_ptr dbStore); ConcurrentMap> dbManagers_; ConcurrentMap>> stores_; Convertor *convertors_[INVALID_TYPE]; diff --git a/kv_store/frameworks/innerkitsimpl/kvdb/src/backup_manager.cpp b/kv_store/frameworks/innerkitsimpl/kvdb/src/backup_manager.cpp index 253c32723d703462492fd81aa91a58055658c6e4..087b34f6b78254986932598d5f4aeaacf55b466e 100644 --- a/kv_store/frameworks/innerkitsimpl/kvdb/src/backup_manager.cpp +++ b/kv_store/frameworks/innerkitsimpl/kvdb/src/backup_manager.cpp @@ -127,22 +127,22 @@ Status BackupManager::Backup(const std::string &name, const std::string &baseDir (void)StoreUtil::InitPath(topPath); (void)StoreUtil::InitPath(storePath); KeepData(backupFullName, isCreate); - auto password = SecurityManager::GetInstance().GetDBPassword(storeId, baseDir); - if (password.GetSize() != 0) { + auto dbPassword = SecurityManager::GetInstance().GetDBPassword(storeId, baseDir); + if (dbPassword.IsValid()) { KeepData(keyFullName, isCreate); } - auto dbStatus = dbStore->Export(backupFullName, password); + auto dbStatus = dbStore->Export(backupFullName, dbPassword.password); auto status = StoreUtil::ConvertStatus(dbStatus); if (status == SUCCESS) { - if (password.GetSize() != 0) { - SecurityManager::GetInstance().SaveDBPassword(keyName, baseDir, password); + if (dbPassword.IsValid()) { + SecurityManager::GetInstance().SaveDBPassword(keyName, baseDir, dbPassword.password); CleanTmpData(keyFullName); } CleanTmpData(backupFullName); } else { RollBackData(backupFullName, isCreate); - if (password.GetSize() != 0) { + if (dbPassword.IsValid()) { RollBackData(keyFullName, isCreate); } } @@ -186,31 +186,31 @@ Status BackupManager::Restore(const std::string &name, const std::string &baseDi return INVALID_ARGUMENT; } auto fullName = baseDir + BACKUP_TOP_PATH + "/" + storeId + "/" + backupFile.name; - auto password = GetRestorePassword(backupFile.name, baseDir, appId, storeId); + auto password = GetRestorePassword(backupFile.name, baseDir, appId, storeId).password; auto dbStatus = dbStore->Import(fullName, password); auto status = StoreUtil::ConvertStatus(dbStatus); return status; } -SecurityManager::DBPassword BackupManager::GetRestorePassword(const std::string &name, const std::string &baseDir, +BackupManager::DBPassword BackupManager::GetRestorePassword(const std::string &name, const std::string &baseDir, const std::string &appId, const std::string &storeId) { auto backupName = name.substr(0, name.length() - BACKUP_POSTFIX_SIZE); auto keyName = BACKUP_KEY_PREFIX + storeId + "_" + backupName; - SecurityManager::DBPassword password; + DBPassword dbPassword; if (backupName == AUTO_BACKUP_NAME) { auto service = KVDBServiceClient::GetInstance(); if (service == nullptr) { - return SecurityManager::DBPassword(); + return dbPassword; } std::vector pwd; service->GetBackupPassword({ appId }, { storeId }, pwd); - password.SetValue(pwd.data(), pwd.size()); + dbPassword.SetValue(pwd.data(), pwd.size()); pwd.assign(pwd.size(), 0); } else { - password = SecurityManager::GetInstance().GetDBPassword(keyName, baseDir); + dbPassword = SecurityManager::GetInstance().GetDBPassword(keyName, baseDir); } - return password; + return dbPassword; } Status BackupManager::DeleteBackup(std::map &deleteList, const std::string &baseDir, @@ -428,4 +428,4 @@ bool BackupManager::IsBeginWith(const std::string &fullString, const std::string return false; } } -} // namespace OHOS::DistributedKv \ No newline at end of file +} // namespace OHOS::DistributedKv diff --git a/kv_store/frameworks/innerkitsimpl/kvdb/src/dev_manager.cpp b/kv_store/frameworks/innerkitsimpl/kvdb/src/dev_manager.cpp index 0beb71ff4fb79c1c21346914dcc368ca4bb5dc8d..544d883b649802759b8c13164ba7da0385d88865 100644 --- a/kv_store/frameworks/innerkitsimpl/kvdb/src/dev_manager.cpp +++ b/kv_store/frameworks/innerkitsimpl/kvdb/src/dev_manager.cpp @@ -19,6 +19,7 @@ #include "device_manager.h" #include "device_manager_callback.h" #include "dm_device_info.h" +#include "kvdb_service_client.h" #include "log_print.h" #include "store_util.h" #include "task_executor.h" @@ -118,44 +119,43 @@ DevManager &DevManager::GetInstance() return instance; } -std::string DevManager::ToUUID(const std::string &networkId) const +std::string DevManager::ToUUID(const std::string &networkId) { - DetailInfo deviceInfo; - if (deviceInfos_.Get(networkId, deviceInfo)) { - return deviceInfo.uuid; - } + return GetDevInfoFromBucket(networkId).uuid; +} - std::string uuid; - std::string udid; - auto &deviceManager = DeviceManager::GetInstance(); - deviceManager.GetUuidByNetworkId(PKG_NAME, networkId, uuid); - deviceManager.GetUdidByNetworkId(PKG_NAME, networkId, udid); - if (uuid.empty() || udid.empty() || networkId.empty()) { - return ""; +std::string DevManager::ToNetworkId(const std::string &uuid) +{ + return GetDevInfoFromBucket(uuid).networkId; +} + +DevManager::DetailInfo DevManager::GetDevInfoFromBucket(const std::string &id) +{ + DetailInfo detailInfo; + if (!deviceInfos_.Get(id, detailInfo)) { + UpdateBucket(); + deviceInfos_.Get(id, detailInfo); } - deviceInfo = { uuid, std::move(udid), networkId, "", "" }; - deviceInfos_.Set(networkId, deviceInfo); - deviceInfos_.Set(uuid, deviceInfo); - return uuid; + if (detailInfo.uuid.empty()) { + ZLOGE("id:%{public}s", StoreUtil::Anonymous(id).c_str()); + } + return detailInfo; } -std::string DevManager::ToNetworkId(const std::string &uuid) const +void DevManager::UpdateBucket() { - DetailInfo deviceInfo; - if (deviceInfos_.Get(uuid, deviceInfo)) { - return deviceInfo.networkId; + auto detailInfos = GetRemoteDevices(); + if (detailInfos.empty()) { + ZLOGD("no remote device"); } - auto infos = GetRemoteDevices(); - for (auto &info : infos) { - if (info.uuid == uuid) { - deviceInfos_.Set(info.uuid, info); - deviceInfos_.Set(info.networkId, info); - return info.networkId; + detailInfos.emplace_back(GetLocalDevice()); + for (const auto &detailInfo : detailInfos) { + if (detailInfo.uuid.empty() || detailInfo.networkId.empty()) { + continue; } + deviceInfos_.Set(detailInfo.uuid, detailInfo); + deviceInfos_.Set(detailInfo.networkId, detailInfo); } - - std::lock_guard lockGuard(mutex_); - return (localInfo_.uuid == uuid) ? localInfo_.networkId : ""; } const DevManager::DetailInfo &DevManager::GetLocalDevice() @@ -164,51 +164,42 @@ const DevManager::DetailInfo &DevManager::GetLocalDevice() if (!localInfo_.uuid.empty()) { return localInfo_; } - - DmDeviceInfo info; - auto &deviceManager = DeviceManager::GetInstance(); - int32_t ret = deviceManager.GetLocalDeviceInfo(PKG_NAME, info); - if (ret != DM_OK) { - ZLOGE("GetLocalNodeDeviceInfo error"); + auto service = KVDBServiceClient::GetInstance(); + if (service == nullptr) { + ZLOGE("service unavailable"); return invalidDetail_; } - std::string networkId = std::string(info.networkId); - std::string uuid; - deviceManager.GetUuidByNetworkId(PKG_NAME, networkId, uuid); - std::string udid; - deviceManager.GetUdidByNetworkId(PKG_NAME, networkId, udid); - if (uuid.empty() || udid.empty() || networkId.empty()) { + auto device = service->GetLocalDevice(); + if (device.uuid.empty() || device.networkId.empty()) { return invalidDetail_; } - ZLOGI("[LocalDevice] id:%{public}s, name:%{public}s, type:%{public}d", StoreUtil::Anonymous(uuid).c_str(), - info.deviceName, info.deviceTypeId); - localInfo_ = { std::move(uuid), std::move(udid), std::move(networkId), std::string(info.deviceName), - std::string(info.deviceName) }; + localInfo_.networkId = std::move(device.networkId); + localInfo_.uuid = std::move(device.uuid); + ZLOGI("[LocalDevice] uuid:%{public}s, networkId:%{public}s", + StoreUtil::Anonymous(localInfo_.uuid).c_str(), StoreUtil::Anonymous(localInfo_.networkId).c_str()); return localInfo_; } std::vector DevManager::GetRemoteDevices() const { - std::vector devices; - std::vector dmDeviceInfos{}; - auto &deviceManager = DeviceManager::GetInstance(); - int32_t ret = deviceManager.GetTrustedDeviceList(PKG_NAME, "", dmDeviceInfos); - if (ret != DM_OK) { - ZLOGE("GetTrustedDeviceList error"); - return devices; + auto service = KVDBServiceClient::GetInstance(); + if (service == nullptr) { + ZLOGE("service unavailable"); + return {}; } - - for (const auto &dmDeviceInfo : dmDeviceInfos) { - std::string networkId = dmDeviceInfo.networkId; - std::string uuid; - std::string udid; - deviceManager.GetUuidByNetworkId(PKG_NAME, networkId, uuid); - deviceManager.GetUdidByNetworkId(PKG_NAME, networkId, udid); - DetailInfo deviceInfo = { std::move(uuid), std::move(udid), std::move(networkId), - std::string(dmDeviceInfo.deviceName), std::to_string(dmDeviceInfo.deviceTypeId) }; - devices.push_back(std::move(deviceInfo)); + auto devices = service->GetRemoteDevices(); + if (devices.empty()) { + ZLOGD("no remote device"); + return {}; + } + std::vector dtInfos; + for (auto &device : devices) { + DetailInfo dtInfo; + dtInfo.networkId = std::move(device.networkId); + dtInfo.uuid = std::move(device.uuid); + dtInfos.push_back(dtInfo); } - return devices; + return dtInfos; } void DevManager::Online(const std::string &networkId) diff --git a/kv_store/frameworks/innerkitsimpl/kvdb/src/kv_types_util.cpp b/kv_store/frameworks/innerkitsimpl/kvdb/src/kv_types_util.cpp index efd5b76a8aabe860488437d8275acf063eb25dec..70045bdb16e5e062213ebc746e1759191d26860b 100644 --- a/kv_store/frameworks/innerkitsimpl/kvdb/src/kv_types_util.cpp +++ b/kv_store/frameworks/innerkitsimpl/kvdb/src/kv_types_util.cpp @@ -160,6 +160,18 @@ bool Unmarshalling(SyncPolicy &output, MessageParcel &data) return ITypesUtil::Unmarshal(data, output.type, output.value); } +template<> +bool Marshalling(const DevBrief &input, MessageParcel &data) +{ + return ITypesUtil::Marshal(data, input.uuid, input.networkId); +} + +template<> +bool Unmarshalling(DevBrief &output, MessageParcel &data) +{ + return ITypesUtil::Unmarshal(data, output.uuid, output.networkId); +} + int64_t GetTotalSize(const std::vector &entries) { int64_t bufferSize = 1; diff --git a/kv_store/frameworks/innerkitsimpl/kvdb/src/kvdb_service_client.cpp b/kv_store/frameworks/innerkitsimpl/kvdb/src/kvdb_service_client.cpp index 3464c910de2b7deab3002b6b08cbc442a9b21a69..211d9b66582895aaa04f5a05374290ec92b068a9 100644 --- a/kv_store/frameworks/innerkitsimpl/kvdb/src/kvdb_service_client.cpp +++ b/kv_store/frameworks/innerkitsimpl/kvdb/src/kvdb_service_client.cpp @@ -290,6 +290,30 @@ Status KVDBServiceClient::GetBackupPassword( return static_cast(status); } +KVDBService::DevBrief KVDBServiceClient::GetLocalDevice() +{ + DevBrief brief; + MessageParcel reply; + int32_t status = IPC_SEND(TRANS_GET_LOCAL_DEVICE, reply); + if (status != SUCCESS) { + ZLOGE("status:0x%{public}x", status); + } + ITypesUtil::Unmarshal(reply, brief); + return brief; +} + +std::vector KVDBServiceClient::GetRemoteDevices() +{ + std::vector briefs; + MessageParcel reply; + int32_t status = IPC_SEND(TRANS_GET_REMOTE_DEVICES, reply); + if (status != SUCCESS) { + ZLOGE("status:0x%{public}x", status); + } + ITypesUtil::Unmarshal(reply, briefs); + return briefs; +} + sptr KVDBServiceClient::GetSyncAgent(const AppId &appId) { std::lock_guard lockGuard(agentMtx_); diff --git a/kv_store/frameworks/innerkitsimpl/kvdb/src/security_manager.cpp b/kv_store/frameworks/innerkitsimpl/kvdb/src/security_manager.cpp index 166b8531818074ccd70e60c2401502d44462a434..330a372c796510ccfce9412b7cce448c18b60c26 100644 --- a/kv_store/frameworks/innerkitsimpl/kvdb/src/security_manager.cpp +++ b/kv_store/frameworks/innerkitsimpl/kvdb/src/security_manager.cpp @@ -14,14 +14,18 @@ */ #define LOG_TAG "SECURITYMANAGER" #include "security_manager.h" + +#include #include #include #include -#include "log_print.h" + +#include "file_ex.h" #include "hks_api.h" #include "hks_param.h" -#include "file_ex.h" +#include "log_print.h" #include "securec.h" +#include "store_types.h" #include "store_util.h" #include "task_executor.h" namespace OHOS::DistributedKv { @@ -61,26 +65,26 @@ bool SecurityManager::Retry() return false; } -SecurityManager::DBPassword SecurityManager::GetDBPassword(const std::string &name, const std::string &path, - bool needCreate) +SecurityManager::DBPassword SecurityManager::GetDBPassword(const std::string &name, + const std::string &path, bool needCreate) { - DBPassword password; - auto secKey = LoadKeyFromFile(name, path); + DBPassword dbPassword; + auto secKey = LoadKeyFromFile(name, path, dbPassword.isKeyOutdated); if (secKey.empty() && needCreate) { secKey = Random(KEY_SIZE); if (!SaveKeyToFile(name, path, secKey)) { secKey.assign(secKey.size(), 0); - return password; + return dbPassword; } } - password.SetValue(secKey.data(), secKey.size()); + dbPassword.SetValue(secKey.data(), secKey.size()); secKey.assign(secKey.size(), 0); - return password; + return dbPassword; } bool SecurityManager::SaveDBPassword(const std::string &name, const std::string &path, - const SecurityManager::DBPassword &key) + const DistributedDB::CipherPassword &key) { std::vector pwd(key.GetData(), key.GetData() + key.GetSize()); auto result = SaveKeyToFile(name, path, pwd); @@ -105,7 +109,8 @@ std::vector SecurityManager::Random(int32_t len) return key; } -std::vector SecurityManager::LoadKeyFromFile(const std::string &name, const std::string &path) +std::vector SecurityManager::LoadKeyFromFile(const std::string &name, const std::string &path, + bool &isOutdated) { auto keyPath = path + "/key/" + name + ".key"; if (!FileExists(keyPath)) { @@ -130,6 +135,7 @@ std::vector SecurityManager::LoadKeyFromFile(const std::string &name, c offset++; std::vector date; date.assign(content.begin() + offset, content.begin() + (sizeof(time_t) / sizeof(uint8_t)) + offset); + isOutdated = IsKeyOutdated(date); offset += (sizeof(time_t) / sizeof(uint8_t)); std::vector key{content.begin() + offset, content.end()}; content.assign(content.size(), 0); @@ -147,7 +153,6 @@ bool SecurityManager::SaveKeyToFile(const std::string &name, const std::string & ZLOGE("failed! no root key and generation failed"); return false; } - auto secretKey = Encrypt(key); auto keyPath = path + "/key"; StoreUtil::InitPath(keyPath); @@ -342,4 +347,12 @@ int32_t SecurityManager::CheckRootKey() ZLOGI("HksKeyExist status: %{public}d", ret); return ret; } -} // namespace OHOS::DistributedKv \ No newline at end of file + +bool SecurityManager::IsKeyOutdated(const std::vector &date) +{ + time_t time = *reinterpret_cast(const_cast(&date[0])); + auto createTime = std::chrono::system_clock::from_time_t(time); + return ((createTime + std::chrono::hours(HOURS_PER_YEAR)) < std::chrono::system_clock::now()); +} + +} // namespace OHOS::DistributedKv diff --git a/kv_store/frameworks/innerkitsimpl/kvdb/src/single_store_impl.cpp b/kv_store/frameworks/innerkitsimpl/kvdb/src/single_store_impl.cpp index 606dfb4bf68f9a25ea46bc528ac12f3aa595dfc6..e79f8a3835750293ec5232350842715858a69ee2 100644 --- a/kv_store/frameworks/innerkitsimpl/kvdb/src/single_store_impl.cpp +++ b/kv_store/frameworks/innerkitsimpl/kvdb/src/single_store_impl.cpp @@ -14,6 +14,7 @@ */ #define LOG_TAG "SingleStoreImpl" #include "single_store_impl.h" + #include "auto_sync_timer.h" #include "backup_manager.h" #include "dds_trace.h" @@ -42,7 +43,7 @@ SingleStoreImpl::SingleStoreImpl(std::shared_ptr dbStore, const AppId & continue; } auto exist = std::get_if(&policy.value); - if (exist == nullptr && *exist <= 0) { + if (exist == nullptr || *exist <= 0) { break; } interval_ = *exist; @@ -62,6 +63,18 @@ StoreId SingleStoreImpl::GetStoreId() const return { storeId_ }; } +Status SingleStoreImpl::RetryWithCheckPoint(std::function lambda) +{ + auto dbStatus = lambda(); + if (dbStatus != DistributedDB::LOG_OVER_LIMITS) { + return StoreUtil::ConvertStatus(dbStatus); + } + DistributedDB::PragmaData data; + dbStore_->Pragma(DistributedDB::EXEC_CHECKPOINT, data); + dbStatus = lambda(); + return StoreUtil::ConvertStatus(dbStatus); +} + Status SingleStoreImpl::Put(const Key &key, const Value &value) { DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__)); @@ -78,8 +91,7 @@ Status SingleStoreImpl::Put(const Key &key, const Value &value) return INVALID_ARGUMENT; } - auto dbStatus = dbStore_->Put(dbKey, value); - auto status = StoreUtil::ConvertStatus(dbStatus); + auto status = RetryWithCheckPoint([this, &dbKey, &value]() { return dbStore_->Put(dbKey, value); }); if (status != SUCCESS) { ZLOGE("status:0x%{public}x key:%{public}s, value size:%{public}zu", status, StoreUtil::Anonymous(key.ToString()).c_str(), value.Size()); @@ -109,8 +121,8 @@ Status SingleStoreImpl::PutBatch(const std::vector &entries) dbEntry.value = entry.value; dbEntries.push_back(std::move(dbEntry)); } - auto dbStatus = dbStore_->PutBatch(dbEntries); - auto status = StoreUtil::ConvertStatus(dbStatus); + + auto status = RetryWithCheckPoint([this, &dbEntries]() { return dbStore_->PutBatch(dbEntries); }); if (status != SUCCESS) { ZLOGE("status:0x%{public}x entries size:%{public}zu", status, entries.size()); } @@ -133,8 +145,7 @@ Status SingleStoreImpl::Delete(const Key &key) return INVALID_ARGUMENT; } - auto dbStatus = dbStore_->Delete(dbKey); - auto status = StoreUtil::ConvertStatus(dbStatus); + auto status = RetryWithCheckPoint([this, &dbKey]() { return dbStore_->Delete(dbKey); }); if (status != SUCCESS) { ZLOGE("status:0x%{public}x key:%{public}s", status, StoreUtil::Anonymous(key.ToString()).c_str()); } @@ -161,8 +172,7 @@ Status SingleStoreImpl::DeleteBatch(const std::vector &keys) dbKeys.push_back(std::move(dbKey)); } - auto dbStatus = dbStore_->DeleteBatch(dbKeys); - auto status = StoreUtil::ConvertStatus(dbStatus); + auto status = RetryWithCheckPoint([this, &dbKeys]() { return dbStore_->DeleteBatch(dbKeys); }); if (status != SUCCESS) { ZLOGE("status:0x%{public}x keys size:%{public}zu", status, keys.size()); } @@ -179,8 +189,7 @@ Status SingleStoreImpl::StartTransaction() return ALREADY_CLOSED; } - auto dbStatus = dbStore_->StartTransaction(); - auto status = StoreUtil::ConvertStatus(dbStatus); + auto status = RetryWithCheckPoint([this]() { return dbStore_->StartTransaction(); }); if (status != SUCCESS) { ZLOGE("status:0x%{public}x storeId:%{public}s", status, storeId_.c_str()); } @@ -238,7 +247,7 @@ Status SingleStoreImpl::SubscribeKvStore(SubscribeType type, std::shared_ptr bridge = PutIn(realType, observer); if (bridge == nullptr) { - return (realType == type) ? OVER_MAX_SUBSCRIBE_LIMITS : STORE_ALREADY_SUBSCRIBE; + return (realType == type) ? OVER_MAX_LIMITS : STORE_ALREADY_SUBSCRIBE; } Status status = SUCCESS; @@ -772,7 +781,11 @@ Status SingleStoreImpl::DoSync(const SyncInfo &syncInfo, std::shared_ptrAddSyncCallback(observer, syncInfo.seqId); - return service->Sync({ appId_ }, { storeId_ }, syncInfo); + auto status = service->Sync({ appId_ }, { storeId_ }, syncInfo); + if (status != Status::SUCCESS) { + syncAgent->DeleteSyncCallback(syncInfo.seqId); + } + return status; } void SingleStoreImpl::DoAutoSync() diff --git a/kv_store/frameworks/innerkitsimpl/kvdb/src/store_factory.cpp b/kv_store/frameworks/innerkitsimpl/kvdb/src/store_factory.cpp index d0fea9209edacb1dcc06badbaba8e56ec19a692c..aa1c82dc6c04011f60120d49ef49e4513e757a54 100644 --- a/kv_store/frameworks/innerkitsimpl/kvdb/src/store_factory.cpp +++ b/kv_store/frameworks/innerkitsimpl/kvdb/src/store_factory.cpp @@ -40,6 +40,16 @@ StoreFactory::StoreFactory() } (void)DBManager::SetProcessSystemAPIAdapter(std::make_shared()); } +Status StoreFactory::SetDbConfig(std::shared_ptr dbStore) +{ + PragmaData data = + static_cast(const_cast(static_cast(&MAX_WAL_SIZE))); + auto status = dbStore->Pragma(DistributedDB::SET_MAX_LOG_LIMIT, data); + if (status != DistributedDB::DBStatus::OK) { + ZLOGE("failed to set max log limit! status:%{public}d", status); + } + return StoreUtil::ConvertStatus(status); +} std::shared_ptr StoreFactory::GetOrOpenStore(const AppId &appId, const StoreId &storeId, const Options &options, Status &status, bool &isCreate) @@ -55,13 +65,27 @@ std::shared_ptr StoreFactory::GetOrOpenStore(const AppId &appId, } auto dbManager = GetDBManager(options.baseDir, appId); - auto password = SecurityManager::GetInstance().GetDBPassword(storeId.storeId, options.baseDir, options.encrypt); - if (password.GetSize() == 0 && options.encrypt) { + auto dbPassword = + SecurityManager::GetInstance().GetDBPassword(storeId.storeId, options.baseDir, options.encrypt); + if (options.encrypt && !dbPassword.IsValid()) { status = CRYPT_ERROR; + ZLOGE("Crypt kvStore failed to get password, storeId is %{public}s, error is %{public}d", + storeId.storeId.c_str(), static_cast(status)); return !stores.empty(); } + if (options.encrypt) { + status = RekeyRecover(storeId, options.baseDir, dbPassword, dbManager, options); + if (status != SUCCESS) { + ZLOGE("KvStore password error, storeId is %{public}s, error is %{public}d", storeId.storeId.c_str(), + static_cast(status)); + return !stores.empty(); + } + if (dbPassword.isKeyOutdated) { + ReKey(storeId, options.baseDir, dbPassword, dbManager, options); + } + } DBStatus dbStatus = DBStatus::DB_ERROR; - dbManager->GetKvStore(storeId, GetDBOption(options, password), + dbManager->GetKvStore(storeId, GetDBOption(options, dbPassword), [this, &dbManager, &kvStore, &appId, &dbStatus, &options](auto status, auto *store) { dbStatus = status; if (store == nullptr) { @@ -69,6 +93,7 @@ std::shared_ptr StoreFactory::GetOrOpenStore(const AppId &appId, } auto release = [dbManager](auto *store) { dbManager->CloseKvStore(store); }; auto dbStore = std::shared_ptr(store, release); + SetDbConfig(dbStore); const Convertor &convertor = *(convertors_[options.kvStoreType]); kvStore = std::make_shared(dbStore, appId, options, convertor); }); @@ -136,7 +161,7 @@ std::shared_ptr StoreFactory::GetDBManager(const std::s return dbManager; } -StoreFactory::DBOption StoreFactory::GetDBOption(const Options &options, const DBPassword &password) const +StoreFactory::DBOption StoreFactory::GetDBOption(const Options &options, const DBPassword &dbPassword) const { DBOption dbOption; dbOption.syncDualTupleMode = true; // tuple of (appid+storeid) @@ -146,7 +171,7 @@ StoreFactory::DBOption StoreFactory::GetDBOption(const Options &options, const D dbOption.isEncryptedDb = options.encrypt; if (options.encrypt) { dbOption.cipher = DistributedDB::CipherType::AES_256_GCM; - dbOption.passwd = password; + dbOption.passwd = dbPassword.password; } if (options.kvStoreType == KvStoreType::SINGLE_VERSION) { @@ -158,6 +183,113 @@ StoreFactory::DBOption StoreFactory::GetDBOption(const Options &options, const D dbOption.schema = options.schema; dbOption.createDirByStoreIdOnly = true; dbOption.secOption = StoreUtil::GetDBSecurity(options.securityLevel); + dbOption.localOnly = !options.syncable; return dbOption; } -} // namespace OHOS::DistributedKv \ No newline at end of file + +void StoreFactory::ReKey(const std::string &storeId, const std::string &path, DBPassword &dbPassword, + std::shared_ptr dbManager, const Options &options) +{ + int32_t retry = 0; + DBStatus status; + DBStore *kvStore; + auto dbOption = GetDBOption(options, dbPassword); + dbManager->GetKvStore(storeId, dbOption, [&status, &kvStore](auto dbStatus, auto *dbStore) { + status = dbStatus; + kvStore = dbStore; + }); + while (retry < REKEY_TIMES) { + auto status = RekeyRecover(storeId, path, dbPassword, dbManager, options); + if (status != SUCCESS) { + break; + } + auto succeed = ExecuteRekey(storeId, path, dbPassword, kvStore); + if (succeed) { + break; + } + ++retry; + } + dbManager->CloseKvStore(kvStore); + kvStore = nullptr; +} + +Status StoreFactory::RekeyRecover(const std::string &storeId, const std::string &path, DBPassword &dbPassword, + std::shared_ptr dbManager, const Options &options) +{ + auto rekeyPath = path + "/rekey"; + auto keyName = path + "/key/" + storeId + ".key"; + Status pwdValid = DB_ERROR; + if (StoreUtil::IsFileExist(keyName)) { + dbPassword = SecurityManager::GetInstance().GetDBPassword(storeId, path); + pwdValid = IsPwdValid(storeId, dbManager, options, dbPassword); + } + + if (pwdValid == SUCCESS) { + StoreUtil::Remove(rekeyPath); + return pwdValid; + } + auto reKeyFile = storeId + REKEY_NEW; + auto rekeyName = path + "/rekey/key/" + reKeyFile + ".key"; + if (StoreUtil::IsFileExist(rekeyName)) { + dbPassword = SecurityManager::GetInstance().GetDBPassword(reKeyFile, rekeyPath); + pwdValid = IsPwdValid(storeId, dbManager, options, dbPassword); + } else { + return pwdValid; + } + if (pwdValid == SUCCESS) { + UpdateKeyFile(storeId, path); + } + return pwdValid; +} + +Status StoreFactory::IsPwdValid(const std::string &storeId, std::shared_ptr dbManager, + const Options &options, DBPassword &dbPassword) +{ + DBStatus status = DistributedDB::DB_ERROR; + DBStore *kvstore = nullptr; + auto dbOption = GetDBOption(options, dbPassword); + dbManager->GetKvStore(storeId, dbOption, [&status, &kvstore](auto dbStatus, auto *dbStore) { + status = dbStatus; + kvstore = dbStore; + }); + dbManager->CloseKvStore(kvstore); + return StoreUtil::ConvertStatus(status); +} + +bool StoreFactory::ExecuteRekey(const std::string &storeId, const std::string &path, DBPassword &dbPassword, + DBStore *dbStore) +{ + std::string rekeyPath = path + "/rekey"; + (void)StoreUtil::InitPath(rekeyPath); + + auto newDbPassword = SecurityManager::GetInstance().GetDBPassword(storeId + REKEY_NEW, rekeyPath, true); + if (!newDbPassword.IsValid()) { + ZLOGE("failed to generate new key."); + newDbPassword.Clear(); + StoreUtil::Remove(rekeyPath); + return false; + } + + auto dbStatus = dbStore->Rekey(newDbPassword.password); + auto status = StoreUtil::ConvertStatus(dbStatus); + if (status != SUCCESS) { + ZLOGE("failed to rekey the substitute database."); + StoreUtil::Remove(rekeyPath); + newDbPassword.Clear(); + return false; + } + UpdateKeyFile(storeId, path); + dbPassword.password = newDbPassword.password; + newDbPassword.Clear(); + dbPassword.isKeyOutdated = false; + return true; +} + +void StoreFactory::UpdateKeyFile(const std::string &storeId, const std::string &path) +{ + std::string rekeyFile = path + "/rekey/key/" + storeId + REKEY_NEW + ".key"; + std::string keyFile = path + "/key/" + storeId + ".key"; + StoreUtil::Rename(rekeyFile, keyFile); + StoreUtil::Remove(rekeyFile); +} +} // namespace OHOS::DistributedKv diff --git a/kv_store/frameworks/innerkitsimpl/kvdb/src/store_manager.cpp b/kv_store/frameworks/innerkitsimpl/kvdb/src/store_manager.cpp index 55f2e20cf1afb3ae2cdb8c7a32fae0917d0485f8..baed9cde255b401f0ce5ec4b664a218c6e771e20 100644 --- a/kv_store/frameworks/innerkitsimpl/kvdb/src/store_manager.cpp +++ b/kv_store/frameworks/innerkitsimpl/kvdb/src/store_manager.cpp @@ -51,8 +51,9 @@ std::shared_ptr StoreManager::GetKVStore(const AppId &appId, cons bool isCreate = false; auto kvStore = StoreFactory::GetInstance().GetOrOpenStore(appId, storeId, options, status, isCreate); if (isCreate && options.persistent) { - auto password = SecurityManager::GetInstance().GetDBPassword(storeId.storeId, options.baseDir, options.encrypt); - std::vector pwd(password.GetData(), password.GetData() + password.GetSize()); + auto dbPassword = SecurityManager::GetInstance().GetDBPassword(storeId.storeId, + options.baseDir, options.encrypt); + std::vector pwd(dbPassword.GetData(), dbPassword.GetData() + dbPassword.GetSize()); if (service != nullptr) { // delay notify service->AfterCreate(appId, storeId, options, pwd); @@ -110,4 +111,4 @@ Status StoreManager::Delete(const AppId &appId, const StoreId &storeId, const st } return StoreFactory::GetInstance().Delete(appId, storeId, path); } -} // namespace OHOS::DistributedKv \ No newline at end of file +} // namespace OHOS::DistributedKv diff --git a/kv_store/frameworks/innerkitsimpl/kvdb/src/store_util.cpp b/kv_store/frameworks/innerkitsimpl/kvdb/src/store_util.cpp index 14632eef0c4a624461c394bc10bf138cf099702d..b5c404a5220b74debfab26469fd1b8ad5daeeb7f 100644 --- a/kv_store/frameworks/innerkitsimpl/kvdb/src/store_util.cpp +++ b/kv_store/frameworks/innerkitsimpl/kvdb/src/store_util.cpp @@ -135,7 +135,7 @@ Status StoreUtil::ConvertStatus(DBStatus status) case DBStatus::TIME_OUT: return Status::TIME_OUT; case DBStatus::OVER_MAX_LIMITS: - return Status::OVER_MAX_SUBSCRIBE_LIMITS; + return Status::OVER_MAX_LIMITS; case DBStatus::INVALID_PASSWD_OR_CORRUPTED_DB: return Status::CRYPT_ERROR; case DBStatus::SCHEMA_MISMATCH: @@ -145,6 +145,8 @@ Status StoreUtil::ConvertStatus(DBStatus status) case DBStatus::EKEYREVOKED_ERROR: // fallthrough case DBStatus::SECURITY_OPTION_CHECK_ERROR: return Status::SECURITY_LEVEL_ERROR; + case DBStatus::LOG_OVER_LIMITS: + return Status::WAL_OVER_LIMITS; default: ZLOGE("unknown db error:0x%{public}x", status); break; diff --git a/kv_store/frameworks/innerkitsimpl/kvdb/test/BUILD.gn b/kv_store/frameworks/innerkitsimpl/kvdb/test/BUILD.gn index e94bd9a18e947584914b522357ed58ab4d8e7b94..f9928742adce8e0c2b8a97503efcc93d5ae22764 100644 --- a/kv_store/frameworks/innerkitsimpl/kvdb/test/BUILD.gn +++ b/kv_store/frameworks/innerkitsimpl/kvdb/test/BUILD.gn @@ -239,6 +239,29 @@ ohos_unittest("SingleStoreImplGetTopTest") { ] } +ohos_unittest("StoreFactoryTest") { + module_out_path = module_output_path + + sources = [ "store_factory_test.cpp" ] + + configs = [ ":module_private_config" ] + + external_deps = [ + "c_utils:utils", + "hilog_native:libhilog", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + ] + + deps = [ + ":kvdb_src_file", + "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter:distributeddata_adapter", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/:distributeddb", + "//third_party/googletest:gtest", + ] +} + ############################################################################### group("unittest") { testonly = true @@ -250,6 +273,7 @@ group("unittest") { ":DevManagerTest", ":SingleStoreImplGetTopTest", ":SingleStoreImplTest", + ":StoreFactoryTest", ":StoreUtilTest", ] } diff --git a/kv_store/frameworks/innerkitsimpl/kvdb/test/backup_manager_test.cpp b/kv_store/frameworks/innerkitsimpl/kvdb/test/backup_manager_test.cpp index 0a25300375fad9ec3ef4f5aa1a396eef13505680..001aaf8251edcfa98163e720ab175b0cf3a1a4cb 100644 --- a/kv_store/frameworks/innerkitsimpl/kvdb/test/backup_manager_test.cpp +++ b/kv_store/frameworks/innerkitsimpl/kvdb/test/backup_manager_test.cpp @@ -23,6 +23,7 @@ #include "store_util.h" #include "sys/stat.h" #include "types.h" +namespace OHOS::Test { using namespace testing::ext; using namespace OHOS::DistributedKv; class BackupManagerTest : public testing::Test { @@ -469,4 +470,5 @@ HWTEST_F(BackupManagerTest, BackUpEntry, TestSize.Level0) ASSERT_EQ(status, SUCCESS); status = StoreManager::GetInstance().Delete(appId, storeId, baseDir); ASSERT_EQ(status, SUCCESS); -} \ No newline at end of file +} +} // namespace OHOS::Test \ No newline at end of file diff --git a/kv_store/frameworks/innerkitsimpl/kvdb/test/dev_manager_test.cpp b/kv_store/frameworks/innerkitsimpl/kvdb/test/dev_manager_test.cpp index b143860233b04c2f1355a6125590507e70ceceb0..01bf94431e59a9a61bfdedcfbe4fc7b34d2520b7 100644 --- a/kv_store/frameworks/innerkitsimpl/kvdb/test/dev_manager_test.cpp +++ b/kv_store/frameworks/innerkitsimpl/kvdb/test/dev_manager_test.cpp @@ -19,6 +19,7 @@ #include "dev_manager.h" #include "types.h" #include "log_print.h" +namespace OHOS::Test { using namespace testing::ext; using namespace OHOS::DistributedKv; @@ -44,52 +45,67 @@ void DevManagerTest::TearDown(void) {} /** -* @tc.name: GetLocalDevice001 +* @tc.name: GetLocalDevice * @tc.desc: Get local device's infomation * @tc.type: FUNC * @tc.require: * @tc.author: taoyuxin */ -HWTEST_F(DevManagerTest, GetLocalDevice001, TestSize.Level1) +HWTEST_F(DevManagerTest, GetLocalDevice, TestSize.Level1) { - ZLOGI("GetLocalDevice001 begin."); - DevManager &devManager = OHOS::DistributedKv::DevManager::GetInstance(); - DevManager::DetailInfo devInfo = devManager.GetLocalDevice(); - + ZLOGI("GetLocalDevice begin."); + auto devInfo = DevManager::GetInstance().GetLocalDevice(); EXPECT_NE(devInfo.networkId, ""); EXPECT_NE(devInfo.uuid, ""); - EXPECT_NE(devInfo.udid, ""); } /** -* @tc.name: ToUUID001 +* @tc.name: ToUUID * @tc.desc: Get uuid from networkId * @tc.type: FUNC * @tc.require: * @tc.author: taoyuxin */ -HWTEST_F(DevManagerTest, ToUUID001, TestSize.Level1) +HWTEST_F(DevManagerTest, ToUUID, TestSize.Level1) { - ZLOGI("ToUUID001 begin."); - DevManager &devManager = OHOS::DistributedKv::DevManager::GetInstance(); - DevManager::DetailInfo devInfo = devManager.GetLocalDevice(); + ZLOGI("ToUUID begin."); + auto &devMgr = DevManager::GetInstance(); + auto devInfo = devMgr.GetLocalDevice(); EXPECT_NE(devInfo.networkId, ""); - std::string uuid = devManager.ToUUID(devInfo.networkId); + auto uuid = devMgr.ToUUID(devInfo.networkId); EXPECT_NE(uuid, ""); EXPECT_EQ(uuid, devInfo.uuid); } /** -* @tc.name: GetRemoteDevices001 +* @tc.name: ToNetworkId +* @tc.desc: Get networkId from uuid +* @tc.type: FUNC +* @tc.require: +* @tc.author: zuojiangjiang +*/ +HWTEST_F(DevManagerTest, ToNetworkId, TestSize.Level1) +{ + auto &devMgr = DevManager::GetInstance(); + auto devInfo = devMgr.GetLocalDevice(); + EXPECT_NE(devInfo.uuid, ""); + auto networkId = devMgr.ToNetworkId(devInfo.uuid); + EXPECT_NE(networkId, ""); + EXPECT_EQ(networkId, devInfo.networkId); +} + +/** +* @tc.name: GetRemoteDevices * @tc.desc: Get remote devices * @tc.type: FUNC * @tc.require: * @tc.author: taoyuxin */ -HWTEST_F(DevManagerTest, GetRemoteDevices001, TestSize.Level1) +HWTEST_F(DevManagerTest, GetRemoteDevices, TestSize.Level1) { - ZLOGI("GetRemoteDevices001 begin."); + ZLOGI("GetRemoteDevices begin."); DevManager &devManager = OHOS::DistributedKv::DevManager::GetInstance(); - vector devInfo = devManager.GetRemoteDevices(); - EXPECT_EQ(devInfo.size(), 0); + auto devInfos = devManager.GetRemoteDevices(); + EXPECT_EQ(devInfos.size(), 0); } +} // namespace OHOS::Test \ No newline at end of file diff --git a/kv_store/frameworks/innerkitsimpl/kvdb/test/single_store_impl_get_top_test.cpp b/kv_store/frameworks/innerkitsimpl/kvdb/test/single_store_impl_get_top_test.cpp index 38ad5f63e249601eeff5805a44a68453cf3f161a..21f09dae8957ce87cb635a391b2720c04f38346d 100644 --- a/kv_store/frameworks/innerkitsimpl/kvdb/test/single_store_impl_get_top_test.cpp +++ b/kv_store/frameworks/innerkitsimpl/kvdb/test/single_store_impl_get_top_test.cpp @@ -22,6 +22,7 @@ #include "distributed_kv_data_manager.h" #include "types.h" +namespace OHOS::Test { using namespace testing::ext; using namespace OHOS::DistributedKv; class SingleStoreImplGetTopTest : public testing::Test { @@ -36,7 +37,6 @@ public: static std::shared_ptr singleKvStore; // declare kvstore instance. static Status initStatus; - static int MAX_VALUE_SIZE; }; const std::string VALID_SCHEMA_STRICT_DEFINE = "{\"SCHEMA_VERSION\":\"1.0\"," @@ -49,7 +49,6 @@ const std::string VALID_SCHEMA_STRICT_DEFINE = "{\"SCHEMA_VERSION\":\"1.0\"," std::shared_ptr SingleStoreImplGetTopTest::singleKvStore = nullptr; Status SingleStoreImplGetTopTest::initStatus = Status::ERROR; -int SingleStoreImplGetTopTest::MAX_VALUE_SIZE = 4 * 1024 * 1024; // max value size is 4M. void SingleStoreImplGetTopTest::SetUpTestCase(void) { @@ -283,4 +282,5 @@ HWTEST_F(SingleStoreImplGetTopTest, GetResultSetOrderByWriteTimeNoPrefix, TestSi auto status = singleKvStore->GetResultSet(query, output); ASSERT_EQ(status, NOT_SUPPORT); ASSERT_EQ(output, nullptr); -} \ No newline at end of file +} +} // namespace OHOS::Test \ No newline at end of file diff --git a/kv_store/frameworks/innerkitsimpl/kvdb/test/single_store_impl_test.cpp b/kv_store/frameworks/innerkitsimpl/kvdb/test/single_store_impl_test.cpp index b669a2a2ad3ed25aeac5bb0bc02e29db94b55d2f..0a3458f7224842a36e5c6d50c214b51a54203195 100644 --- a/kv_store/frameworks/innerkitsimpl/kvdb/test/single_store_impl_test.cpp +++ b/kv_store/frameworks/innerkitsimpl/kvdb/test/single_store_impl_test.cpp @@ -14,17 +14,31 @@ */ #include #include +#include #include #include "block_data.h" #include "dev_manager.h" #include "distributed_kv_data_manager.h" +#include "kv_store_nb_delegate.h" #include "store_manager.h" #include "sys/stat.h" #include "types.h" using namespace testing::ext; using namespace OHOS::DistributedKv; namespace OHOS::Test { + +std::vector Random(int32_t len) +{ + std::random_device randomDevice; + std::uniform_int_distribution distribution(0, std::numeric_limits::max()); + std::vector key(len); + for (int32_t i = 0; i < len; i++) { + key[i] = static_cast(distribution(randomDevice)); + } + return key; +} + class SingleStoreImplTest : public testing::Test { public: class TestObserver : public KvStoreObserver { @@ -57,6 +71,7 @@ public: std::shared_ptr CreateKVStore(std::string storeIdTest, KvStoreType type, bool encrypt, bool backup); std::shared_ptr kvStore_; + static constexpr int MAX_RESULTSET_SIZE = 8; }; void SingleStoreImplTest::SetUpTestCase(void) @@ -360,8 +375,8 @@ HWTEST_F(SingleStoreImplTest, SubscribeKvStore002, TestSize.Level0) ASSERT_EQ(status2, SUCCESS); subscribedObserver = observer; } else { - ASSERT_EQ(status1, OVER_MAX_SUBSCRIBE_LIMITS); - ASSERT_EQ(status2, OVER_MAX_SUBSCRIBE_LIMITS); + ASSERT_EQ(status1, OVER_MAX_LIMITS); + ASSERT_EQ(status2, OVER_MAX_LIMITS); unSubscribedObserver = observer; } } @@ -397,7 +412,7 @@ HWTEST_F(SingleStoreImplTest, SubscribeKvStore002, TestSize.Level0) ASSERT_EQ(status, SUCCESS); observer = std::make_shared(); status = kvStore_->SubscribeKvStore(SUBSCRIBE_TYPE_ALL, observer); - ASSERT_EQ(status, OVER_MAX_SUBSCRIBE_LIMITS); + ASSERT_EQ(status, OVER_MAX_LIMITS); } /** @@ -484,7 +499,7 @@ HWTEST_F(SingleStoreImplTest, GetEntries_Less_Prefix, TestSize.Level0) auto status = kvStore->PutBatch(input); ASSERT_EQ(status, SUCCESS); std::vector output; - status = kvStore->GetEntries({"1"}, output); + status = kvStore->GetEntries({ "1" }, output); ASSERT_NE(output.empty(), true); ASSERT_EQ(status, SUCCESS); @@ -498,7 +513,7 @@ HWTEST_F(SingleStoreImplTest, GetEntries_Less_Prefix, TestSize.Level0) status = kvStore_->PutBatch(input); ASSERT_EQ(status, SUCCESS); std::vector output1; - status = kvStore_->GetEntries({"1"}, output1); + status = kvStore_->GetEntries({ "1" }, output1); ASSERT_NE(output1.empty(), true); ASSERT_EQ(status, SUCCESS); } @@ -708,6 +723,179 @@ HWTEST_F(SingleStoreImplTest, CloseResultSet, TestSize.Level0) ASSERT_EQ(outputTmp->GetEntry(entry), ALREADY_CLOSED); } +/** + * @tc.name: ResultSetMaxSizeTest + * @tc.desc: test if kv supports 8 resultSets at the same time + * @tc.type: FUNC + * @tc.require: I4XVQQ + * @tc.author: Yang Qing + */ +HWTEST_F(SingleStoreImplTest, ResultSetMaxSizeTest_Query, TestSize.Level0) +{ + ASSERT_NE(kvStore_, nullptr); + /** + * @tc.steps:step1. Put the entry into the database. + * @tc.expected: step1. Returns SUCCESS. + */ + std::vector input; + for (int i = 0; i < 10; ++i) { + Entry entry; + entry.key = "k_" + std::to_string(i); + entry.value = "v_" + std::to_string(i); + input.push_back(entry); + } + auto status = kvStore_->PutBatch(input); + ASSERT_EQ(status, SUCCESS); + /** + * @tc.steps:step2. Get the resultset. + * @tc.expected: step2. Returns SUCCESS. + */ + DataQuery query; + query.KeyPrefix("k_"); + std::vector> outputs(MAX_RESULTSET_SIZE + 1); + for (int i = 0; i < MAX_RESULTSET_SIZE; i++) { + std::shared_ptr output; + status = kvStore_->GetResultSet(query, outputs[i]); + ASSERT_EQ(status, SUCCESS); + } + /** + * @tc.steps:step3. Get the resultset while resultset size is over the limit. + * @tc.expected: step3. Returns OVER_MAX_LIMITS. + */ + status = kvStore_->GetResultSet(query, outputs[MAX_RESULTSET_SIZE]); + ASSERT_EQ(status, OVER_MAX_LIMITS); + /** + * @tc.steps:step4. Close the resultset and getting the resultset is retried + * @tc.expected: step4. Returns SUCCESS. + */ + status = kvStore_->CloseResultSet(outputs[0]); + ASSERT_EQ(status, SUCCESS); + status = kvStore_->GetResultSet(query, outputs[MAX_RESULTSET_SIZE]); + ASSERT_EQ(status, SUCCESS); + + for (int i = 1; i <= MAX_RESULTSET_SIZE; i++) { + status = kvStore_->CloseResultSet(outputs[i]); + ASSERT_EQ(status, SUCCESS); + } +} + +/** + * @tc.name: ResultSetMaxSizeTest + * @tc.desc: test if kv supports 8 resultSets at the same time + * @tc.type: FUNC + * @tc.require: I4XVQQ + * @tc.author: Yang Qing + */ +HWTEST_F(SingleStoreImplTest, ResultSetMaxSizeTest_Prefix, TestSize.Level0) +{ + ASSERT_NE(kvStore_, nullptr); + /** + * @tc.steps:step1. Put the entry into the database. + * @tc.expected: step1. Returns SUCCESS. + */ + std::vector input; + for (int i = 0; i < 10; ++i) { + Entry entry; + entry.key = "k_" + std::to_string(i); + entry.value = "v_" + std::to_string(i); + input.push_back(entry); + } + auto status = kvStore_->PutBatch(input); + ASSERT_EQ(status, SUCCESS); + /** + * @tc.steps:step2. Get the resultset. + * @tc.expected: step2. Returns SUCCESS. + */ + std::vector> outputs(MAX_RESULTSET_SIZE + 1); + for (int i = 0; i < MAX_RESULTSET_SIZE; i++) { + std::shared_ptr output; + status = kvStore_->GetResultSet({ "k_i" }, outputs[i]); + ASSERT_EQ(status, SUCCESS); + } + /** + * @tc.steps:step3. Get the resultset while resultset size is over the limit. + * @tc.expected: step3. Returns OVER_MAX_LIMITS. + */ + status = kvStore_->GetResultSet({ "" }, outputs[MAX_RESULTSET_SIZE]); + ASSERT_EQ(status, OVER_MAX_LIMITS); + /** + * @tc.steps:step4. Close the resultset and getting the resultset is retried + * @tc.expected: step4. Returns SUCCESS. + */ + status = kvStore_->CloseResultSet(outputs[0]); + ASSERT_EQ(status, SUCCESS); + status = kvStore_->GetResultSet({ "" }, outputs[MAX_RESULTSET_SIZE]); + ASSERT_EQ(status, SUCCESS); + + for (int i = 1; i <= MAX_RESULTSET_SIZE; i++) { + status = kvStore_->CloseResultSet(outputs[i]); + ASSERT_EQ(status, SUCCESS); + } +} + +/** + * @tc.name: MaxLogSizeTest + * @tc.desc: test if the default max limit of wal is 200MB + * @tc.type: FUNC + * @tc.require: I4XVQQ + * @tc.author: Yang Qing + */ +HWTEST_F(SingleStoreImplTest, MaxLogSizeTest, TestSize.Level0) +{ + ASSERT_NE(kvStore_, nullptr); + /** + * @tc.steps:step1. Put the random entry into the database. + * @tc.expected: step1. Returns SUCCESS. + */ + std::vector key; + std::vector value; + key = Random(24); // for 24B random key + value = Random(3 * 1024 * 1024); // 3M value + EXPECT_EQ(kvStore_->Put(key, value), SUCCESS); + key = Random(40); // for 40B random key + EXPECT_EQ(kvStore_->Put(key, value), SUCCESS); + key = Random(24); // for 24B random key + value = Random(4 * 1024 * 1024); // 4M value + EXPECT_EQ(kvStore_->Put(key, value), SUCCESS); + /** + * @tc.steps:step2. Get the resultset. + * @tc.expected: step2. Returns SUCCESS. + */ + std::shared_ptr output; + auto status = kvStore_->GetResultSet({ "" }, output); + ASSERT_EQ(status, SUCCESS); + ASSERT_NE(output, nullptr); + ASSERT_EQ(output->GetCount(), 3); + EXPECT_EQ(output->MoveToFirst(), true); + /** + * @tc.steps:step3. Put more data into the database. + * @tc.expected: step3. Returns SUCCESS. + */ + for (int i = 0; i < 50; i++) { + key = Random(16); // for 16B random key + value = Random(4 * 1024 * 1024); // 4M value + EXPECT_EQ(kvStore_->Put(key, value), SUCCESS); + } + /** + * @tc.steps:step4. Put more data into the database while the log size is over the limit. + * @tc.expected: step4. Returns LOG_LIMITS_ERROR. + */ + key = Random(10); // for 16B random key + value = Random(4 * 1024 * 1024); // 1M value + EXPECT_EQ(kvStore_->Put(key, value), WAL_OVER_LIMITS); + EXPECT_EQ(kvStore_->Delete(key), WAL_OVER_LIMITS); + EXPECT_EQ(kvStore_->StartTransaction(), WAL_OVER_LIMITS); + /** + * @tc.steps:step5. Close the resultset and put again. + * @tc.expected: step4. Return SUCCESS. + */ + + status = kvStore_->CloseResultSet(output); + ASSERT_EQ(status, SUCCESS); + value = Random(1 * 1024 * 1024); // 1M value + EXPECT_EQ(kvStore_->Put(key, value), SUCCESS); +} + /** * @tc.name: Move_Offset * @tc.desc: Move the ResultSet Relative Distance @@ -826,7 +1014,7 @@ HWTEST_F(SingleStoreImplTest, RemoveDeviceData, TestSize.Level0) status = store->GetCount({}, count); ASSERT_EQ(status, SUCCESS); ASSERT_EQ(count, 10); - status = store->RemoveDeviceData(DevManager::GetInstance().GetLocalDevice().networkId); + status = store->RemoveDeviceData(DevManager::GetInstance().GetLocalDevice().uuid); ASSERT_EQ(status, SUCCESS); status = store->GetCount({}, count); ASSERT_EQ(status, SUCCESS); @@ -1015,9 +1203,7 @@ HWTEST_F(SingleStoreImplTest, RemoveNullDeviceData, TestSize.Level0) auto store = CreateKVStore("DeviceKVStore", DEVICE_COLLABORATION, false, true); ASSERT_NE(store, nullptr); std::vector input; - auto cmp = [](const Key &entry, const Key &sentry) { - return entry.Data() < sentry.Data(); - }; + auto cmp = [](const Key &entry, const Key &sentry) { return entry.Data() < sentry.Data(); }; std::map dictionary(cmp); for (int i = 0; i < 10; ++i) { Entry entry; @@ -1293,4 +1479,4 @@ HWTEST_F(SingleStoreImplTest, GetKVStoreWithRebuildTrue, TestSize.Level0) status = StoreManager::GetInstance().CloseKVStore(appId, storeId); ASSERT_EQ(status, SUCCESS); } -} \ No newline at end of file +} // namespace OHOS::Test \ No newline at end of file diff --git a/kv_store/frameworks/innerkitsimpl/kvdb/test/store_factory_test.cpp b/kv_store/frameworks/innerkitsimpl/kvdb/test/store_factory_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5f213bf18792805876f3dfe33df7653a485bc917 --- /dev/null +++ b/kv_store/frameworks/innerkitsimpl/kvdb/test/store_factory_test.cpp @@ -0,0 +1,350 @@ +/* +* Copyright (c) 2022 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 "store_factory.h" + +#include +#include +#include +#include +#include + +#include "backup_manager.h" +#include "file_ex.h" +#include "store_manager.h" +#include "store_util.h" +#include "sys/stat.h" +#include "types.h" +using namespace testing::ext; +using namespace OHOS::DistributedKv; + +static StoreId storeId = { "single_test" }; +static AppId appId = { "rekey" }; +static Options options = { + .encrypt = true, + .securityLevel = S1, + .area = EL1, + .kvStoreType = SINGLE_VERSION, + .baseDir = "/data/service/el1/public/database/rekey", +}; + +class StoreFactoryTest : public testing::Test { +public: + using DBStore = DistributedDB::KvStoreNbDelegate; + using DBManager = DistributedDB::KvStoreDelegateManager; + using DBOption = DistributedDB::KvStoreNbDelegate::Option; + using DBPassword = SecurityManager::DBPassword; + using DBStatus = DistributedDB::DBStatus; + + static constexpr int OUTDATED_TIME = (24 * 500); + static constexpr int NOT_OUTDATED_TIME = (24 * 50); + + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); + + std::chrono::system_clock::time_point GetDate(const std::string &name, const std::string &path); + bool ChangeKeyDate(const std::string &name, const std::string &path, int duration); + bool MoveToRekeyPath(Options options, StoreId storeId); + std::shared_ptr GetDBManager(const std::string &path, const AppId &appId); + DBOption GetOption(const Options &options, const DBPassword &dbPassword); + DBStatus ChangeKVStoreDate(const std::string &storeId, std::shared_ptr dbManager, + const Options &options, DBPassword &dbPassword, int time); + bool ModifyDate(int time); + static void DeleteKVStore(); +}; + +void StoreFactoryTest::SetUpTestCase(void) +{ + std::string baseDir = "/data/service/el1/public/database/rekey"; + mkdir(baseDir.c_str(), (S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH)); +} + +void StoreFactoryTest::TearDownTestCase(void) +{ + DeleteKVStore(); + (void)remove("/data/service/el1/public/database/rekey"); +} + +void StoreFactoryTest::SetUp(void) {} + +void StoreFactoryTest::TearDown(void) {} + +void StoreFactoryTest::DeleteKVStore() +{ + StoreManager::GetInstance().Delete(appId, storeId, options.baseDir); +} + +std::chrono::system_clock::time_point StoreFactoryTest::GetDate(const std::string &name, const std::string &path) +{ + std::chrono::system_clock::time_point timePoint; + auto keyPath = path + "/key/" + name + ".key"; + if (!OHOS::FileExists(keyPath)) { + return timePoint; + } + + std::vector content; + auto loaded = OHOS::LoadBufferFromFile(keyPath, content); + if (!loaded) { + return timePoint; + } + constexpr uint32_t DATE_FILE_OFFSET = 1; + constexpr uint32_t DATE_FILE_LENGTH = sizeof(time_t) / sizeof(uint8_t); + std::vector date; + date.assign(content.begin() + DATE_FILE_OFFSET, content.begin() + DATE_FILE_LENGTH + DATE_FILE_OFFSET); + timePoint = std::chrono::system_clock::from_time_t(*reinterpret_cast(const_cast(&date[0]))); + return timePoint; +} + +bool StoreFactoryTest::ChangeKeyDate(const std::string &name, const std::string &path, int duration) +{ + auto keyPath = path + "/key/" + name + ".key"; + if (!OHOS::FileExists(keyPath)) { + return false; + } + + std::vector content; + auto loaded = OHOS::LoadBufferFromFile(keyPath, content); + if (!loaded) { + return false; + } + auto time = std::chrono::system_clock::to_time_t( + std::chrono::system_clock::system_clock::now() - std::chrono::hours(duration)); + std::vector date(reinterpret_cast(&time), reinterpret_cast(&time) + sizeof(time)); + std::copy(date.begin(), date.end(), ++content.begin()); + + auto saved = OHOS::SaveBufferToFile(keyPath, content); + return saved; +} + +bool StoreFactoryTest::MoveToRekeyPath(Options options, StoreId storeId) +{ + std::string keyFileName = options.baseDir + "/key/" + storeId.storeId + ".key"; + std::string rekeyFileName = options.baseDir + "/rekey/key/" + storeId.storeId + ".new.key"; + bool res = StoreUtil::Rename(keyFileName, rekeyFileName); + res = StoreUtil::Remove(keyFileName); + return res; +} + +std::shared_ptr StoreFactoryTest::GetDBManager(const std::string &path, const AppId &appId) +{ + std::string fullPath = path + "/kvdb"; + StoreUtil::InitPath(fullPath); + std::shared_ptr dbManager = std::make_shared(appId.appId, "default"); + dbManager->SetKvStoreConfig({ fullPath }); + BackupManager::GetInstance().Init(path); + return dbManager; +} + +StoreFactoryTest::DBOption StoreFactoryTest::GetOption(const Options &options, const DBPassword &dbPassword) +{ + DBOption dbOption; + dbOption.syncDualTupleMode = true; // tuple of (appid+storeid) + dbOption.createIfNecessary = options.createIfMissing; + dbOption.isNeedRmCorruptedDb = options.rebuild; + dbOption.isMemoryDb = (!options.persistent); + dbOption.isEncryptedDb = options.encrypt; + if (options.encrypt) { + dbOption.cipher = DistributedDB::CipherType::AES_256_GCM; + dbOption.passwd = dbPassword.password; + } + + dbOption.conflictResolvePolicy = options.kvStoreType == KvStoreType::SINGLE_VERSION + ? DistributedDB::LAST_WIN + : KvStoreType::DEVICE_COLLABORATION; + + dbOption.schema = options.schema; + dbOption.createDirByStoreIdOnly = true; + dbOption.secOption = StoreUtil::GetDBSecurity(options.securityLevel); + return dbOption; +} + +StoreFactoryTest::DBStatus StoreFactoryTest::ChangeKVStoreDate(const std::string &storeId, + std::shared_ptr dbManager, const Options &options, DBPassword &dbPassword, int time) +{ + DBStatus status; + const auto dbOption = GetOption(options, dbPassword); + DBStore *store = nullptr; + dbManager->GetKvStore(storeId, dbOption, [&status, &store](auto dbStatus, auto *dbStore) { + status = dbStatus; + store = dbStore; + }); + if (!ChangeKeyDate(storeId, options.baseDir, time)) { + std::cout << "failed" << std::endl; + } + dbPassword = SecurityManager::GetInstance().GetDBPassword(storeId, options.baseDir, false); + auto dbStatus = store->Rekey(dbPassword.password); + dbManager->CloseKvStore(store); + return dbStatus; +} + +bool StoreFactoryTest::ModifyDate(int time) +{ + auto dbPassword = SecurityManager::GetInstance().GetDBPassword(storeId, options.baseDir, false); + auto dbManager = GetDBManager(options.baseDir, appId); + auto dbstatus = ChangeKVStoreDate(storeId, dbManager, options, dbPassword, time); + return StoreUtil::ConvertStatus(dbstatus) == SUCCESS; +} + +/** +* @tc.name: Rekey +* @tc.desc: test rekey function +* @tc.type: FUNC +* @tc.require: +* @tc.author: Cui Renjie +*/ +HWTEST_F(StoreFactoryTest, Rekey, TestSize.Level1) +{ + Status status = DB_ERROR; + StoreManager::GetInstance().GetKVStore(appId, storeId, options, status); + status = StoreManager::GetInstance().CloseKVStore(appId, storeId); + ASSERT_EQ(status, SUCCESS); + + ASSERT_TRUE(ModifyDate(OUTDATED_TIME)); + + auto oldKeyTime = GetDate(storeId, options.baseDir); + ASSERT_FALSE(std::chrono::system_clock::now() - oldKeyTime < std::chrono::seconds(2)); + + StoreManager::GetInstance().GetKVStore(appId, storeId, options, status); + status = StoreManager::GetInstance().CloseKVStore(appId, storeId); + ASSERT_EQ(status, SUCCESS); + + std::vector newDate; + auto newKeyTime = GetDate(storeId, options.baseDir); + ASSERT_TRUE(std::chrono::system_clock::now() - newKeyTime < std::chrono::seconds(2)); +} + +/** +* @tc.name: RekeyNotOutdated +* @tc.desc: try to rekey kvstore with not outdated password +* @tc.type: FUNC +* @tc.require: +* @tc.author: Cui Renjie +*/ +HWTEST_F(StoreFactoryTest, RekeyNotOutdated, TestSize.Level1) +{ + Status status = DB_ERROR; + StoreManager::GetInstance().GetKVStore(appId, storeId, options, status); + status = StoreManager::GetInstance().CloseKVStore(appId, storeId); + ASSERT_EQ(status, SUCCESS); + + ASSERT_TRUE(ModifyDate(NOT_OUTDATED_TIME)); + auto oldKeyTime = GetDate(storeId, options.baseDir); + + StoreManager::GetInstance().GetKVStore(appId, storeId, options, status); + status = StoreManager::GetInstance().CloseKVStore(appId, storeId); + ASSERT_EQ(status, SUCCESS); + + auto newKeyTime = GetDate(storeId, options.baseDir); + ASSERT_EQ(oldKeyTime, newKeyTime); +} + +/** +* @tc.name: RekeyInterrupted0 +* @tc.desc: mock the situation that open store after rekey was interrupted last time, +* which caused key file lost but rekey key file exist. +* @tc.type: FUNC +* @tc.require: +* @tc.author: Cui Renjie +*/ +HWTEST_F(StoreFactoryTest, RekeyInterruptedWhileChangeKeyFile, TestSize.Level1) +{ + Status status = DB_ERROR; + StoreManager::GetInstance().GetKVStore(appId, storeId, options, status); + ASSERT_EQ(status, SUCCESS); + auto oldKeyTime = GetDate(storeId, options.baseDir); + + status = StoreManager::GetInstance().CloseKVStore(appId, storeId); + ASSERT_EQ(status, SUCCESS); + ASSERT_TRUE(MoveToRekeyPath(options, storeId)); + + StoreManager::GetInstance().GetKVStore(appId, storeId, options, status); + status = StoreManager::GetInstance().CloseKVStore(appId, storeId); + ASSERT_EQ(status, SUCCESS); + std::string keyFileName = options.baseDir + "/key/" + storeId.storeId + ".key"; + auto isKeyExist = StoreUtil::IsFileExist(keyFileName); + ASSERT_TRUE(isKeyExist); + + auto newKeyTime = GetDate(storeId, options.baseDir); + ASSERT_EQ(oldKeyTime, newKeyTime); +} + +/** +* @tc.name: RekeyInterrupted1 +* @tc.desc: mock the situation that open store after rekey was interrupted last time, +* which caused key file not changed but rekey key file exist. +* @tc.type: FUNC +* @tc.require: +* @tc.author: Cui Renjie +*/ +HWTEST_F(StoreFactoryTest, RekeyInterruptedBeforeChangeKeyFile, TestSize.Level1) +{ + Status status = DB_ERROR; + StoreManager::GetInstance().GetKVStore(appId, storeId, options, status); + ASSERT_EQ(status, SUCCESS); + auto oldKeyTime = GetDate(storeId, options.baseDir); + + status = StoreManager::GetInstance().CloseKVStore(appId, storeId); + ASSERT_EQ(status, SUCCESS); + ASSERT_EQ(MoveToRekeyPath(options, storeId), true); + + StoreId newStoreId = { "newStore" }; + std::string mockPath = options.baseDir; + StoreManager::GetInstance().GetKVStore(appId, newStoreId, options, status); + + std::string keyFileName = options.baseDir + "/key/" + storeId.storeId + ".key"; + std::string mockKeyFileName = options.baseDir + "/key/" + newStoreId.storeId + ".key"; + StoreUtil::Rename(mockKeyFileName, keyFileName); + StoreUtil::Remove(mockKeyFileName); + auto isKeyExist = StoreUtil::IsFileExist(mockKeyFileName); + ASSERT_FALSE(isKeyExist); + isKeyExist = StoreUtil::IsFileExist(keyFileName); + ASSERT_TRUE(isKeyExist); + + StoreManager::GetInstance().GetKVStore(appId, storeId, options, status); + status = StoreManager::GetInstance().CloseKVStore(appId, storeId); + ASSERT_EQ(status, SUCCESS); + + isKeyExist = StoreUtil::IsFileExist(keyFileName); + ASSERT_TRUE(isKeyExist); + + auto newKeyTime = GetDate(storeId, options.baseDir); + ASSERT_EQ(oldKeyTime, newKeyTime); +} + +/** +* @tc.name: RekeyNoPwdFile +* @tc.desc: try to open kvstore and execute RekeyRecover() without key and rekey key files. +* @tc.type: FUNC +* @tc.require: +* @tc.author: Cui Renjie +*/ +HWTEST_F(StoreFactoryTest, RekeyNoPwdFile, TestSize.Level1) +{ + Status status = DB_ERROR; + StoreManager::GetInstance().GetKVStore(appId, storeId, options, status); + ASSERT_EQ(status, SUCCESS); + + status = StoreManager::GetInstance().CloseKVStore(appId, storeId); + ASSERT_EQ(status, SUCCESS); + std::string keyFileName = options.baseDir + "/key/" + storeId.storeId + ".key"; + StoreUtil::Remove(keyFileName); + + auto isKeyExist = StoreUtil::IsFileExist(keyFileName); + ASSERT_EQ(isKeyExist, false); + + StoreManager::GetInstance().GetKVStore(appId, storeId, options, status); + ASSERT_EQ(status, CRYPT_ERROR); +} diff --git a/kv_store/frameworks/innerkitsimpl/kvdb/test/store_util_test.cpp b/kv_store/frameworks/innerkitsimpl/kvdb/test/store_util_test.cpp index 942fb8f2bdc49db1a52958e0bc94fb44df04092e..f93cc7e6280b0c038c14c164067cf42fd2b1b872 100644 --- a/kv_store/frameworks/innerkitsimpl/kvdb/test/store_util_test.cpp +++ b/kv_store/frameworks/innerkitsimpl/kvdb/test/store_util_test.cpp @@ -20,6 +20,7 @@ #include "store_manager.h" #include "types.h" +namespace OHOS::Test { using namespace testing::ext; using namespace OHOS::DistributedKv; @@ -127,4 +128,5 @@ HWTEST_F(StoreUtilTest, GetObserverMode, TestSize.Level1) mode = storeUtil_.GetObserverMode(SUBSCRIBE_TYPE_ALL); ASSERT_EQ(mode, DistributedDB::OBSERVER_CHANGES_FOREIGN | DistributedDB::OBSERVER_CHANGES_NATIVE); -} \ No newline at end of file +} +} // namespace OHOS::Test \ No newline at end of file diff --git a/kv_store/frameworks/jskitsimpl/distributeddata/include/napi_queue.h b/kv_store/frameworks/jskitsimpl/distributeddata/include/napi_queue.h index f401df12d41ae76b6653b92a9e6447a107be6c78..f989c4b684e86c90afe4eaeabf94461a5d47d9d9 100644 --- a/kv_store/frameworks/jskitsimpl/distributeddata/include/napi_queue.h +++ b/kv_store/frameworks/jskitsimpl/distributeddata/include/napi_queue.h @@ -98,6 +98,15 @@ private: } \ } while (0) +#define ASSERT_CALL(env, theCall, object) \ + do { \ + if ((theCall) != napi_ok) { \ + delete (object); \ + GET_AND_THROW_LAST_ERROR((env)); \ + return nullptr; \ + } \ + } while (0) + class NapiQueue { public: static napi_value AsyncWork(napi_env env, std::shared_ptr ctxt, const std::string& name, diff --git a/kv_store/frameworks/jskitsimpl/distributeddata/src/js_device_kv_store.cpp b/kv_store/frameworks/jskitsimpl/distributeddata/src/js_device_kv_store.cpp index 0e7d5dc104b63a7a412afac28c9e445b28de0482..9d132f1b7643b92dfae37bedee474d907a850874 100644 --- a/kv_store/frameworks/jskitsimpl/distributeddata/src/js_device_kv_store.cpp +++ b/kv_store/frameworks/jskitsimpl/distributeddata/src/js_device_kv_store.cpp @@ -475,7 +475,7 @@ napi_value JsDeviceKVStore::New(napi_env env, napi_callback_info info) CHECK_RETURN_VOID(kvStore != nullptr, "finalize null!"); delete kvStore; }; - NAPI_CALL(env, napi_wrap(env, ctxt->self, kvStore, finalize, nullptr, nullptr)); + ASSERT_CALL(env, napi_wrap(env, ctxt->self, kvStore, finalize, nullptr, nullptr), kvStore); return ctxt->self; } } // namespace OHOS::DistributedData diff --git a/kv_store/frameworks/jskitsimpl/distributeddata/src/js_field_node.cpp b/kv_store/frameworks/jskitsimpl/distributeddata/src/js_field_node.cpp index 186f070dd5f7a004162076eadcafc318ce10fa97..5762b4fb56d067c934f5cdd106ff6eccf92c34bb 100644 --- a/kv_store/frameworks/jskitsimpl/distributeddata/src/js_field_node.cpp +++ b/kv_store/frameworks/jskitsimpl/distributeddata/src/js_field_node.cpp @@ -97,7 +97,7 @@ napi_value JsFieldNode::New(napi_env env, napi_callback_info info) CHECK_RETURN_VOID(field != nullptr, "finalize null!"); delete field; }; - NAPI_CALL(env, napi_wrap(env, ctxt->self, fieldNode, finalize, nullptr, nullptr)); + ASSERT_CALL(env, napi_wrap(env, ctxt->self, fieldNode, finalize, nullptr, nullptr), fieldNode); return ctxt->self; } diff --git a/kv_store/frameworks/jskitsimpl/distributeddata/src/js_kv_manager.cpp b/kv_store/frameworks/jskitsimpl/distributeddata/src/js_kv_manager.cpp index 7933a3262039d1e7c109fd25b9c4f3b86026f53c..17b15e38cd6ac3a5587c372114571c1db9846164 100644 --- a/kv_store/frameworks/jskitsimpl/distributeddata/src/js_kv_manager.cpp +++ b/kv_store/frameworks/jskitsimpl/distributeddata/src/js_kv_manager.cpp @@ -20,7 +20,6 @@ #include "js_util.h" #include "log_print.h" #include "napi_queue.h" -#include using namespace OHOS::DistributedKv; @@ -143,14 +142,7 @@ napi_value JsKVManager::GetKVStore(napi_env env, napi_callback_info info) ZLOGD("GetSingleKvStore status:%{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "GetSingleKvStore() failed!"); - ZLOGI("thread sleep start"); - std::this_thread::sleep_for(std::chrono::seconds(3)); - ZLOGI("thread sleep end, ctxt->kvStore->SetNative(kvStore) start"); - uint32_t result; - napi_reference_ref(ctxt->env,ctxt->ref,&result); - ZLOGI("ctxt->ref:%{public}d",result); ctxt->kvStore->SetNative(kvStore); - ZLOGI("ctxt->kvStore->SetNative(kvStore) end"); ctxt->kvStore->SetSchemaInfo(!ctxt->options.schema.empty()); ctxt->kvStore->SetContextParam(kvm->param_); ctxt->kvStore->SetUvQueue(kvm->uvQueue_); @@ -398,7 +390,7 @@ napi_value JsKVManager::New(napi_env env, napi_callback_info info) CHECK_RETURN_VOID(kvManager != nullptr, "finalize null!"); delete kvManager; }; - NAPI_CALL(env, napi_wrap(env, ctxt->self, kvManager, finalize, nullptr, nullptr)); + ASSERT_CALL(env, napi_wrap(env, ctxt->self, kvManager, finalize, nullptr, nullptr), kvManager); return ctxt->self; } diff --git a/kv_store/frameworks/jskitsimpl/distributeddata/src/js_kv_store_resultset.cpp b/kv_store/frameworks/jskitsimpl/distributeddata/src/js_kv_store_resultset.cpp index b55ddd52c209c074ba7841a50fe1809b5e8db2ee..892822b33b657785ad40cb018a3f6668ba96704b 100644 --- a/kv_store/frameworks/jskitsimpl/distributeddata/src/js_kv_store_resultset.cpp +++ b/kv_store/frameworks/jskitsimpl/distributeddata/src/js_kv_store_resultset.cpp @@ -71,7 +71,7 @@ napi_value JsKVStoreResultSet::New(napi_env env, napi_callback_info info) CHECK_RETURN_VOID(resultSet != nullptr, "finalize null!"); delete resultSet; }; - NAPI_CALL(env, napi_wrap(env, ctxt->self, resultSet, finalize, nullptr, nullptr)); + ASSERT_CALL(env, napi_wrap(env, ctxt->self, resultSet, finalize, nullptr, nullptr), resultSet); return ctxt->self; } diff --git a/kv_store/frameworks/jskitsimpl/distributeddata/src/js_query.cpp b/kv_store/frameworks/jskitsimpl/distributeddata/src/js_query.cpp index feda047779ab26ffbfb4aef87088f9814646e4e0..ca8836f5dd74787b7a09cf05b52d743eb4239fbc 100644 --- a/kv_store/frameworks/jskitsimpl/distributeddata/src/js_query.cpp +++ b/kv_store/frameworks/jskitsimpl/distributeddata/src/js_query.cpp @@ -80,7 +80,7 @@ napi_value JsQuery::New(napi_env env, napi_callback_info info) CHECK_RETURN_VOID(query != nullptr, "finalize null!"); delete query; }; - NAPI_CALL(env, napi_wrap(env, ctxt->self, query, finalize, nullptr, nullptr)); + ASSERT_CALL(env, napi_wrap(env, ctxt->self, query, finalize, nullptr, nullptr), query); return ctxt->self; } diff --git a/kv_store/frameworks/jskitsimpl/distributeddata/src/js_schema.cpp b/kv_store/frameworks/jskitsimpl/distributeddata/src/js_schema.cpp index 2be1e27167099437859be5d9eefe62105a9af669..c13b67edcc9fac7d8eaf83ed80bb1695e17cd035 100644 --- a/kv_store/frameworks/jskitsimpl/distributeddata/src/js_schema.cpp +++ b/kv_store/frameworks/jskitsimpl/distributeddata/src/js_schema.cpp @@ -75,7 +75,7 @@ napi_value JsSchema::New(napi_env env, napi_callback_info info) CHECK_RETURN_VOID(schema != nullptr, "finalize null!"); delete schema; }; - NAPI_CALL(env, napi_wrap(env, ctxt->self, schema, finalize, nullptr, nullptr)); + ASSERT_CALL(env, napi_wrap(env, ctxt->self, schema, finalize, nullptr, nullptr), schema); return ctxt->self; } diff --git a/kv_store/frameworks/jskitsimpl/distributeddata/src/js_single_kv_store.cpp b/kv_store/frameworks/jskitsimpl/distributeddata/src/js_single_kv_store.cpp index 8cd0ed9ef09136e38079b2e3f303064fe0d9c190..504b3eb7ad9b58be0ba83b777859cad79688b23c 100644 --- a/kv_store/frameworks/jskitsimpl/distributeddata/src/js_single_kv_store.cpp +++ b/kv_store/frameworks/jskitsimpl/distributeddata/src/js_single_kv_store.cpp @@ -473,7 +473,7 @@ napi_value JsSingleKVStore::New(napi_env env, napi_callback_info info) CHECK_RETURN_VOID(kvStore != nullptr, "finalize null!"); delete kvStore; }; - NAPI_CALL(env, napi_wrap(env, ctxt->self, kvStore, finalize, nullptr, nullptr)); + ASSERT_CALL(env, napi_wrap(env, ctxt->self, kvStore, finalize, nullptr, nullptr), kvStore); return ctxt->self; } } // namespace OHOS::DistributedData diff --git a/kv_store/frameworks/jskitsimpl/distributeddata/src/napi_queue.cpp b/kv_store/frameworks/jskitsimpl/distributeddata/src/napi_queue.cpp index f225e70b76d78a6abba61958c8a01ed6793b6b43..f91afc4b2576b263ddef2812c0f7bae40761b649 100644 --- a/kv_store/frameworks/jskitsimpl/distributeddata/src/napi_queue.cpp +++ b/kv_store/frameworks/jskitsimpl/distributeddata/src/napi_queue.cpp @@ -23,12 +23,17 @@ ContextBase::~ContextBase() ZLOGD("no memory leak after callback or promise[resolved/rejected]"); if (env != nullptr) { if (work != nullptr) { - napi_delete_async_work(env, work); + auto status = napi_delete_async_work(env, work); + ZLOGD("status:%{public}d", status); } if (callbackRef != nullptr) { - napi_delete_reference(env, callbackRef); + auto status = napi_delete_reference(env, callbackRef); + ZLOGD("status:%{public}d", status); + } + if (selfRef != nullptr) { + auto status = napi_delete_reference(env, selfRef); + ZLOGD("status:%{public}d", status); } - napi_delete_reference(env, selfRef); env = nullptr; } } @@ -42,7 +47,9 @@ void ContextBase::GetCbInfo(napi_env envi, napi_callback_info info, NapiCbInfoPa CHECK_STATUS_RETURN_VOID(this, "napi_get_cb_info failed!"); CHECK_ARGS_RETURN_VOID(this, argc <= ARGC_MAX, "too many arguments!"); CHECK_ARGS_RETURN_VOID(this, self != nullptr, "no JavaScript this argument!"); - napi_create_reference(env, self, 1, &selfRef); + if (!sync) { + napi_create_reference(env, self, 1, &selfRef); + } status = napi_unwrap(env, self, &native); CHECK_STATUS_RETURN_VOID(this, "self unwrap failed!"); @@ -72,8 +79,6 @@ napi_value NapiQueue::AsyncWork(napi_env env, std::shared_ptr ctxt, NapiAsyncExecute execute, NapiAsyncComplete complete) { ZLOGD("name=%{public}s", name.c_str()); - ctxt->execute = std::move(execute); - ctxt->complete = std::move(complete); napi_value promise = nullptr; if (ctxt->callbackRef == nullptr) { @@ -108,8 +113,10 @@ napi_value NapiQueue::AsyncWork(napi_env env, std::shared_ptr ctxt, GenerateOutput(ctxt); }, reinterpret_cast(ctxt.get()), &ctxt->work); - napi_queue_async_work(ctxt->env, ctxt->work); + ctxt->execute = std::move(execute); + ctxt->complete = std::move(complete); ctxt->hold = ctxt; // save crossing-thread ctxt. + napi_queue_async_work(ctxt->env, ctxt->work); return promise; } @@ -143,6 +150,8 @@ void NapiQueue::GenerateOutput(ContextBase* ctxt) ZLOGD("call callback function"); napi_call_function(ctxt->env, nullptr, callback, RESULT_ALL, result, &callbackResult); } + ctxt->execute = nullptr; + ctxt->complete = nullptr; ctxt->hold.reset(); // release ctxt. } } // namespace OHOS::DistributedData diff --git a/kv_store/frameworks/jskitsimpl/distributeddata/src/uv_queue.cpp b/kv_store/frameworks/jskitsimpl/distributeddata/src/uv_queue.cpp index 17938431bbf7274e6b53c2c76c7fc9591feda7a5..a54641eff80b4cd8e007123def36d78489526a95 100644 --- a/kv_store/frameworks/jskitsimpl/distributeddata/src/uv_queue.cpp +++ b/kv_store/frameworks/jskitsimpl/distributeddata/src/uv_queue.cpp @@ -53,9 +53,14 @@ void UvQueue::AsyncCall(NapiCallbackGetter getter, NapiArgsGenerator genArgs) delete data; delete work; }); + napi_handle_scope scope = nullptr; + napi_open_handle_scope(entry->env, &scope); napi_value method = entry->callback(entry->env); if (method == nullptr) { ZLOGE("the callback is invalid, maybe is cleared!"); + if (scope != nullptr) { + napi_close_handle_scope(entry->env, scope); + } return ; } int argc = 0; @@ -72,6 +77,9 @@ void UvQueue::AsyncCall(NapiCallbackGetter getter, NapiArgsGenerator genArgs) if (status != napi_ok) { ZLOGE("notify data change failed status:%{public}d.", status); } + if (scope != nullptr) { + napi_close_handle_scope(entry->env, scope); + } }); } diff --git a/kv_store/frameworks/jskitsimpl/distributedkvstore/include/napi_queue.h b/kv_store/frameworks/jskitsimpl/distributedkvstore/include/napi_queue.h index 29d9a95e69b61bb6c4956437ba39e328c6442889..234100f00f673f36ebb33a59cd9074e392109672 100644 --- a/kv_store/frameworks/jskitsimpl/distributedkvstore/include/napi_queue.h +++ b/kv_store/frameworks/jskitsimpl/distributedkvstore/include/napi_queue.h @@ -102,6 +102,15 @@ private: #define ASSERT_NULL(condition, message) ASSERT(condition, message, nullptr) \ +#define ASSERT_CALL(env, theCall, object) \ + do { \ + if ((theCall) != napi_ok) { \ + delete (object); \ + GET_AND_THROW_LAST_ERROR((env)); \ + return nullptr; \ + } \ + } while (0) + class NapiQueue { public: static napi_value AsyncWork(napi_env env, std::shared_ptr ctxt, const std::string& name, diff --git a/kv_store/frameworks/jskitsimpl/distributedkvstore/src/js_device_kv_store.cpp b/kv_store/frameworks/jskitsimpl/distributedkvstore/src/js_device_kv_store.cpp index 2e6fe5dfe80eeceada8c86a9c1c48eda1ef102c9..f6b4f874cb96822b5f74a8bb3018735ab773addf 100644 --- a/kv_store/frameworks/jskitsimpl/distributedkvstore/src/js_device_kv_store.cpp +++ b/kv_store/frameworks/jskitsimpl/distributedkvstore/src/js_device_kv_store.cpp @@ -323,7 +323,7 @@ napi_value JsDeviceKVStore::New(napi_env env, napi_callback_info info) ASSERT_VOID(kvStore != nullptr, "finalize null!"); delete kvStore; }; - NAPI_CALL(env, napi_wrap(env, ctxt->self, kvStore, finalize, nullptr, nullptr)); + ASSERT_CALL(env, napi_wrap(env, ctxt->self, kvStore, finalize, nullptr, nullptr), kvStore); return ctxt->self; } } // namespace OHOS::DistributedKVStore diff --git a/kv_store/frameworks/jskitsimpl/distributedkvstore/src/js_error_utils.cpp b/kv_store/frameworks/jskitsimpl/distributedkvstore/src/js_error_utils.cpp index 831039653c0bf12dbd773ffdde9c5d33f3db0148..7904735dc4f8cd0a5f3d38f4811d8925096c2377 100644 --- a/kv_store/frameworks/jskitsimpl/distributedkvstore/src/js_error_utils.cpp +++ b/kv_store/frameworks/jskitsimpl/distributedkvstore/src/js_error_utils.cpp @@ -15,22 +15,23 @@ #define LOG_TAG "JS_ERROR_UTILS" #include "js_error_utils.h" + #include namespace OHOS::DistributedKVStore { using JsErrorCode = OHOS::DistributedKVStore::JsErrorCode; static constexpr JsErrorCode JS_ERROR_CODE_MSGS[] = { - {Status::INVALID_ARGUMENT, 401, "Parameter error."}, - {Status::STORE_NOT_OPEN, 0, ""}, - {Status::STORE_ALREADY_SUBSCRIBE, 0, ""}, - {Status::STORE_NOT_SUBSCRIBE, 0, ""}, - {Status::NOT_FOUND, 15100004, "Not found."}, - {Status::STORE_META_CHANGED, 15100002, "Open existed database with changed options."}, - {Status::PERMISSION_DENIED, 202, "Permission denied"}, - {Status::CRYPT_ERROR, 15100003, "Database corrupted."}, - {Status::OVER_MAX_SUBSCRIBE_LIMITS, 15100001, "Over max subscribe limits."}, - {Status::ALREADY_CLOSED, 15100005, "Database or result set already closed."}, + { Status::INVALID_ARGUMENT, 401, "Parameter error." }, + { Status::STORE_NOT_OPEN, 0, "" }, + { Status::STORE_ALREADY_SUBSCRIBE, 0, "" }, + { Status::STORE_NOT_SUBSCRIBE, 0, "" }, + { Status::NOT_FOUND, 15100004, "Not found." }, + { Status::STORE_META_CHANGED, 15100002, "Open existed database with changed options." }, + { Status::PERMISSION_DENIED, 202, "Permission denied" }, + { Status::CRYPT_ERROR, 15100003, "Database corrupted." }, + { Status::OVER_MAX_LIMITS, 15100001, "Over max subscribe limits." }, + { Status::ALREADY_CLOSED, 15100005, "Database or result set already closed." }, }; const std::optional GetJsErrorCode(int32_t errorCode) diff --git a/kv_store/frameworks/jskitsimpl/distributedkvstore/src/js_field_node.cpp b/kv_store/frameworks/jskitsimpl/distributedkvstore/src/js_field_node.cpp index b73e5eff27e393fb2b76078b98e10c6f1f53bccd..872ef1bd0c50426629b356e6fb11a5c25df6acd7 100644 --- a/kv_store/frameworks/jskitsimpl/distributedkvstore/src/js_field_node.cpp +++ b/kv_store/frameworks/jskitsimpl/distributedkvstore/src/js_field_node.cpp @@ -97,7 +97,7 @@ napi_value JsFieldNode::New(napi_env env, napi_callback_info info) ASSERT_VOID(field != nullptr, "finalize null!"); delete field; }; - NAPI_CALL(env, napi_wrap(env, ctxt->self, fieldNode, finalize, nullptr, nullptr)); + ASSERT_CALL(env, napi_wrap(env, ctxt->self, fieldNode, finalize, nullptr, nullptr), fieldNode); return ctxt->self; } diff --git a/kv_store/frameworks/jskitsimpl/distributedkvstore/src/js_kv_manager.cpp b/kv_store/frameworks/jskitsimpl/distributedkvstore/src/js_kv_manager.cpp index cb786e29d3bd224b6d0ead5a29724aa5246d0d33..4870603c7a8b89d5a103471ff8930fcad61ce51a 100644 --- a/kv_store/frameworks/jskitsimpl/distributedkvstore/src/js_kv_manager.cpp +++ b/kv_store/frameworks/jskitsimpl/distributedkvstore/src/js_kv_manager.cpp @@ -21,7 +21,6 @@ #include "log_print.h" #include "napi_queue.h" #include "js_error_utils.h" -#include using namespace OHOS::DistributedKv; @@ -151,11 +150,7 @@ napi_value JsKVManager::GetKVStore(napi_env env, napi_callback_info info) ctxt->status = (GenerateNapiError(status, ctxt->jsCode, ctxt->error) == Status::SUCCESS) ? napi_ok : napi_generic_failure; - ZLOGI("thread sleep start"); - std::this_thread::sleep_for(std::chrono::seconds(10)); - ZLOGI("thread sleep end, ctxt->kvStore->SetKvStorePtr(kvStore) start"); ctxt->kvStore->SetKvStorePtr(kvStore); - ZLOGI("ctxt->kvStore->SetKvStorePtr(kvStore) end"); ctxt->kvStore->SetSchemaInfo(!ctxt->options.schema.empty()); ctxt->kvStore->SetContextParam(kvm->param_); ctxt->kvStore->SetUvQueue(kvm->uvQueue_); @@ -415,7 +410,7 @@ napi_value JsKVManager::New(napi_env env, napi_callback_info info) ASSERT_VOID(kvManager != nullptr, "finalize null!"); delete kvManager; }; - NAPI_CALL(env, napi_wrap(env, ctxt->self, kvManager, finalize, nullptr, nullptr)); + ASSERT_CALL(env, napi_wrap(env, ctxt->self, kvManager, finalize, nullptr, nullptr), kvManager); return ctxt->self; } diff --git a/kv_store/frameworks/jskitsimpl/distributedkvstore/src/js_kv_store_resultset.cpp b/kv_store/frameworks/jskitsimpl/distributedkvstore/src/js_kv_store_resultset.cpp index 68e1760f201fbec10022d272953d9f844db544a1..a967b4c42ddeefc26568f0cc3738f574163cb20b 100644 --- a/kv_store/frameworks/jskitsimpl/distributedkvstore/src/js_kv_store_resultset.cpp +++ b/kv_store/frameworks/jskitsimpl/distributedkvstore/src/js_kv_store_resultset.cpp @@ -71,7 +71,7 @@ napi_value JsKVStoreResultSet::New(napi_env env, napi_callback_info info) ASSERT_VOID(resultSet != nullptr, "finalize null!"); delete resultSet; }; - NAPI_CALL(env, napi_wrap(env, ctxt->self, resultSet, finalize, nullptr, nullptr)); + ASSERT_CALL(env, napi_wrap(env, ctxt->self, resultSet, finalize, nullptr, nullptr), resultSet); return ctxt->self; } diff --git a/kv_store/frameworks/jskitsimpl/distributedkvstore/src/js_query.cpp b/kv_store/frameworks/jskitsimpl/distributedkvstore/src/js_query.cpp index 13c0173474b3cb35677e2f8d731d70bb762958e6..1e29df24bec533db527336d5c64140ccf75daf06 100644 --- a/kv_store/frameworks/jskitsimpl/distributedkvstore/src/js_query.cpp +++ b/kv_store/frameworks/jskitsimpl/distributedkvstore/src/js_query.cpp @@ -80,7 +80,7 @@ napi_value JsQuery::New(napi_env env, napi_callback_info info) ASSERT_VOID(query != nullptr, "finalize null!"); delete query; }; - NAPI_CALL(env, napi_wrap(env, ctxt->self, query, finalize, nullptr, nullptr)); + ASSERT_CALL(env, napi_wrap(env, ctxt->self, query, finalize, nullptr, nullptr), query); return ctxt->self; } diff --git a/kv_store/frameworks/jskitsimpl/distributedkvstore/src/js_schema.cpp b/kv_store/frameworks/jskitsimpl/distributedkvstore/src/js_schema.cpp index 12ce7a873a234a893a1cc02387248e61076ea846..84e60a9bec944831721eb27b9fdeee2548757281 100644 --- a/kv_store/frameworks/jskitsimpl/distributedkvstore/src/js_schema.cpp +++ b/kv_store/frameworks/jskitsimpl/distributedkvstore/src/js_schema.cpp @@ -75,7 +75,7 @@ napi_value JsSchema::New(napi_env env, napi_callback_info info) ASSERT_VOID(schema != nullptr, "finalize null!"); delete schema; }; - NAPI_CALL(env, napi_wrap(env, ctxt->self, schema, finalize, nullptr, nullptr)); + ASSERT_CALL(env, napi_wrap(env, ctxt->self, schema, finalize, nullptr, nullptr), schema); return ctxt->self; } diff --git a/kv_store/frameworks/jskitsimpl/distributedkvstore/src/js_single_kv_store.cpp b/kv_store/frameworks/jskitsimpl/distributedkvstore/src/js_single_kv_store.cpp index 451a2a17d23f293c2bd3cdbfe5751fc427e37943..70758ae6f755c97ef679f3030133842f0ed86eef 100644 --- a/kv_store/frameworks/jskitsimpl/distributedkvstore/src/js_single_kv_store.cpp +++ b/kv_store/frameworks/jskitsimpl/distributedkvstore/src/js_single_kv_store.cpp @@ -1267,7 +1267,7 @@ napi_value JsSingleKVStore::New(napi_env env, napi_callback_info info) ASSERT_VOID(kvStore != nullptr, "finalize null!"); delete kvStore; }; - NAPI_CALL(env, napi_wrap(env, ctxt->self, kvStore, finalize, nullptr, nullptr)); + ASSERT_CALL(env, napi_wrap(env, ctxt->self, kvStore, finalize, nullptr, nullptr), kvStore); return ctxt->self; } } // namespace OHOS::DistributedKVStore diff --git a/kv_store/frameworks/jskitsimpl/distributedkvstore/src/js_util.cpp b/kv_store/frameworks/jskitsimpl/distributedkvstore/src/js_util.cpp index beabe9dcd5c03ba55ce6f9e82b86d718f1641548..8945b21fab67263473a9044bd7acea307cd8f3ff 100644 --- a/kv_store/frameworks/jskitsimpl/distributedkvstore/src/js_util.cpp +++ b/kv_store/frameworks/jskitsimpl/distributedkvstore/src/js_util.cpp @@ -1166,12 +1166,8 @@ JSUtil::StatusMsg JSUtil::GetCurrentAbilityParam(napi_env env, ContextParam &par if (hapInfo != nullptr) { param.hapName = hapInfo->moduleName; } - auto appInfo = context->GetApplicationInfo(); - if (appInfo != nullptr) { - param.isSystemApp = appInfo->isSystemApp; - } - ZLOGI("area:%{public}d hapName:%{public}s baseDir:%{public}s isSystemApp:%{public}d", param.area, - param.hapName.c_str(), param.baseDir.c_str(), param.isSystemApp); + ZLOGI("area:%{public}d hapName:%{public}s baseDir:%{public}s", param.area, param.hapName.c_str(), + param.baseDir.c_str()); return napi_ok; } diff --git a/kv_store/frameworks/jskitsimpl/distributedkvstore/src/napi_queue.cpp b/kv_store/frameworks/jskitsimpl/distributedkvstore/src/napi_queue.cpp index 45c9c97c8b28564fcbbb8137479147593a0b80a4..09b1405b82606edce47369c79acae90335c4cfc3 100644 --- a/kv_store/frameworks/jskitsimpl/distributedkvstore/src/napi_queue.cpp +++ b/kv_store/frameworks/jskitsimpl/distributedkvstore/src/napi_queue.cpp @@ -23,12 +23,17 @@ ContextBase::~ContextBase() ZLOGD("no memory leak after callback or promise[resolved/rejected]"); if (env != nullptr) { if (work != nullptr) { - napi_delete_async_work(env, work); + auto status = napi_delete_async_work(env, work); + ZLOGD("status:%{public}d", status); } if (callbackRef != nullptr) { - napi_delete_reference(env, callbackRef); + auto status = napi_delete_reference(env, callbackRef); + ZLOGD("status:%{public}d", status); + } + if (selfRef != nullptr) { + auto status = napi_delete_reference(env, selfRef); + ZLOGD("status:%{public}d", status); } - napi_delete_reference(env, selfRef); env = nullptr; } } @@ -42,7 +47,9 @@ void ContextBase::GetCbInfo(napi_env envi, napi_callback_info info, NapiCbInfoPa ASSERT_STATUS(this, "napi_get_cb_info failed!"); ASSERT_ARGS(this, argc <= ARGC_MAX, "too many arguments!"); ASSERT_ARGS(this, self != nullptr, "no JavaScript this argument!"); - napi_create_reference(env, self, 1, &selfRef); + if (!sync) { + napi_create_reference(env, self, 1, &selfRef); + } status = napi_unwrap(env, self, &native); ASSERT_STATUS(this, "self unwrap failed!"); diff --git a/kv_store/frameworks/jskitsimpl/distributedkvstore/src/uv_queue.cpp b/kv_store/frameworks/jskitsimpl/distributedkvstore/src/uv_queue.cpp index 4c44b977e2b8506c04f702efec632872c877706a..2397918dee214236dae8cdbe54ed01dca5cf4880 100644 --- a/kv_store/frameworks/jskitsimpl/distributedkvstore/src/uv_queue.cpp +++ b/kv_store/frameworks/jskitsimpl/distributedkvstore/src/uv_queue.cpp @@ -53,9 +53,14 @@ void UvQueue::AsyncCall(NapiCallbackGetter getter, NapiArgsGenerator genArgs) delete data; delete work; }); + napi_handle_scope scope = nullptr; + napi_open_handle_scope(entry->env, &scope); napi_value method = entry->callback(entry->env); if (method == nullptr) { ZLOGE("the callback is invalid, maybe is cleared!"); + if (scope != nullptr) { + napi_close_handle_scope(entry->env, scope); + } return ; } int argc = 0; @@ -72,6 +77,9 @@ void UvQueue::AsyncCall(NapiCallbackGetter getter, NapiArgsGenerator genArgs) if (status != napi_ok) { ZLOGE("notify data change failed status:%{public}d.", status); } + if (scope != nullptr) { + napi_close_handle_scope(entry->env, scope); + } }); } diff --git a/kv_store/frameworks/libs/distributeddb/BUILD.gn b/kv_store/frameworks/libs/distributeddb/BUILD.gn index f756983923e06ddabd69dabdbb3aac75dd675e89..54f1c86f58e05059c50d16c58ccabf754776555a 100644 --- a/kv_store/frameworks/libs/distributeddb/BUILD.gn +++ b/kv_store/frameworks/libs/distributeddb/BUILD.gn @@ -279,6 +279,7 @@ ohos_shared_library("distributeddb") { configs += [ "//third_party/jsoncpp:jsoncpp_config" ] ldflags = [ "-Wl,--exclude-libs,ALL" ] + cflags_cc = [ "-fvisibility=hidden" ] deps += [ "//third_party/jsoncpp:jsoncpp", "//third_party/openssl:libcrypto_shared", diff --git a/kv_store/frameworks/libs/distributeddb/common/include/notification_chain.h b/kv_store/frameworks/libs/distributeddb/common/include/notification_chain.h index 8c0d50b5a9f035f522994839c67951016ebf507a..b2c42c4844fb9717d36c99c2c5ad3f69a9a5317c 100644 --- a/kv_store/frameworks/libs/distributeddb/common/include/notification_chain.h +++ b/kv_store/frameworks/libs/distributeddb/common/include/notification_chain.h @@ -88,6 +88,8 @@ public: // Should be call when events happened. void NotifyEvent(EventType type, void *arg); + bool EmptyListener(EventType type) const; + NotificationChain() = default; // Delete the copy and assign constructors @@ -111,6 +113,8 @@ private: // Clear all listeners void ClearListeners(); + bool Empty() const; + ListenerChain(); // Delete the copy and assign constructors @@ -129,7 +133,7 @@ private: // Find a ListenerChain from the eventChains_ with given type, // this function needs to lock. - ListenerChain *FindAndGetListenerChainLocked(EventType type); + ListenerChain *FindAndGetListenerChainLocked(EventType type) const; // Find a ListenerChain from the eventChains_ with given type, ListenerChain *FindListenerChain(EventType type) const; diff --git a/kv_store/frameworks/libs/distributeddb/common/include/runtime_context.h b/kv_store/frameworks/libs/distributeddb/common/include/runtime_context.h index 85c22557ed5b0b51ffe6569b6cad0dd04bfe0f6d..856c5b31d8a09a284f806dc1356d8dbf79adb08d 100644 --- a/kv_store/frameworks/libs/distributeddb/common/include/runtime_context.h +++ b/kv_store/frameworks/libs/distributeddb/common/include/runtime_context.h @@ -139,6 +139,8 @@ public: virtual std::map GetPermissionCheckParam(const DBProperties &properties) = 0; virtual void StopTaskPool() = 0; + + virtual void StopTimeTickMonitorIfNeed() = 0; protected: RuntimeContext() = default; virtual ~RuntimeContext() {} diff --git a/kv_store/frameworks/libs/distributeddb/common/src/notification_chain.cpp b/kv_store/frameworks/libs/distributeddb/common/src/notification_chain.cpp index 1bfecec6665030547b0c7e3bbd7f5dfb1019c46a..c9d9870bcb55f46a5797e12f890d488aacd411bb 100644 --- a/kv_store/frameworks/libs/distributeddb/common/src/notification_chain.cpp +++ b/kv_store/frameworks/libs/distributeddb/common/src/notification_chain.cpp @@ -122,11 +122,22 @@ void NotificationChain::NotifyEvent(EventType type, void *arg) listenerChain = nullptr; } +bool NotificationChain::EmptyListener(EventType type) const +{ + NotificationChain::ListenerChain *listenerChain = FindAndGetListenerChainLocked(type); + if (listenerChain == nullptr) { + return true; + } + bool empty = listenerChain->Empty(); + RefObject::DecObjRef(listenerChain); + return empty; +} + NotificationChain::ListenerChain::ListenerChain() {} NotificationChain::ListenerChain::~ListenerChain() {} -NotificationChain::ListenerChain *NotificationChain::FindAndGetListenerChainLocked(EventType type) +NotificationChain::ListenerChain *NotificationChain::FindAndGetListenerChainLocked(EventType type) const { AutoLock lockGuard(this); ListenerChain *listenerChain = FindListenerChain(type); @@ -231,6 +242,12 @@ void NotificationChain::ListenerChain::ClearListeners() LockObj(); } +bool NotificationChain::ListenerChain::Empty() const +{ + AutoLock lockGuard(this); + return listenerSet_.empty(); +} + void NotificationChain::Listener::NotifyListener(void *arg) { if (onEvent_ && !IsKilled()) { diff --git a/kv_store/frameworks/libs/distributeddb/common/src/runtime_context_impl.cpp b/kv_store/frameworks/libs/distributeddb/common/src/runtime_context_impl.cpp index 8398c979b1f0b460c6b4364776d2c7b71687cc43..0d7078872b3110d0b8f2fd31e21d3c8120a32c7e 100644 --- a/kv_store/frameworks/libs/distributeddb/common/src/runtime_context_impl.cpp +++ b/kv_store/frameworks/libs/distributeddb/common/src/runtime_context_impl.cpp @@ -280,6 +280,7 @@ NotificationChain::Listener *RuntimeContextImpl::RegisterTimeChangedLister(const timeTickMonitor_ = nullptr; return nullptr; } + LOGD("[RuntimeContext] TimeTickMonitor start success"); } return timeTickMonitor_->RegisterTimeChangedLister(action, errCode); } @@ -733,4 +734,16 @@ void RuntimeContextImpl::StopTaskPool() taskPool_ = nullptr; } } + +void RuntimeContextImpl::StopTimeTickMonitorIfNeed() +{ + std::lock_guard autoLock(timeTickMonitorLock_); + if (timeTickMonitor_ == nullptr) { + return; + } + if (timeTickMonitor_->EmptyListener()) { + LOGD("[RuntimeContext] TimeTickMonitor exist because no listener"); + timeTickMonitor_ = nullptr; + } +} } // namespace DistributedDB diff --git a/kv_store/frameworks/libs/distributeddb/common/src/runtime_context_impl.h b/kv_store/frameworks/libs/distributeddb/common/src/runtime_context_impl.h index e79d23eee3db91ab9ccfcff3a0139bb23817a405..62b9ce623c790f949af7c6b026006c2e9b50c8c1 100644 --- a/kv_store/frameworks/libs/distributeddb/common/src/runtime_context_impl.h +++ b/kv_store/frameworks/libs/distributeddb/common/src/runtime_context_impl.h @@ -127,6 +127,9 @@ public: std::map GetPermissionCheckParam(const DBProperties &properties) override; void StopTaskPool() override; + + void StopTimeTickMonitorIfNeed() override; + private: static constexpr int MAX_TP_THREADS = 10; // max threads of the task pool. static constexpr int MIN_TP_THREADS = 1; // min threads of the task pool. diff --git a/kv_store/frameworks/libs/distributeddb/common/src/time_tick_monitor.cpp b/kv_store/frameworks/libs/distributeddb/common/src/time_tick_monitor.cpp index 1bb415e6899cf18cbb78895efb8a5414f6613d4a..2d5c3e184c4358bca948deda5595bd5d4bb1dade 100644 --- a/kv_store/frameworks/libs/distributeddb/common/src/time_tick_monitor.cpp +++ b/kv_store/frameworks/libs/distributeddb/common/src/time_tick_monitor.cpp @@ -66,10 +66,17 @@ void TimeTickMonitor::Stop() return; } - timeChangedNotifier_->UnRegisterEventType(TIME_CHANGE_EVENT); - RefObject::KillAndDecObjRef(timeChangedNotifier_); - timeChangedNotifier_ = nullptr; - runtimeCxt_->RemoveTimer(monitorTimerId_); + NotificationChain *notifier; + { + std::lock_guard autoLock(timeTickMonitorLock_); + notifier = timeChangedNotifier_; + timeChangedNotifier_ = nullptr; + } + if (notifier != nullptr) { + notifier->UnRegisterEventType(TIME_CHANGE_EVENT); + RefObject::KillAndDecObjRef(notifier); + } + runtimeCxt_->RemoveTimer(monitorTimerId_, true); isStarted_ = false; } @@ -123,9 +130,19 @@ int TimeTickMonitor::TimeTick(TimerId timerId) int64_t changedOffset = systemOffset - monotonicOffset; if (std::abs(changedOffset) > MAX_NOISE) { LOGI("Local system time may be changed! changedOffset %ld", changedOffset); - int ret = RuntimeContext::GetInstance()->ScheduleTask([this, changedOffset](){ + NotificationChain *notifier = nullptr; + { + std::lock_guard autoLock(timeTickMonitorLock_); + notifier = timeChangedNotifier_; + RefObject::IncObjRef(notifier); + } + int ret = RuntimeContext::GetInstance()->ScheduleTask([notifier, changedOffset](){ + if (notifier == nullptr) { + return; + } int64_t offset = changedOffset; - timeChangedNotifier_->NotifyEvent(TIME_CHANGE_EVENT, &offset); + notifier->NotifyEvent(TIME_CHANGE_EVENT, &offset); + RefObject::DecObjRef(notifier); }); if (ret != E_OK) { LOGE("TimeTickMonitor ScheduleTask failed %d", ret); @@ -165,4 +182,10 @@ void TimeTickMonitor::NotifyTimeChange(TimeOffset offset) const } timeChangedNotifier_->NotifyEvent(TIME_CHANGE_EVENT, static_cast(&offset)); } + +bool TimeTickMonitor::EmptyListener() const +{ + std::lock_guard lock(timeTickMonitorLock_); + return timeChangedNotifier_->EmptyListener(TIME_CHANGE_EVENT); +} } // namespace DistributedDB \ No newline at end of file diff --git a/kv_store/frameworks/libs/distributeddb/common/src/time_tick_monitor.h b/kv_store/frameworks/libs/distributeddb/common/src/time_tick_monitor.h index eab966e3b742a0a884519b1a83873e744ebec315..7513f950142af62c9dd74dad309662162dc95a38 100644 --- a/kv_store/frameworks/libs/distributeddb/common/src/time_tick_monitor.h +++ b/kv_store/frameworks/libs/distributeddb/common/src/time_tick_monitor.h @@ -40,6 +40,8 @@ public: // Notify TIME_CHANGE_EVENT. void NotifyTimeChange(TimeOffset offset) const; + + bool EmptyListener() const; private: static constexpr uint64_t MONITOR_INTERVAL = 1 * 1000; // 1s static constexpr int64_t MAX_NOISE = 9 * 100 * 1000; // 900ms diff --git a/kv_store/frameworks/libs/distributeddb/interfaces/include/kv_store_nb_delegate.h b/kv_store/frameworks/libs/distributeddb/interfaces/include/kv_store_nb_delegate.h index e10ec80c174d213392346af0059da766d3a0987f..21a112187afa4849d6db44b17519a3964384cdab 100644 --- a/kv_store/frameworks/libs/distributeddb/interfaces/include/kv_store_nb_delegate.h +++ b/kv_store/frameworks/libs/distributeddb/interfaces/include/kv_store_nb_delegate.h @@ -54,6 +54,7 @@ public: bool isNeedCompressOnSync = false; uint8_t compressionRate = 100; // Valid in [1, 100]. bool syncDualTupleMode = false; // communicator label use dualTuple hash or not + bool localOnly = false; // active sync module }; DB_API virtual ~KvStoreNbDelegate() {} diff --git a/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_delegate_manager.cpp b/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_delegate_manager.cpp index adc8a0eca769af907465c5fe0a9873b9414e4e06..84da4cadd834e79046834837e1f3c236c48e89d9 100644 --- a/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_delegate_manager.cpp +++ b/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_delegate_manager.cpp @@ -108,6 +108,7 @@ namespace { ParamCheckUtils::GetValidCompressionRate(option.compressionRate)); } properties.SetBoolProp(KvDBProperties::SYNC_DUAL_TUPLE_MODE, option.syncDualTupleMode); + properties.SetBoolProp(KvDBProperties::LOCAL_ONLY, option.localOnly); } bool CheckObserverConflictParam(const KvStoreNbDelegate::Option &option) diff --git a/kv_store/frameworks/libs/distributeddb/storage/include/kvdb_properties.h b/kv_store/frameworks/libs/distributeddb/storage/include/kvdb_properties.h index 6b668a791ee71433c3b69a179eae8827de5fa4e9..1f8749eab590579d1cc492bcecfafa1330e1587e 100644 --- a/kv_store/frameworks/libs/distributeddb/storage/include/kvdb_properties.h +++ b/kv_store/frameworks/libs/distributeddb/storage/include/kvdb_properties.h @@ -66,6 +66,7 @@ public: static const std::string RM_CORRUPTED_DB; static const std::string COMPRESS_ON_SYNC; static const std::string COMPRESSION_RATE; + static const std::string LOCAL_ONLY; static const int LOCAL_TYPE = 1; static const int MULTI_VER_TYPE = 2; diff --git a/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_manager.cpp b/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_manager.cpp index 74337966543c1b7cb708120c0275ede9bec8dea6..162457d3804b573072792b9c81dbe09c7412a876 100644 --- a/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_manager.cpp +++ b/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_manager.cpp @@ -926,7 +926,13 @@ int KvDBManager::CheckKvDBProperties(const IKvDB *kvDB, const KvDBProperties &pr properties.GetBoolProp(KvDBProperties::SYNC_DUAL_TUPLE_MODE, false)) { LOGE("Different dual tuple sync mode"); return -E_MODE_MISMATCH; - } + } + + if (kvDB->GetMyProperties().GetBoolProp(KvDBProperties::LOCAL_ONLY, false) != + properties.GetBoolProp(KvDBProperties::LOCAL_ONLY, false)) { + LOGE("Different local only mode"); + return -E_INVALID_ARGS; + } if (!CheckSecOptions(properties, kvDB->GetMyProperties())) { return -E_INVALID_ARGS; diff --git a/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_properties.cpp b/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_properties.cpp index 72885909301823820d8d04ebc45acb5044151f95..bf07aba2f189116938f2ffdbc61875e6d60f26c3 100644 --- a/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_properties.cpp +++ b/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_properties.cpp @@ -30,6 +30,7 @@ const std::string KvDBProperties::CHECK_INTEGRITY = "checkIntegrity"; const std::string KvDBProperties::RM_CORRUPTED_DB = "rmCorruptedDb"; const std::string KvDBProperties::COMPRESS_ON_SYNC = "needCompressOnSync"; const std::string KvDBProperties::COMPRESSION_RATE = "compressionRate"; +const std::string KvDBProperties::LOCAL_ONLY = "localOnly"; KvDBProperties::KvDBProperties() : cipherType_(CipherType::AES_256_GCM) diff --git a/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.h b/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.h index e96328972513cbaa07c91577e2956dabe00edee9..84381bfcb90f8669fc9e4a1314c445b8d20fb85f 100644 --- a/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.h +++ b/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.h @@ -210,7 +210,7 @@ private: DECLARE_OBJECT_TAG(SQLiteSingleVerNaturalStoreConnection); // ResultSet Related Info - static constexpr std::size_t MAX_RESULT_SET_SIZE = 4; // Max 4 ResultSet At The Same Time + static constexpr std::size_t MAX_RESULT_SET_SIZE = 8; // Max 8 ResultSet At The Same Time std::atomic cacheModeForNewResultSet_{ResultSetCacheMode::CACHE_FULL_ENTRY}; std::atomic cacheMaxSizeForNewResultSet_{0}; // Will be init to default value in constructor diff --git a/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_kvdb.cpp b/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_kvdb.cpp index ba66fcfcd4a495f243e940b36d3ac3f0c11444ef..711621e3ce1071c8752ce9b4e4b4bc398894aeee 100644 --- a/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_kvdb.cpp +++ b/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_kvdb.cpp @@ -176,7 +176,7 @@ int SyncAbleKvDB::StartSyncerWithNoLock(bool isCheckSyncActive, bool isNeedActiv if (errCode == E_OK) { started_ = true; } else { - LOGE("KvDB start syncer failed, err:'%d'.", errCode); + LOGW("KvDB start syncer failed, err:'%d'.", errCode); } bool isSyncDualTupleMode = syncInterface->GetDbProperties().GetBoolProp(KvDBProperties::SYNC_DUAL_TUPLE_MODE, false); diff --git a/kv_store/frameworks/libs/distributeddb/syncer/src/generic_syncer.cpp b/kv_store/frameworks/libs/distributeddb/syncer/src/generic_syncer.cpp index 7df6e2acca4da743b3344ff930cb13bd94e9b682..8227f3c29e28f45645da4bfee396cd75ea6bc2d0 100644 --- a/kv_store/frameworks/libs/distributeddb/syncer/src/generic_syncer.cpp +++ b/kv_store/frameworks/libs/distributeddb/syncer/src/generic_syncer.cpp @@ -101,6 +101,9 @@ int GenericSyncer::Initialize(ISyncInterface *syncInterface, bool isNeedActive) // It will be clear in destructor. int errCodeTimeHelper = InitTimeHelper(syncInterface); + if (!IsNeedActive(syncInterface)) { + return -E_NO_NEED_ACTIVE; + } // As timeChangedListener_ will record time change, it should not be clear even if engine init failed. // It will be clear in destructor. int errCodeTimeChangedListener = InitTimeChangedListener(); @@ -905,6 +908,7 @@ void GenericSyncer::ReleaseInnerResource() } if (timeChangedListener != nullptr) { timeChangedListener->Drop(true); + RuntimeContext::GetInstance()->StopTimeTickMonitorIfNeed(); } } @@ -1009,4 +1013,14 @@ int GenericSyncer::GetSyncDataSize(const std::string &device, size_t &size) cons size = (totalLen >= expectedMtuSize) ? expectedMtuSize : totalLen; return E_OK; } + +bool GenericSyncer::IsNeedActive(ISyncInterface *syncInterface) +{ + bool localOnly = syncInterface->GetDbProperties().GetBoolProp(KvDBProperties::LOCAL_ONLY, false); + if (localOnly) { + LOGD("[Syncer] Local only db, don't need active syncer"); + return false; + } + return true; +} } // namespace DistributedDB diff --git a/kv_store/frameworks/libs/distributeddb/syncer/src/generic_syncer.h b/kv_store/frameworks/libs/distributeddb/syncer/src/generic_syncer.h index d38ad390480f81ace49435460b60390d8956258a..7d89adbfa14df566dbd95886b4fbfe81b21c538f 100644 --- a/kv_store/frameworks/libs/distributeddb/syncer/src/generic_syncer.h +++ b/kv_store/frameworks/libs/distributeddb/syncer/src/generic_syncer.h @@ -192,6 +192,8 @@ protected: static int SyncResourceInit(); + static bool IsNeedActive(ISyncInterface *syncInterface); + static const int MIN_VALID_SYNC_ID; static std::mutex moduleInitLock_; diff --git a/kv_store/frameworks/libs/distributeddb/test/fuzztest/delegate_fuzzer/BUILD.gn b/kv_store/frameworks/libs/distributeddb/test/fuzztest/delegate_fuzzer/BUILD.gn index c76f6e9e6a744d9ce649c3ecf5976280d08d4d8c..1f3c8f9ebc4850b3faf14b8906c132000eb7df37 100644 --- a/kv_store/frameworks/libs/distributeddb/test/fuzztest/delegate_fuzzer/BUILD.gn +++ b/kv_store/frameworks/libs/distributeddb/test/fuzztest/delegate_fuzzer/BUILD.gn @@ -26,12 +26,18 @@ ohos_fuzztest("DelegateFuzzTest") { "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/unittest/common/storage", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/include", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/include/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src", - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/include", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/include/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src", @@ -57,9 +63,201 @@ ohos_fuzztest("DelegateFuzzTest") { fuzz_config_file = "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/fuzztest/delegate_fuzzer" sources = [ + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/auto_launch.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/data_compression.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/data_value.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_common.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_constant.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_dfx_adapter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_dump_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_epoll.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_select.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/ievent.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/ievent_loop.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/flatbuffer_schema.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/hash.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/json_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/lock_status_observer.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/log_print.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/notification_chain.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/param_check_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/parcel.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/performance_analysis.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/platform_specific.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/query.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/query_expression.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/ref_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/prepared_stmt.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_result_set_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_row_data_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_schema_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/table_info.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/runtime_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/runtime_context_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_constant.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_negotiate.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/semaphore_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_pool.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_pool_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_queue.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/time_tick_monitor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/types_export.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/user_change_monitor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/value_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/combine_status.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator_aggregator.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator_linker.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/frame_combiner.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/frame_retainer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/header_converter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/message_transform.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/network_adapter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/protocol_proto.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/send_task_scheduler.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/serial_buffer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/intercepted_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_changed_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_delegate_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_errno.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_nb_conflict_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_nb_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_result_set_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_snapshot_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_changed_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/runtime_config.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/data_transformer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/db_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/default_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_single_ver_kv_entry.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/iconnection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/ikvdb_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_commit_notify_filterable_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_observer_handle.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_windowed_result_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/generic_multi_ver_kv_entry.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_commit.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_kvdata_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_notify_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_snapshot.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_transfer_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_vacuum.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_vacuum_executor_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_value_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/local_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/multi_ver_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/single_ver_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/package_file.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_row_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_store_instance.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_sync_able_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relationaldb_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/result_entries_window.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/single_ver_natural_store_commit_notify_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/collaboration_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/log_table_manager_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/query_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/query_sync_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/relational_remote_query_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_single_relational_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/split_device_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb_snapshot.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_data_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_transaction.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_query_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_forward_cursor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_result_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_schema_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_cache.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_subscribe.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_engine_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader/single_ver_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader/single_ver_schema_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/ability_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/commit_history_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/communicator_proxy.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/db_ability.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/device_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/generic_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/meta_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_data_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/query_sync_water_mark_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/remote_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/remote_executor_packet.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_message_schedule.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_packet.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_sync_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_kv_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_kv_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_relational_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_relational_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_serialize_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_target.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/subscribe_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_config.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_operation.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_target.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/syncer_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/syncer_proxy.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/time_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/time_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/value_slice_sync.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/fuzztest/common/distributeddb_tools_test.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/unittest/common/common/distributeddb_data_generate_unit_test.cpp", "delegate_fuzzer.cpp", @@ -79,12 +277,15 @@ ohos_fuzztest("DelegateFuzzTest") { "OMIT_FLATBUFFER", "RELATIONAL_STORE", "SQLITE_DISTRIBUTE_RELATIONAL", + "SQLITE_ENABLE_DROPTABLE_CALLBACK", ] deps = [ "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", "//third_party/jsoncpp:jsoncpp", "//third_party/openssl:libcrypto_shared", + "//third_party/sqlite:sqlite", + "//third_party/zlib:shared_libz", ] external_deps = [ diff --git a/kv_store/frameworks/libs/distributeddb/test/fuzztest/fileoper_fuzzer/BUILD.gn b/kv_store/frameworks/libs/distributeddb/test/fuzztest/fileoper_fuzzer/BUILD.gn index 839275c83513f181d88ac6d353b987ab9ff034a2..4726054e039ad024c5dd90af85bfdab5e6d2a3a4 100644 --- a/kv_store/frameworks/libs/distributeddb/test/fuzztest/fileoper_fuzzer/BUILD.gn +++ b/kv_store/frameworks/libs/distributeddb/test/fuzztest/fileoper_fuzzer/BUILD.gn @@ -26,18 +26,23 @@ ohos_fuzztest("FileOperFuzzTest") { "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/unittest/common/storage", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/include", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/include/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src", - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/include", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/include/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src", - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/include/relational", "//third_party/jsoncpp/include/json", "//third_party/skia/third_party/externals/spirv-headers/tools/buildHeaders/jsoncpp/dist/json", "//third_party/skia/third_party/externals/swiftshader/third_party/SPIRV-Headers/tools/buildHeaders/jsoncpp/dist/json", @@ -58,9 +63,201 @@ ohos_fuzztest("FileOperFuzzTest") { fuzz_config_file = "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/fuzztest/fileoper_fuzzer" sources = [ + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/auto_launch.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/data_compression.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/data_value.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_common.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_constant.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_dfx_adapter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_dump_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_epoll.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_select.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/ievent.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/ievent_loop.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/flatbuffer_schema.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/hash.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/json_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/lock_status_observer.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/log_print.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/notification_chain.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/param_check_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/parcel.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/performance_analysis.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/platform_specific.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/query.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/query_expression.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/ref_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/prepared_stmt.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_result_set_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_row_data_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_schema_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/table_info.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/runtime_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/runtime_context_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_constant.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_negotiate.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/semaphore_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_pool.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_pool_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_queue.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/time_tick_monitor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/types_export.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/user_change_monitor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/value_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/combine_status.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator_aggregator.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator_linker.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/frame_combiner.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/frame_retainer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/header_converter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/message_transform.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/network_adapter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/protocol_proto.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/send_task_scheduler.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/serial_buffer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/intercepted_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_changed_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_delegate_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_errno.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_nb_conflict_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_nb_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_result_set_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_snapshot_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_changed_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/runtime_config.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/data_transformer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/db_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/default_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_single_ver_kv_entry.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/iconnection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/ikvdb_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_commit_notify_filterable_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_observer_handle.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_windowed_result_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/generic_multi_ver_kv_entry.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_commit.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_kvdata_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_notify_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_snapshot.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_transfer_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_vacuum.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_vacuum_executor_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_value_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/local_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/multi_ver_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/single_ver_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/package_file.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_row_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_store_instance.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_sync_able_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relationaldb_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/result_entries_window.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/single_ver_natural_store_commit_notify_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/collaboration_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/log_table_manager_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/query_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/query_sync_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/relational_remote_query_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_single_relational_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/split_device_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb_snapshot.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_data_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_transaction.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_query_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_forward_cursor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_result_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_schema_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_cache.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_subscribe.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_engine_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader/single_ver_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader/single_ver_schema_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/ability_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/commit_history_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/communicator_proxy.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/db_ability.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/device_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/generic_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/meta_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_data_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/query_sync_water_mark_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/remote_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/remote_executor_packet.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_message_schedule.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_packet.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_sync_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_kv_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_kv_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_relational_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_relational_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_serialize_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_target.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/subscribe_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_config.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_operation.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_target.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/syncer_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/syncer_proxy.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/time_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/time_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/value_slice_sync.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/fuzztest/common/distributeddb_tools_test.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/unittest/common/common/distributeddb_data_generate_unit_test.cpp", "fileoper_fuzzer.cpp", @@ -70,6 +267,8 @@ ohos_fuzztest("FileOperFuzzTest") { "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", "//third_party/jsoncpp:jsoncpp", "//third_party/openssl:libcrypto_shared", + "//third_party/sqlite:sqlite", + "//third_party/zlib:shared_libz", ] defines = [ @@ -86,6 +285,7 @@ ohos_fuzztest("FileOperFuzzTest") { "OMIT_FLATBUFFER", "RELATIONAL_STORE", "SQLITE_DISTRIBUTE_RELATIONAL", + "SQLITE_ENABLE_DROPTABLE_CALLBACK", ] external_deps = [ diff --git a/kv_store/frameworks/libs/distributeddb/test/fuzztest/importfile_fuzzer/BUILD.gn b/kv_store/frameworks/libs/distributeddb/test/fuzztest/importfile_fuzzer/BUILD.gn index de2338af598acd38690dc93dbde09199a5d688cf..3e214090588d59e66118ae043fc9d4e8facef627 100644 --- a/kv_store/frameworks/libs/distributeddb/test/fuzztest/importfile_fuzzer/BUILD.gn +++ b/kv_store/frameworks/libs/distributeddb/test/fuzztest/importfile_fuzzer/BUILD.gn @@ -26,12 +26,18 @@ ohos_fuzztest("ImportFileFuzzTest") { "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/unittest/common/storage", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/include", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/include/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src", - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/include", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/include/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src", @@ -57,9 +63,201 @@ ohos_fuzztest("ImportFileFuzzTest") { fuzz_config_file = "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/fuzztest/importfile_fuzzer" sources = [ + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/auto_launch.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/data_compression.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/data_value.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_common.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_constant.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_dfx_adapter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_dump_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_epoll.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_select.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/ievent.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/ievent_loop.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/flatbuffer_schema.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/hash.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/json_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/lock_status_observer.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/log_print.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/notification_chain.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/param_check_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/parcel.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/performance_analysis.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/platform_specific.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/query.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/query_expression.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/ref_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/prepared_stmt.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_result_set_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_row_data_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_schema_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/table_info.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/runtime_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/runtime_context_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_constant.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_negotiate.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/semaphore_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_pool.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_pool_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_queue.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/time_tick_monitor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/types_export.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/user_change_monitor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/value_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/combine_status.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator_aggregator.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator_linker.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/frame_combiner.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/frame_retainer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/header_converter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/message_transform.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/network_adapter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/protocol_proto.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/send_task_scheduler.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/serial_buffer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/intercepted_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_changed_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_delegate_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_errno.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_nb_conflict_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_nb_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_result_set_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_snapshot_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_changed_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/runtime_config.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/data_transformer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/db_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/default_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_single_ver_kv_entry.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/iconnection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/ikvdb_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_commit_notify_filterable_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_observer_handle.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_windowed_result_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/generic_multi_ver_kv_entry.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_commit.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_kvdata_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_notify_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_snapshot.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_transfer_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_vacuum.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_vacuum_executor_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_value_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/local_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/multi_ver_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/single_ver_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/package_file.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_row_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_store_instance.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_sync_able_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relationaldb_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/result_entries_window.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/single_ver_natural_store_commit_notify_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/collaboration_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/log_table_manager_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/query_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/query_sync_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/relational_remote_query_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_single_relational_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/split_device_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb_snapshot.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_data_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_transaction.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_query_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_forward_cursor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_result_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_schema_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_cache.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_subscribe.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_engine_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader/single_ver_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader/single_ver_schema_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/ability_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/commit_history_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/communicator_proxy.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/db_ability.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/device_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/generic_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/meta_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_data_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/query_sync_water_mark_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/remote_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/remote_executor_packet.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_message_schedule.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_packet.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_sync_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_kv_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_kv_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_relational_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_relational_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_serialize_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_target.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/subscribe_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_config.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_operation.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_target.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/syncer_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/syncer_proxy.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/time_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/time_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/value_slice_sync.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/fuzztest/common/distributeddb_tools_test.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/unittest/common/common/distributeddb_data_generate_unit_test.cpp", "importfile_fuzzer.cpp", @@ -79,12 +277,15 @@ ohos_fuzztest("ImportFileFuzzTest") { "OMIT_FLATBUFFER", "RELATIONAL_STORE", "SQLITE_DISTRIBUTE_RELATIONAL", + "SQLITE_ENABLE_DROPTABLE_CALLBACK", ] deps = [ "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", "//third_party/jsoncpp:jsoncpp", "//third_party/openssl:libcrypto_shared", + "//third_party/sqlite:sqlite", + "//third_party/zlib:shared_libz", ] external_deps = [ diff --git a/kv_store/frameworks/libs/distributeddb/test/fuzztest/iprocesscommunicator_fuzzer/BUILD.gn b/kv_store/frameworks/libs/distributeddb/test/fuzztest/iprocesscommunicator_fuzzer/BUILD.gn index 8f0ad1f28ea00cba474a88f64d5c44d4bdaa0f59..2b552af265e10d20df5922ec28eea9ebfc9b4889 100644 --- a/kv_store/frameworks/libs/distributeddb/test/fuzztest/iprocesscommunicator_fuzzer/BUILD.gn +++ b/kv_store/frameworks/libs/distributeddb/test/fuzztest/iprocesscommunicator_fuzzer/BUILD.gn @@ -26,12 +26,18 @@ ohos_fuzztest("IProcessCommunicatorFuzzTest") { "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/unittest/common/storage", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/include", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/include/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src", - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/include", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/include/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src", @@ -57,9 +63,201 @@ ohos_fuzztest("IProcessCommunicatorFuzzTest") { fuzz_config_file = "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/fuzztest/iprocesscommunicator_fuzzer" sources = [ + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/auto_launch.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/data_compression.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/data_value.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_common.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_constant.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_dfx_adapter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_dump_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_epoll.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_select.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/ievent.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/ievent_loop.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/flatbuffer_schema.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/hash.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/json_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/lock_status_observer.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/log_print.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/notification_chain.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/param_check_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/parcel.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/performance_analysis.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/platform_specific.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/query.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/query_expression.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/ref_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/prepared_stmt.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_result_set_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_row_data_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_schema_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/table_info.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/runtime_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/runtime_context_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_constant.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_negotiate.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/semaphore_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_pool.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_pool_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_queue.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/time_tick_monitor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/types_export.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/user_change_monitor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/value_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/combine_status.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator_aggregator.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator_linker.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/frame_combiner.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/frame_retainer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/header_converter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/message_transform.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/network_adapter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/protocol_proto.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/send_task_scheduler.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/serial_buffer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/intercepted_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_changed_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_delegate_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_errno.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_nb_conflict_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_nb_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_result_set_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_snapshot_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_changed_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/runtime_config.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/data_transformer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/db_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/default_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_single_ver_kv_entry.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/iconnection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/ikvdb_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_commit_notify_filterable_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_observer_handle.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_windowed_result_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/generic_multi_ver_kv_entry.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_commit.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_kvdata_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_notify_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_snapshot.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_transfer_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_vacuum.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_vacuum_executor_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_value_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/local_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/multi_ver_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/single_ver_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/package_file.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_row_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_store_instance.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_sync_able_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relationaldb_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/result_entries_window.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/single_ver_natural_store_commit_notify_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/collaboration_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/log_table_manager_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/query_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/query_sync_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/relational_remote_query_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_single_relational_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/split_device_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb_snapshot.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_data_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_transaction.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_query_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_forward_cursor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_result_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_schema_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_cache.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_subscribe.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_engine_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader/single_ver_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader/single_ver_schema_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/ability_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/commit_history_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/communicator_proxy.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/db_ability.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/device_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/generic_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/meta_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_data_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/query_sync_water_mark_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/remote_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/remote_executor_packet.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_message_schedule.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_packet.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_sync_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_kv_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_kv_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_relational_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_relational_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_serialize_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_target.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/subscribe_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_config.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_operation.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_target.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/syncer_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/syncer_proxy.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/time_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/time_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/value_slice_sync.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/fuzztest/common/distributeddb_tools_test.cpp", "iprocesscommunicator_fuzzer.cpp", ] @@ -78,12 +276,15 @@ ohos_fuzztest("IProcessCommunicatorFuzzTest") { "OMIT_FLATBUFFER", "RELATIONAL_STORE", "SQLITE_DISTRIBUTE_RELATIONAL", + "SQLITE_ENABLE_DROPTABLE_CALLBACK", ] deps = [ "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", "//third_party/jsoncpp:jsoncpp", "//third_party/openssl:libcrypto_shared", + "//third_party/sqlite:sqlite", + "//third_party/zlib:shared_libz", ] external_deps = [ diff --git a/kv_store/frameworks/libs/distributeddb/test/fuzztest/kvdelegatemanager_fuzzer/BUILD.gn b/kv_store/frameworks/libs/distributeddb/test/fuzztest/kvdelegatemanager_fuzzer/BUILD.gn index 587b29e224156c3a3bc2ac36d9dca75f13459a92..12423b76766ed1224f8dba01870dd1178badb7f2 100644 --- a/kv_store/frameworks/libs/distributeddb/test/fuzztest/kvdelegatemanager_fuzzer/BUILD.gn +++ b/kv_store/frameworks/libs/distributeddb/test/fuzztest/kvdelegatemanager_fuzzer/BUILD.gn @@ -26,12 +26,18 @@ ohos_fuzztest("KvDelegateManagerFuzzTest") { "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/unittest/common/storage", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/include", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/include/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src", - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/include", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/include/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src", @@ -57,9 +63,201 @@ ohos_fuzztest("KvDelegateManagerFuzzTest") { fuzz_config_file = "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/fuzztest/kvdelegatemanager_fuzzer" sources = [ + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/auto_launch.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/data_compression.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/data_value.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_common.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_constant.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_dfx_adapter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_dump_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_epoll.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_select.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/ievent.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/ievent_loop.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/flatbuffer_schema.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/hash.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/json_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/lock_status_observer.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/log_print.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/notification_chain.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/param_check_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/parcel.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/performance_analysis.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/platform_specific.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/query.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/query_expression.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/ref_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/prepared_stmt.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_result_set_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_row_data_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_schema_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/table_info.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/runtime_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/runtime_context_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_constant.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_negotiate.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/semaphore_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_pool.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_pool_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_queue.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/time_tick_monitor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/types_export.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/user_change_monitor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/value_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/combine_status.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator_aggregator.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator_linker.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/frame_combiner.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/frame_retainer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/header_converter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/message_transform.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/network_adapter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/protocol_proto.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/send_task_scheduler.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/serial_buffer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/intercepted_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_changed_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_delegate_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_errno.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_nb_conflict_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_nb_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_result_set_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_snapshot_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_changed_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/runtime_config.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/data_transformer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/db_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/default_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_single_ver_kv_entry.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/iconnection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/ikvdb_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_commit_notify_filterable_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_observer_handle.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_windowed_result_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/generic_multi_ver_kv_entry.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_commit.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_kvdata_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_notify_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_snapshot.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_transfer_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_vacuum.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_vacuum_executor_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_value_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/local_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/multi_ver_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/single_ver_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/package_file.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_row_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_store_instance.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_sync_able_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relationaldb_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/result_entries_window.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/single_ver_natural_store_commit_notify_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/collaboration_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/log_table_manager_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/query_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/query_sync_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/relational_remote_query_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_single_relational_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/split_device_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb_snapshot.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_data_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_transaction.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_query_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_forward_cursor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_result_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_schema_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_cache.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_subscribe.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_engine_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader/single_ver_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader/single_ver_schema_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/ability_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/commit_history_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/communicator_proxy.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/db_ability.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/device_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/generic_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/meta_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_data_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/query_sync_water_mark_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/remote_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/remote_executor_packet.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_message_schedule.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_packet.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_sync_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_kv_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_kv_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_relational_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_relational_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_serialize_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_target.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/subscribe_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_config.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_operation.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_target.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/syncer_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/syncer_proxy.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/time_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/time_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/value_slice_sync.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/fuzztest/common/distributeddb_tools_test.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/unittest/common/common/distributeddb_data_generate_unit_test.cpp", "kvdelegatemanager_fuzzer.cpp", @@ -79,12 +277,15 @@ ohos_fuzztest("KvDelegateManagerFuzzTest") { "OMIT_FLATBUFFER", "RELATIONAL_STORE", "SQLITE_DISTRIBUTE_RELATIONAL", + "SQLITE_ENABLE_DROPTABLE_CALLBACK", ] deps = [ "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", "//third_party/jsoncpp:jsoncpp", "//third_party/openssl:libcrypto_shared", + "//third_party/sqlite:sqlite", + "//third_party/zlib:shared_libz", ] external_deps = [ diff --git a/kv_store/frameworks/libs/distributeddb/test/fuzztest/kvstoreresultset_fuzzer/BUILD.gn b/kv_store/frameworks/libs/distributeddb/test/fuzztest/kvstoreresultset_fuzzer/BUILD.gn index 7be73aca218e8dda44cd7cf80eeb64869f05d8ba..229ee3bd9f158f486c8889fb9f9792013d5fb9b5 100644 --- a/kv_store/frameworks/libs/distributeddb/test/fuzztest/kvstoreresultset_fuzzer/BUILD.gn +++ b/kv_store/frameworks/libs/distributeddb/test/fuzztest/kvstoreresultset_fuzzer/BUILD.gn @@ -26,12 +26,18 @@ ohos_fuzztest("KvStoreResultSetFuzzTest") { "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/unittest/common/storage", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/include", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/include/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src", - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/include", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/include/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src", @@ -57,9 +63,201 @@ ohos_fuzztest("KvStoreResultSetFuzzTest") { fuzz_config_file = "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/fuzztest/kvstoreresultset_fuzzer" sources = [ + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/auto_launch.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/data_compression.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/data_value.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_common.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_constant.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_dfx_adapter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_dump_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_epoll.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_select.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/ievent.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/ievent_loop.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/flatbuffer_schema.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/hash.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/json_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/lock_status_observer.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/log_print.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/notification_chain.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/param_check_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/parcel.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/performance_analysis.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/platform_specific.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/query.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/query_expression.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/ref_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/prepared_stmt.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_result_set_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_row_data_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_schema_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/table_info.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/runtime_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/runtime_context_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_constant.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_negotiate.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/semaphore_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_pool.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_pool_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_queue.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/time_tick_monitor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/types_export.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/user_change_monitor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/value_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/combine_status.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator_aggregator.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator_linker.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/frame_combiner.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/frame_retainer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/header_converter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/message_transform.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/network_adapter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/protocol_proto.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/send_task_scheduler.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/serial_buffer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/intercepted_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_changed_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_delegate_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_errno.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_nb_conflict_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_nb_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_result_set_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_snapshot_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_changed_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/runtime_config.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/data_transformer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/db_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/default_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_single_ver_kv_entry.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/iconnection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/ikvdb_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_commit_notify_filterable_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_observer_handle.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_windowed_result_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/generic_multi_ver_kv_entry.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_commit.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_kvdata_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_notify_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_snapshot.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_transfer_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_vacuum.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_vacuum_executor_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_value_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/local_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/multi_ver_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/single_ver_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/package_file.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_row_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_store_instance.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_sync_able_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relationaldb_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/result_entries_window.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/single_ver_natural_store_commit_notify_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/collaboration_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/log_table_manager_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/query_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/query_sync_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/relational_remote_query_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_single_relational_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/split_device_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb_snapshot.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_data_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_transaction.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_query_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_forward_cursor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_result_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_schema_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_cache.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_subscribe.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_engine_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader/single_ver_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader/single_ver_schema_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/ability_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/commit_history_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/communicator_proxy.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/db_ability.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/device_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/generic_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/meta_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_data_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/query_sync_water_mark_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/remote_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/remote_executor_packet.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_message_schedule.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_packet.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_sync_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_kv_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_kv_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_relational_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_relational_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_serialize_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_target.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/subscribe_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_config.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_operation.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_target.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/syncer_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/syncer_proxy.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/time_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/time_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/value_slice_sync.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/fuzztest/common/distributeddb_tools_test.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/unittest/common/common/distributeddb_data_generate_unit_test.cpp", "kvstoreresultset_fuzzer.cpp", @@ -79,12 +277,15 @@ ohos_fuzztest("KvStoreResultSetFuzzTest") { "OMIT_FLATBUFFER", "RELATIONAL_STORE", "SQLITE_DISTRIBUTE_RELATIONAL", + "SQLITE_ENABLE_DROPTABLE_CALLBACK", ] deps = [ "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", "//third_party/jsoncpp:jsoncpp", "//third_party/openssl:libcrypto_shared", + "//third_party/sqlite:sqlite", + "//third_party/zlib:shared_libz", ] external_deps = [ diff --git a/kv_store/frameworks/libs/distributeddb/test/fuzztest/nbdelegate_fuzzer/BUILD.gn b/kv_store/frameworks/libs/distributeddb/test/fuzztest/nbdelegate_fuzzer/BUILD.gn index e73260a66ee163541c7d4609e33751f967799b35..b912d80c3ca13b848f69ec896d66a8f730b5e6e7 100644 --- a/kv_store/frameworks/libs/distributeddb/test/fuzztest/nbdelegate_fuzzer/BUILD.gn +++ b/kv_store/frameworks/libs/distributeddb/test/fuzztest/nbdelegate_fuzzer/BUILD.gn @@ -26,12 +26,18 @@ ohos_fuzztest("NbDelegateFuzzTest") { "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/unittest/common/storage", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/include", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/include/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src", - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/include", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/include/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src", @@ -57,9 +63,201 @@ ohos_fuzztest("NbDelegateFuzzTest") { fuzz_config_file = "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/fuzztest/nbdelegate_fuzzer" sources = [ + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/auto_launch.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/data_compression.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/data_value.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_common.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_constant.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_dfx_adapter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_dump_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_epoll.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_select.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/ievent.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/ievent_loop.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/flatbuffer_schema.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/hash.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/json_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/lock_status_observer.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/log_print.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/notification_chain.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/param_check_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/parcel.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/performance_analysis.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/platform_specific.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/query.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/query_expression.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/ref_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/prepared_stmt.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_result_set_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_row_data_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_schema_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/table_info.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/runtime_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/runtime_context_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_constant.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_negotiate.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/semaphore_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_pool.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_pool_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_queue.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/time_tick_monitor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/types_export.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/user_change_monitor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/value_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/combine_status.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator_aggregator.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator_linker.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/frame_combiner.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/frame_retainer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/header_converter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/message_transform.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/network_adapter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/protocol_proto.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/send_task_scheduler.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/serial_buffer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/intercepted_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_changed_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_delegate_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_errno.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_nb_conflict_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_nb_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_result_set_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_snapshot_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_changed_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/runtime_config.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/data_transformer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/db_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/default_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_single_ver_kv_entry.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/iconnection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/ikvdb_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_commit_notify_filterable_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_observer_handle.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_windowed_result_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/generic_multi_ver_kv_entry.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_commit.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_kvdata_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_notify_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_snapshot.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_transfer_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_vacuum.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_vacuum_executor_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_value_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/local_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/multi_ver_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/single_ver_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/package_file.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_row_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_store_instance.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_sync_able_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relationaldb_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/result_entries_window.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/single_ver_natural_store_commit_notify_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/collaboration_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/log_table_manager_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/query_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/query_sync_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/relational_remote_query_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_single_relational_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/split_device_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb_snapshot.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_data_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_transaction.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_query_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_forward_cursor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_result_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_schema_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_cache.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_subscribe.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_engine_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader/single_ver_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader/single_ver_schema_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/ability_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/commit_history_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/communicator_proxy.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/db_ability.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/device_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/generic_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/meta_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_data_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/query_sync_water_mark_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/remote_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/remote_executor_packet.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_message_schedule.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_packet.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_sync_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_kv_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_kv_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_relational_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_relational_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_serialize_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_target.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/subscribe_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_config.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_operation.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_target.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/syncer_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/syncer_proxy.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/time_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/time_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/value_slice_sync.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/fuzztest/common/distributeddb_tools_test.cpp", "nbdelegate_fuzzer.cpp", ] @@ -78,12 +276,15 @@ ohos_fuzztest("NbDelegateFuzzTest") { "OMIT_FLATBUFFER", "RELATIONAL_STORE", "SQLITE_DISTRIBUTE_RELATIONAL", + "SQLITE_ENABLE_DROPTABLE_CALLBACK", ] deps = [ "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", "//third_party/jsoncpp:jsoncpp", "//third_party/openssl:libcrypto_shared", + "//third_party/sqlite:sqlite", + "//third_party/zlib:shared_libz", ] external_deps = [ diff --git a/kv_store/frameworks/libs/distributeddb/test/fuzztest/parseckeck_fuzzer/BUILD.gn b/kv_store/frameworks/libs/distributeddb/test/fuzztest/parseckeck_fuzzer/BUILD.gn index d083e09ec06c3e4b749a0787795c7f7466d3f53c..d995db2ed836426a175800aaf0c88cb84525d847 100644 --- a/kv_store/frameworks/libs/distributeddb/test/fuzztest/parseckeck_fuzzer/BUILD.gn +++ b/kv_store/frameworks/libs/distributeddb/test/fuzztest/parseckeck_fuzzer/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -#####################hydra-fuzz################### +#####################hydra-fuzz###################common\src\schema_constant. import("//build/config/features.gni") import("//build/test.gni") @@ -26,12 +26,18 @@ ohos_fuzztest("ParseCkeckFuzzTest") { "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/unittest/common/storage", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/include", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/include/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src", - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/include", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/include/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src", @@ -57,13 +63,201 @@ ohos_fuzztest("ParseCkeckFuzzTest") { fuzz_config_file = "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/fuzztest/parseckeck_fuzzer" sources = [ + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/auto_launch.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/data_compression.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/data_value.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_common.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_constant.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_dfx_adapter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_dump_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_epoll.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_select.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/ievent.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/ievent_loop.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/flatbuffer_schema.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/hash.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/json_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/lock_status_observer.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/log_print.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/notification_chain.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/param_check_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/parcel.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/performance_analysis.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/platform_specific.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/query.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/query_expression.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/ref_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/prepared_stmt.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_result_set_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_row_data_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_schema_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/table_info.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/runtime_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/runtime_context_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_constant.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_negotiate.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_object.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/semaphore_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_pool.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_pool_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_queue.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/time_tick_monitor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/types_export.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/user_change_monitor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/value_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/combine_status.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator_aggregator.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator_linker.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/frame_combiner.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/frame_retainer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/header_converter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/message_transform.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/network_adapter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/protocol_proto.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/send_task_scheduler.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/serial_buffer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/intercepted_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_changed_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_delegate_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_errno.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_nb_conflict_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_nb_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_result_set_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_snapshot_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_changed_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/runtime_config.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/data_transformer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/db_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/default_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_single_ver_kv_entry.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/iconnection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/ikvdb_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_commit_notify_filterable_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_observer_handle.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_windowed_result_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/generic_multi_ver_kv_entry.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_commit.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_kvdata_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_notify_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_snapshot.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_transfer_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_vacuum.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_vacuum_executor_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_value_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/local_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/multi_ver_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/single_ver_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/package_file.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_row_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_store_instance.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_sync_able_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relationaldb_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/result_entries_window.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/single_ver_natural_store_commit_notify_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/collaboration_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/log_table_manager_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/query_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/query_sync_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/relational_remote_query_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_single_relational_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/split_device_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb_snapshot.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_data_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_transaction.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_query_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_forward_cursor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_result_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_schema_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_cache.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_subscribe.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_engine_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader/single_ver_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader/single_ver_schema_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/ability_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/commit_history_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/communicator_proxy.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/db_ability.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/device_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/generic_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/meta_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_data_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/query_sync_water_mark_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/remote_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/remote_executor_packet.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_message_schedule.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_packet.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_sync_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_kv_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_kv_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_relational_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_relational_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_serialize_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_target.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/subscribe_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_config.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_operation.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_target.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/syncer_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/syncer_proxy.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/time_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/time_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/value_slice_sync.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/fuzztest/common/distributeddb_tools_test.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/unittest/common/common/distributeddb_data_generate_unit_test.cpp", "parseckeck_fuzzer.cpp", @@ -83,12 +277,15 @@ ohos_fuzztest("ParseCkeckFuzzTest") { "OMIT_FLATBUFFER", "RELATIONAL_STORE", "SQLITE_DISTRIBUTE_RELATIONAL", + "SQLITE_ENABLE_DROPTABLE_CALLBACK", ] deps = [ "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", "//third_party/jsoncpp:jsoncpp", "//third_party/openssl:libcrypto_shared", + "//third_party/sqlite:sqlite", + "//third_party/zlib:shared_libz", ] external_deps = [ diff --git a/kv_store/frameworks/libs/distributeddb/test/fuzztest/query_fuzzer/BUILD.gn b/kv_store/frameworks/libs/distributeddb/test/fuzztest/query_fuzzer/BUILD.gn index f40c73a3d72f4a6630bfa65e3ea90a9d24ade785..d3ff70fbdf690b5548ba02f0a931af99946ac29f 100644 --- a/kv_store/frameworks/libs/distributeddb/test/fuzztest/query_fuzzer/BUILD.gn +++ b/kv_store/frameworks/libs/distributeddb/test/fuzztest/query_fuzzer/BUILD.gn @@ -25,12 +25,18 @@ ohos_fuzztest("QueryFuzzTest") { "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/unittest/common/storage", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/include", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/include/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src", - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/include", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/include/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src", @@ -56,12 +62,201 @@ ohos_fuzztest("QueryFuzzTest") { fuzz_config_file = "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/fuzztest/query_fuzzer" sources = [ + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/auto_launch.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/data_compression.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/data_value.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_common.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_constant.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_dfx_adapter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_dump_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_epoll.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_select.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/ievent.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/ievent_loop.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/flatbuffer_schema.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/hash.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/json_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/lock_status_observer.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/log_print.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/notification_chain.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/param_check_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/parcel.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/performance_analysis.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/platform_specific.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/query.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/query_expression.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/ref_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/prepared_stmt.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_result_set_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_row_data_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_schema_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/table_info.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/runtime_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/runtime_context_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_constant.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_negotiate.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_object.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/semaphore_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_pool.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_pool_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_queue.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/time_tick_monitor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/types_export.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/user_change_monitor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/value_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/combine_status.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator_aggregator.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator_linker.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/frame_combiner.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/frame_retainer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/header_converter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/message_transform.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/network_adapter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/protocol_proto.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/send_task_scheduler.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/serial_buffer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/intercepted_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_changed_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_delegate_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_errno.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_nb_conflict_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_nb_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_result_set_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_snapshot_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_changed_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/runtime_config.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/data_transformer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/db_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/default_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_single_ver_kv_entry.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/iconnection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/ikvdb_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_commit_notify_filterable_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_observer_handle.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_windowed_result_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/generic_multi_ver_kv_entry.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_commit.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_kvdata_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_notify_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_snapshot.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_transfer_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_vacuum.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_vacuum_executor_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_value_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/local_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/multi_ver_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/single_ver_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/package_file.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_row_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_store_instance.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_sync_able_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relationaldb_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/result_entries_window.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/single_ver_natural_store_commit_notify_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/collaboration_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/log_table_manager_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/query_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/query_sync_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/relational_remote_query_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_single_relational_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/split_device_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb_snapshot.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_data_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_transaction.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_query_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_forward_cursor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_result_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_schema_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_cache.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_subscribe.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_engine_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader/single_ver_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader/single_ver_schema_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/ability_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/commit_history_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/communicator_proxy.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/db_ability.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/device_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/generic_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/meta_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_data_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/query_sync_water_mark_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/remote_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/remote_executor_packet.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_message_schedule.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_packet.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_sync_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_kv_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_kv_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_relational_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_relational_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_serialize_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_target.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/subscribe_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_config.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_operation.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_target.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/syncer_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/syncer_proxy.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/time_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/time_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/value_slice_sync.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/unittest/common/common/distributeddb_data_generate_unit_test.cpp", "query_fuzzer.cpp", ] @@ -80,12 +275,15 @@ ohos_fuzztest("QueryFuzzTest") { "OMIT_FLATBUFFER", "RELATIONAL_STORE", "SQLITE_DISTRIBUTE_RELATIONAL", + "SQLITE_ENABLE_DROPTABLE_CALLBACK", ] deps = [ "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", "//third_party/jsoncpp:jsoncpp", "//third_party/openssl:libcrypto_shared", + "//third_party/sqlite:sqlite", + "//third_party/zlib:shared_libz", ] external_deps = [ diff --git a/kv_store/frameworks/libs/distributeddb/test/fuzztest/rekey_fuzzer/BUILD.gn b/kv_store/frameworks/libs/distributeddb/test/fuzztest/rekey_fuzzer/BUILD.gn index f6c00e2c45cc6b9f8634c1e91851047d7bd02193..74f91697f980ad5bf18c98c9cb56a95a53e8afe3 100644 --- a/kv_store/frameworks/libs/distributeddb/test/fuzztest/rekey_fuzzer/BUILD.gn +++ b/kv_store/frameworks/libs/distributeddb/test/fuzztest/rekey_fuzzer/BUILD.gn @@ -26,12 +26,18 @@ ohos_fuzztest("ReKeyFuzzTest") { "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/unittest/common/storage", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/include", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/include/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src", - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/include", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/include/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src", @@ -57,9 +63,201 @@ ohos_fuzztest("ReKeyFuzzTest") { fuzz_config_file = "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/fuzztest/rekey_fuzzer" sources = [ + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/auto_launch.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/data_compression.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/data_value.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_common.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_constant.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_dfx_adapter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_dump_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_epoll.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_select.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/ievent.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/ievent_loop.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/flatbuffer_schema.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/hash.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/json_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/lock_status_observer.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/log_print.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/notification_chain.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/param_check_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/parcel.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/performance_analysis.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/platform_specific.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/query.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/query_expression.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/ref_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/prepared_stmt.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_result_set_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_row_data_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_schema_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/table_info.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/runtime_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/runtime_context_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_constant.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_negotiate.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/semaphore_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_pool.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_pool_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_queue.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/time_tick_monitor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/types_export.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/user_change_monitor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/value_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/combine_status.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator_aggregator.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator_linker.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/frame_combiner.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/frame_retainer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/header_converter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/message_transform.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/network_adapter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/protocol_proto.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/send_task_scheduler.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/serial_buffer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/intercepted_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_changed_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_delegate_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_errno.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_nb_conflict_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_nb_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_result_set_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_snapshot_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_changed_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/runtime_config.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/data_transformer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/db_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/default_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_single_ver_kv_entry.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/iconnection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/ikvdb_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_commit_notify_filterable_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_observer_handle.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_windowed_result_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/generic_multi_ver_kv_entry.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_commit.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_kvdata_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_notify_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_snapshot.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_transfer_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_vacuum.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_vacuum_executor_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_value_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/local_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/multi_ver_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/single_ver_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/package_file.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_row_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_store_instance.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_sync_able_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relationaldb_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/result_entries_window.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/single_ver_natural_store_commit_notify_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/collaboration_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/log_table_manager_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/query_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/query_sync_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/relational_remote_query_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_single_relational_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/split_device_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb_snapshot.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_data_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_transaction.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_query_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_forward_cursor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_result_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_schema_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_cache.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_subscribe.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_engine_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader/single_ver_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader/single_ver_schema_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/ability_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/commit_history_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/communicator_proxy.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/db_ability.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/device_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/generic_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/meta_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_data_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/query_sync_water_mark_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/remote_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/remote_executor_packet.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_message_schedule.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_packet.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_sync_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_kv_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_kv_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_relational_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_relational_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_serialize_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_target.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/subscribe_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_config.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_operation.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_target.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/syncer_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/syncer_proxy.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/time_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/time_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/value_slice_sync.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/fuzztest/common/distributeddb_tools_test.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/unittest/common/common/distributeddb_data_generate_unit_test.cpp", "rekey_fuzzer.cpp", @@ -79,12 +277,15 @@ ohos_fuzztest("ReKeyFuzzTest") { "OMIT_FLATBUFFER", "RELATIONAL_STORE", "SQLITE_DISTRIBUTE_RELATIONAL", + "SQLITE_ENABLE_DROPTABLE_CALLBACK", ] deps = [ "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", "//third_party/jsoncpp:jsoncpp", "//third_party/openssl:libcrypto_shared", + "//third_party/sqlite:sqlite", + "//third_party/zlib:shared_libz", ] external_deps = [ diff --git a/kv_store/frameworks/libs/distributeddb/test/fuzztest/relationalstoredelegate_fuzzer/BUILD.gn b/kv_store/frameworks/libs/distributeddb/test/fuzztest/relationalstoredelegate_fuzzer/BUILD.gn index 10541455230d3a6530f2a69fe7edb16848af54d1..9c18e643f2820b0b2ef95d4b3dafb954e6991850 100644 --- a/kv_store/frameworks/libs/distributeddb/test/fuzztest/relationalstoredelegate_fuzzer/BUILD.gn +++ b/kv_store/frameworks/libs/distributeddb/test/fuzztest/relationalstoredelegate_fuzzer/BUILD.gn @@ -27,12 +27,18 @@ ohos_fuzztest("RelationalstoredelegateFuzzTest") { "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/include/distributeddb", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/include", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/include/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src", - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/include", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/include/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src", @@ -58,9 +64,201 @@ ohos_fuzztest("RelationalstoredelegateFuzzTest") { fuzz_config_file = "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/fuzztest/relationalstoredelegate_fuzzer" sources = [ + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/auto_launch.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/data_compression.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/data_value.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_common.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_constant.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_dfx_adapter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_dump_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_epoll.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_select.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/ievent.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/ievent_loop.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/flatbuffer_schema.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/hash.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/json_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/lock_status_observer.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/log_print.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/notification_chain.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/param_check_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/parcel.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/performance_analysis.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/platform_specific.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/query.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/query_expression.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/ref_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/prepared_stmt.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_result_set_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_row_data_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_schema_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/table_info.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/runtime_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/runtime_context_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_constant.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_negotiate.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/semaphore_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_pool.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_pool_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_queue.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/time_tick_monitor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/types_export.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/user_change_monitor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/value_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/combine_status.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator_aggregator.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator_linker.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/frame_combiner.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/frame_retainer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/header_converter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/message_transform.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/network_adapter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/protocol_proto.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/send_task_scheduler.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/serial_buffer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/intercepted_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_changed_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_delegate_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_errno.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_nb_conflict_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_nb_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_result_set_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_snapshot_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_changed_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/runtime_config.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/data_transformer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/db_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/default_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_single_ver_kv_entry.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/iconnection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/ikvdb_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_commit_notify_filterable_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_observer_handle.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_windowed_result_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/generic_multi_ver_kv_entry.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_commit.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_kvdata_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_notify_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_snapshot.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_transfer_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_vacuum.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_vacuum_executor_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_value_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/local_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/multi_ver_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/single_ver_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/package_file.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_row_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_store_instance.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_sync_able_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relationaldb_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/result_entries_window.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/single_ver_natural_store_commit_notify_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/collaboration_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/log_table_manager_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/query_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/query_sync_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/relational_remote_query_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_single_relational_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/split_device_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb_snapshot.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_data_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_transaction.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_query_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_forward_cursor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_result_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_schema_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_cache.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_subscribe.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_engine_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader/single_ver_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader/single_ver_schema_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/ability_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/commit_history_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/communicator_proxy.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/db_ability.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/device_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/generic_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/meta_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_data_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/query_sync_water_mark_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/remote_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/remote_executor_packet.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_message_schedule.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_packet.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_sync_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_kv_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_kv_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_relational_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_relational_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_serialize_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_target.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/subscribe_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_config.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_operation.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_target.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/syncer_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/syncer_proxy.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/time_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/time_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/value_slice_sync.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/fuzztest/common/distributeddb_tools_test.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/fuzztest/common/fuzzer_data.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/fuzztest/relationalstoredelegate_fuzzer/relationalstoredelegate_fuzzer.cpp", @@ -84,6 +282,7 @@ ohos_fuzztest("RelationalstoredelegateFuzzTest") { "RELATIONAL_STORE", "SQLITE_DISTRIBUTE_RELATIONAL", "SQLITE_EXPORT_SYMBOLS", + "SQLITE_ENABLE_DROPTABLE_CALLBACK", ] deps = [ @@ -91,6 +290,7 @@ ohos_fuzztest("RelationalstoredelegateFuzzTest") { "//third_party/jsoncpp:jsoncpp", "//third_party/openssl:libcrypto_shared", "//third_party/sqlite:sqlite", + "//third_party/zlib:shared_libz", ] external_deps = [ diff --git a/kv_store/frameworks/libs/distributeddb/test/fuzztest/relationalstoremanager_fuzzer/BUILD.gn b/kv_store/frameworks/libs/distributeddb/test/fuzztest/relationalstoremanager_fuzzer/BUILD.gn index 558de907d0999f5d49d5ddb7287d073ae6ef3b04..6139ab5a43b28887c207c268800265103b6db518 100644 --- a/kv_store/frameworks/libs/distributeddb/test/fuzztest/relationalstoremanager_fuzzer/BUILD.gn +++ b/kv_store/frameworks/libs/distributeddb/test/fuzztest/relationalstoremanager_fuzzer/BUILD.gn @@ -25,14 +25,19 @@ ohos_fuzztest("RelationalstoremanagerFuzzTest") { "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/unittest/common/syncer", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/unittest/common/storage", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/include", - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/include/distributeddb", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/include", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/include/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src", - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/include", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/include/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src", @@ -58,9 +63,201 @@ ohos_fuzztest("RelationalstoremanagerFuzzTest") { fuzz_config_file = "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/fuzztest/relationalstoremanager_fuzzer" sources = [ + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/auto_launch.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/data_compression.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/data_value.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_common.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_constant.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_dfx_adapter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_dump_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_epoll.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_select.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/ievent.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/ievent_loop.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/flatbuffer_schema.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/hash.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/json_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/lock_status_observer.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/log_print.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/notification_chain.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/param_check_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/parcel.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/performance_analysis.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/platform_specific.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/query.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/query_expression.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/ref_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/prepared_stmt.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_result_set_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_row_data_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_schema_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/table_info.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/runtime_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/runtime_context_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_constant.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_negotiate.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/semaphore_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_pool.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_pool_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_queue.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/time_tick_monitor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/types_export.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/user_change_monitor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/value_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/combine_status.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator_aggregator.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator_linker.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/frame_combiner.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/frame_retainer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/header_converter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/message_transform.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/network_adapter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/protocol_proto.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/send_task_scheduler.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/serial_buffer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/intercepted_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_changed_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_delegate_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_errno.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_nb_conflict_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_nb_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_result_set_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_snapshot_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_changed_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/runtime_config.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/data_transformer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/db_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/default_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_single_ver_kv_entry.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/iconnection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/ikvdb_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_commit_notify_filterable_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_observer_handle.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_windowed_result_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/generic_multi_ver_kv_entry.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_commit.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_kvdata_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_notify_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_snapshot.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_transfer_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_vacuum.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_vacuum_executor_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_value_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/local_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/multi_ver_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/single_ver_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/package_file.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_row_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_store_instance.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_sync_able_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relationaldb_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/result_entries_window.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/single_ver_natural_store_commit_notify_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/collaboration_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/log_table_manager_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/query_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/query_sync_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/relational_remote_query_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_single_relational_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/split_device_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb_snapshot.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_data_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_transaction.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_query_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_forward_cursor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_result_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_schema_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_cache.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_subscribe.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_engine_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader/single_ver_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader/single_ver_schema_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/ability_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/commit_history_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/communicator_proxy.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/db_ability.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/device_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/generic_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/meta_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_data_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/query_sync_water_mark_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/remote_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/remote_executor_packet.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_message_schedule.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_packet.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_sync_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_kv_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_kv_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_relational_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_relational_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_serialize_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_target.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/subscribe_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_config.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_operation.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_target.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/syncer_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/syncer_proxy.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/time_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/time_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/value_slice_sync.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/fuzztest/common/distributeddb_tools_test.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/fuzztest/common/fuzzer_data.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/fuzztest/relationalstoremanager_fuzzer/relationalstoremanager_fuzzer.cpp", @@ -84,6 +281,7 @@ ohos_fuzztest("RelationalstoremanagerFuzzTest") { "RELATIONAL_STORE", "SQLITE_DISTRIBUTE_RELATIONAL", "SQLITE_EXPORT_SYMBOLS", + "SQLITE_ENABLE_DROPTABLE_CALLBACK", ] deps = [ @@ -91,6 +289,7 @@ ohos_fuzztest("RelationalstoremanagerFuzzTest") { "//third_party/jsoncpp:jsoncpp", "//third_party/openssl:libcrypto_shared", "//third_party/sqlite:sqlite", + "//third_party/zlib:shared_libz", ] external_deps = [ diff --git a/kv_store/frameworks/libs/distributeddb/test/fuzztest/schemadelegate_fuzzer/BUILD.gn b/kv_store/frameworks/libs/distributeddb/test/fuzztest/schemadelegate_fuzzer/BUILD.gn index e9fbd144dff3ba206fc4c194928c08194377eda4..5138b341d276c5a2c869afb701384624536ca003 100644 --- a/kv_store/frameworks/libs/distributeddb/test/fuzztest/schemadelegate_fuzzer/BUILD.gn +++ b/kv_store/frameworks/libs/distributeddb/test/fuzztest/schemadelegate_fuzzer/BUILD.gn @@ -26,12 +26,18 @@ ohos_fuzztest("SchemaDelegateFuzzTest") { "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/unittest/common/storage", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/include", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/include/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src", - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/include", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/include/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src", @@ -55,9 +61,201 @@ ohos_fuzztest("SchemaDelegateFuzzTest") { fuzz_config_file = "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/fuzztest/schemadelegate_fuzzer" sources = [ + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/auto_launch.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/data_compression.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/data_value.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_common.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_constant.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_dfx_adapter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_dump_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_epoll.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_select.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/ievent.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/ievent_loop.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/flatbuffer_schema.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/hash.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/json_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/lock_status_observer.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/log_print.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/notification_chain.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/param_check_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/parcel.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/performance_analysis.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/platform_specific.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/query.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/query_expression.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/ref_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/prepared_stmt.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_result_set_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_row_data_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_schema_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/table_info.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/runtime_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/runtime_context_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_constant.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_negotiate.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/semaphore_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_pool.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_pool_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_queue.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/time_tick_monitor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/types_export.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/user_change_monitor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/value_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/combine_status.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator_aggregator.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator_linker.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/frame_combiner.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/frame_retainer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/header_converter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/message_transform.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/network_adapter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/protocol_proto.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/send_task_scheduler.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/serial_buffer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/intercepted_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_changed_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_delegate_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_errno.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_nb_conflict_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_nb_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_result_set_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_snapshot_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_changed_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/runtime_config.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/data_transformer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/db_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/default_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_single_ver_kv_entry.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/iconnection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/ikvdb_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_commit_notify_filterable_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_observer_handle.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_windowed_result_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/generic_multi_ver_kv_entry.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_commit.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_kvdata_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_notify_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_snapshot.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_transfer_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_vacuum.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_vacuum_executor_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_value_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/local_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/multi_ver_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/single_ver_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/package_file.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_row_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_store_instance.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_sync_able_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relationaldb_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/result_entries_window.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/single_ver_natural_store_commit_notify_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/collaboration_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/log_table_manager_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/query_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/query_sync_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/relational_remote_query_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_single_relational_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/split_device_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb_snapshot.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_data_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_transaction.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_query_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_forward_cursor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_result_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_schema_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_cache.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_subscribe.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_engine_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader/single_ver_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader/single_ver_schema_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/ability_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/commit_history_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/communicator_proxy.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/db_ability.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/device_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/generic_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/meta_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_data_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/query_sync_water_mark_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/remote_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/remote_executor_packet.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_message_schedule.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_packet.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_sync_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_kv_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_kv_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_relational_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_relational_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_serialize_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_target.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/subscribe_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_config.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_operation.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_target.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/syncer_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/syncer_proxy.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/time_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/time_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/value_slice_sync.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/fuzztest/common/distributeddb_tools_test.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/fuzztest/common/fuzzer_data.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/unittest/common/common/distributeddb_data_generate_unit_test.cpp", @@ -78,12 +276,15 @@ ohos_fuzztest("SchemaDelegateFuzzTest") { "OMIT_FLATBUFFER", "RELATIONAL_STORE", "SQLITE_DISTRIBUTE_RELATIONAL", + "SQLITE_ENABLE_DROPTABLE_CALLBACK", ] deps = [ "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", "//third_party/jsoncpp:jsoncpp", "//third_party/openssl:libcrypto_shared", + "//third_party/sqlite:sqlite", + "//third_party/zlib:shared_libz", ] external_deps = [ diff --git a/kv_store/frameworks/libs/distributeddb/test/fuzztest/sync_fuzzer/BUILD.gn b/kv_store/frameworks/libs/distributeddb/test/fuzztest/sync_fuzzer/BUILD.gn index 76e3ead5d3d22dcec8cdbefa3420242a9dd72d2b..55cbb16d131a84af4e56369bb7a628d877578115 100644 --- a/kv_store/frameworks/libs/distributeddb/test/fuzztest/sync_fuzzer/BUILD.gn +++ b/kv_store/frameworks/libs/distributeddb/test/fuzztest/sync_fuzzer/BUILD.gn @@ -26,12 +26,18 @@ ohos_fuzztest("SyncFuzzTest") { "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/unittest/common/storage", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/include", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/include/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src", - "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/include", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/include/relational", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/include", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src", @@ -57,9 +63,201 @@ ohos_fuzztest("SyncFuzzTest") { fuzz_config_file = "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/fuzztest/sync_fuzzer" sources = [ + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/auto_launch.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/data_compression.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/data_value.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_common.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_constant.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_dfx_adapter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/db_dump_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_epoll.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_select.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/ievent.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/evloop/src/ievent_loop.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/flatbuffer_schema.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/hash.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/json_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/lock_status_observer.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/log_print.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/notification_chain.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/param_check_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/parcel.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/performance_analysis.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/platform_specific.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/query.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/query_expression.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/ref_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/prepared_stmt.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_result_set_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_row_data_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/relational_schema_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/relational/table_info.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/runtime_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/runtime_context_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_constant.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_negotiate.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/schema_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/semaphore_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_pool.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_pool_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/task_queue.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/time_tick_monitor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/types_export.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/user_change_monitor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/common/src/value_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/combine_status.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator_aggregator.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/communicator_linker.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/frame_combiner.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/frame_retainer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/header_converter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/message_transform.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/network_adapter.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/protocol_proto.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/send_task_scheduler.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/communicator/src/serial_buffer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/intercepted_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_changed_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_delegate_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_errno.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_nb_conflict_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_nb_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_result_set_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/kv_store_snapshot_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_changed_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_delegate_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/src/runtime_config.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/data_transformer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/db_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/default_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/generic_single_ver_kv_entry.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/iconnection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/ikvdb_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_commit_notify_filterable_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_observer_handle.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/kvdb_windowed_result_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/generic_multi_ver_kv_entry.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_commit.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_kvdata_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_notify_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_snapshot.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_transfer_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_vacuum.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_vacuum_executor_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/multiver/multi_ver_value_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/local_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/multi_ver_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/operation/single_ver_database_oper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/package_file.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_row_data_impl.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_store_instance.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relational_sync_able_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/relationaldb_properties.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/result_entries_window.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/single_ver_natural_store_commit_notify_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/collaboration_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/log_table_manager_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/query_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/query_sync_object.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/relational_remote_query_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/relational/sqlite_single_relational_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/split_device_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_kvdb_snapshot.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_local_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_log_table_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_data_storage.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_transaction.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_query_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_forward_cursor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_continue_token.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_result_set.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_schema_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_cache.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_subscribe.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_engine_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/storage_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_kvdb.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/sync_able_kvdb_connection.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader/single_ver_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/storage/src/upgrader/single_ver_schema_database_upgrader.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/ability_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/commit_history_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/communicator_proxy.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/db_ability.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/device_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/generic_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/meta_data.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_data_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/multi_ver_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/query_sync_water_mark_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/remote_executor.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/remote_executor_packet.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_message_schedule.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_packet.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_data_sync_utils.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_kv_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_kv_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_relational_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_relational_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_serialize_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_target.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/single_ver_syncer.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/subscribe_manager.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_config.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_engine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_operation.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_state_machine.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_target.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/sync_task_context.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/syncer_factory.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/syncer_proxy.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/time_helper.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/time_sync.cpp", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/syncer/src/value_slice_sync.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/fuzztest/common/distributeddb_tools_test.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/unittest/common/syncer/generic_virtual_device.cpp", "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/test/unittest/common/syncer/kv_virtual_device.cpp", @@ -84,12 +282,15 @@ ohos_fuzztest("SyncFuzzTest") { "OMIT_MULTI_VER", "RELATIONAL_STORE", "SQLITE_DISTRIBUTE_RELATIONAL", + "SQLITE_ENABLE_DROPTABLE_CALLBACK", ] deps = [ "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", "//third_party/jsoncpp:jsoncpp", "//third_party/openssl:libcrypto_shared", + "//third_party/sqlite:sqlite", + "//third_party/zlib:shared_libz", ] external_deps = [ diff --git a/kv_store/frameworks/libs/distributeddb/test/moduletest/BUILD.gn b/kv_store/frameworks/libs/distributeddb/test/moduletest/BUILD.gn index 0095263f882c87ad973f46cf988f6a6fcee1787b..eeb51b201b37a3e04334d951c402879e01e99177 100644 --- a/kv_store/frameworks/libs/distributeddb/test/moduletest/BUILD.gn +++ b/kv_store/frameworks/libs/distributeddb/test/moduletest/BUILD.gn @@ -58,6 +58,7 @@ config("module_private_config") { "LOW_LEVEL_MEM_DEV", "RELEASE_MODE_V2", "RELEASE_MODE_V3", + "OMIT_MULTI_VER", ] ldflags = [ "-Wl,--exclude-libs,ALL" ] } diff --git a/kv_store/frameworks/libs/distributeddb/test/moduletest/common/distributeddb/include/distributeddb_nb_test_tools.h b/kv_store/frameworks/libs/distributeddb/test/moduletest/common/distributeddb/include/distributeddb_nb_test_tools.h index b75b70866c89256ae1758e8a557e5e0d7f07b842..fdc8b858a60e52de5bedaa3eb327e35b97b9dc04 100644 --- a/kv_store/frameworks/libs/distributeddb/test/moduletest/common/distributeddb/include/distributeddb_nb_test_tools.h +++ b/kv_store/frameworks/libs/distributeddb/test/moduletest/common/distributeddb/include/distributeddb_nb_test_tools.h @@ -351,6 +351,7 @@ private: }; #endif // endif of RELEASE_MODE_V2 - bool EndCaseDeleteDB(DistributedDB::KvStoreDelegateManager *&manager, DistributedDB::KvStoreNbDelegate *&nbDelegate, - const std::string base, bool isMemoryDb); +bool EndCaseDeleteDB(DistributedDB::KvStoreDelegateManager *&manager, DistributedDB::KvStoreNbDelegate *&nbDelegate, + const std::string base, bool isMemoryDb); + #endif // DISTRIBUTEDDB_NB_TEST_TOOLS_H \ No newline at end of file diff --git a/kv_store/frameworks/libs/distributeddb/test/moduletest/common/distributeddb/src/distributed_rdb_tools.cpp b/kv_store/frameworks/libs/distributeddb/test/moduletest/common/distributeddb/src/distributed_rdb_tools.cpp index ac2ba1e346fa81dd7e25e634301d6d2be76009a5..7c36546d57ff3b8b855524eb303c938d1586fe17 100644 --- a/kv_store/frameworks/libs/distributeddb/test/moduletest/common/distributeddb/src/distributed_rdb_tools.cpp +++ b/kv_store/frameworks/libs/distributeddb/test/moduletest/common/distributeddb/src/distributed_rdb_tools.cpp @@ -92,9 +92,6 @@ DBStatus DistributedRdbTools::GetOpenStoreStatus(const RelatetionalStoreManager MST_LOG("%s GetRdbStore failed! manager nullptr.", TAG.c_str()); return DBStatus::DB_ERROR; } - if (delegate != nullptr) { - delegate = nullptr; - } DBStatus status = manager->OpenStore(param.path, param.storeId, delegate); if (delegate == nullptr) { MST_LOG("%s GetRdbStore failed! delegate nullptr.", TAG.c_str()); @@ -128,12 +125,12 @@ bool DistributedRdbTools::InitSqlite3Store(sqlite3 *&db, const RdbParameters &pa const std::string dbName = param.path + param.storeId + ".db"; DBStributedDB::OS::RemoveFile(dbName); int errCode = sqlite3_open(dbName, &db); - if (errCode1 != SQLITE_OK) { + if (errCode != SQLITE_OK) { MST_LOG("sqlite3_open Failed!"); return false; } - errCode = sqlite3_exec(db, "PRAGMA journal_mode = WAL;", 0, 0, 0); - if (errCode != SQLITE_OK) { + int errCode1 = sqlite3_exec(db, "PRAGMA journal_mode = WAL;", 0, 0, 0); + if (errCode1 != SQLITE_OK) { MST_LOG("PRAGMA journal_mode = WAL Failed!"); return false; } @@ -166,7 +163,7 @@ bool DistributedRdbTools::InitTableDataAndTrigger(const sqlite3 *&db) SqliteExecSql(db, SQL_INSERT_NORMAL_TABLE); for (int i = 1; i <= MAX_DISTRIBUTED_TABLE_COUNT + 1; i++) { - std::string str_0 = "RDB_" + i; + std::string str_0 = "RDB_" + std::to_string(i); std::string str_1 = "CREATE TABLE IF NOT EXISTS " std::string str_2 = "( id INT NOT NULL PRIMARY KEY AUTO_INCREMENT," \ "name VARCHAR(100) NOT NULL, age VARCHAR(100) NOT NULL);"; @@ -191,32 +188,32 @@ bool DistributedRdbTools::AlterTableAttributes(const sqlite3 *&db) return false; } - errCode = sqlite3_exec(db, SQL_ADD_INDEX_TABLE2, nullptr, nullptr, &errMsg); - if (errCode != SQLITE_OK && errMsg != nullptr) { + int errCode1 = sqlite3_exec(db, SQL_ADD_INDEX_TABLE2, nullptr, nullptr, &errMsg); + if (errCode1 != SQLITE_OK && errMsg != nullptr) { MST_LOG("sqlite3_exec SQL_ADD_INDEX_TABLE2 Failed(%s)", errMsg.c_str()); return false; } - errCode = sqlite3_exec(db, SQL_DROP_TABLE3, nullptr, nullptr, &errMsg); - if (errCode != SQLITE_OK && errMsg != nullptr) { + int errCode2 = sqlite3_exec(db, SQL_DROP_TABLE3, nullptr, nullptr, &errMsg); + if (errCode2 != SQLITE_OK && errMsg != nullptr) { MST_LOG("sqlite3_exec SQL_DROP_TABLE3 Failed(%s)", errMsg.c_str()); return false; } - errCode = sqlite3_exec(db, SQL_DROP_CREATE_TABLE3, nullptr, nullptr, &errMsg); - if (errCode1 != SQLITE_OK && errMsg != nullptr) { + int errCode3 = sqlite3_exec(db, SQL_DROP_CREATE_TABLE3, nullptr, nullptr, &errMsg); + if (errCode3 != SQLITE_OK && errMsg != nullptr) { MST_LOG("sqlite3_exec SQL_ADD_INDEX_TABLE Failed(%s)", errMsg.c_str()); return false; } - errCode = sqlite3_exec(db, SQL_DROP_TABLE4, nullptr, nullptr, &errMsg); - if (errCode != SQLITE_OK && errMsg != nullptr) { + int errCode4 = sqlite3_exec(db, SQL_DROP_TABLE4, nullptr, nullptr, &errMsg); + if (errCode4 != SQLITE_OK && errMsg != nullptr) { MST_LOG("sqlite3_exec SQL_DROP_TABLE4 Failed(%s)", errMsg.c_str()); return false; } - errCode = sqlite3_exec(db, SQL_DROP_CREATE_TABLE4, nullptr, nullptr, &errMsg); - if (errCode != SQLITE_OK && errMsg != nullptr) { + int errCode5 = sqlite3_exec(db, SQL_DROP_CREATE_TABLE4, nullptr, nullptr, &errMsg); + if (errCode5 != SQLITE_OK && errMsg != nullptr) { MST_LOG("sqlite3_exec SQL_DROP_CREATE_TABLE4 Failed(%s)", errMsg.c_str()); return false; } diff --git a/kv_store/frameworks/libs/distributeddb/test/moduletest/common/distributeddb/src/distributeddb_schema_test_tools.cpp b/kv_store/frameworks/libs/distributeddb/test/moduletest/common/distributeddb/src/distributeddb_schema_test_tools.cpp index 21f88d963f65b7b3bce9f3649afdf4f53a5efe48..094e78eb6ae808ce9001f074f8bf6b5c756efbd3 100644 --- a/kv_store/frameworks/libs/distributeddb/test/moduletest/common/distributeddb/src/distributeddb_schema_test_tools.cpp +++ b/kv_store/frameworks/libs/distributeddb/test/moduletest/common/distributeddb/src/distributeddb_schema_test_tools.cpp @@ -241,7 +241,7 @@ bool DistributedDBSchemaTestTools::PreInsertRecords(KvStoreNbDelegate *&delegate } // insert query condition between brackets. -static void SpliceQueryMethod(int flag, Query &query) +void SpliceQueryMethod(int flag, Query &query) { switch (flag) { case 0: // query condition 0 diff --git a/kv_store/frameworks/libs/distributeddb/test/moduletest/include/distributed_crud_transaction_tools.h b/kv_store/frameworks/libs/distributeddb/test/moduletest/include/distributed_crud_transaction_tools.h index 1363b2780c3bf4b25fde56c21de852c7b9d890ac..37e3605a574848e064f977c1200e80c2cb6624b9 100644 --- a/kv_store/frameworks/libs/distributeddb/test/moduletest/include/distributed_crud_transaction_tools.h +++ b/kv_store/frameworks/libs/distributeddb/test/moduletest/include/distributed_crud_transaction_tools.h @@ -14,7 +14,7 @@ */ #ifndef DISTRIBUTED_DB_MODULE_CRUD_TRANSACTION_TOOLS_H #define DISTRIBUTED_DB_MODULE_CRUD_TRANSACTION_TOOLS_H - +#ifndef OMIT_MULTI_VER #include "kv_store_delegate.h" #include "kv_store_delegate_manager.h" @@ -60,5 +60,5 @@ private: bool secondComplete_ = false; bool success_ = true; }; - +#endif // OMIT_MULTI_VER #endif // DISTRIBUTED_DB_MODULE_CRUD_TRANSACTION_TOOLS_H \ No newline at end of file diff --git a/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributed_crud_transaction_tools.cpp b/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributed_crud_transaction_tools.cpp index a9fa618047bb1c9576600ffab832fea4f924213d..b439bebd4dc0562a35d3b211c16dcfb608c2e8dc 100644 --- a/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributed_crud_transaction_tools.cpp +++ b/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributed_crud_transaction_tools.cpp @@ -12,6 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#ifndef OMIT_MULTI_VER #include "distributed_crud_transaction_tools.h" #include #include @@ -199,8 +200,8 @@ void SleepOneSecond() std::this_thread::sleep_for(std::chrono::duration(1)); } -bool DeleteDataBase(bool success_, KvStoreDelegate *delegate1, KvStoreDelegate *delegate2, - KvStoreDelegateManager *delegateManager1, KvStoreDelegateManager *delegateManager2) +bool DeleteDataBase(bool success_, KvStoreDelegate *&delegate1, KvStoreDelegate *&delegate2, + KvStoreDelegateManager *&delegateManager1, KvStoreDelegateManager *&delegateManager2) { SleepOneSecond(); if ((delegateManager1->CloseKvStore(delegate1) != OK) || @@ -271,4 +272,5 @@ bool DistributedCrudTransactionTools::testCrudTransaction() ERROR: secondComplete_ = true; return false; -} \ No newline at end of file +} +#endif // OMIT_MULTI_VER \ No newline at end of file diff --git a/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_backup_test.cpp b/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_backup_test.cpp index b168cdb5d8b4dcee15a7e05fa38725cfafe9be47..e592ca2b034a288c370b5ee251099f1600f59503 100644 --- a/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_backup_test.cpp +++ b/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_backup_test.cpp @@ -12,6 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#ifndef OMIT_MULTI_VER #include #include #include @@ -1223,4 +1224,5 @@ HWTEST_F(DistributeddbKvBackupTest, Exchange003, TestSize.Level2) EXPECT_EQ(g_kvBackupDelegate->Delete(KEY_2), OK); RemoveDir(exportPath); } -} \ No newline at end of file +} +#endif // OMIT_MULTI_VER \ No newline at end of file diff --git a/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_batch_crud_test.cpp b/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_batch_crud_test.cpp index 8784a7a8d488b010d6ce25ed6badef94d2f4489d..dfba8cf922c71a6c1515173ebc6460e443675b3e 100644 --- a/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_batch_crud_test.cpp +++ b/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_batch_crud_test.cpp @@ -12,6 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#ifndef OMIT_MULTI_VER #include #include #include @@ -1083,3 +1084,4 @@ HWTEST_F(DistributeddbKvBatchCrudTest, ComplexSnap002, TestSize.Level1) DistributedTestTools::Clear(*g_kvStoreBatchDelegate); } } +#endif // OMIT_MULTI_VER diff --git a/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_concurrency_crud_test.cpp b/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_concurrency_crud_test.cpp index 62612011c9225d085522c0b3bf95ae4917b94820..95bfcdc403fac9ca4162767b68d794e56bed0c85 100644 --- a/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_concurrency_crud_test.cpp +++ b/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_concurrency_crud_test.cpp @@ -12,6 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#ifndef OMIT_MULTI_VER #include #include #include @@ -321,3 +322,4 @@ HWTEST_F(DistributeddbKvConcurrencyCrudTest, ReadWrite004, TestSize.Level3) } #endif } +#endif // OMIT_MULTI_VER diff --git a/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_create_test.cpp b/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_create_test.cpp index 34166d4d5e5fe5b0180e7ff5c93d31ce447010f8..76341c65b1eee961e44e48df93157349acdbd372 100644 --- a/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_create_test.cpp +++ b/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_create_test.cpp @@ -12,6 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#ifndef OMIT_MULTI_VER #include #include #include @@ -1977,3 +1978,4 @@ HWTEST_F(DistributeddbKvCreateTest, MergeRepeat001, TestSize.Level2) } #endif } +#endif // OMIT_MULTI_VER diff --git a/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_crud_test.cpp b/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_crud_test.cpp index 16b064a468f176ef4e67f18562db2bd0d3ff9a89..b9ee63b181c366c4dce38013bf65a8784769cacb 100644 --- a/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_crud_test.cpp +++ b/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_crud_test.cpp @@ -12,6 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#ifndef OMIT_MULTI_VER #include #include #include @@ -717,4 +718,5 @@ HWTEST_F(DistributeddbKvCrudTest, ReadWritePerformance001, TestSize.Level3) DistributedTestTools::CalculateUseClearPerformance(performanceData[ps]); } } -} \ No newline at end of file +} +#endif // OMIT_MULTI_VER \ No newline at end of file diff --git a/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_observer_snap_test.cpp b/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_observer_snap_test.cpp index 4321f824ef2d6c523b3f690fbc28aaba66877aa4..f31d47f5f05d36f67a5dbe48ef6d3caf33d0973a 100644 --- a/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_observer_snap_test.cpp +++ b/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_observer_snap_test.cpp @@ -12,6 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#ifndef OMIT_MULTI_VER #include #include #include @@ -1584,4 +1585,5 @@ HWTEST_F(DistributeddbKvObserverSnapTest, RekeyDb001, TestSize.Level1) delete manager; manager = nullptr; } -} \ No newline at end of file +} +#endif // OMIT_MULTI_VER \ No newline at end of file diff --git a/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_observer_test.cpp b/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_observer_test.cpp index f3ac0120daba8e6c4a93c411b216b2e173726ed8..97f9303e1748f11226c352355a0ab4d61ad60b41 100644 --- a/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_observer_test.cpp +++ b/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_observer_test.cpp @@ -12,6 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#ifndef OMIT_MULTI_VER #include #include #include @@ -1681,3 +1682,4 @@ HWTEST_F(DistributeddbKvObserverTest, ObserverRekeyDb001, TestSize.Level3) } #endif } +#endif // OMIT_MULTI_VER \ No newline at end of file diff --git a/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_realdel_test.cpp b/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_realdel_test.cpp index 837cbaab05435b24889b9eccb09c22e38cea26e6..5e2879f887fdcd29d521583c3ccdb7f9dfc54a6e 100644 --- a/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_realdel_test.cpp +++ b/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_realdel_test.cpp @@ -12,6 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#ifndef OMIT_MULTI_VER #include #include #include @@ -371,4 +372,5 @@ HWTEST_F(DistributeddbKvRealdelTest, KvDeleteAll007, TestSize.Level2) manager2 = nullptr; } #endif -} \ No newline at end of file +} +#endif // OMIT_MULTI_VER \ No newline at end of file diff --git a/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_transaction_perf_test.cpp b/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_transaction_perf_test.cpp index 257ee5f97c41afdd569746c4d691145d6490a230..7fb8f49f6ef437ee5001b1f5aa29a8c4846b414c 100644 --- a/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_transaction_perf_test.cpp +++ b/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_transaction_perf_test.cpp @@ -12,6 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#ifndef OMIT_MULTI_VER #include #include "distributeddb_data_generator.h" @@ -336,4 +337,5 @@ HWTEST_F(DistributeddbKvTransactionPerfTest, Performance006, TestSize.Level3) EXPECT_TRUE(DistributedTestTools::CalculateGetUpdatePerformance(performance)); EXPECT_TRUE(DistributedTestTools::CalculateUseClearPerformance(performance)); } -} \ No newline at end of file +} +#endif // OMIT_MULTI_VER \ No newline at end of file diff --git a/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_transaction_test.cpp b/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_transaction_test.cpp index 4a4bc76805bb51ab8490e9e8008f1f8eb2cdd1c9..be2a5a731e4d62a9ff0a8821e168d91972160866 100644 --- a/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_transaction_test.cpp +++ b/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_kv_transaction_test.cpp @@ -12,6 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#ifndef OMIT_MULTI_VER #include #include #include @@ -1994,4 +1995,5 @@ HWTEST_F(DistributeddbKvTransactionTest, BasicActionAcid008, TestSize.Level2) EXPECT_TRUE(transactionTools.testCrudTransaction()); } } -} \ No newline at end of file +} +#endif // OMIT_MULTI_VER \ No newline at end of file diff --git a/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_nb_backup_test.cpp b/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_nb_backup_test.cpp index b2db1d98ba9658aa38884c34dd5fe3eea804b24d..817fe9c07e2c090e1ed08878e2635718bfd22571 100644 --- a/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_nb_backup_test.cpp +++ b/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_nb_backup_test.cpp @@ -662,6 +662,7 @@ HWTEST_F(DistributeddbNbBackupTest, ImportTest003, TestSize.Level1) * @tc.require: SR000D4878 * @tc.author: fengxiaoyun */ +#ifndef OMIT_MULTI_VER HWTEST_F(DistributeddbNbBackupTest, ImportTest004, TestSize.Level1) { KvStoreDelegate *multiEncryptDelegate = nullptr; @@ -732,7 +733,7 @@ HWTEST_F(DistributeddbNbBackupTest, ImportTest004, TestSize.Level1) RemoveDir(multiImportPath); RemoveDir(nbImportPath); } - +#endif // OMIT_MULTI_VER /* * @tc.name: ImportTest 006 * @tc.desc: Verify that many kvstore of one DB or the DB registered observer can't import the backup file. diff --git a/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_nb_batch_crud_test.cpp b/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_nb_batch_crud_test.cpp index b3f361d80105cee8b923ce6043ebbc2cf0a30479..fb3ebe9727271bd3c6f4b69af25a2d18f00bef21 100644 --- a/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_nb_batch_crud_test.cpp +++ b/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_nb_batch_crud_test.cpp @@ -14,6 +14,8 @@ */ #include #include +#include +#include #include "distributeddb_nb_test_tools.h" #include "process_communicator_test_stub.h" @@ -2469,4 +2471,58 @@ HWTEST_F(DistributeddbNbBatchCrudTest, TransactionObserver003, TestSize.Level1) EXPECT_TRUE(VerifyObserverResult(observers[cnt], CHANGED_ONE_TIME, DELETE_LIST, observerCheckList)); } } + +/** + * @tc.name: GetKeysPressure 001 + * @tc.desc: Concurrent GetEntries and GetKeys. + * @tc.type: FUNC + * @tc.require: SR000DORPP + * @tc.author: xuhongkang + */ +#ifdef GETKEYS_PRESSURE001 +HWTEST_F(DistributeddbNbBatchCrudTest, GetKeysPressure001, TestSize.Level3) +{ + DBStatus status, status1, status2; + std::vector allKeysKA, allKeysKB, expectKeyResult; + std::vector entriesA, entriesB, entriesBatch; + DistributedDB::Value longValue1; + DistributedDB::Key ka = {'k', 'a'}; + DistributedDB::Key kb = {'k', 'b'}; + longValue1.assign(ONE_K_LONG_STRING, (uint8_t)'v'); + GenerateRecords(TEN_THOUSAND_RECORDS, DEFAULT_START, allKeysKA, entriesA, ka); + GenerateRecords(FIVE_THOUSANDS_RECORDS, DEFAULT_START, allKeysKB, entriesB, kb); + + entriesBatch.insert(entriesBatch.end(), entriesA.begin(), entriesA.end()); + entriesBatch.insert(entriesBatch.end(), entriesB.begin(), entriesB.end()); + for (unsigned int index = 0; index < FIFTEEN_THOUSAND_RECORDS; index++) + { + if (index < TEN_THOUSAND_RECORDS) { + entriesA[index].value = longValue1; + } + entriesBatch[index].value = longValue1; + status = g_nbBatchCrudDelegate->Put(entriesBatch[index].key, entriesBatch[index].value); + EXPECT_EQ(status, OK); + } + std::vector keyResult; + std::vector valueResult; + std::thread sub = std::thread([&status1, &ka, &valueResult]() { + status1 = DistributedDBNbTestTools::GetEntries(*g_nbBatchCrudDelegate, ka, valueResult); + }); + status2 = DistributedDBNbTestTools::GetKeys(*g_nbBatchCrudDelegate, KEY_EMPTY, keyResult); + sub.join(); + EXPECT_EQ(status1, OK); + EXPECT_EQ(status2, OK); + expectKeyResult.insert(expectKeyResult.end(), allKeysKA.begin(), allKeysKA.end()); + expectKeyResult.insert(expectKeyResult.end(), allKeysKB.begin(), allKeysKB.end()); + sort(keyResult.begin(), keyResult.end()); + sort(expectKeyResult.begin(), expectKeyResult.end()); + for (unsigned int index = 0; index < FIFTEEN_THOUSAND_RECORDS; index++) { + string actResult(keyResult[index].begin(), keyResult[index].end()); + string expectResult(expectKeyResult[index].begin(), expectKeyResult[index].end()); + bool result = (actResult == expectResult); + EXPECT_EQ(result, true); + } + EXPECT_TRUE(CompareEntriesVector(valueResult, entriesA)); +} +#endif // GETKEYS_PRESSURE001 } diff --git a/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_nb_cursor_testcase.cpp b/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_nb_cursor_testcase.cpp index 54773729e71b0d09cbc157811637552c03d49822..bebdd962f8542f15f9c227e1e7cb1083ced77c78 100644 --- a/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_nb_cursor_testcase.cpp +++ b/kv_store/frameworks/libs/distributeddb/test/moduletest/src/distributeddb_nb_cursor_testcase.cpp @@ -247,17 +247,15 @@ void DistributeddbNbCursorTestcase::ResultSetDb002(KvStoreNbDelegate *delegate, * @tc.steps: step2. set the current position is 100, call MoveToPrevious, GetPostion, GetEntry looply. * @tc.expected: step2. return values are all right. */ - int positionGot = CURSOR_POSITION_NEGATIVE1; Entry entry; - bool result = true; for (int position = CURSOR_POSITION_100; position > CURSOR_POSITION_NEGATIVE1; --position) { - result = resultSet->MoveToPrevious(); + bool result = resultSet->MoveToPrevious(); if (position > (CURSOR_POSITION_NEGATIVE1 + CURSOR_POSITION_1)) { EXPECT_TRUE(result == true); } else { EXPECT_TRUE(result == false); } - positionGot = resultSet->GetPosition(); + int positionGot = resultSet->GetPosition(); EXPECT_TRUE(positionGot == (position - CURSOR_POSITION_1)); if (position > (CURSOR_POSITION_NEGATIVE1 + CURSOR_POSITION_1)) { EXPECT_TRUE(resultSet->GetEntry(entry) == OK); @@ -541,17 +539,15 @@ void DistributeddbNbCursorTestcase::ResultSetDb006(KvStoreNbDelegate *delegate, * @tc.steps: step2. set the current position is -1, call MoveToNext, GetPostion and GetEntry interface looply. * @tc.expected: step2. return values are all right. */ - int currentPosition = CURSOR_POSITION_NEGATIVE1; Entry entry; - bool result = true; for (int position = CURSOR_POSITION_NEGATIVE1; position < ONE_RECORD; ++position) { - result = resultSet->MoveToNext(); + bool result = resultSet->MoveToNext(); if (position < (ONE_RECORD - CURSOR_POSITION_1)) { EXPECT_TRUE(result == true); } else { EXPECT_TRUE(result == false); } - currentPosition = resultSet->GetPosition(); + int currentPosition = resultSet->GetPosition(); EXPECT_TRUE(currentPosition == (position + CURSOR_POSITION_1)); if (position < (ONE_RECORD - CURSOR_POSITION_1)) { EXPECT_TRUE(resultSet->GetEntry(entry) == OK); @@ -566,13 +562,13 @@ void DistributeddbNbCursorTestcase::ResultSetDb006(KvStoreNbDelegate *delegate, * @tc.expected: step2. return values are all right. */ for (int position = ONE_RECORD; position > CURSOR_POSITION_NEGATIVE1; --position) { - result = resultSet->MoveToPrevious(); + bool result = resultSet->MoveToPrevious(); if (position > (CURSOR_POSITION_NEGATIVE1 + CURSOR_POSITION_1)) { EXPECT_TRUE(result == true); } else { EXPECT_TRUE(result == false); } - currentPosition = resultSet->GetPosition(); + int currentPosition = resultSet->GetPosition(); EXPECT_TRUE(currentPosition == (position - CURSOR_POSITION_1)); if (position > (CURSOR_POSITION_NEGATIVE1 + CURSOR_POSITION_1)) { EXPECT_TRUE(resultSet->GetEntry(entry) == OK); @@ -817,9 +813,8 @@ void DistributeddbNbCursorTestcase::ResultSetDb010(KvStoreNbDelegate *delegate, */ int currentPosition = CURSOR_POSITION_NEGATIVE1; Entry entry; - bool result = true; for (int position = ONE_HUNDRED_RECORDS; position > CURSOR_POSITION_NEGATIVE1; --position) { - result = resultSet->MoveToPrevious(); + bool result = resultSet->MoveToPrevious(); if (position > (CURSOR_POSITION_NEGATIVE1 + CURSOR_POSITION_1)) { EXPECT_TRUE(result == true); } else { @@ -1409,8 +1404,41 @@ void DistributeddbNbCursorTestcase::ResultSetDb020(KvStoreNbDelegate *delegate, Key keyPrefixKC = kc; EXPECT_EQ(delegate->GetEntries(keyPrefixKC, resultSetKC), OK); /** - * @tc.steps: step1. call GetEntries interface with "" parameter to get KvStoreResultSet. - * @tc.expected: step1. get success. + * @tc.steps: step4. call GetEntries interface with "kd" parameter to get KvStoreResultSet. + * @tc.expected: step4. get success. + */ + KvStoreResultSet *resultSetKD = nullptr; + std::vector kd = { 'k', 'd' }; + Key keyPrefixKD = kd; + EXPECT_EQ(delegate->GetEntries(keyPrefixKD, resultSetKD), OK); + /** + * @tc.steps: step5. call GetEntries interface with "ke" parameter to get KvStoreResultSet. + * @tc.expected: step5. get success. + */ + KvStoreResultSet *resultSetKE = nullptr; + std::vector ke = { 'k', 'e' }; + Key keyPrefixKE = ke; + EXPECT_EQ(delegate->GetEntries(keyPrefixKE, resultSetKE), OK); + /** + * @tc.steps: step6. call GetEntries interface with "kf" parameter to get KvStoreResultSet. + * @tc.expected: step6. get success. + */ + KvStoreResultSet *resultSetKF = nullptr; + std::vector kf = { 'k', 'f' }; + Key keyPrefixKF = kf; + EXPECT_EQ(delegate->GetEntries(keyPrefixKF, resultSetKF), OK); + + /** + * @tc.steps: step7. call GetEntries interface with "kg" parameter to get KvStoreResultSet. + * @tc.expected: step7. get success. + */ + KvStoreResultSet *resultSetKG = nullptr; + std::vector kg = { 'k', 'g' }; + Key keyPrefixKG = kg; + EXPECT_EQ(delegate->GetEntries(keyPrefixKG, resultSetKG), OK); + /** + * @tc.steps: step8. call GetEntries interface with "" parameter to get KvStoreResultSet. + * @tc.expected: step8. get success. */ KvStoreResultSet *resultSetAll2 = nullptr; EXPECT_EQ(delegate->GetEntries(KEY_EMPTY, resultSetAll2), OVER_MAX_LIMITS); @@ -1419,6 +1447,13 @@ void DistributeddbNbCursorTestcase::ResultSetDb020(KvStoreNbDelegate *delegate, EXPECT_EQ(delegate->CloseResultSet(resultSetKA), OK); EXPECT_EQ(delegate->CloseResultSet(resultSetKB), OK); EXPECT_EQ(delegate->CloseResultSet(resultSetKC), OK); + EXPECT_EQ(delegate->CloseResultSet(resultSetKD), OK); + EXPECT_EQ(delegate->CloseResultSet(resultSetKE), OK); + EXPECT_EQ(delegate->CloseResultSet(resultSetKF), OK); + EXPECT_EQ(delegate->CloseResultSet(resultSetKG), OK); + if (resultSetAll2 != nullptr) { + EXPECT_EQ(delegate->CloseResultSet(resultSetAll2), OK); + } } void DistributeddbNbCursorTestcase::ResultSetDb021(KvStoreNbDelegate *delegate, @@ -1994,7 +2029,6 @@ void DistributeddbNbCursorTestcase::ResultSetDb027(bool isRowIdMode) SetResultSetCacheMode(delegates[INDEX_ZEROTH], isRowIdMode); vector entriesKA, entriesKB; - vector allKeysKA, allKeysKB; std::vector ka = { 'k', 'a' }; std::vector kb = { 'k', 'b' }; EntrySize entrySizeKA = { FIVE_BYTE_KEY, ONE_K_LONG_STRING }; diff --git a/kv_store/frameworks/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_nb_delegate_schema_put_test.cpp b/kv_store/frameworks/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_nb_delegate_schema_put_test.cpp index eefdbe910498b964131970093faf61aa1ab6cb31..06b91ce12e1a6da71433fcfe0c016184f0ee0faa 100644 --- a/kv_store/frameworks/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_nb_delegate_schema_put_test.cpp +++ b/kv_store/frameworks/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_nb_delegate_schema_put_test.cpp @@ -409,4 +409,60 @@ HWTEST_F(DistributedDBInterfacesNBDelegateSchemaPutTest, SqliteKeyWord001, TestS EXPECT_EQ(g_kvStore->GetEntries(query, entries), OK); EXPECT_EQ(entries.size(), 1U); } + +/** + * @tc.name: ResultSetLimitTest001 + * @tc.desc: Get result set over limit + * @tc.type: FUNC + * @tc.require: + * @tc.author: lianhuix + */ +HWTEST_F(DistributedDBInterfacesNBDelegateSchemaPutTest, ResultSetLimitTest001, TestSize.Level0) +{ + /** + * @tc.steps:step1. Create database. + * @tc.expected: step1. Returns a non-null kvstore. + */ + g_mgr.GetKvStore(g_storeName, g_strictOpt, g_kvNbDelegateCallback); + ASSERT_TRUE(g_kvStore != nullptr); + EXPECT_TRUE(g_kvDelegateStatus == OK); + + /** + * @tc.steps:step2. Put the random entry into the database. + * @tc.expected: step2. Returns OK. + */ + Key key1; + std::string valueData = "{\"field_name1\":true,\"field_name2\":1}"; + Value value(valueData.begin(), valueData.end()); + DistributedDBToolsUnitTest::GetRandomKeyValue(key1); + EXPECT_EQ(g_kvStore->Put(key1, value), OK); + + /** + * @tc.steps:step3. Get the resultset overlimit. + * @tc.expected: step3. In limit returns OK, else return OVER_MAX_LIMITS. + */ + Query query = Query::Select().EqualTo("$.field_name2", 1); + std::vector dataResultSet; + for (int i = 0; i < 8; i++) { // 8: max result set count + KvStoreResultSet *resultSet = nullptr; + EXPECT_EQ(g_kvStore->GetEntries(query, resultSet), OK); + dataResultSet.push_back(resultSet); + EXPECT_NE(resultSet, nullptr); + } + + KvStoreResultSet *resultSet = nullptr; + EXPECT_EQ(g_kvStore->GetEntries(query, resultSet), OVER_MAX_LIMITS); + EXPECT_EQ(resultSet, nullptr); + if (resultSet != nullptr) { + EXPECT_EQ(g_kvStore->CloseResultSet(resultSet), OK); + } + + /** + * @tc.steps:step4. Close result set. + * @tc.expected: step4. Returns OK. + */ + for (auto it : dataResultSet) { + EXPECT_EQ(g_kvStore->CloseResultSet(it), OK); + } +} #endif // OMIT_JSON \ No newline at end of file diff --git a/kv_store/frameworks/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_nb_delegate_test.cpp b/kv_store/frameworks/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_nb_delegate_test.cpp index 9e0d295214dcead92da2136536129c6c0ec6b8a0..367c74658bdc7d53ec372d1c57c339518ce1e673 100644 --- a/kv_store/frameworks/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_nb_delegate_test.cpp +++ b/kv_store/frameworks/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_nb_delegate_test.cpp @@ -2245,6 +2245,7 @@ HWTEST_F(DistributedDBInterfacesNBDelegateTest, RemoveDeviceDataTest001, TestSiz FreeVirtualDevice(g_deviceD); } +#ifdef RUNNING_ON_SIMULATED_ENV /** * @tc.name: TimeChangeWithCloseStoreTest001 * @tc.desc: Test close store with time changed @@ -2293,4 +2294,177 @@ HWTEST_F(DistributedDBInterfacesNBDelegateTest, TimeChangeWithCloseStoreTest001, it.join(); } EXPECT_EQ(mgr.DeleteKvStore(STORE_ID_1), OK); +} + +/** + * @tc.name: TimeChangeWithCloseStoreTest002 + * @tc.desc: Test close store with time changed + * @tc.type: FUNC + * @tc.require: + * @tc.author: zhangqiquan + */ +HWTEST_F(DistributedDBInterfacesNBDelegateTest, TimeChangeWithCloseStoreTest002, TestSize.Level3) +{ + KvStoreDelegateManager mgr(APP_ID, USER_ID); + mgr.SetKvStoreConfig(g_config); + + const KvStoreNbDelegate::Option option = {true, false, false}; + mgr.GetKvStore(STORE_ID_1, option, g_kvNbDelegateCallback); + ASSERT_TRUE(g_kvNbDelegatePtr != nullptr); + EXPECT_EQ(g_kvDelegateStatus, OK); + const int threadPoolMax = 10; + for (int i = 0; i < threadPoolMax; ++i) { + (void) RuntimeContext::GetInstance()->ScheduleTask([]() { + std::this_thread::sleep_for(std::chrono::seconds(10)); // sleep 10s for block thread pool + }); + } + OS::SetOffsetBySecond(100); // 100 2 : fake system time change + std::this_thread::sleep_for(std::chrono::seconds(1)); // sleep 1s for time tick + + EXPECT_EQ(mgr.CloseKvStore(g_kvNbDelegatePtr), OK); + g_kvNbDelegatePtr = nullptr; + + EXPECT_EQ(mgr.DeleteKvStore(STORE_ID_1), OK); + RuntimeContext::GetInstance()->StopTaskPool(); // stop all async task +} +#endif // RUNNING_ON_SIMULATED_ENV + +/** + * @tc.name: LocalStore001 + * @tc.desc: Test get kv store with localOnly + * @tc.type: FUNC + * @tc.require: + * @tc.author: zhangqiquan + */ +HWTEST_F(DistributedDBInterfacesNBDelegateTest, LocalStore001, TestSize.Level1) +{ + KvStoreDelegateManager mgr(APP_ID, USER_ID); + mgr.SetKvStoreConfig(g_config); + + /** + * @tc.steps:step1. Create database with localOnly. + * @tc.expected: step1. Returns a non-null store. + */ + KvStoreNbDelegate::Option option = {true, false, false}; + option.localOnly = true; + DBStatus openStatus = DBStatus::DB_ERROR; + KvStoreNbDelegate *openDelegate = nullptr; + mgr.GetKvStore(STORE_ID_1, option, [&openStatus, &openDelegate](DBStatus status, KvStoreNbDelegate *delegate) { + openStatus = status; + openDelegate = delegate; + }); + ASSERT_TRUE(openDelegate != nullptr); + EXPECT_EQ(openStatus, OK); + /** + * @tc.steps:step2. call sync and put/get interface. + * @tc.expected: step2. sync return NOT_ACTIVE. + */ + DBStatus actionStatus = openDelegate->Sync({}, SyncMode::SYNC_MODE_PUSH_ONLY, nullptr); + EXPECT_EQ(actionStatus, DBStatus::NOT_ACTIVE); + Key key = {'k'}; + Value expectValue = {'v'}; + EXPECT_EQ(openDelegate->Put(key, expectValue), OK); + Value actualValue; + EXPECT_EQ(openDelegate->Get(key, actualValue), OK); + EXPECT_EQ(actualValue, expectValue); + EXPECT_EQ(mgr.CloseKvStore(openDelegate), OK); +} + +/** + * @tc.name: LocalStore002 + * @tc.desc: Test get kv store different local mode + * @tc.type: FUNC + * @tc.require: + * @tc.author: zhangqiquan + */ +HWTEST_F(DistributedDBInterfacesNBDelegateTest, LocalStore002, TestSize.Level1) +{ + KvStoreDelegateManager mgr(APP_ID, USER_ID); + mgr.SetKvStoreConfig(g_config); + + /** + * @tc.steps:step1. Create database with localOnly. + * @tc.expected: step1. Returns a non-null store. + */ + KvStoreNbDelegate::Option option = {true, false, false}; + option.localOnly = true; + DBStatus openStatus = DBStatus::DB_ERROR; + KvStoreNbDelegate *localDelegate = nullptr; + mgr.GetKvStore(STORE_ID_1, option, [&openStatus, &localDelegate](DBStatus status, KvStoreNbDelegate *delegate) { + openStatus = status; + localDelegate = delegate; + }); + ASSERT_TRUE(localDelegate != nullptr); + EXPECT_EQ(openStatus, OK); + /** + * @tc.steps:step2. Create database without localOnly. + * @tc.expected: step2. Returns a null store. + */ + option.localOnly = false; + KvStoreNbDelegate *syncDelegate = nullptr; + mgr.GetKvStore(STORE_ID_1, option, [&openStatus, &syncDelegate](DBStatus status, KvStoreNbDelegate *delegate) { + openStatus = status; + syncDelegate = delegate; + }); + EXPECT_EQ(syncDelegate, nullptr); + EXPECT_EQ(openStatus, INVALID_ARGS); + EXPECT_EQ(mgr.CloseKvStore(localDelegate), OK); +} + +/** + * @tc.name: ResultSetLimitTest001 + * @tc.desc: Get result set over limit + * @tc.type: FUNC + * @tc.require: + * @tc.author: lianhuix + */ +HWTEST_F(DistributedDBInterfacesNBDelegateTest, ResultSetLimitTest001, TestSize.Level0) +{ + /** + * @tc.steps:step1. Create database. + * @tc.expected: step1. Returns a non-null kvstore. + */ + KvStoreNbDelegate::Option option; + g_mgr.GetKvStore("ResultSetLimitTest001", option, g_kvNbDelegateCallback); + ASSERT_TRUE(g_kvNbDelegatePtr != nullptr); + EXPECT_TRUE(g_kvDelegateStatus == OK); + + /** + * @tc.steps:step2. Put the random entry into the database. + * @tc.expected: step2. Returns OK. + */ + EXPECT_EQ(g_kvNbDelegatePtr->Put(KEY_1, VALUE_1), OK); + EXPECT_EQ(g_kvNbDelegatePtr->Put(KEY_2, VALUE_2), OK); + EXPECT_EQ(g_kvNbDelegatePtr->Put(KEY_3, VALUE_3), OK); + + /** + * @tc.steps:step3. Get the resultset overlimit. + * @tc.expected: step3. In limit returns OK, else return OVER_MAX_LIMITS. + */ + std::vector dataResultSet; + for (int i = 0; i < 8; i++) { // 8: max result set count + KvStoreResultSet *resultSet = nullptr; + EXPECT_EQ(g_kvNbDelegatePtr->GetEntries(Key{}, resultSet), OK); + dataResultSet.push_back(resultSet); + EXPECT_NE(resultSet, nullptr); + } + + KvStoreResultSet *resultSet = nullptr; + EXPECT_EQ(g_kvNbDelegatePtr->GetEntries(Key{}, resultSet), OVER_MAX_LIMITS); + EXPECT_EQ(resultSet, nullptr); + if (resultSet != nullptr) { + EXPECT_EQ(g_kvNbDelegatePtr->CloseResultSet(resultSet), OK); + } + + /** + * @tc.steps:step4. Close result set and store. + * @tc.expected: step4. Returns OK. + */ + for (auto it : dataResultSet) { + EXPECT_EQ(g_kvNbDelegatePtr->CloseResultSet(it), OK); + } + + EXPECT_EQ(g_mgr.CloseKvStore(g_kvNbDelegatePtr), OK); + EXPECT_EQ(g_mgr.DeleteKvStore("ResultSetLimitTest001"), OK); + g_kvNbDelegatePtr = nullptr; } \ No newline at end of file diff --git a/kv_store/frameworks/libs/distributeddb/test/unittest/common/syncer/distributeddb_mock_sync_module_test.cpp b/kv_store/frameworks/libs/distributeddb/test/unittest/common/syncer/distributeddb_mock_sync_module_test.cpp index 0c42e30cb42cbaf827cf2663ec9f5926d21629ab..bb3efcf30bfc61c0acef68bb56f7447d008aa196 100644 --- a/kv_store/frameworks/libs/distributeddb/test/unittest/common/syncer/distributeddb_mock_sync_module_test.cpp +++ b/kv_store/frameworks/libs/distributeddb/test/unittest/common/syncer/distributeddb_mock_sync_module_test.cpp @@ -69,7 +69,7 @@ public: private: SyncerProxy syncer_; }; -class TestInterface : public TestKvDb, public VirtualSingleVerSyncDBInterface { +class TestInterface : public TestKvDb, public VirtualSingleVerSyncDBInterface, public RefObject { public: TestInterface() {} ~TestInterface() @@ -88,6 +88,16 @@ public: { VirtualSingleVerSyncDBInterface::SetIdentifier(identifierVec); } + + void IncRefCount() override + { + RefObject::IncObjRef(this); + } + + void DecRefCount() override + { + RefObject::DecObjRef(this); + } }; namespace { @@ -932,7 +942,11 @@ HWTEST_F(DistributedDBMockSyncModuleTest, SyncLifeTest003, TestSize.Level3) syncDBInterface->Initialize(); virtualCommunicatorAggregator->OnlineDevice(DEVICE_B); syncDBInterface->TestLocalChange(); - delete syncDBInterface; + virtualCommunicatorAggregator->OfflineDevice(DEVICE_B); + syncDBInterface->Close(); + RefObject::KillAndDecObjRef(syncDBInterface); + RuntimeContext::GetInstance()->StopTaskPool(); + std::this_thread::sleep_for(std::chrono::seconds(1)); RuntimeContext::GetInstance()->SetCommunicatorAggregator(nullptr); } diff --git a/kv_store/frameworks/libs/distributeddb/test/unittest/common/syncer/distributeddb_relational_ver_p2p_sync_test.cpp b/kv_store/frameworks/libs/distributeddb/test/unittest/common/syncer/distributeddb_relational_ver_p2p_sync_test.cpp index cea44770b11056dc741d1d08c80d1ce095b0d04c..1ab5d57cc6009a585589dc315aa80d14cdc4ff8f 100644 --- a/kv_store/frameworks/libs/distributeddb/test/unittest/common/syncer/distributeddb_relational_ver_p2p_sync_test.cpp +++ b/kv_store/frameworks/libs/distributeddb/test/unittest/common/syncer/distributeddb_relational_ver_p2p_sync_test.cpp @@ -1859,19 +1859,28 @@ HWTEST_F(DistributedDBRelationalVerP2PSyncTest, RemoteQuery006, TestSize.Level1) PrepareEnvironment(dataMap, {g_deviceB}); ASSERT_NE(g_deviceB, nullptr); ASSERT_NE(g_rdbDelegatePtr, nullptr); - g_communicatorAggregator->RegOnDispatch([](const std::string &device, Message *inMsg) { + std::thread offlineThread; + std::atomic offline = false; + g_communicatorAggregator->RegOnDispatch([&offlineThread, &offline](const std::string &device, Message *inMsg) { ASSERT_NE(inMsg, nullptr); inMsg->SetMessageId(INVALID_MESSAGE_ID); + if (offline) { + return; + } + offline = true; std::thread t([]() { g_deviceB->Offline(); }); - t.detach(); + offlineThread = std::move(t); }); RemoteCondition condition; condition.sql = "SELECT * FROM " + g_tableName + " WHERE 1=0"; std::shared_ptr result = nullptr; EXPECT_EQ(g_rdbDelegatePtr->RemoteQuery(DEVICE_B, condition, DBConstant::MIN_TIMEOUT, result), COMM_FAILURE); ASSERT_EQ(result, nullptr); + if (offline) { + offlineThread.join(); + } } /** diff --git a/kv_store/interfaces/innerkits/distributeddata/include/store_errno.h b/kv_store/interfaces/innerkits/distributeddata/include/store_errno.h index 45a44e0f24843dcd763a046d242ada6fb3884c74..28061c2b87801a6e59d4f9cc36d19589532f70f2 100644 --- a/kv_store/interfaces/innerkits/distributeddata/include/store_errno.h +++ b/kv_store/interfaces/innerkits/distributeddata/include/store_errno.h @@ -54,10 +54,11 @@ enum Status : int32_t { RECOVER_FAILED = DISTRIBUTEDDATAMGR_ERR_OFFSET + 29, EXCEED_MAX_ACCESS_RATE = DISTRIBUTEDDATAMGR_ERR_OFFSET + 31, SECURITY_LEVEL_ERROR = DISTRIBUTEDDATAMGR_ERR_OFFSET + 32, - OVER_MAX_SUBSCRIBE_LIMITS = DISTRIBUTEDDATAMGR_ERR_OFFSET + 33, + OVER_MAX_LIMITS = DISTRIBUTEDDATAMGR_ERR_OFFSET + 33, ALREADY_CLOSED = DISTRIBUTEDDATAMGR_ERR_OFFSET + 34, IPC_PARCEL_ERROR = DISTRIBUTEDDATAMGR_ERR_OFFSET + 35, DATA_CORRUPTED = DISTRIBUTEDDATAMGR_ERR_OFFSET + 36, + WAL_OVER_LIMITS = DISTRIBUTEDDATAMGR_ERR_OFFSET + 37, }; -} +} // namespace OHOS::DistributedKv #endif // OHOS_DISTRIBUTED_DATA_INTERFACES_DISTRIBUTEDDATA_STORE_ERRNO_H diff --git a/kv_store/interfaces/innerkits/distributeddata/include/types.h b/kv_store/interfaces/innerkits/distributeddata/include/types.h index a3bf298c3e37fb6056cac2a7e7fc10cc47b656c7..d14564b5b9313c7859c0516c247a39ad2cd72e29 100644 --- a/kv_store/interfaces/innerkits/distributeddata/include/types.h +++ b/kv_store/interfaces/innerkits/distributeddata/include/types.h @@ -225,7 +225,7 @@ struct Options { bool persistent = true; bool backup = true; bool autoSync = true; - bool syncable = true; // let bms delete first + bool syncable = true; // true if is distributed store, false if is local store bool rebuild = false; int32_t securityLevel = NO_LABEL; int32_t area = EL1; diff --git a/kv_store/kvstoremock/frameworks/innerkitsimpl/kvdb/src/store_util.cpp b/kv_store/kvstoremock/frameworks/innerkitsimpl/kvdb/src/store_util.cpp index b109a40b53c70f7f3cedb588c978358ef6c96011..8b0586a6273f9c3073671103b7a5e5d8f790bc09 100644 --- a/kv_store/kvstoremock/frameworks/innerkitsimpl/kvdb/src/store_util.cpp +++ b/kv_store/kvstoremock/frameworks/innerkitsimpl/kvdb/src/store_util.cpp @@ -13,13 +13,15 @@ * limitations under the License. */ #define LOG_TAG "StoreUtil" +#include "store_util.h" + #include +#include #include #include -#include + #include "log_print.h" #include "types.h" -#include "store_util.h" namespace OHOS::DistributedKv { constexpr mode_t DEFAULT_UMASK = 0002; constexpr int32_t HEAD_SIZE = 3; @@ -136,7 +138,7 @@ Status StoreUtil::ConvertStatus(DBStatus status) case DBStatus::TIME_OUT: return Status::TIME_OUT; case DBStatus::OVER_MAX_LIMITS: - return Status::OVER_MAX_SUBSCRIBE_LIMITS; + return Status::OVER_MAX_LIMITS; case DBStatus::INVALID_PASSWD_OR_CORRUPTED_DB: return Status::CRYPT_ERROR; case DBStatus::SCHEMA_MISMATCH: diff --git a/kv_store/test/unittest/distributedKVStore/DeviceKvStoreKVCallbackJsTest.js b/kv_store/test/unittest/distributedKVStore/DeviceKvStoreKVCallbackJsTest.js index 6a52849885c4363fc21f96fd01662f73589a3e1a..11bc52a6d1086e0946304aadc4e0a69ee8b6e0bc 100644 --- a/kv_store/test/unittest/distributedKVStore/DeviceKvStoreKVCallbackJsTest.js +++ b/kv_store/test/unittest/distributedKVStore/DeviceKvStoreKVCallbackJsTest.js @@ -436,7 +436,7 @@ describe('DeviceKvStoreCallbackTest', function () { expect(err == undefined).assertTrue(); }); } catch (e) { - console.error('DeviceKvStorePutBoolCallbackTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStorePutBoolCallbackTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -682,31 +682,31 @@ describe('DeviceKvStoreCallbackTest', function () { }) /** - * @tc.name DeviceKvStoreDeletePredicatesCallbackSucTest - * @tc.desc Test Js Api DeviceKvStore.Delete() successfully + * @tc.name DeviceKvStoreDeletePredicatesCallbackTest + * @tc.desc Test Js Api DeviceKvStore.Delete() * @tc.type: FUNC * @tc.require: issueNumber */ - it('DeviceKvStoreDeletePredicatesCallbackSucTest', 0, async function (done) { - console.log('DeviceKvStoreDeletePredicatesCallbackSucTest'); + it('DeviceKvStoreDeletePredicatesCallbackTest', 0, async function (done) { + console.log('DeviceKvStoreDeletePredicatesCallbackTest'); try { let predicates = new dataShare.DataSharePredicates(); let arr = ["name"]; predicates.inKeys(arr); - await kvStore.put("name", "Bob", async function (err, data) { - console.log('DeviceKvStoreDeletePredicatesCallbackSucTest put success'); - expect(err == undefined).assertTrue(); - await kvStore.delete(predicates, function (err, data) { - console.log('DeviceKvStoreDeletePredicatesCallbackSucTest delete success'); - expect(err == undefined).assertTrue(); - done(); - }); - }) + await kvStore.delete(predicates, function (err, data) { + if (err == undefined) { + console.error('DeviceKvStoreDeletePredicatesCallbackTest delete success'); + expect(null).assertFail(); + } else { + console.error('DeviceKvStoreDeletePredicatesCallbackTest delete fail' + `, error code is ${err.code}, message is ${err.message}`); + expect(null).assertFail(); + } + }); } catch (e) { - console.error('DeviceKvStoreDeletePredicatesCallbackSucTest e' + `, error code is ${e.code}, message is ${e.message}`); - expect(null).assertFail(); - done(); + console.info('DeviceKvStoreDeletePredicatesCallbackTest fail' + `, error code is ${e.code}, message is ${e.message}`); + expect(e.code == 202).assertTrue(); } + done(); }) /** @@ -867,7 +867,7 @@ describe('DeviceKvStoreCallbackTest', function () { kvStore.on('dataChange', 0, func); kvStore.off('dataChange', func); } catch (e) { - console.error('DeviceKvStoreOffChangeCallbackSucTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreOffChangeCallbackSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -889,7 +889,7 @@ describe('DeviceKvStoreCallbackTest', function () { expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStoreOffChangeCallbackSucTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.info('DeviceKvStoreOffChangeCallbackSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); } done(); @@ -910,7 +910,7 @@ describe('DeviceKvStoreCallbackTest', function () { kvStore.off('syncComplete', func); expect(true).assertTrue(); } catch (e) { - console.error('DeviceKvStoreOffSyncCompleteCallbackSucTest put e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreOffSyncCompleteCallbackSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -933,7 +933,7 @@ describe('DeviceKvStoreCallbackTest', function () { } }); } catch (e) { - console.error('DeviceKvStoreOffSyncCompleteCallbackInvalidArgsTest put e ' + `, error code is ${e.code}, message is ${e.message}`); + console.info('DeviceKvStoreOffSyncCompleteCallbackInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); } done(); @@ -951,12 +951,12 @@ describe('DeviceKvStoreCallbackTest', function () { var localLabels = ['A', 'B']; var remoteSupportLabels = ['C', 'D']; await kvStore.setSyncRange(localLabels, remoteSupportLabels, function (err, data) { - console.info('DeviceKvStoreSetSyncRangeCallbackDisjointTest put success'); + console.info('DeviceKvStoreSetSyncRangeCallbackDisjointTest setSyncRange success'); expect(err == undefined).assertTrue(); done(); }); } catch (e) { - console.error('DeviceKvStoreSetSyncRangeCallbackDisjointTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreSetSyncRangeCallbackDisjointTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -974,12 +974,12 @@ describe('DeviceKvStoreCallbackTest', function () { var localLabels = ['A', 'B']; var remoteSupportLabels = ['B', 'C']; await kvStore.setSyncRange(localLabels, remoteSupportLabels, function (err, data) { - console.info('DeviceKvStoreSetSyncRangeCallbackTest put success'); + console.info('DeviceKvStoreSetSyncRangeCallbackTest setSyncRange success'); expect(err == undefined).assertTrue(); done(); }); } catch (e) { - console.error('DeviceKvStoreSetSyncRangeCallbackTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreSetSyncRangeCallbackTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -1002,7 +1002,7 @@ describe('DeviceKvStoreCallbackTest', function () { done(); }); } catch (e) { - console.error(' DeviceKvStoreSetSyncRangeCallbackSameTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreSetSyncRangeCallbackSameTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -1022,7 +1022,7 @@ describe('DeviceKvStoreCallbackTest', function () { expect(null).assertFail(); }); } catch (e) { - console.error(' DeviceKvStoreSetSyncRangeCallbackSameTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreSetSyncRangeCallbackSameTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); } done(); @@ -1060,7 +1060,7 @@ describe('DeviceKvStoreCallbackTest', function () { }); }); } catch (e) { - console.error('DeviceKvStorePutBatchEntryCallbackStringTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStorePutBatchEntryCallbackStringTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -1098,7 +1098,7 @@ describe('DeviceKvStoreCallbackTest', function () { }); }); } catch (e) { - console.error('DeviceKvStorePutBatchEntryCallbackIntegerTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStorePutBatchEntryCallbackIntegerTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -1136,7 +1136,7 @@ describe('DeviceKvStoreCallbackTest', function () { }); }); } catch (e) { - console.error('DeviceKvStorePutBatchEntryCallbackFloatTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStorePutBatchEntryCallbackFloatTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -1174,7 +1174,7 @@ describe('DeviceKvStoreCallbackTest', function () { }); }); } catch (e) { - console.error('DeviceKvStorePutBatchEntryCallbackDoubleTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStorePutBatchEntryCallbackDoubleTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -1213,7 +1213,7 @@ describe('DeviceKvStoreCallbackTest', function () { }); }); } catch (e) { - console.error('DeviceKvStorePutBatchEntryCallbackBooleanTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStorePutBatchEntryCallbackBooleanTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -1252,7 +1252,7 @@ describe('DeviceKvStoreCallbackTest', function () { }); }); } catch (e) { - console.error('DeviceKvStorePutBatchEntryCallbackByteArrayTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStorePutBatchEntryCallbackByteArrayTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -1265,7 +1265,7 @@ describe('DeviceKvStoreCallbackTest', function () { * @tc.require: issueNumber */ it('DeviceKvStorePutBatchValueCallbackUint8ArrayTest', 0, async function (done) { - console.info('DeviceKvStorePutBatchValueCallbackUint8ArrayTest001'); + console.info('DeviceKvStorePutBatchValueCallbackUint8ArrayTest'); try { let values = []; let arr1 = new Uint8Array([4, 5, 6, 7]); @@ -1274,23 +1274,21 @@ describe('DeviceKvStoreCallbackTest', function () { let vb2 = {key: "name_2", value: arr2}; values.push(vb1); values.push(vb2); - console.info('DeviceKvStorePutBatchValueCallbackUint8ArrayTest001 values: ' + JSON.stringify(values)); + console.info('DeviceKvStorePutBatchValueCallbackUint8ArrayTest values: ' + JSON.stringify(values)); await kvStore.putBatch(values, async function (err, data) { - console.info('DeviceKvStorePutBatchValueCallbackUint8ArrayTest001 putBatch success'); - expect(err == undefined).assertTrue(); - var query = new factory.Query(); - query.prefixKey("name_"); - kvStore.getEntries(localDeviceId, query, function (err, entrys) { - console.info(JSON.stringify(entrys)); - expect(entrys.length == 2).assertTrue(); - done(); - }); + if (err == undefined) { + console.error('DeviceKvStorePutBatchValueCallbackUint8ArrayTest putBatch success'); + expect(null).assertFail(); + } else { + console.error('DeviceKvStorePutBatchValueCallbackUint8ArrayTest putBatch fail' + `, error code is ${err.code}, message is ${err.message}`); + expect(null).assertFail(); + } }); } catch (e) { - console.error('DeviceKvStorePutBatchValueCallbackUint8ArrayTest001 e ' + `, error code is ${e.code}, message is ${e.message}`); - expect(null).assertFail(); - done(); + console.info('DeviceKvStorePutBatchValueCallbackUint8ArrayTest fail' + `, error code is ${e.code}, message is ${e.message}`); + expect(e.code == 202).assertTrue(); } + done(); }) /** @@ -1309,7 +1307,7 @@ describe('DeviceKvStoreCallbackTest', function () { } }); } catch (e) { - console.error('DeviceKvStorePutBatchCallbackInvalidArgsTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.info('DeviceKvStorePutBatchCallbackInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); } done(); @@ -1335,12 +1333,13 @@ describe('DeviceKvStoreCallbackTest', function () { if (err == undefined) { expect(null).assertFail(); } else { - expect(err.code == 15100005).assertFail(); + console.info('DeviceKvStorePutBatchCallbackClosedKvstoreTest putBatch fail' + `, error code is ${err.code}, message is ${err.message}`); + expect(null).assertFail(); } }); } catch (e) { - console.error('DeviceKvStorePutBatchCallbackClosedKvstoreTest e ' + `, error code is ${e.code}, message is ${e.message}`); - expect(null).assertFail(); + console.info('DeviceKvStorePutBatchCallbackClosedKvstoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); + expect(e.code == 202).assertTrue(); } done(); }) @@ -1379,7 +1378,7 @@ describe('DeviceKvStoreCallbackTest', function () { }); }); } catch (e) { - console.error('DeviceKvStoreDeleteBatchCallbackSucTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreDeleteBatchCallbackSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -1419,7 +1418,7 @@ describe('DeviceKvStoreCallbackTest', function () { }); }); } catch (e) { - console.error('DeviceKvStoreDeleteBatchCallbackInvalidArgsTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.info('DeviceKvStoreDeleteBatchCallbackInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); } done(); @@ -1462,7 +1461,7 @@ describe('DeviceKvStoreCallbackTest', function () { }); }); } catch (e) { - console.error('DeviceKvStoreDeleteBatchCallbackClosedKVStoreTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreDeleteBatchCallbackClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -1500,7 +1499,7 @@ describe('DeviceKvStoreCallbackTest', function () { }); }); } catch (e) { - console.error('DeviceKvStoreGetEntriesCallbackQueryTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreGetEntriesCallbackQueryTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -1543,7 +1542,7 @@ describe('DeviceKvStoreCallbackTest', function () { }); }); } catch (e) { - console.error('DeviceKvStoreGetEntriesCallbackQueryClosedKVStoreTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreGetEntriesCallbackQueryClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -1579,7 +1578,7 @@ describe('DeviceKvStoreCallbackTest', function () { }); }); } catch (e) { - console.error('DeviceKvStoreGetEntriesCallbackSucTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreGetEntriesCallbackSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -1620,7 +1619,7 @@ describe('DeviceKvStoreCallbackTest', function () { }); }); } catch (e) { - console.error('DeviceKvStoreGetEntriesCallbackClosedKVStoreTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreGetEntriesCallbackClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -1658,7 +1657,7 @@ describe('DeviceKvStoreCallbackTest', function () { }); }); } catch (e) { - console.error('DeviceKvStoreGetEntriesCallbackInvalidArgsTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.info('DeviceKvStoreGetEntriesCallbackInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); } done(); @@ -1697,7 +1696,7 @@ describe('DeviceKvStoreCallbackTest', function () { }); }); } catch (e) { - console.error('DeviceKvstoreStartTransactionCallbackCommitTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvstoreStartTransactionCallbackCommitTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -1733,7 +1732,7 @@ describe('DeviceKvStoreCallbackTest', function () { }); }); } catch (e) { - console.error('DeviceKvstoreStartTransactionCallbackRollbackTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvstoreStartTransactionCallbackRollbackTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -1759,7 +1758,7 @@ describe('DeviceKvStoreCallbackTest', function () { done(); }); } catch (e) { - console.error('DeviceKvstoreStartTransactionCallbackClosedKVStoreTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvstoreStartTransactionCallbackClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -1786,7 +1785,7 @@ describe('DeviceKvStoreCallbackTest', function () { done(); }); } catch (e) { - console.error('DeviceKvStoreCommitCallbackClosedKVStoreTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreCommitCallbackClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -1813,7 +1812,7 @@ describe('DeviceKvStoreCallbackTest', function () { done(); }); } catch (e) { - console.error('DeviceKvStoreRollbackCallbackClosedKVStoreTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreRollbackCallbackClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -1839,7 +1838,7 @@ describe('DeviceKvStoreCallbackTest', function () { done(); }); } catch (e) { - console.error('DeviceKvStoreEnableSyncCallbackTrueTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreEnableSyncCallbackTrueTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -1865,7 +1864,7 @@ describe('DeviceKvStoreCallbackTest', function () { done(); }); } catch (e) { - console.error('DeviceKvStoreEnableSyncCallbackFalseTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreEnableSyncCallbackFalseTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -1891,7 +1890,7 @@ describe('DeviceKvStoreCallbackTest', function () { done(); }); } catch (e) { - console.error('DeviceKvStoreEnableSyncCallbackInvalidArgsTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreEnableSyncCallbackInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); done(); } @@ -1921,7 +1920,7 @@ describe('DeviceKvStoreCallbackTest', function () { } }); } catch (e) { - console.error('DeviceKvStoreRemoveDeviceDataCallbackClosedKvstoreTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreRemoveDeviceDataCallbackClosedKvstoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -1944,7 +1943,7 @@ describe('DeviceKvStoreCallbackTest', function () { done(); }); } catch (e) { - console.error('DeviceKvStoreRemoveDeviceDataCallbackInvalidArgsTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreRemoveDeviceDataCallbackInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); done(); } @@ -1987,7 +1986,7 @@ describe('DeviceKvStoreCallbackTest', function () { }); }); } catch (e) { - console.error('DeviceKvStoreGetResultSetCallbackSucTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreGetResultSetCallbackSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -2009,7 +2008,7 @@ describe('DeviceKvStoreCallbackTest', function () { done(); }); } catch (e) { - console.error('DeviceKvStoreGetResultSetCallbackInvalidArgsTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreGetResultSetCallbackInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); done(); } @@ -2026,18 +2025,15 @@ describe('DeviceKvStoreCallbackTest', function () { try { let predicates = new dataShare.DataSharePredicates(); await kvStore.getResultSet(localDeviceId, predicates).then((result) => { - console.log('DeviceKvStoreGetResultSetPredicatesCallbackTest getResultSet success'); - expect(true).assertTrue(); - kvStore.closeResultSet(result).then(() => { - expect(true).assertTrue(); - }); + console.error('DeviceKvStoreGetResultSetPredicatesCallbackTest getResultSet success'); + expect(null).assertFail(); }).catch((err) => { - console.error('DeviceKvStoreGetResultSetPredicatesCallbackTest getResultSet fail ' + err`, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStoreGetResultSetPredicatesCallbackTest getResultSet fail' + err`, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStoreGetResultSetPredicatesCallbackTest e ' + `, error code is ${e.code}, message is ${e.message}`); - expect(null).assertFail(); + console.info('DeviceKvStoreGetResultSetPredicatesCallbackTest fail' + `, error code is ${e.code}, message is ${e.message}`); + expect(e.code == 202).assertTrue(); } done(); }) @@ -2077,7 +2073,7 @@ describe('DeviceKvStoreCallbackTest', function () { }); }); } catch (e) { - console.error('DeviceKvStoreGetResultSetQueryCallbackTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreGetResultSetQueryCallbackTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -2108,7 +2104,7 @@ describe('DeviceKvStoreCallbackTest', function () { }); }); } catch (e) { - console.error('DeviceKvStoreCloseResultSetCallbackSucTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreCloseResultSetCallbackSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -2135,7 +2131,7 @@ describe('DeviceKvStoreCallbackTest', function () { done(); }); } catch (e) { - console.error('DeviceKvStoreCloseResultSetCallbackInvalidArgsTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.info('DeviceKvStoreCloseResultSetCallbackInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); done(); } @@ -2171,7 +2167,7 @@ describe('DeviceKvStoreCallbackTest', function () { expect(resultSize == 10).assertTrue(); }) } catch (e) { - console.error('DeviceKvStoreGetResultSizePromiseQueryTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreGetResultSizePromiseQueryTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -2204,7 +2200,7 @@ describe('DeviceKvStoreCallbackTest', function () { expect(null).assertFail(); }) } catch (e) { - console.error('DeviceKvStoreGetResultSizeCallbackInvalidArgsTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.info('DeviceKvStoreGetResultSizeCallbackInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); } done(); @@ -2246,7 +2242,7 @@ describe('DeviceKvStoreCallbackTest', function () { } }); } catch (e) { - console.error('DeviceKvStoreGetResultSizeCallbackClosedKVStoreTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreGetResultSizeCallbackClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -2288,7 +2284,7 @@ describe('DeviceKvStoreCallbackTest', function () { }); console.info('DeviceKvStoreGetEntriesCallbackSucTest success'); } catch (e) { - console.error('DeviceKvStoreGetEntriesCallbackSucTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreGetEntriesCallbackSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); diff --git a/kv_store/test/unittest/distributedKVStore/DeviceKvStoreKVPromiseJsTest.js b/kv_store/test/unittest/distributedKVStore/DeviceKvStoreKVPromiseJsTest.js index 7d161ebe1902fb8a92f2d5be76abf1aa75719ea6..6d4bcce013625dc35c5eb5547250f9623eb47df5 100644 --- a/kv_store/test/unittest/distributedKVStore/DeviceKvStoreKVPromiseJsTest.js +++ b/kv_store/test/unittest/distributedKVStore/DeviceKvStoreKVPromiseJsTest.js @@ -103,7 +103,7 @@ describe('DeviceKvStorePromiseTest', function () { console.info('beforeAll getDeviceId ' + JSON.stringify(deviceId)); localDeviceId = deviceId; }).catch((error) => { - console.error('beforeAll can NOT getDeviceId, fail: ' + `, error code is ${error.code}, message is ${error.message}`); + console.error('beforeAll can NOT getDeviceId, fail:' + `, error code is ${error.code}, message is ${error.message}`); expect(null).assertFail(); }); await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID); @@ -158,11 +158,11 @@ describe('DeviceKvStorePromiseTest', function () { console.info('DeviceKvStorePutStringPromiseInvalidArgsTest put success'); expect(null).assertFail(); }).catch((error) => { - console.error('DeviceKvStorePutStringPromiseInvalidArgsTest put error' + `, error code is ${error.code}, message is ${error.message}`); + console.error('DeviceKvStorePutStringPromiseInvalidArgsTest put fail' + `, error code is ${error.code}, message is ${error.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStorePutStringPromiseInvalidArgsTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStorePutStringPromiseInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); } done(); @@ -188,11 +188,11 @@ describe('DeviceKvStorePromiseTest', function () { console.info('DeviceKvStorePutStringPromiseClosedKVStoreTest put success'); expect(null).assertFail(); }).catch((error) => { - console.error('DeviceKvStorePutStringPromiseClosedKVStoreTest put error' + `, error code is ${error.code}, message is ${error.message}`); + console.error('DeviceKvStorePutStringPromiseClosedKVStoreTest put fail' + `, error code is ${error.code}, message is ${error.message}`); expect(error.code == 15100005).assertTrue(); }); } catch (e) { - console.error('DeviceKvStorePutStringPromiseClosedKVStoreTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStorePutStringPromiseClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -211,11 +211,11 @@ describe('DeviceKvStorePromiseTest', function () { console.info('DeviceKvStorePutStringPromiseSucTest put success'); expect(data == undefined).assertTrue(); }).catch((error) => { - console.error('DeviceKvStorePutStringPromiseSucTest put error' + `, error code is ${error.code}, message is ${error.message}`); + console.error('DeviceKvStorePutStringPromiseSucTest put fail' + `, error code is ${error.code}, message is ${error.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStorePutStringPromiseSucTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStorePutStringPromiseSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -265,7 +265,7 @@ describe('DeviceKvStorePromiseTest', function () { expect(error.code == 401).assertTrue(); }); } catch (e) { - console.error('DeviceKvStoreGetStringPromiseInvalidArgsTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreGetStringPromiseInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -282,7 +282,7 @@ describe('DeviceKvStorePromiseTest', function () { await kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then(async (data) => { expect(data == undefined).assertTrue(); }).catch((error) => { - console.error('DeviceKvStoreGetStringPromiseClosedKVStoreTest put error' + `, error code is ${error.code}, message is ${error.message}`); + console.error('DeviceKvStoreGetStringPromiseClosedKVStoreTest put fail' + `, error code is ${error.code}, message is ${error.message}`); expect(null).assertFail(); }); await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID).then(async () => { @@ -298,7 +298,7 @@ describe('DeviceKvStorePromiseTest', function () { expect(err.code == 15100005).assertTrue(); }); } catch (e) { - console.error('DeviceKvStoreGetStringPromiseClosedKVStoreTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreGetStringPromiseClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -317,11 +317,11 @@ describe('DeviceKvStorePromiseTest', function () { console.info('DeviceKvStoreGetStringPromiseNoPutTest get success'); expect(null).assertFail(); }).catch((err) => { - console.error('DeviceKvStoreGetStringPromiseNoPutTest get fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStoreGetStringPromiseNoPutTest get fail' + `, error code is ${err.code}, message is ${err.message}`); expect(err.code == 15100004).assertTrue(); }); } catch (e) { - console.error('DeviceKvStoreGetStringPromiseNoPutTest get e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreGetStringPromiseNoPutTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -340,11 +340,11 @@ describe('DeviceKvStorePromiseTest', function () { console.info('DeviceKvStorePutIntPromiseSucTest put success'); expect(data == undefined).assertTrue(); }).catch((err) => { - console.error('DeviceKvStorePutIntPromiseSucTest put fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStorePutIntPromiseSucTest put fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStorePutIntPromiseSucTest put e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStorePutIntPromiseSucTest put fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -367,15 +367,15 @@ describe('DeviceKvStorePromiseTest', function () { console.info('DeviceKvStorePutIntPromiseMaxTest get success'); expect(intValue == data).assertTrue(); }).catch((err) => { - console.error('DeviceKvStorePutIntPromiseMaxTest get fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStorePutIntPromiseMaxTest get fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); }).catch((err) => { - console.error('DeviceKvStorePutIntPromiseMaxTest put fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStorePutIntPromiseMaxTest put fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStorePutIntPromiseMaxTest put e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStorePutIntPromiseMaxTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -398,15 +398,15 @@ describe('DeviceKvStorePromiseTest', function () { console.info('DeviceKvStorePutIntPromiseMinTest get success'); expect(intValue == data).assertTrue(); }).catch((err) => { - console.error('DeviceKvStorePutIntPromiseMinTest get fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStorePutIntPromiseMinTest get fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); }).catch((err) => { - console.error('DeviceKvStorePutIntPromiseMinTest put fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStorePutIntPromiseMinTest put fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStorePutIntPromiseMinTest put e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStorePutIntPromiseMinTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -428,15 +428,15 @@ describe('DeviceKvStorePromiseTest', function () { console.info('DeviceKvStoreGetIntPromiseSucTest get success'); expect(VALUE_TEST_INT_ELEMENT == data).assertTrue(); }).catch((err) => { - console.error('DeviceKvStoreGetIntPromiseSucTest get fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStoreGetIntPromiseSucTest get fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); }).catch((err) => { - console.error('DeviceKvStoreGetIntPromiseSucTest put fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStoreGetIntPromiseSucTest put fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStoreGetIntPromiseSucTest put e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreGetIntPromiseSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -455,11 +455,11 @@ describe('DeviceKvStorePromiseTest', function () { console.info('DeviceKvStorePutBoolPromiseSucTest put success'); expect(data == undefined).assertTrue(); }).catch((err) => { - console.error('DeviceKvStorePutBoolPromiseSucTest put fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStorePutBoolPromiseSucTest put fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStorePutBoolPromiseSucTest put e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStorePutBoolPromiseSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -482,15 +482,15 @@ describe('DeviceKvStorePromiseTest', function () { console.info('DeviceKvStoreGetBoolPromiseSucTest get success'); expect(boolValue == data).assertTrue(); }).catch((err) => { - console.error('DeviceKvStoreGetBoolPromiseSucTest get fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStoreGetBoolPromiseSucTest get fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); }).catch((err) => { - console.error('DeviceKvStoreGetBoolPromiseSucTest put fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStoreGetBoolPromiseSucTest put fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStoreGetBoolPromiseSucTest put e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreGetBoolPromiseSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -509,11 +509,11 @@ describe('DeviceKvStorePromiseTest', function () { console.info('DeviceKvStorePutFloatPromiseSucTest put success'); expect(data == undefined).assertTrue(); }).catch((err) => { - console.error('DeviceKvStorePutFloatPromiseSucTest put fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStorePutFloatPromiseSucTest put fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStorePutFloatPromiseSucTest put e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStorePutFloatPromiseSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -536,15 +536,15 @@ describe('DeviceKvStorePromiseTest', function () { console.info('DeviceKvStoreGetFloatPromiseSucTest get success'); expect(floatValue == data).assertTrue(); }).catch((err) => { - console.error('DeviceKvStoreGetFloatPromiseSucTest get fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStoreGetFloatPromiseSucTest get fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); }).catch((err) => { - console.error('DeviceKvStoreGetFloatPromiseSucTest put fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStoreGetFloatPromiseSucTest put fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStoreGetFloatPromiseSucTest put e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreGetFloatPromiseSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -567,15 +567,15 @@ describe('DeviceKvStorePromiseTest', function () { console.info('DeviceKvStoreDeleteStringPromiseSucTest delete success'); expect(data == undefined).assertTrue(); }).catch((err) => { - console.error('DeviceKvStoreDeleteStringPromiseSucTest delete fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStoreDeleteStringPromiseSucTest delete fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); }).catch((err) => { - console.error('DeviceKvStoreDeleteStringPromiseSucTest put fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStoreDeleteStringPromiseSucTest put fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStoreDeleteStringPromiseSucTest put e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreDeleteStringPromiseSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -621,7 +621,7 @@ describe('DeviceKvStorePromiseTest', function () { console.info('DeviceKvStoreDeleteStringPromiseSucTest put success'); expect(true).assertTrue(); }).catch((err) => { - console.error('DeviceKvStoreDeleteStringPromiseClosedKVStoreTest put fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStoreDeleteStringPromiseClosedKVStoreTest put fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID).then(async () => { @@ -635,80 +635,39 @@ describe('DeviceKvStorePromiseTest', function () { console.info('DeviceKvStoreDeleteStringPromiseSucTest delete success'); expect(null).assertFail(); }).catch((err) => { - console.error('DeviceKvStoreDeleteStringPromiseSucTest delete fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStoreDeleteStringPromiseSucTest delete fail' + `, error code is ${err.code}, message is ${err.message}`); expect(err.code == 15100005).assertTrue(); }); } catch (e) { - console.error('DeviceKvStorePutStringPromiseClosedKVStoreTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreDeleteStringPromiseClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); }) /** - * @tc.name DeviceKvStoreDeletePredicatesPromiseSucTest - * @tc.desc Test Js Api DeviceKvStore.Delete() success + * @tc.name DeviceKvStoreDeletePredicatesPromiseTest + * @tc.desc Test Js Api DeviceKvStore.Delete() * @tc.type: FUNC * @tc.require: issueNumber */ - it('DeviceKvStoreDeletePredicatesPromiseSucTest', 0, async function (done) { - console.log('DeviceKvStoreDeletePredicatesPromiseSucTest'); + it('DeviceKvStoreDeletePredicatesPromiseTest', 0, async function (done) { + console.log('DeviceKvStoreDeletePredicatesPromiseTest'); try { let predicates = new dataShare.DataSharePredicates(); let arr = ["name"]; predicates.inKeys(arr); - await kvStore.put("name", "Bob").then(async (data) => { - console.log('DeviceKvStoreDeletePredicatesPromiseSucTest put success'); - expect(data == undefined).assertTrue(); - await kvStore.delete(predicates).then((data) => { - console.log('DeviceKvStoreDeletePredicatesPromiseSucTest delete success'); - expect(data == undefined).assertTrue(); - }).catch((err) => { - console.error('DeviceKvStoreDeletePredicatesPromiseSucTest delete fail ' + `, error code is ${err.code}, message is ${err.message}`); - expect(null).assertFail(); - }); - }).catch((err) => { - console.error('DeviceKvStoreDeletePredicatesPromiseSucTest put fail ' + `, error code is ${err.code}, message is ${err.message}`); - expect(null).assertFail(); - }); - } catch (e) { - console.error('DeviceKvStoreDeletePredicatesPromiseSucTest put e ' + `, error code is ${e.code}, message is ${e.message}`); - expect(null).assertFail(); - } - done(); - }) - - /** - * @tc.name DeviceKvStoreDeletePredicatesPromiseClosedKVStoreTest - * @tc.desc Test Js Api DeviceKvStoreDelete predicates into a closed kvstore - * @tc.type: FUNC - * @tc.require: issueNumber - */ - it('DeviceKvStoreDeletePredicatesPromiseClosedKVStoreTest', 0, async function (done) { - try { - let predicates = new dataShare.DataSharePredicates(); - let arr = ["name"]; - predicates.inKeys(arr); - await kvStore.put("name", "Bob").then(async () => { - expect(true).assertTrue(); - }).catch((err) => { - expect(null).assertFail(); - }); - await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID).then(async () => { - await kvManager.deleteKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID).then(() => { - expect(true).assertTrue(); - }).catch((err) => { - console.error('deleteKVStore err ' + `, error code is ${err.code}, message is ${err.message}`); - }); - }) await kvStore.delete(predicates).then((data) => { + console.error('DeviceKvStoreDeletePredicatesPromiseTest delete success'); expect(null).assertFail(); }).catch((err) => { - expect(err.code == 15100005).assertTrue(); + console.error('DeviceKvStoreDeletePredicatesPromiseTest delete fail' + `, error code is ${err.code}, message is ${err.message}`); + expect(null).assertFail(); }); + } catch (e) { - console.error('DeviceKvStoreDeletePredicatesPromiseClosedKVStoreTest e ' + `, error code is ${e.code}, message is ${e.message}`); - expect(null).assertFail(); + console.info('DeviceKvStoreDeletePredicatesPromiseTest fail' + `, error code is ${e.code}, message is ${e.message}`); + expect(e.code == 202).assertTrue(); } done(); }) @@ -756,11 +715,11 @@ describe('DeviceKvStorePromiseTest', function () { console.info('DeviceKvStoreSetSyncRangePromiseDisjointTest setSyncRange success'); expect(err == undefined).assertTrue(); }).catch((err) => { - console.error('DeviceKvStoreDeleteStringPromiseNoPutTest delete fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStoreSetSyncRangePromiseDisjointTest setSyncRange fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStoreSetSyncRangePromiseDisjointTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreSetSyncRangePromiseDisjointTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -781,11 +740,11 @@ describe('DeviceKvStorePromiseTest', function () { console.info('DeviceKvStoreSetSyncRangePromiseJointTest setSyncRange success'); expect(err == undefined).assertTrue(); }).catch((err) => { - console.error('DeviceKvStoreSetSyncRangePromiseJointTest delete fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStoreSetSyncRangePromiseJointTest setSyncRange fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStoreSetSyncRangePromiseJointTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreSetSyncRangePromiseJointTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -806,11 +765,11 @@ describe('DeviceKvStorePromiseTest', function () { console.info('DeviceKvStoreSetSyncRangePromiseSameTest setSyncRange success'); expect(err == undefined).assertTrue(); }).catch((err) => { - console.error('DeviceKvStoreSetSyncRangePromiseSameTest delete fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStoreSetSyncRangePromiseSameTest setSyncRange fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStoreSetSyncRangePromiseSameTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreSetSyncRangePromiseSameTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -823,16 +782,18 @@ describe('DeviceKvStorePromiseTest', function () { * @tc.require: issueNumber */ it('DeviceKvStoreSetSyncRangePromiseInvalidArgsTest', 0, async function (done) { - console.info('DeviceKvStoreSetSyncRangePromiseSameTest'); + console.info('DeviceKvStoreSetSyncRangePromiseInvalidArgsTest'); try { var remoteSupportLabels = ['A', 'B']; await kvStore.setSyncRange(remoteSupportLabels).then((err) => { + console.info('DeviceKvStoreSetSyncRangePromiseInvalidArgsTest setSyncRange success'); expect(null).assertFail(); }).catch((err) => { + console.error('DeviceKvStoreSetSyncRangePromiseInvalidArgsTest setSyncRange fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStoreSetSyncRangePromiseSameTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreSetSyncRangePromiseInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); } done(); @@ -858,15 +819,15 @@ describe('DeviceKvStorePromiseTest', function () { expect(entrys.length == 10).assertTrue(); expect(entrys[0].value.value == 'batch_test_string_value').assertTrue(); }).catch((err) => { - console.error('DeviceKvStorePutBatchPromiseStringTest getEntries fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStorePutBatchPromiseStringTest getEntries fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); }).catch((err) => { - console.error('DeviceKvStorePutBatchPromiseStringTest putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStorePutBatchPromiseStringTest putBatch fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStorePutBatchPromiseStringTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStorePutBatchPromiseStringTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -902,15 +863,15 @@ describe('DeviceKvStorePromiseTest', function () { expect(entrys.length == 10).assertTrue(); expect(entrys[0].value.value == 222).assertTrue(); }).catch((err) => { - console.error('DeviceKvStorePutBatchPromiseIntegerTest getEntries fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStorePutBatchPromiseIntegerTest getEntries fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); }).catch((err) => { - console.error('DeviceKvStorePutBatchPromiseIntegerTest putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStorePutBatchPromiseIntegerTest putBatch fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStorePutBatchPromiseIntegerTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStorePutBatchPromiseIntegerTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -946,15 +907,15 @@ describe('DeviceKvStorePromiseTest', function () { expect(entrys.length == 10).assertTrue(); expect(entrys[0].value.value == 2.0).assertTrue(); }).catch((err) => { - console.error('DeviceKvStorePutBatchPromiseFloatTest getEntries fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStorePutBatchPromiseFloatTest getEntries fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); }).catch((err) => { - console.error('DeviceKvStorePutBatchPromiseFloatTest putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStorePutBatchPromiseFloatTest putBatch fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStorePutBatchPromiseFloatTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStorePutBatchPromiseFloatTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -990,15 +951,15 @@ describe('DeviceKvStorePromiseTest', function () { expect(entrys.length == 10).assertTrue(); expect(entrys[0].value.value == 2.00).assertTrue(); }).catch((err) => { - console.error('DeviceKvStorePutBatchPromiseDoubleTest getEntries fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStorePutBatchPromiseDoubleTest getEntries fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); }).catch((err) => { - console.error('DeviceKvStorePutBatchPromiseDoubleTest putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStorePutBatchPromiseDoubleTest putBatch fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStorePutBatchPromiseDoubleTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStorePutBatchPromiseDoubleTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -1035,15 +996,15 @@ describe('DeviceKvStorePromiseTest', function () { expect(entrys.length == 10).assertTrue(); expect(entrys[0].value.value == bo).assertTrue(); }).catch((err) => { - console.error('DeviceKvStorePutBatchPromiseBooleanTest getEntries fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStorePutBatchPromiseBooleanTest getEntries fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); }).catch((err) => { - console.error('DeviceKvStorePutBatchPromiseBooleanTest putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStorePutBatchPromiseBooleanTest putBatch fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStorePutBatchPromiseBooleanTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStorePutBatchPromiseBooleanTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -1080,15 +1041,15 @@ describe('DeviceKvStorePromiseTest', function () { expect(entrys.length == 10).assertTrue(); expect(entrys[0].value.value.toString() == arr.toString()).assertTrue(); }).catch((err) => { - console.error('DeviceKvStorePutBatchPromiseByteArrayTest getEntries fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStorePutBatchPromiseByteArrayTest getEntries fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); }).catch((err) => { - console.error('DeviceKvStorePutBatchPromiseByteArrayTest putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStorePutBatchPromiseByteArrayTest putBatch fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStorePutBatchPromiseBooleanTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStorePutBatchPromiseByteArrayTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -1112,20 +1073,17 @@ describe('DeviceKvStorePromiseTest', function () { values.push(vb2); console.info('DeviceKvStorePutBatchValuePromiseUint8ArrayTest values: ' + JSON.stringify(values)); await kvStore.putBatch(values).then(async (err) => { - console.info('DeviceKvStorePutBatchValuePromiseUint8ArrayTest putBatch success'); - expect(err == undefined).assertTrue(); - var query = new factory.Query(); - query.prefixKey("name_"); - await kvStore.getEntries(localDeviceId, query).then((entrys) => { - expect(entrys.length == 2).assertTrue(); - done(); - }); + console.error('DeviceKvStorePutBatchValuePromiseUint8ArrayTest PutBatch success'); + expect(null).assertFail(); + }).catch((err) => { + console.error('DeviceKvStorePutBatchValuePromiseUint8ArrayTest PutBatch fail' + `, error code is ${err.code}, message is ${err.message}`); + expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStorePutBatchValuePromiseUint8ArrayTest e ' + `, error code is ${e.code}, message is ${e.message}`); - expect(null).assertFail(); - done(); + console.info('DeviceKvStorePutBatchValuePromiseUint8ArrayTest fail' + `, error code is ${e.code}, message is ${e.message}`); + expect(e.code == 202).assertTrue(); } + done(); }) /** @@ -1144,24 +1102,15 @@ describe('DeviceKvStorePromiseTest', function () { values.push(vb2); console.info('DeviceKvStorePutBatchValuePromiseStringTest values: ' + JSON.stringify(values)); await kvStore.putBatch(values).then(async (err) => { - console.info('DeviceKvStorePutBatchValuePromiseUint8ArrayTest putBatch success'); - expect(err == undefined).assertTrue(); - var query = new factory.Query(); - query.prefixKey("name_"); - await kvStore.getEntries(localDeviceId, query).then((entrys) => { - expect(entrys.length == 2).assertTrue(); - done(); - }).catch((err) => { - console.log('DeviceKvStorePutBatchValueTest delete fail ' + err); - expect(null).assertFail(); - }); + console.error('DeviceKvStorePutBatchValuePromiseStringTest putBatch success'); + expect(null).assertFail(); }).catch((err) => { - console.log('DeviceKvStorePutBatchValueTest delete fail ' + err); + console.error('DeviceKvStorePutBatchValuePromiseStringTest PutBatch fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStorePutBatchValuePromiseStringTest e ' + `, error code is ${e.code}, message is ${e.message}`); - expect(null).assertFail(); + console.info('DeviceKvStorePutBatchValuePromiseStringTest fail' + `, error code is ${e.code}, message is ${e.message}`); + expect(e.code == 202).assertTrue(); } done(); }) @@ -1182,19 +1131,17 @@ describe('DeviceKvStorePromiseTest', function () { values.push(vb2); values.push(vb3); await kvStore.putBatch(values).then(async (err) => { - expect(err == undefined).assertTrue(); - var query = new factory.Query(); - query.prefixKey("name_"); - await kvStore.getEntries(localDeviceId, query).then((entrys) => { - expect(entrys.length == 3).assertTrue(); - done(); - }); + console.error('DeviceKvStorePutBatchValuePromiseNumbersTest putBatch success'); + expect(null).assertFail(); + }).catch((err) => { + console.error('DeviceKvStorePutBatchValuePromiseNumbersTest putBatch fail' + `, error code is ${err.code}, message is ${err.message}`); + expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStorePutBatchValuePromiseTest e ' + `, error code is ${e.code}, message is ${e.message}`); - expect(null).assertFail(); - done(); + console.info('DeviceKvStorePutBatchValuePromiseNumbersTest fail' + `, error code is ${e.code}, message is ${e.message}`); + expect(e.code == 202).assertTrue(); } + done(); }) /** @@ -1211,17 +1158,15 @@ describe('DeviceKvStorePromiseTest', function () { values.push(vb1); values.push(vb2); await kvStore.putBatch(values).then(async (err) => { - expect(err == undefined).assertTrue(); - var query = new factory.Query(); - query.prefixKey("name_"); - await kvStore.getEntries(localDeviceId, query).then((entrys) => { - expect(entrys.length == 2).assertTrue(); - done(); - }); + console.error('DeviceKvStorePutBatchValuePromiseBooleanTest putBatch success'); + expect(null).assertFail(); + }).catch((err) => { + console.error('DeviceKvStorePutBatchValuePromiseBooleanTest putBatch fail' + `, error code is ${err.code}, message is ${err.message}`); + expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStorePutBatchValuePromiseTest e ' + `, error code is ${e.code}, message is ${e.message}`); - expect(null).assertFail(); + console.info('DeviceKvStorePutBatchValuePromiseBooleanTest fail' + `, error code is ${e.code}, message is ${e.message}`); + expect(e.code == 202).assertTrue(); done(); } }) @@ -1242,21 +1187,17 @@ describe('DeviceKvStorePromiseTest', function () { values.push(vb2); console.info('DeviceKvStorePutBatchValuePromiseNullTest values: ' + JSON.stringify(values)); await kvStore.putBatch(values).then(async (err) => { - console.info('DeviceKvStorePutBatchValuePromiseNullTest putBatch success'); - expect(err == undefined).assertTrue(); - var query = new factory.Query(); - query.prefixKey("name_"); - await kvStore.getEntries(localDeviceId, query).then((entrys) => { - expect(entrys.length == 2).assertTrue(); - expect(entrys[0].value == null).assertTrue(); - done(); - }); + console.error('DeviceKvStorePutBatchValuePromiseNullTest putBatch success'); + expect(null).assertFail(); + }).catch((err) => { + console.error('DeviceKvStorePutBatchValuePromiseNullTest putBatch fail' + `, error code is ${err.code}, message is ${err.message}`); + expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStorePutBatchValuePromiseNullTest e ' + `, error code is ${e.code}, message is ${e.message}`); - expect(null).assertFail(); - done(); + console.info('DeviceKvStorePutBatchValuePromiseNullTest fail' + `, error code is ${e.code}, message is ${e.message}`); + expect(e.code == 202).assertTrue(); } + done(); }) /** @@ -1273,7 +1214,7 @@ describe('DeviceKvStorePromiseTest', function () { expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStorePutBatchValuePromiseNullTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStorePutBatchValuePromiseInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); } done(); @@ -1300,13 +1241,15 @@ describe('DeviceKvStorePromiseTest', function () { values.push(vb1); values.push(vb2); await kvStore.putBatch(values).then(() => { + console.error('DeviceKvStorePutBatchValuePromiseClosedKvstoreTest putBatch success'); expect(null).assertFail(); }).catch((err) => { - expect(err.code == 15100005).assertTrue(); + console.error('DeviceKvStorePutBatchValuePromiseClosedKvstoreTest putBatch fail' + `, error code is ${err.code}, message is ${err.message}`); + expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStorePutBatchValuePromiseNullTest e ' + `, error code is ${e.code}, message is ${e.message}`); - expect(null).assertFail(); + console.info('DeviceKvStorePutBatchValuePromiseClosedKvstoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); + expect(e.code == 202).assertTrue(); } done(); }) @@ -1345,7 +1288,7 @@ describe('DeviceKvStorePromiseTest', function () { expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStoreDeleteBatchPromiseSucTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreDeleteBatchPromiseSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -1388,7 +1331,7 @@ describe('DeviceKvStorePromiseTest', function () { expect(err.code == 401).assertTrue(); }); } catch (e) { - console.error('DeviceKvStoreDeleteBatchPromiseInvalidArgsTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreDeleteBatchPromiseInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -1436,7 +1379,7 @@ describe('DeviceKvStorePromiseTest', function () { expect(err.code == 15100005).assertTrue(); }); } catch (e) { - console.error('DeviceKvStoreDeleteBatchPromiseClosedKVStoreTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreDeleteBatchPromiseClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -1482,7 +1425,7 @@ describe('DeviceKvStorePromiseTest', function () { expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStoreGetEntriesPromiseQueryTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreGetEntriesPromiseQueryTest fail' + `, error code is ${e.code}, message is ${e.message}`); console.log("errr3") expect(null).assertFail(); } @@ -1530,7 +1473,7 @@ describe('DeviceKvStorePromiseTest', function () { expect(err.code == 15100005).assertTrue(); }); } catch (e) { - console.error('DeviceKvStoreGetEntriesPromiseQueryClosedKVStoreTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreGetEntriesPromiseQueryClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -1572,7 +1515,7 @@ describe('DeviceKvStorePromiseTest', function () { expect(error == undefined).assertTrue(); }); } catch (e) { - console.error('DeviceKvStoreGetEntriesPromiseSucTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreGetEntriesPromiseSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -1617,7 +1560,7 @@ describe('DeviceKvStorePromiseTest', function () { expect(err.code == 15100005).assertTrue(); }); } catch (e) { - console.error('DeviceKvStoreGetEntriesPromiseSucTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreGetEntriesPromiseClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -1656,7 +1599,7 @@ describe('DeviceKvStorePromiseTest', function () { expect(err.code == 401).assertTrue(); }); } catch (e) { - console.error('DeviceKvStoreGetEntriesPromiseInvalidArgsTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreGetEntriesPromiseInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -1964,11 +1907,11 @@ describe('DeviceKvStorePromiseTest', function () { console.info('DeviceKvStoreRemoveDeviceDataPromiseInvalidArgsTest removeDeviceData success'); expect(null).assertFail(); }).catch((err) => { - console.error('DeviceKvStoreRemoveDeviceDataPromiseInvalidArgsTest removeDeviceData fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStoreRemoveDeviceDataPromiseInvalidArgsTest removeDeviceData fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStoreRemoveDeviceDataPromiseInvalidArgsTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreRemoveDeviceDataPromiseInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); } done(); @@ -2003,7 +1946,7 @@ describe('DeviceKvStorePromiseTest', function () { }); } catch (e) { - console.error('DeviceKvStoreRemoveDeviceDataPromiseClosedKVStoreTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreRemoveDeviceDataPromiseClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -2048,7 +1991,7 @@ describe('DeviceKvStorePromiseTest', function () { expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStoreGetResultSetPromiseSucTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreGetResultSetPromiseSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -2068,11 +2011,11 @@ describe('DeviceKvStorePromiseTest', function () { console.info('DeviceKvStoreGetResultSetPromiseInvalidArgsTest getResultSet success'); expect(null).assertFail(); }).catch((err) => { - console.error('DeviceKvStoreGetResultSetPromiseInvalidArgsTest getResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStoreGetResultSetPromiseInvalidArgsTest getResultSet fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStoreGetResultSetPromiseInvalidArgsTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreGetResultSetPromiseInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); } done(); @@ -2103,11 +2046,11 @@ describe('DeviceKvStorePromiseTest', function () { await kvStore.getResultSet(localDeviceId, 'batch_test_string_key').then((result) => { expect(null).assertFail(); }).catch((err) => { - console.error('DeviceKvStoreGetResultSetPromiseClosedKVStoreTest getResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStoreGetResultSetPromiseClosedKVStoreTest getResultSet fail' + `, error code is ${err.code}, message is ${err.message}`); expect(err.code == 15100005).assertTrue(); }); } catch (e) { - console.error('DeviceKvStoreGetResultSetPromiseClosedKVStoreTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreGetResultSetPromiseClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -2139,7 +2082,7 @@ describe('DeviceKvStorePromiseTest', function () { console.info('DeviceKvStoreGetResultSetPromiseQueryTest putBatch success'); expect(err == undefined).assertTrue(); }).catch((err) => { - console.error('DeviceKvStorePutBatchPromiseStringTest putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStoreGetResultSetPromiseQueryTest putBatch fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); var query = new factory.Query(); @@ -2149,18 +2092,18 @@ describe('DeviceKvStorePromiseTest', function () { resultSet = result; expect(resultSet.getCount() == 10).assertTrue(); }).catch((err) => { - console.error('DeviceKvStoreGetResultSetPromiseQueryTest getResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStoreGetResultSetPromiseQueryTest getResultSet fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); await kvStore.closeResultSet(resultSet).then((err) => { console.info('DeviceKvStoreGetResultSetPromiseQueryTest closeResultSet success'); expect(err == undefined).assertTrue(); }).catch((err) => { - console.error('DeviceKvStoreGetResultSetPromiseQueryTest closeResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStoreGetResultSetPromiseQueryTest closeResultSet fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStoreGetResultSetPromiseQueryTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreGetResultSetPromiseQueryTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -2202,28 +2145,29 @@ describe('DeviceKvStorePromiseTest', function () { var query = new factory.Query(); query.prefixKey("batch_test"); await kvStore.getResultSet(localDeviceId, query).then((result) => { + console.info('DeviceKvStoreGetResultSetQueryPromiseClosedKVStoreTest getResultSet success'); expect(null).assertFail(); }).catch((err) => { + console.error('DeviceKvStoreGetResultSetQueryPromiseClosedKVStoreTest getResultSet fail' + `, error code is ${err.code}, message is ${err.message}`); expect(err.code == 15100005).assertTrue(); }); } catch (e) { - console.error('DeviceKvStoreGetResultSetQueryPromiseClosedKVStoreTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreGetResultSetQueryPromiseClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); }) /** - * @tc.name DeviceKvStoreGetResultSetPredicatesPromiseSucTest - * @tc.desc Test Js Api DeviceKvStore.GetResultSet() with predicates success + * @tc.name DeviceKvStoreGetResultSetPredicatesPromiseTest + * @tc.desc Test Js Api DeviceKvStore.GetResultSet() with predicates * @tc.type: FUNC * @tc.require: issueNumber */ - it('DeviceKvStoreGetResultSetPredicatesPromiseSucTest', 0, async function (done) { - console.log('DeviceKvStoreGetResultSetPredicatesPromiseSucTest'); + it('DeviceKvStoreGetResultSetPredicatesPromiseTest', 0, async function (done) { + console.log('DeviceKvStoreGetResultSetPredicatesPromiseTest'); try { let entries = []; - let resultSet; for (let i = 0; i < 10; i++) { let key = 'name_'; let value = 'Bob_' @@ -2244,18 +2188,15 @@ describe('DeviceKvStorePromiseTest', function () { let predicates = new dataShare.DataSharePredicates(); predicates.prefixKey("name_"); await kvStore.getResultSet(localDeviceId, predicates).then((result) => { - resultSet = result; - expect(resultSet.getCount() == 10).assertTrue(); - }).catch((err) => { + console.error('DeviceKvStoreGetResultSetPredicatesPromiseTest getResultSet success'); expect(null).assertFail(); - }); - await kvStore.closeResultSet(resultSet).then((err) => { - expect(err == undefined).assertTrue(); }).catch((err) => { + console.error('DeviceKvStoreGetResultSetPredicatesPromiseTest getResultSet fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - expect(null).assertFail(); + console.info('DeviceKvStoreGetResultSetPredicatesPromiseTest fail' + `, error code is ${e.code}, message is ${e.message}`); + expect(e.code== 202).assertTrue(); } done(); }) @@ -2296,13 +2237,15 @@ describe('DeviceKvStorePromiseTest', function () { let predicates = new dataShare.DataSharePredicates(); predicates.prefixKey("batch_test"); await kvStore.getResultSet(localDeviceId, predicates).then((result) => { + console.error('DeviceKvStoreGetResultSetPredicatesPromiseClosedKVStoreTest getResultSet success'); expect(null).assertFail(); }).catch((err) => { - expect(err.code == 15100005).assertTrue(); + console.error('DeviceKvStoreGetResultSetPredicatesPromiseClosedKVStoreTest getResultSet fail' + `, error code is ${err.code}, message is ${err.message}`); + expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStoreGetResultSetPredicatesPromiseClosedKVStoreTest e ' + `, error code is ${e.code}, message is ${e.message}`); - expect(null).assertFail(); + console.info('DeviceKvStoreGetResultSetPredicatesPromiseClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); + expect(e.code== 202).assertTrue(); } done(); }) @@ -2322,18 +2265,18 @@ describe('DeviceKvStorePromiseTest', function () { console.info('DeviceKvStoreCloseResultSetPromiseSucTest getResultSet success'); resultSet = result; }).catch((err) => { - console.error('DeviceKvStoreCloseResultSetPromiseSucTest getResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStoreCloseResultSetPromiseSucTest getResultSet fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); await kvStore.closeResultSet(resultSet).then((err) => { console.info('DeviceKvStoreCloseResultSetPromiseSucTest closeResultSet success'); expect(err == undefined).assertTrue(); }).catch((err) => { - console.error('DeviceKvStoreCloseResultSetPromiseSucTest closeResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStoreCloseResultSetPromiseSucTest closeResultSet fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStoreCloseResultSetPromiseSucTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreCloseResultSetPromiseSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -2350,10 +2293,10 @@ describe('DeviceKvStorePromiseTest', function () { await kvStore.closeResultSet().then(() => { expect(null).assertFail(); }).catch((err) => { - console.error('DeviceKvStoreCloseResultSetPromiseInvalidArgsTest closeResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStoreCloseResultSetPromiseInvalidArgsTest closeResultSet fail' + `, error code is ${err.code}, message is ${err.message}`); }); } catch (e) { - console.error('DeviceKvStoreCloseResultSetPromiseInvalidArgsTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.info('DeviceKvStoreCloseResultSetPromiseInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); } done(); @@ -2383,7 +2326,7 @@ describe('DeviceKvStorePromiseTest', function () { console.info('DeviceKvStoreGetResultSizePromiseQueryTest putBatch success'); expect(err == undefined).assertTrue(); }).catch((err) => { - console.error('DeviceKvStorePutBatchPromiseStringTest putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStoreGetResultSizePromiseQueryTest putBatch fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); var query = new factory.Query(); @@ -2392,11 +2335,11 @@ describe('DeviceKvStorePromiseTest', function () { console.info('DeviceKvStoreGetResultSizePromiseQueryTest getResultSet success'); expect(resultSize == 10).assertTrue(); }).catch((err) => { - console.error('DeviceKvStoreGetResultSizePromiseQueryTest getResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('DeviceKvStoreGetResultSizePromiseQueryTest getResultSet fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStoreGetResultSizePromiseQueryTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreGetResultSizePromiseQueryTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -2433,7 +2376,7 @@ describe('DeviceKvStorePromiseTest', function () { expect(null).assertFail(); }); } catch (e) { - console.error('DeviceKvStoreGetResultSizePromiseInvalidArgsTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.info('DeviceKvStoreGetResultSizePromiseInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); } done(); @@ -2477,11 +2420,11 @@ describe('DeviceKvStorePromiseTest', function () { console.info('DeviceKvStoreGetResultSizePromiseClosedKVStoreTest getResultSet success'); expect(null).assertFail(); }).catch((err) => { - console.error('DeviceKvStoreGetResultSizePromiseClosedKVStoreTest getResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.info('DeviceKvStoreGetResultSizePromiseClosedKVStoreTest getResultSet fail' + `, error code is ${err.code}, message is ${err.message}`); expect(err.code == 15100005).assertTrue(); }); } catch (e) { - console.error('DeviceKvStoreGetResultSizePromiseQueryTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('DeviceKvStoreGetResultSizePromiseClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -2506,7 +2449,7 @@ describe('DeviceKvStorePromiseTest', function () { console.info('DeviceKvStoreChangeNotificationPromiseTest getInsertEntries' + JSON.stringify(insertEntries)); expect(insertEntries != null).assertTrue(); }).catch((error) => { - console.error('DeviceKvStoreChangeNotificationPromiseTest can NOT getInsertEntries, fail:' + `, error code is ${error.code}, message is ${error.message}`); + console.error('DeviceKvStoreChangeNotificationPromiseTest getInsertEntries fail' + `, error code is ${error.code}, message is ${error.message}`); expect(null).assertFail(); }); done(); @@ -2534,7 +2477,7 @@ describe('DeviceKvStorePromiseTest', function () { console.info('DeviceKvStoreChangeNotificationPromisePutTest getUpdateEntries' + JSON.stringify(updateEntries)); expect(updateEntries != null).assertTrue(); }).catch((error) => { - console.error('DeviceKvStoreChangeNotificationPromisePutTest can NOT getUpdateEntries, fail:' + `, error code is ${error.code}, message is ${error.message}`); + console.error('DeviceKvStoreChangeNotificationPromisePutTest getUpdateEntries fail' + `, error code is ${error.code}, message is ${error.message}`); expect(null).assertFail(); }); done(); @@ -2562,7 +2505,7 @@ describe('DeviceKvStorePromiseTest', function () { console.info('DeviceKvStoreChangeNotificationPromiseDeleteTest deleteEntries' + JSON.stringify(getdeleteEntries)); expect(deleteEntries != null).assertTrue(); }).catch((error) => { - console.error('DeviceKvStoreChangeNotificationPromiseDeleteTest can NOT getdeleteEntries, fail:' + `, error code is ${error.code}, message is ${error.message}`); + console.error('DeviceKvStoreChangeNotificationPromiseDeleteTest getdeleteEntries fail' + `, error code is ${error.code}, message is ${error.message}`); expect(null).assertFail(); }); done(); diff --git a/kv_store/test/unittest/distributedKVStore/SingleKvStoreKVCallbackJsTest.js b/kv_store/test/unittest/distributedKVStore/SingleKvStoreKVCallbackJsTest.js index 42a8e5013ce05c9fd48f5a348a0ec52181fd2f68..b318facd5f251f51817af2f751b905854064ac67 100644 --- a/kv_store/test/unittest/distributedKVStore/SingleKvStoreKVCallbackJsTest.js +++ b/kv_store/test/unittest/distributedKVStore/SingleKvStoreKVCallbackJsTest.js @@ -107,7 +107,7 @@ describe('SingleKvStoreCallbackTest', function () { }); kvStore = null; } catch (e) { - console.error('afterEach closeKVStore err ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('afterEach closeKVStore fail' + `, error code is ${err.code}, message is ${err.message}`); } }) @@ -130,7 +130,7 @@ describe('SingleKvStoreCallbackTest', function () { done(); }); } catch (e) { - console.error('SingleKvStorePutStringCallbackSucTest put e' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStorePutStringCallbackSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -155,7 +155,7 @@ describe('SingleKvStoreCallbackTest', function () { } }); } catch (e) { - console.error('SingleKvStorePutStringCallbackInvalidArgsTest put e' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStorePutStringCallbackInvalidArgsTest put fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); } done(); @@ -183,7 +183,7 @@ describe('SingleKvStoreCallbackTest', function () { } }); } catch (e) { - console.error('SingleKvStorePutStringCallbackClosedKvStoreTest put e' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStorePutStringCallbackClosedKvStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -208,7 +208,7 @@ describe('SingleKvStoreCallbackTest', function () { }); }) } catch (e) { - console.error('SingleKvStoreGetStringCallbackSucTest get e' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreGetStringCallbackSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -230,13 +230,15 @@ describe('SingleKvStoreCallbackTest', function () { }); await kvStore.get(KEY_TEST_STRING_ELEMENT, function (err) { if (err == undefined) { + console.error('SingleKvStoreGetStringCallbackClosedKVStoreTest get success'); expect(null).assertFail(); } else { + console.info('SingleKvStoreGetStringCallbackClosedKVStoreTest get fail' + `, error code is ${e.code}, message is ${e.message}`); expect(err.code == 15100005).assertTrue(); } }); } catch (e) { - console.error('SingleKvStoreGetStringCallbackClosedKVStoreTest get e' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreGetStringCallbackClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -262,7 +264,7 @@ describe('SingleKvStoreCallbackTest', function () { }); }) } catch (e) { - console.error('SingleKvStoreGetStringCallbackInvalidArgsTest get e' + `, error code is ${e.code}, message is ${e.message}`); + console.info('SingleKvStoreGetStringCallbackInvalidArgsTest get fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); } done(); @@ -287,7 +289,7 @@ describe('SingleKvStoreCallbackTest', function () { }) }); } catch (e) { - console.error('SingleKvStorePutIntCallbackSucTest put e' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStorePutIntCallbackSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -313,7 +315,7 @@ describe('SingleKvStoreCallbackTest', function () { }) }); } catch (e) { - console.error('SingleKvStorePutIntCallbackMaxTest put e' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStorePutIntCallbackMaxTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -339,7 +341,7 @@ describe('SingleKvStoreCallbackTest', function () { }) }); } catch (e) { - console.error('SingleKvStorePutIntCallbackMinTest put e' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStorePutIntCallbackMinTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -356,7 +358,7 @@ describe('SingleKvStoreCallbackTest', function () { try { await kvStore.get(KEY_TEST_INT_ELEMENT, function (err) { if (err == undefined) { - console.info('SingleKvStoreGetIntCallbackTest get success'); + console.error('SingleKvStoreGetIntCallbackTest get success'); expect(null).assertFail(); } else { console.info('SingleKvStoreGetIntCallbackTest get fail'); @@ -365,7 +367,7 @@ describe('SingleKvStoreCallbackTest', function () { done(); }) } catch (e) { - console.error('SingleKvStoreGetIntCallbackTest put e' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreGetIntCallbackTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -386,7 +388,7 @@ describe('SingleKvStoreCallbackTest', function () { done(); }); } catch (e) { - console.error('SingleKvStorePutBoolCallbackTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStorePutBoolCallbackTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -411,7 +413,7 @@ describe('SingleKvStoreCallbackTest', function () { }); }) } catch (e) { - console.error('SingleKvStoreGetBoolCallbackSucTest e' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreGetBoolCallbackSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -432,7 +434,7 @@ describe('SingleKvStoreCallbackTest', function () { done(); }); } catch (e) { - console.error('SingleKvStorePutFloatCallbackSucTest e' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStorePutFloatCallbackSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -463,7 +465,7 @@ describe('SingleKvStoreCallbackTest', function () { }); } catch (e) { - console.error('SingleKvStoreGetFloatCallbackSucTest e' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreGetFloatCallbackSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -488,7 +490,7 @@ describe('SingleKvStoreCallbackTest', function () { }); }) } catch (e) { - console.error('SingleKvStoreDeleteStringCallbackSucTest e' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreDeleteStringCallbackSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -512,7 +514,7 @@ describe('SingleKvStoreCallbackTest', function () { }); }) } catch (e) { - console.error('SingleKvStoreDeleteStringCallbackInvalidArgsTest e' + `, error code is ${e.code}, message is ${e.message}`); + console.info('SingleKvStoreDeleteStringCallbackInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); } done(); @@ -529,9 +531,9 @@ describe('SingleKvStoreCallbackTest', function () { await kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err) { if (err == undefined) { expect(true).assertTrue(); - console.info('SingleKvStorePutStringCallbackClosedKvStoreTest put success'); + console.info('SingleKvStoreDeleteCallbackClosedKVStoreTest put success'); } else { - console.error('SingleKvStorePutStringCallbackClosedKvStoreTest put fail' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStoreDeleteCallbackClosedKVStoreTest put fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); } }); @@ -544,13 +546,15 @@ describe('SingleKvStoreCallbackTest', function () { }); await kvStore.delete(KEY_TEST_STRING_ELEMENT, function (err) { if (err == undefined) { + console.info('SingleKvStoreDeleteCallbackClosedKVStoreTest delete success'); expect(null).assertFail(); } else { + console.info('SingleKvStoreDeleteCallbackClosedKVStoreTest delete fail' + `, error code is ${err.code}, message is ${err.message}`); expect(err.code == 15100005).assertTrue(); } }); } catch (e) { - console.error('SingleKvStorePutStringCallbackClosedKvStoreTest put e' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreDeleteCallbackClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -575,7 +579,7 @@ describe('SingleKvStoreCallbackTest', function () { }); }) } catch (e) { - console.error('SingleKvStoreDeleteIntCallbackSucTest e' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreDeleteIntCallbackSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -600,7 +604,7 @@ describe('SingleKvStoreCallbackTest', function () { }); }) } catch (e) { - console.error('SingleKvStoreDeleteFloatCallbackSucTest e' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreDeleteFloatCallbackSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -625,7 +629,7 @@ describe('SingleKvStoreCallbackTest', function () { }); }) } catch (e) { - console.error('SingleKvStoreDeleteBoolCallbackSucTest e' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreDeleteBoolCallbackSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -643,20 +647,20 @@ describe('SingleKvStoreCallbackTest', function () { let predicates = new dataShare.DataSharePredicates(); let arr = ["name"]; predicates.inKeys(arr); - await kvStore.put("name", "Bob", async function (err, data) { - console.log('SingleKvStoreDeletePredicatesCallbackSucTest put success'); - expect(err == undefined).assertTrue(); - await kvStore.delete(predicates, function (err, data) { - console.log('SingleKvStoreDeletePredicatesCallbackSucTest delete success'); - expect(err == undefined).assertTrue(); - done(); - }); - }) + await kvStore.delete(predicates, async function (err) { + if (err == undefined) { + console.error('SingleKvStoreDeletePredicatesCallbackSucTest delete success'); + expect(null).assertFail(); + } else { + console.error('SingleKvStoreDeletePredicatesCallbackSucTest delete fail' + `, error code is ${err.code}, message is ${err.message}`); + expect(null).assertFail(); + } + }); } catch (e) { - console.error('SingleKvStoreDeletePredicatesCallbackSucTest e' + `, error code is ${e.code}, message is ${e.message}`); - expect(null).assertFail(); - done(); + console.info('SingleKvStoreDeletePredicatesCallbackSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); + expect(e.code == 202).assertTrue(); } + done(); }) /** @@ -824,7 +828,7 @@ describe('SingleKvStoreCallbackTest', function () { done(); }); } catch (e) { - console.error('SingleKvStoreOnChangeCallbackTest e' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreOnChangeCallbackTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -849,7 +853,7 @@ describe('SingleKvStoreCallbackTest', function () { done(); }); } catch (e) { - console.error('SingleKvStoreOnChangeCallbackType1Test e' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreOnChangeCallbackType1Test fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -874,7 +878,7 @@ describe('SingleKvStoreCallbackTest', function () { done(); }); } catch (e) { - console.error('SingleKvStoreOnChangeCallbackType2Test e' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreOnChangeCallbackType2Test fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -896,7 +900,7 @@ describe('SingleKvStoreCallbackTest', function () { }); }); } catch (e) { - console.error('SingleKvStoreOnChangeCallbackClosedKVStoreTest e' + `, error code is ${e.code}, message is ${e.message}`); + console.info('SingleKvStoreOnChangeCallbackClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 15100005).assertTrue(); } done(); @@ -921,7 +925,7 @@ describe('SingleKvStoreCallbackTest', function () { expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStoreOnChangeCallbackPassMaxTest e' + `, error code is ${e.code}, message is ${e.message}`); + console.info('SingleKvStoreOnChangeCallbackPassMaxTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 15100001).assertTrue(); } done(); @@ -942,7 +946,7 @@ describe('SingleKvStoreCallbackTest', function () { }); } catch (e) { - console.error('SingleKvStoreOnChangeCallbackInvalidArgsTest e' + `, error code is ${e.code}, message is ${e.message}`); + console.info('SingleKvStoreOnChangeCallbackInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); done(); } @@ -963,7 +967,7 @@ describe('SingleKvStoreCallbackTest', function () { kvStore.on('dataChange', 0, func); kvStore.off('dataChange', func); } catch (e) { - console.error('SingleKvStoreOffChangeCallbackSucTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.info('SingleKvStoreOffChangeCallbackSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -985,7 +989,7 @@ describe('SingleKvStoreCallbackTest', function () { expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStoreOffChangeCallbackSucTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.info('SingleKvStoreOffChangeCallbackSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); } done(); @@ -1006,7 +1010,7 @@ describe('SingleKvStoreCallbackTest', function () { kvStore.off('syncComplete', func); expect(true).assertTrue(); } catch (e) { - console.error('SingleKvStoreOffSyncCompleteCallbackSucTest put e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreOffSyncCompleteCallbackSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -1029,7 +1033,7 @@ describe('SingleKvStoreCallbackTest', function () { } }); } catch (e) { - console.error('SingleKvStoreOffSyncCompleteCallbackInvalidArgsTest put e ' + `, error code is ${e.code}, message is ${e.message}`); + console.info('SingleKvStoreOffSyncCompleteCallbackInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); } done(); @@ -1052,7 +1056,7 @@ describe('SingleKvStoreCallbackTest', function () { done(); }); } catch (e) { - console.error('SingleKvStoreSetSyncRangeCallbackDisjointTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreSetSyncRangeCallbackDisjointTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -1075,7 +1079,7 @@ describe('SingleKvStoreCallbackTest', function () { done(); }); } catch (e) { - console.error('SingleKvStoreSetSyncRangeCallbackTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreSetSyncRangeCallbackTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -1098,7 +1102,7 @@ describe('SingleKvStoreCallbackTest', function () { done(); }); } catch (e) { - console.error(' SingleKvStoreSetSyncRangeCallbackSameTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreSetSyncRangeCallbackSameTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -1118,7 +1122,7 @@ describe('SingleKvStoreCallbackTest', function () { expect(null).assertFail(); }); } catch (e) { - console.error(' SingleKvStoreSetSyncRangeCallbackSameTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.info(' SingleKvStoreSetSyncRangeCallbackSameTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); } done(); @@ -1156,7 +1160,7 @@ describe('SingleKvStoreCallbackTest', function () { }); }); } catch (e) { - console.error('SingleKvStorePutBatchEntryCallbackStringTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStorePutBatchEntryCallbackStringTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -1194,7 +1198,7 @@ describe('SingleKvStoreCallbackTest', function () { }); }); } catch (e) { - console.error('SingleKvStorePutBatchEntryCallbackIntegerTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStorePutBatchEntryCallbackIntegerTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -1232,7 +1236,7 @@ describe('SingleKvStoreCallbackTest', function () { }); }); } catch (e) { - console.error('SingleKvStorePutBatchEntryCallbackFloatTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStorePutBatchEntryCallbackFloatTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -1270,7 +1274,7 @@ describe('SingleKvStoreCallbackTest', function () { }); }); } catch (e) { - console.error('SingleKvStorePutBatchEntryCallbackDoubleTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStorePutBatchEntryCallbackDoubleTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -1309,7 +1313,7 @@ describe('SingleKvStoreCallbackTest', function () { }); }); } catch (e) { - console.error('SingleKvStorePutBatchEntryCallbackBooleanTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStorePutBatchEntryCallbackBooleanTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -1348,7 +1352,7 @@ describe('SingleKvStoreCallbackTest', function () { }); }); } catch (e) { - console.error('SingleKvStorePutBatchEntryCallbackByteArrayTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStorePutBatchEntryCallbackByteArrayTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -1361,7 +1365,7 @@ describe('SingleKvStoreCallbackTest', function () { * @tc.require: issueNumber */ it('SingleKvStorePutBatchValueCallbackUint8ArrayTest', 0, async function (done) { - console.info('SingleKvStorePutBatchValueCallbackUint8ArrayTest001'); + console.info('SingleKvStorePutBatchValueCallbackUint8ArrayTest'); try { let values = []; let arr1 = new Uint8Array([4, 5, 6, 7]); @@ -1371,21 +1375,20 @@ describe('SingleKvStoreCallbackTest', function () { values.push(vb1); values.push(vb2); console.info('SingleKvStorePutBatchValueCallbackUint8ArrayTest001 values: ' + JSON.stringify(values)); - await kvStore.putBatch(values, async function (err, data) { - console.info('SingleKvStorePutBatchValueCallbackUint8ArrayTest001 putBatch success'); - expect(err == undefined).assertTrue(); - var query = new factory.Query(); - query.prefixKey("name_"); - kvStore.getEntries(query, function (err, entrys) { - expect(entrys.length == 2).assertTrue(); - done(); - }); + await kvStore.putBatch(values, async function (err) { + if (err == undefined) { + console.error('SingleKvStorePutBatchValueCallbackUint8ArrayTest putBatch success'); + expect(null).assertFail(); + } else { + console.error('SingleKvStorePutBatchValueCallbackUint8ArrayTest putBatch fail' + `, error code is ${err.code}, message is ${err.message}`); + expect(null).assertFail(); + } }); } catch (e) { - console.error('SingleKvStorePutBatchValueCallbackUint8ArrayTest001 e ' + `, error code is ${e.code}, message is ${e.message}`); - expect(null).assertFail(); - done(); + console.info('SingleKvStorePutBatchValueCallbackUint8ArrayTest fail' + `, error code is ${e.code}, message is ${e.message}`); + expect(e.code == 202).assertTrue(); } + done(); }) /** @@ -1404,7 +1407,7 @@ describe('SingleKvStoreCallbackTest', function () { } }); } catch (e) { - console.error('SingleKvStorePutBatchCallbackInvalidArgsTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.info('SingleKvStorePutBatchCallbackInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); } done(); @@ -1428,14 +1431,16 @@ describe('SingleKvStoreCallbackTest', function () { values.push(vb2); await kvStore.putBatch(values, async function (err) { if (err == undefined) { + console.error('SingleKvStorePutBatchCallbackClosedKvstoreTest putBatch success'); expect(null).assertFail(); } else { - expect(err.code == 15100005).assertFail(); + console.error('SingleKvStorePutBatchCallbackClosedKvstoreTest putBatch fail' + `, error code is ${err.code}, message is ${err.message}`); + expect(null).assertFail(); } }); } catch (e) { - console.error('SingleKvStorePutBatchCallbackClosedKvstoreTest e ' + `, error code is ${e.code}, message is ${e.message}`); - expect(null).assertFail(); + console.info('SingleKvStorePutBatchCallbackClosedKvstoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); + expect(e.code == 202).assertTrue(); } done(); }) @@ -1474,7 +1479,7 @@ describe('SingleKvStoreCallbackTest', function () { }); }); } catch (e) { - console.error('SingleKvStoreDeleteBatchCallbackSucTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreDeleteBatchCallbackSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -1514,7 +1519,7 @@ describe('SingleKvStoreCallbackTest', function () { }); }); } catch (e) { - console.error('SingleKvStoreDeleteBatchCallbackInvalidArgsTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreDeleteBatchCallbackInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); } done(); @@ -1557,7 +1562,7 @@ describe('SingleKvStoreCallbackTest', function () { }); }); } catch (e) { - console.error('SingleKvStoreDeleteBatchCallbackClosedKVStoreTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreDeleteBatchCallbackClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -1595,7 +1600,7 @@ describe('SingleKvStoreCallbackTest', function () { }); }); } catch (e) { - console.error('SingleKvStoreGetEntriesCallbackQueryTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreGetEntriesCallbackQueryTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -1638,7 +1643,7 @@ describe('SingleKvStoreCallbackTest', function () { }); }); } catch (e) { - console.error('SingleKvStoreGetEntriesCallbackQueryClosedKVStoreTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreGetEntriesCallbackQueryClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -1674,7 +1679,7 @@ describe('SingleKvStoreCallbackTest', function () { }); }); } catch (e) { - console.error('SingleKvStoreGetEntriesCallbackSucTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreGetEntriesCallbackSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -1715,7 +1720,7 @@ describe('SingleKvStoreCallbackTest', function () { }); }); } catch (e) { - console.error('SingleKvStoreGetEntriesCallbackClosedKVStoreTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreGetEntriesCallbackClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -1753,7 +1758,7 @@ describe('SingleKvStoreCallbackTest', function () { }); }); } catch (e) { - console.error('SingleKvStoreGetEntriesCallbackInvalidArgsTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreGetEntriesCallbackInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); } done(); @@ -1792,7 +1797,7 @@ describe('SingleKvStoreCallbackTest', function () { }); }); } catch (e) { - console.error('SingleKvstoreStartTransactionCallbackCommitTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvstoreStartTransactionCallbackCommitTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -1828,7 +1833,7 @@ describe('SingleKvStoreCallbackTest', function () { }); }); } catch (e) { - console.error('SingleKvstoreStartTransactionCallbackRollbackTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvstoreStartTransactionCallbackRollbackTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -1854,7 +1859,7 @@ describe('SingleKvStoreCallbackTest', function () { done(); }); } catch (e) { - console.error('SingleKvstoreStartTransactionCallbackClosedKVStoreTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvstoreStartTransactionCallbackClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -1881,7 +1886,7 @@ describe('SingleKvStoreCallbackTest', function () { done(); }); } catch (e) { - console.error('SingleKvStoreCommitCallbackClosedKVStoreTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreCommitCallbackClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -1908,7 +1913,7 @@ describe('SingleKvStoreCallbackTest', function () { done(); }); } catch (e) { - console.error('SingleKvStoreRollbackCallbackClosedKVStoreTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreRollbackCallbackClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -1934,7 +1939,7 @@ describe('SingleKvStoreCallbackTest', function () { done(); }); } catch (e) { - console.error('SingleKvStoreEnableSyncCallbackTrueTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreEnableSyncCallbackTrueTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -1960,7 +1965,7 @@ describe('SingleKvStoreCallbackTest', function () { done(); }); } catch (e) { - console.error('SingleKvStoreEnableSyncCallbackFalseTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreEnableSyncCallbackFalseTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -1986,7 +1991,7 @@ describe('SingleKvStoreCallbackTest', function () { done(); }); } catch (e) { - console.error('SingleKvStoreEnableSyncCallbackInvalidArgsTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreEnableSyncCallbackInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); done(); } @@ -2016,7 +2021,7 @@ describe('SingleKvStoreCallbackTest', function () { } }); } catch (e) { - console.error('SingleKvStoreRemoveDeviceDataCallbackClosedKvstoreTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreRemoveDeviceDataCallbackClosedKvstoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -2039,7 +2044,7 @@ describe('SingleKvStoreCallbackTest', function () { done(); }); } catch (e) { - console.error('SingleKvStoreRemoveDeviceDataCallbackInvalidArgsTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreRemoveDeviceDataCallbackInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); done(); } @@ -2061,7 +2066,7 @@ describe('SingleKvStoreCallbackTest', function () { done(); }); } catch (e) { - console.error('SingleKvStoreSetSyncParamCallbackSucTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreSetSyncParamCallbackSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -2087,7 +2092,7 @@ describe('SingleKvStoreCallbackTest', function () { done(); }); } catch (e) { - console.error('SingleKvStoreSetSyncParamCallbackInvalidArgsTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreSetSyncParamCallbackInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); done(); } @@ -2107,7 +2112,7 @@ describe('SingleKvStoreCallbackTest', function () { done(); }); } catch (e) { - console.error('SingleKvStoreGetSecurityLevelCallbackSucTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreGetSecurityLevelCallbackSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -2136,7 +2141,7 @@ describe('SingleKvStoreCallbackTest', function () { done(); }); } catch (e) { - console.error('SingleKvStoreGetSecurityLevelCallbackClosedKVStoreTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreGetSecurityLevelCallbackClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -2179,7 +2184,7 @@ describe('SingleKvStoreCallbackTest', function () { }); }); } catch (e) { - console.error('SingleKvStoreGetResultSetCallbackSucTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreGetResultSetCallbackSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -2201,7 +2206,7 @@ describe('SingleKvStoreCallbackTest', function () { done(); }); } catch (e) { - console.error('SingleKvStoreGetResultSetCallbackInvalidArgsTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreGetResultSetCallbackInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); done(); } @@ -2216,24 +2221,21 @@ describe('SingleKvStoreCallbackTest', function () { it('SingleKvStoreGetResultSetPredicatesCallbackTest', 0, async function (done) { console.log('SingleKvStoreGetResultSetPredicatesCallbackTest'); try { - let resultSet; let predicates = new dataShare.DataSharePredicates(); - await kvStore.getResultSet(predicates).then((result) => { - console.log('SingleKvStoreGetResultSetPredicatesCallbackTest getResultSet success'); - resultSet = result; - expect(true).assertTrue(); - }).catch((err) => { - console.error('SingleKvStoreGetResultSetPredicatesCallbackTest getResultSet fail ' + err`, error code is ${err.code}, message is ${err.message}`); - expect(null).assertFail(); - }); - await kvStore.closeResultSet(resultSet).then((err) => { - expect(err == undefined).assertTrue(); - }).catch((err) => { - expect(null).assertFail(); + let arr = ["name"]; + predicates.inKeys(arr); + await kvStore.getResultSet(predicates, async function (err, result) { + if (err == undefined) { + console.error('SingleKvStoreGetResultSetPredicatesCallbackTest getResultSet success'); + expect(null).assertTrue(); + } else { + console.error('SingleKvStoreGetResultSetPredicatesCallbackTest getResultSet fail' + `, error code is ${err.code}, message is ${err.message}`); + expect(null).assertFail(); + } }); } catch (e) { - console.error('SingleKvStoreGetResultSetPredicatesCallbackTest e ' + `, error code is ${e.code}, message is ${e.message}`); - expect(null).assertFail(); + console.info('SingleKvStoreGetResultSetPredicatesCallbackTest fail' + `, error code is ${e.code}, message is ${e.message}`); + expect(e.code == 202).assertTrue(); } done(); }) @@ -2273,7 +2275,7 @@ describe('SingleKvStoreCallbackTest', function () { }); }); } catch (e) { - console.error('SingleKvStoreGetResultSetQueryCallbackTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreGetResultSetQueryCallbackTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -2304,7 +2306,7 @@ describe('SingleKvStoreCallbackTest', function () { }); }); } catch (e) { - console.error('SingleKvStoreCloseResultSetCallbackSucTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreCloseResultSetCallbackSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); done(); } @@ -2331,7 +2333,7 @@ describe('SingleKvStoreCallbackTest', function () { done(); }); } catch (e) { - console.error('SingleKvStoreCloseResultSetCallbackInvalidArgsTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreCloseResultSetCallbackInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); done(); } @@ -2367,7 +2369,7 @@ describe('SingleKvStoreCallbackTest', function () { expect(resultSize == 10).assertTrue(); }) } catch (e) { - console.error('SingleKvStoreGetResultSizePromiseQueryTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreGetResultSizePromiseQueryTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -2400,7 +2402,7 @@ describe('SingleKvStoreCallbackTest', function () { expect(null).assertFail(); }) } catch (e) { - console.error('SingleKvStoreGetResultSizeCallbackInvalidArgsTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreGetResultSizeCallbackInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); } done(); @@ -2442,7 +2444,7 @@ describe('SingleKvStoreCallbackTest', function () { } }); } catch (e) { - console.error('SingleKvStoreGetResultSizeCallbackClosedKVStoreTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreGetResultSizeCallbackClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -2484,7 +2486,7 @@ describe('SingleKvStoreCallbackTest', function () { }); console.info('SingleKvStoreGetEntriesCallbackSucTest success'); } catch (e) { - console.error('SingleKvStoreGetEntriesCallbackSucTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreGetEntriesCallbackSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); diff --git a/kv_store/test/unittest/distributedKVStore/SingleKvStoreKVPromiseJsTest.js b/kv_store/test/unittest/distributedKVStore/SingleKvStoreKVPromiseJsTest.js index 2662d750abbcebfd26808369631390f7bda5355a..dcd1f01c01a091a3628d942b97ae444bdb4d7d7e 100644 --- a/kv_store/test/unittest/distributedKVStore/SingleKvStoreKVPromiseJsTest.js +++ b/kv_store/test/unittest/distributedKVStore/SingleKvStoreKVPromiseJsTest.js @@ -127,11 +127,11 @@ describe('SingleKvStorePromiseTest', function () { console.info('SingleKvStorePutStringPromiseInvalidArgsTest put success'); expect(null).assertFail(); }).catch((error) => { - console.error('SingleKvStorePutStringPromiseInvalidArgsTest put error' + `, error code is ${error.code}, message is ${error.message}`); + console.error('SingleKvStorePutStringPromiseInvalidArgsTest put fail' + `, error code is ${error.code}, message is ${error.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStorePutStringPromiseInvalidArgsTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStorePutStringPromiseInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); } done(); @@ -157,11 +157,11 @@ describe('SingleKvStorePromiseTest', function () { console.info('SingleKvStorePutStringPromiseClosedKVStoreTest put success'); expect(null).assertFail(); }).catch((error) => { - console.error('SingleKvStorePutStringPromiseClosedKVStoreTest put error' + `, error code is ${error.code}, message is ${error.message}`); + console.error('SingleKvStorePutStringPromiseClosedKVStoreTest put fail' + `, error code is ${error.code}, message is ${error.message}`); expect(error.code == 15100005).assertTrue(); }); } catch (e) { - console.error('SingleKvStorePutStringPromiseClosedKVStoreTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStorePutStringPromiseClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -180,11 +180,11 @@ describe('SingleKvStorePromiseTest', function () { console.info('SingleKvStorePutStringPromiseSucTest put success'); expect(data == undefined).assertTrue(); }).catch((error) => { - console.error('SingleKvStorePutStringPromiseSucTest put error' + `, error code is ${error.code}, message is ${error.message}`); + console.error('SingleKvStorePutStringPromiseSucTest put fail' + `, error code is ${error.code}, message is ${error.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStorePutStringPromiseSucTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStorePutStringPromiseSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -234,7 +234,7 @@ describe('SingleKvStorePromiseTest', function () { expect(error.code == 401).assertTrue(); }); } catch (e) { - console.error('SingleKvStoreGetStringPromiseInvalidArgsTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreGetStringPromiseInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -251,7 +251,7 @@ describe('SingleKvStorePromiseTest', function () { await kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then(async (data) => { expect(data == undefined).assertTrue(); }).catch((error) => { - console.error('SingleKvStoreGetStringPromiseClosedKVStoreTest put error' + `, error code is ${error.code}, message is ${error.message}`); + console.error('SingleKvStoreGetStringPromiseClosedKVStoreTest put fail' + `, error code is ${error.code}, message is ${error.message}`); expect(null).assertFail(); }); await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID).then(async () => { @@ -267,7 +267,7 @@ describe('SingleKvStorePromiseTest', function () { expect(err.code == 15100005).assertTrue(); }); } catch (e) { - console.error('SingleKvStoreGetStringPromiseClosedKVStoreTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreGetStringPromiseClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -286,11 +286,11 @@ describe('SingleKvStorePromiseTest', function () { console.info('SingleKvStoreGetStringPromiseNoPutTest get success'); expect(null).assertFail(); }).catch((err) => { - console.error('SingleKvStoreGetStringPromiseNoPutTest get fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStoreGetStringPromiseNoPutTest get fail' + `, error code is ${err.code}, message is ${err.message}`); expect(err.code == 15100004).assertTrue(); }); } catch (e) { - console.error('SingleKvStoreGetStringPromiseNoPutTest get e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreGetStringPromiseNoPutTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -309,11 +309,11 @@ describe('SingleKvStorePromiseTest', function () { console.info('SingleKvStorePutIntPromiseSucTest put success'); expect(data == undefined).assertTrue(); }).catch((err) => { - console.error('SingleKvStorePutIntPromiseSucTest put fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStorePutIntPromiseSucTest put fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStorePutIntPromiseSucTest put e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStorePutIntPromiseSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -336,15 +336,15 @@ describe('SingleKvStorePromiseTest', function () { console.info('SingleKvStorePutIntPromiseMaxTest get success'); expect(intValue == data).assertTrue(); }).catch((err) => { - console.error('SingleKvStorePutIntPromiseMaxTest get fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStorePutIntPromiseMaxTest get fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); }).catch((err) => { - console.error('SingleKvStorePutIntPromiseMaxTest put fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStorePutIntPromiseMaxTest put fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStorePutIntPromiseMaxTest put e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStorePutIntPromiseMaxTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -367,15 +367,15 @@ describe('SingleKvStorePromiseTest', function () { console.info('SingleKvStorePutIntPromiseMinTest get success'); expect(intValue == data).assertTrue(); }).catch((err) => { - console.error('SingleKvStorePutIntPromiseMinTest get fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStorePutIntPromiseMinTest get fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); }).catch((err) => { - console.error('SingleKvStorePutIntPromiseMinTest put fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStorePutIntPromiseMinTest put fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStorePutIntPromiseMinTest put e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStorePutIntPromiseMinTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -397,15 +397,15 @@ describe('SingleKvStorePromiseTest', function () { console.info('SingleKvStoreGetIntPromiseSucTest get success'); expect(VALUE_TEST_INT_ELEMENT == data).assertTrue(); }).catch((err) => { - console.error('SingleKvStoreGetIntPromiseSucTest get fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStoreGetIntPromiseSucTest get fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); }).catch((err) => { - console.error('SingleKvStoreGetIntPromiseSucTest put fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStoreGetIntPromiseSucTest put fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStoreGetIntPromiseSucTest put e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreGetIntPromiseSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -424,11 +424,11 @@ describe('SingleKvStorePromiseTest', function () { console.info('SingleKvStorePutBoolPromiseSucTest put success'); expect(data == undefined).assertTrue(); }).catch((err) => { - console.error('SingleKvStorePutBoolPromiseSucTest put fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStorePutBoolPromiseSucTest put fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStorePutBoolPromiseSucTest put e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStorePutBoolPromiseSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -451,15 +451,15 @@ describe('SingleKvStorePromiseTest', function () { console.info('SingleKvStoreGetBoolPromiseSucTest get success'); expect(boolValue == data).assertTrue(); }).catch((err) => { - console.error('SingleKvStoreGetBoolPromiseSucTest get fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStoreGetBoolPromiseSucTest get fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); }).catch((err) => { - console.error('SingleKvStoreGetBoolPromiseSucTest put fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStoreGetBoolPromiseSucTest put fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStoreGetBoolPromiseSucTest put e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreGetBoolPromiseSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -478,11 +478,11 @@ describe('SingleKvStorePromiseTest', function () { console.info('SingleKvStorePutFloatPromiseSucTest put success'); expect(data == undefined).assertTrue(); }).catch((err) => { - console.error('SingleKvStorePutFloatPromiseSucTest put fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStorePutFloatPromiseSucTest put fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStorePutFloatPromiseSucTest put e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStorePutFloatPromiseSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -505,15 +505,15 @@ describe('SingleKvStorePromiseTest', function () { console.info('SingleKvStoreGetFloatPromiseSucTest get success'); expect(floatValue == data).assertTrue(); }).catch((err) => { - console.error('SingleKvStoreGetFloatPromiseSucTest get fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStoreGetFloatPromiseSucTest get fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); }).catch((err) => { - console.error('SingleKvStoreGetFloatPromiseSucTest put fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStoreGetFloatPromiseSucTest put fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStoreGetFloatPromiseSucTest put e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreGetFloatPromiseSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -536,15 +536,15 @@ describe('SingleKvStorePromiseTest', function () { console.info('SingleKvStoreDeleteStringPromiseSucTest delete success'); expect(data == undefined).assertTrue(); }).catch((err) => { - console.error('SingleKvStoreDeleteStringPromiseSucTest delete fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStoreDeleteStringPromiseSucTest delete fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); }).catch((err) => { - console.error('SingleKvStoreDeleteStringPromiseSucTest put fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStoreDeleteStringPromiseSucTest put fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStoreDeleteStringPromiseSucTest put e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreDeleteStringPromiseSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -590,7 +590,7 @@ describe('SingleKvStorePromiseTest', function () { console.info('SingleKvStoreDeleteStringPromiseSucTest put success'); expect(true).assertTrue(); }).catch((err) => { - console.error('SingleKvStoreDeleteStringPromiseClosedKVStoreTest put fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStoreDeleteStringPromiseClosedKVStoreTest put fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID).then(async () => { @@ -604,11 +604,11 @@ describe('SingleKvStorePromiseTest', function () { console.info('SingleKvStoreDeleteStringPromiseSucTest delete success'); expect(null).assertFail(); }).catch((err) => { - console.error('SingleKvStoreDeleteStringPromiseSucTest delete fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStoreDeleteStringPromiseSucTest delete fail' + `, error code is ${err.code}, message is ${err.message}`); expect(err.code == 15100005).assertTrue(); }); } catch (e) { - console.error('SingleKvStorePutStringPromiseClosedKVStoreTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreDeleteStringPromiseClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -626,23 +626,16 @@ describe('SingleKvStorePromiseTest', function () { let predicates = new dataShare.DataSharePredicates(); let arr = ["name"]; predicates.inKeys(arr); - await kvStore.put("name", "Bob").then(async (data) => { - console.log('SingleKvStoreDeletePredicatesPromiseSucTest put success'); - expect(data == undefined).assertTrue(); - await kvStore.delete(predicates).then((data) => { - console.log('SingleKvStoreDeletePredicatesPromiseSucTest delete success'); - expect(data == undefined).assertTrue(); - }).catch((err) => { - console.error('SingleKvStoreDeletePredicatesPromiseSucTest delete fail ' + `, error code is ${err.code}, message is ${err.message}`); - expect(null).assertFail(); - }); + await kvStore.delete(predicates).then((data) => { + console.error('SingleKvStoreDeletePredicatesPromiseSucTest delete success'); + expect(null).assertFail(); }).catch((err) => { - console.error('SingleKvStoreDeletePredicatesPromiseSucTest put fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStoreDeletePredicatesPromiseSucTest delete fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStoreDeletePredicatesPromiseSucTest put e ' + `, error code is ${e.code}, message is ${e.message}`); - expect(null).assertFail(); + console.log('SingleKvStoreDeletePredicatesPromiseSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); + expect(e.code == 202).assertTrue(); } done(); }) @@ -671,13 +664,15 @@ describe('SingleKvStorePromiseTest', function () { }); }) await kvStore.delete(predicates).then((data) => { + console.error('SingleKvStoreDeletePredicatesPromiseClosedKVStoreTest delete success'); expect(null).assertFail(); }).catch((err) => { - expect(err.code == 15100005).assertTrue(); + console.error('SingleKvStoreDeletePredicatesPromiseClosedKVStoreTest delete fail' + `, error code is ${err.code}, message is ${err.message}`); + expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStoreDeletePredicatesPromiseClosedKVStoreTest e ' + `, error code is ${e.code}, message is ${e.message}`); - expect(null).assertFail(); + console.log('SingleKvStoreDeletePredicatesPromiseClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); + expect(e.code == 202).assertTrue(); } done(); }) @@ -725,11 +720,11 @@ describe('SingleKvStorePromiseTest', function () { console.info('SingleKvStoreSetSyncRangePromiseDisjointTest setSyncRange success'); expect(err == undefined).assertTrue(); }).catch((err) => { - console.error('SingleKvStoreSetSyncRangePromiseDisjointTest delete fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStoreSetSyncRangePromiseDisjointTest setSyncRange fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStoreSetSyncRangePromiseDisjointTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreSetSyncRangePromiseDisjointTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -750,11 +745,11 @@ describe('SingleKvStorePromiseTest', function () { console.info('SingleKvStoreSetSyncRangePromiseJointTest setSyncRange success'); expect(err == undefined).assertTrue(); }).catch((err) => { - console.error('SingleKvStoreSetSyncRangePromiseJointTest delete fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStoreSetSyncRangePromiseJointTest setSyncRange fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStoreSetSyncRangePromiseJointTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreSetSyncRangePromiseJointTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -775,11 +770,11 @@ describe('SingleKvStorePromiseTest', function () { console.info('SingleKvStoreSetSyncRangePromiseSameTest setSyncRange success'); expect(err == undefined).assertTrue(); }).catch((err) => { - console.error('SingleKvStoreSetSyncRangePromiseSameTest delete fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStoreSetSyncRangePromiseSameTest setSyncRange fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStoreSetSyncRangePromiseSameTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreSetSyncRangePromiseSameTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -801,7 +796,7 @@ describe('SingleKvStorePromiseTest', function () { expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStoreSetSyncRangePromiseSameTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreSetSyncRangePromiseSameTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); } done(); @@ -827,15 +822,15 @@ describe('SingleKvStorePromiseTest', function () { expect(entrys.length == 10).assertTrue(); expect(entrys[0].value.value == 'batch_test_string_value').assertTrue(); }).catch((err) => { - console.error('SingleKvStorePutBatchPromiseStringTest getEntries fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStorePutBatchPromiseStringTest getEntries fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); }).catch((err) => { - console.error('SingleKvStorePutBatchPromiseStringTest putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStorePutBatchPromiseStringTest putBatch fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStorePutBatchPromiseStringTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStorePutBatchPromiseStringTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -871,15 +866,15 @@ describe('SingleKvStorePromiseTest', function () { expect(entrys.length == 10).assertTrue(); expect(entrys[0].value.value == 222).assertTrue(); }).catch((err) => { - console.error('SingleKvStorePutBatchPromiseIntegerTest getEntries fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStorePutBatchPromiseIntegerTest getEntries fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); }).catch((err) => { - console.error('SingleKvStorePutBatchPromiseIntegerTest putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStorePutBatchPromiseIntegerTest putBatch fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStorePutBatchPromiseIntegerTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStorePutBatchPromiseIntegerTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -915,15 +910,15 @@ describe('SingleKvStorePromiseTest', function () { expect(entrys.length == 10).assertTrue(); expect(entrys[0].value.value == 2.0).assertTrue(); }).catch((err) => { - console.error('SingleKvStorePutBatchPromiseFloatTest getEntries fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStorePutBatchPromiseFloatTest getEntries fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); }).catch((err) => { - console.error('SingleKvStorePutBatchPromiseFloatTest putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStorePutBatchPromiseFloatTest putBatch fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStorePutBatchPromiseFloatTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStorePutBatchPromiseFloatTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -959,15 +954,15 @@ describe('SingleKvStorePromiseTest', function () { expect(entrys.length == 10).assertTrue(); expect(entrys[0].value.value == 2.00).assertTrue(); }).catch((err) => { - console.error('SingleKvStorePutBatchPromiseDoubleTest getEntries fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStorePutBatchPromiseDoubleTest getEntries fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); }).catch((err) => { - console.error('SingleKvStorePutBatchPromiseDoubleTest putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStorePutBatchPromiseDoubleTest putBatch fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStorePutBatchPromiseDoubleTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStorePutBatchPromiseDoubleTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -1004,15 +999,15 @@ describe('SingleKvStorePromiseTest', function () { expect(entrys.length == 10).assertTrue(); expect(entrys[0].value.value == bo).assertTrue(); }).catch((err) => { - console.error('SingleKvStorePutBatchPromiseBooleanTest getEntries fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStorePutBatchPromiseBooleanTest getEntries fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); }).catch((err) => { - console.error('SingleKvStorePutBatchPromiseBooleanTest putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStorePutBatchPromiseBooleanTest putBatch fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStorePutBatchPromiseBooleanTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStorePutBatchPromiseBooleanTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -1049,15 +1044,15 @@ describe('SingleKvStorePromiseTest', function () { expect(entrys.length == 10).assertTrue(); expect(entrys[0].value.value.toString() == arr.toString()).assertTrue(); }).catch((err) => { - console.error('SingleKvStorePutBatchPromiseByteArrayTest getEntries fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStorePutBatchPromiseByteArrayTest getEntries fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); }).catch((err) => { - console.error('SingleKvStorePutBatchPromiseByteArrayTest putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStorePutBatchPromiseByteArrayTest putBatch fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStorePutBatchPromiseBooleanTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStorePutBatchPromiseByteArrayTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -1081,20 +1076,17 @@ describe('SingleKvStorePromiseTest', function () { values.push(vb2); console.info('SingleKvStorePutBatchValuePromiseUint8ArrayTest values: ' + JSON.stringify(values)); await kvStore.putBatch(values).then(async (err) => { - console.info('SingleKvStorePutBatchValuePromiseUint8ArrayTest putBatch success'); - expect(err == undefined).assertTrue(); - var query = new factory.Query(); - query.prefixKey("name_"); - await kvStore.getEntries(query).then((entrys) => { - expect(entrys.length == 2).assertTrue(); - done(); - }); + console.error('SingleKvStorePutBatchValuePromiseUint8ArrayTest putBatch success'); + expect(null).assertFail(); + }).catch((err) => { + console.error('SingleKvStorePutBatchValuePromiseUint8ArrayTest putBatch fail' + `, error code is ${err.code}, message is ${err.message}`); + expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStorePutBatchValuePromiseUint8ArrayTest e ' + `, error code is ${e.code}, message is ${e.message}`); - expect(null).assertFail(); - done(); + console.info('SingleKvStorePutBatchValuePromiseUint8ArrayTest fail' + `, error code is ${e.code}, message is ${e.message}`); + expect(e.code == 202).assertTrue(); } + done(); }) /** @@ -1113,24 +1105,15 @@ describe('SingleKvStorePromiseTest', function () { values.push(vb2); console.info('SingleKvStorePutBatchValuePromiseStringTest values: ' + JSON.stringify(values)); await kvStore.putBatch(values).then(async (err) => { - console.info('SingleKvStorePutBatchValuePromiseUint8ArrayTest putBatch success'); - expect(err == undefined).assertTrue(); - var query = new factory.Query(); - query.prefixKey("name_"); - await kvStore.getEntries(query).then((entrys) => { - expect(entrys.length == 2).assertTrue(); - done(); - }).catch((err) => { - console.log('SingleKvStorePutBatchValueTest delete fail ' + err); - expect(null).assertFail(); - }); + console.error('SingleKvStorePutBatchValuePromiseStringTest putBatch success'); + expect(null).assertFail(); }).catch((err) => { - console.log('SingleKvStorePutBatchValueTest delete fail ' + err); + console.error('SingleKvStorePutBatchValuePromiseStringTest putBatch fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStorePutBatchValuePromiseStringTest e ' + `, error code is ${e.code}, message is ${e.message}`); - expect(null).assertFail(); + console.info('SingleKvStorePutBatchValuePromiseStringTest fail' + `, error code is ${e.code}, message is ${e.message}`); + expect(e.code == 202).assertTrue(); } done(); }) @@ -1151,19 +1134,17 @@ describe('SingleKvStorePromiseTest', function () { values.push(vb2); values.push(vb3); await kvStore.putBatch(values).then(async (err) => { - expect(err == undefined).assertTrue(); - var query = new factory.Query(); - query.prefixKey("name_"); - await kvStore.getEntries(query).then((entrys) => { - expect(entrys.length == 3).assertTrue(); - done(); - }); + console.info('SingleKvStorePutBatchValuePromiseNumbersTest putBatch success'); + expect(null).assertFail(); + }).catch((err) => { + console.error('SingleKvStorePutBatchValuePromiseNumbersTest putBatch fail' + `, error code is ${err.code}, message is ${err.message}`); + expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStorePutBatchValuePromiseTest e ' + `, error code is ${e.code}, message is ${e.message}`); - expect(null).assertFail(); - done(); + console.error('SingleKvStorePutBatchValuePromiseNumbersTest fail' + `, error code is ${e.code}, message is ${e.message}`); + expect(e.code == 202).assertTrue(); } + done(); }) /** @@ -1180,17 +1161,15 @@ describe('SingleKvStorePromiseTest', function () { values.push(vb1); values.push(vb2); await kvStore.putBatch(values).then(async (err) => { - expect(err == undefined).assertTrue(); - var query = new factory.Query(); - query.prefixKey("name_"); - await kvStore.getEntries(query).then((entrys) => { - expect(entrys.length == 2).assertTrue(); - done(); - }); + console.error('SingleKvStorePutBatchValuePromiseBooleanTest putBatch success'); + expect(null).assertFail(); + }).catch((err) => { + console.error('SingleKvStorePutBatchValuePromiseBooleanTest putBatch fail' + `, error code is ${err.code}, message is ${err.message}`); + expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStorePutBatchValuePromiseTest e ' + `, error code is ${e.code}, message is ${e.message}`); - expect(null).assertFail(); + console.info('SingleKvStorePutBatchValuePromiseBooleanTest fail' + `, error code is ${e.code}, message is ${e.message}`); + expect(e.code == 202).assertTrue(); done(); } }) @@ -1211,19 +1190,15 @@ describe('SingleKvStorePromiseTest', function () { values.push(vb2); console.info('SingleKvStorePutBatchValuePromiseNullTest values: ' + JSON.stringify(values)); await kvStore.putBatch(values).then(async (err) => { - console.info('SingleKvStorePutBatchValuePromiseNullTest putBatch success'); - expect(err == undefined).assertTrue(); - var query = new factory.Query(); - query.prefixKey("name_"); - await kvStore.getEntries(query).then((entrys) => { - expect(entrys.length == 2).assertTrue(); - expect(entrys[0].value == null).assertTrue(); - done(); - }); + console.error('SingleKvStorePutBatchValuePromiseNullTest putBatch success'); + expect(null).assertFail(); + }).catch((err) => { + console.error('SingleKvStorePutBatchValuePromiseNullTest putBatch fail' + `, error code is ${err.code}, message is ${err.message}`); + expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStorePutBatchValuePromiseNullTest e ' + `, error code is ${e.code}, message is ${e.message}`); - expect(null).assertFail(); + console.info('SingleKvStorePutBatchValuePromiseNullTest fail' + `, error code is ${e.code}, message is ${e.message}`); + expect(e.code == 202).assertTrue(); done(); } }) @@ -1242,7 +1217,7 @@ describe('SingleKvStorePromiseTest', function () { expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStorePutBatchValuePromiseNullTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStorePutBatchValuePromiseInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); } done(); @@ -1269,13 +1244,15 @@ describe('SingleKvStorePromiseTest', function () { values.push(vb1); values.push(vb2); await kvStore.putBatch(values).then(() => { + console.error('SingleKvStorePutBatchValuePromiseClosedKvstoreTest putBatch success'); expect(null).assertFail(); }).catch((err) => { - expect(err.code == 15100005).assertTrue(); + console.error('SingleKvStorePutBatchValuePromiseClosedKvstoreTest putBatch fail' + `, error code is ${err.code}, message is ${err.message}`); + expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStorePutBatchValuePromiseNullTest e ' + `, error code is ${e.code}, message is ${e.message}`); - expect(null).assertFail(); + console.info('SingleKvStorePutBatchValuePromiseClosedKvstoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); + expect(e.code == 202).assertTrue(); } done(); }) @@ -1314,7 +1291,7 @@ describe('SingleKvStorePromiseTest', function () { expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStoreDeleteBatchPromiseSucTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreDeleteBatchPromiseSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -1357,7 +1334,7 @@ describe('SingleKvStorePromiseTest', function () { expect(err.code == 401).assertTrue(); }); } catch (e) { - console.error('SingleKvStoreDeleteBatchPromiseInvalidArgsTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreDeleteBatchPromiseInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -1405,7 +1382,7 @@ describe('SingleKvStorePromiseTest', function () { expect(err.code == 15100005).assertTrue(); }); } catch (e) { - console.error('SingleKvStoreDeleteBatchPromiseClosedKVStoreTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreDeleteBatchPromiseClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -1451,7 +1428,7 @@ describe('SingleKvStorePromiseTest', function () { expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStoreGetEntriesPromiseQueryTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreGetEntriesPromiseQueryTest fail' + `, error code is ${e.code}, message is ${e.message}`); console.log("errr3") expect(null).assertFail(); } @@ -1499,7 +1476,7 @@ describe('SingleKvStorePromiseTest', function () { expect(err.code == 15100005).assertTrue(); }); } catch (e) { - console.error('SingleKvStoreGetEntriesPromiseQueryClosedKVStoreTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreGetEntriesPromiseQueryClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -1541,7 +1518,7 @@ describe('SingleKvStorePromiseTest', function () { expect(error == undefined).assertTrue(); }); } catch (e) { - console.error('SingleKvStoreGetEntriesPromiseSucTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreGetEntriesPromiseSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -1586,7 +1563,7 @@ describe('SingleKvStorePromiseTest', function () { expect(err.code == 15100005).assertTrue(); }); } catch (e) { - console.error('SingleKvStoreGetEntriesPromiseSucTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreGetEntriesPromiseSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -1625,7 +1602,7 @@ describe('SingleKvStorePromiseTest', function () { expect(err.code == 401).assertTrue(); }); } catch (e) { - console.error('SingleKvStoreGetEntriesPromiseInvalidArgsTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreGetEntriesPromiseInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -1933,11 +1910,11 @@ describe('SingleKvStorePromiseTest', function () { console.info('SingleKvStoreRemoveDeviceDataPromiseInvalidArgsTest removeDeviceData success'); expect(null).assertFail(); }).catch((err) => { - console.error('SingleKvStoreRemoveDeviceDataPromiseInvalidArgsTest removeDeviceData fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStoreRemoveDeviceDataPromiseInvalidArgsTest removeDeviceData fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStoreRemoveDeviceDataPromiseInvalidArgsTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreRemoveDeviceDataPromiseInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); } done(); @@ -1966,13 +1943,15 @@ describe('SingleKvStorePromiseTest', function () { }) var deviceid = 'no_exist_device_id'; await kvStore.removeDeviceData(deviceid).then(() => { + console.error('SingleKvStoreRemoveDeviceDataPromiseClosedKVStoreTest removeDeviceData success'); expect(null).assertFail(); }).catch((err) => { + console.info('SingleKvStoreRemoveDeviceDataPromiseClosedKVStoreTest removeDeviceData fail' + `, error code is ${err.code}, message is ${err.message}`); expect(err.code == 15100005).assertTrue(); }); } catch (e) { - console.error('SingleKvStoreRemoveDeviceDataPromiseClosedKVStoreTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreRemoveDeviceDataPromiseClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -2013,7 +1992,7 @@ describe('SingleKvStorePromiseTest', function () { expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStoreSetSyncParamPromiseInvalidArgsTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreSetSyncParamPromiseInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); } done(); @@ -2058,11 +2037,11 @@ describe('SingleKvStorePromiseTest', function () { await kvStore.getSecurityLevel().then((data) => { expect(null).assertFail(); }).catch((err) => { - console.error('SingleKvStoreGetSecurityLevelPromiseSucTest getSecurityLevel fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStoreGetSecurityLevelPromiseSucTest getSecurityLevel fail' + `, error code is ${err.code}, message is ${err.message}`); expect(err.code == 15100005).assertTrue(); }); } catch (e) { - console.error('SingleKvStoreGetSecurityLevelPromiseSucTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreGetSecurityLevelPromiseSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -2107,7 +2086,7 @@ describe('SingleKvStorePromiseTest', function () { expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStoreGetResultSetPromiseSucTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreGetResultSetPromiseSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -2127,11 +2106,11 @@ describe('SingleKvStorePromiseTest', function () { console.info('SingleKvStoreGetResultSetPromiseInvalidArgsTest getResultSet success'); expect(null).assertFail(); }).catch((err) => { - console.error('SingleKvStoreGetResultSetPromiseInvalidArgsTest getResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStoreGetResultSetPromiseInvalidArgsTest getResultSet fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStoreGetResultSetPromiseInvalidArgsTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreGetResultSetPromiseInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); } done(); @@ -2162,11 +2141,11 @@ describe('SingleKvStorePromiseTest', function () { await kvStore.getResultSet('batch_test_string_key').then((result) => { expect(null).assertFail(); }).catch((err) => { - console.error('SingleKvStoreGetResultSetPromiseClosedKVStoreTest getResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStoreGetResultSetPromiseClosedKVStoreTest getResultSet fail' + `, error code is ${err.code}, message is ${err.message}`); expect(err.code == 15100005).assertTrue(); }); } catch (e) { - console.error('SingleKvStoreGetResultSetPromiseClosedKVStoreTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreGetResultSetPromiseClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -2198,7 +2177,7 @@ describe('SingleKvStorePromiseTest', function () { console.info('SingleKvStoreGetResultSetPromiseQueryTest putBatch success'); expect(err == undefined).assertTrue(); }).catch((err) => { - console.error('SingleKvStorePutBatchPromiseStringTest putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStorePutBatchPromiseStringTest putBatch fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); var query = new factory.Query(); @@ -2208,18 +2187,18 @@ describe('SingleKvStorePromiseTest', function () { resultSet = result; expect(resultSet.getCount() == 10).assertTrue(); }).catch((err) => { - console.error('SingleKvStoreGetResultSetPromiseQueryTest getResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStoreGetResultSetPromiseQueryTest getResultSet fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); await kvStore.closeResultSet(resultSet).then((err) => { console.info('SingleKvStoreGetResultSetPromiseQueryTest closeResultSet success'); expect(err == undefined).assertTrue(); }).catch((err) => { - console.error('SingleKvStoreGetResultSetPromiseQueryTest closeResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStoreGetResultSetPromiseQueryTest closeResultSet fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStoreGetResultSetPromiseQueryTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreGetResultSetPromiseQueryTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -2266,20 +2245,20 @@ describe('SingleKvStorePromiseTest', function () { expect(err.code == 15100005).assertTrue(); }); } catch (e) { - console.error('SingleKvStoreGetResultSetQueryPromiseClosedKVStoreTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreGetResultSetQueryPromiseClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); }) /** - * @tc.name SingleKvStoreGetResultSetPredicatesPromiseSucTest - * @tc.desc Test Js Api SingleKvStore.GetResultSet() with predicates success + * @tc.name SingleKvStoreGetResultSetPredicatesPromiseTest + * @tc.desc Test Js Api SingleKvStore.GetResultSet() with predicates * @tc.type: FUNC * @tc.require: issueNumber */ - it('SingleKvStoreGetResultSetPredicatesPromiseSucTest', 0, async function (done) { - console.log('SingleKvStoreGetResultSetPredicatesPromiseSucTest'); + it('SingleKvStoreGetResultSetPredicatesPromiseTest', 0, async function (done) { + console.log('SingleKvStoreGetResultSetPredicatesPromiseTest'); try { let entries = []; let resultSet; @@ -2303,18 +2282,15 @@ describe('SingleKvStorePromiseTest', function () { let predicates = new dataShare.DataSharePredicates(); predicates.prefixKey("name_"); await kvStore.getResultSet(predicates).then((result) => { - resultSet = result; - expect(resultSet.getCount() == 10).assertTrue(); - }).catch((err) => { + console.error('SingleKvStoreGetResultSetPredicatesPromiseTest getResultSet success'); expect(null).assertFail(); - }); - await kvStore.closeResultSet(resultSet).then((err) => { - expect(err == undefined).assertTrue(); }).catch((err) => { + console.error('SingleKvStoreGetResultSetPredicatesPromiseTest getResultSet fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - expect(null).assertFail(); + console.info('SingleKvStoreGetResultSetPredicatesPromiseTest fail' + `, error code is ${e.code}, message is ${e.message}`); + expect(e.code == 202).assertTrue(); } done(); }) @@ -2349,19 +2325,21 @@ describe('SingleKvStorePromiseTest', function () { await kvManager.deleteKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID).then(() => { expect(true).assertTrue(); }).catch((err) => { - console.error('deleteKVStore err ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStoreGetResultSetPredicatesPromiseClosedKVStoreTest deleteKVStore fail' + `, error code is ${err.code}, message is ${err.message}`); }); }); let predicates = new dataShare.DataSharePredicates(); predicates.prefixKey("batch_test"); await kvStore.getResultSet(predicates).then((result) => { + console.error('SingleKvStoreGetResultSetPredicatesPromiseClosedKVStoreTest getResultSet success'); expect(null).assertFail(); }).catch((err) => { - expect(err.code == 15100005).assertTrue(); + console.error('SingleKvStoreGetResultSetPredicatesPromiseClosedKVStoreTest getResultSet fail' + `, error code is ${err.code}, message is ${err.message}`); + expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStoreGetResultSetPredicatesPromiseClosedKVStoreTest e ' + `, error code is ${e.code}, message is ${e.message}`); - expect(null).assertFail(); + console.info('SingleKvStoreGetResultSetPredicatesPromiseClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); + expect(e.code == 202).assertTrue(); } done(); }) @@ -2381,18 +2359,18 @@ describe('SingleKvStorePromiseTest', function () { console.info('SingleKvStoreCloseResultSetPromiseSucTest getResultSet success'); resultSet = result; }).catch((err) => { - console.error('SingleKvStoreCloseResultSetPromiseSucTest getResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStoreCloseResultSetPromiseSucTest getResultSet fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); await kvStore.closeResultSet(resultSet).then((err) => { console.info('SingleKvStoreCloseResultSetPromiseSucTest closeResultSet success'); expect(err == undefined).assertTrue(); }).catch((err) => { - console.error('SingleKvStoreCloseResultSetPromiseSucTest closeResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStoreCloseResultSetPromiseSucTest closeResultSet fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStoreCloseResultSetPromiseSucTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreCloseResultSetPromiseSucTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -2409,10 +2387,10 @@ describe('SingleKvStorePromiseTest', function () { await kvStore.closeResultSet().then(() => { expect(null).assertFail(); }).catch((err) => { - console.error('SingleKvStoreCloseResultSetPromiseInvalidArgsTest closeResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStoreCloseResultSetPromiseInvalidArgsTest closeResultSet fail' + `, error code is ${err.code}, message is ${err.message}`); }); } catch (e) { - console.error('SingleKvStoreCloseResultSetPromiseInvalidArgsTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreCloseResultSetPromiseInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); } done(); @@ -2442,7 +2420,7 @@ describe('SingleKvStorePromiseTest', function () { console.info('SingleKvStoreGetResultSizePromiseQueryTest putBatch success'); expect(err == undefined).assertTrue(); }).catch((err) => { - console.error('SingleKvStorePutBatchPromiseStringTest putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStoreGetResultSizePromiseQueryTest putBatch fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); var query = new factory.Query(); @@ -2451,11 +2429,11 @@ describe('SingleKvStorePromiseTest', function () { console.info('SingleKvStoreGetResultSizePromiseQueryTest getResultSet success'); expect(resultSize == 10).assertTrue(); }).catch((err) => { - console.error('SingleKvStoreGetResultSizePromiseQueryTest getResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStoreGetResultSizePromiseQueryTest getResultSet fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStoreGetResultSizePromiseQueryTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreGetResultSizePromiseQueryTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -2492,7 +2470,7 @@ describe('SingleKvStorePromiseTest', function () { expect(null).assertFail(); }); } catch (e) { - console.error('SingleKvStoreGetResultSizePromiseInvalidArgsTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreGetResultSizePromiseInvalidArgsTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(e.code == 401).assertTrue(); } done(); @@ -2527,7 +2505,7 @@ describe('SingleKvStorePromiseTest', function () { await kvManager.deleteKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID).then(() => { expect(true).assertTrue(); }).catch((err) => { - console.error('deleteKVStore err ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStoreGetResultSizePromiseClosedKVStoreTest deleteKVStore fail' + `, error code is ${err.code}, message is ${err.message}`); }); }); var query = new factory.Query(); @@ -2536,11 +2514,11 @@ describe('SingleKvStorePromiseTest', function () { console.info('SingleKvStoreGetResultSizePromiseClosedKVStoreTest getResultSet success'); expect(null).assertFail(); }).catch((err) => { - console.error('SingleKvStoreGetResultSizePromiseClosedKVStoreTest getResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`); + console.error('SingleKvStoreGetResultSizePromiseClosedKVStoreTest getResultSet fail' + `, error code is ${err.code}, message is ${err.message}`); expect(err.code == 15100005).assertTrue(); }); } catch (e) { - console.error('SingleKvStoreGetResultSizePromiseQueryTest e ' + `, error code is ${e.code}, message is ${e.message}`); + console.error('SingleKvStoreGetResultSizePromiseClosedKVStoreTest fail' + `, error code is ${e.code}, message is ${e.message}`); expect(null).assertFail(); } done(); @@ -2565,7 +2543,7 @@ describe('SingleKvStorePromiseTest', function () { console.info('SingleKvStoreChangeNotificationPromiseTest getInsertEntries' + JSON.stringify(insertEntries)); expect(insertEntries != null).assertTrue(); }).catch((error) => { - console.error('SingleKvStoreChangeNotificationPromiseTest can NOT getInsertEntries, fail:' + `, error code is ${error.code}, message is ${error.message}`); + console.error('SingleKvStoreChangeNotificationPromiseTest getInsertEntries fail' + `, error code is ${error.code}, message is ${error.message}`); expect(null).assertFail(); }); done(); @@ -2593,7 +2571,7 @@ describe('SingleKvStorePromiseTest', function () { console.info('SingleKvStoreChangeNotificationPromisePutTest getUpdateEntries' + JSON.stringify(updateEntries)); expect(updateEntries != null).assertTrue(); }).catch((error) => { - console.error('SingleKvStoreChangeNotificationPromisePutTest can NOT getUpdateEntries, fail:' + `, error code is ${error.code}, message is ${error.message}`); + console.error('SingleKvStoreChangeNotificationPromisePutTest getUpdateEntries fail' + `, error code is ${error.code}, message is ${error.message}`); expect(null).assertFail(); }); done(); @@ -2618,10 +2596,10 @@ describe('SingleKvStorePromiseTest', function () { }); }); await getdeleteEntries.then(function (deleteEntries) { - console.info('SingleKvStoreChangeNotificationPromiseDeleteTest deleteEntries' + JSON.stringify(getdeleteEntries)); + console.info('SingleKvStoreChangeNotificationPromiseDeleteTest getdeleteEntries' + JSON.stringify(getdeleteEntries)); expect(deleteEntries != null).assertTrue(); }).catch((error) => { - console.error('SingleKvStoreChangeNotificationPromiseDeleteTest can NOT getdeleteEntries, fail:' + `, error code is ${error.code}, message is ${error.message}`); + console.error('SingleKvStoreChangeNotificationPromiseDeleteTest getdeleteEntries fail' + `, error code is ${error.code}, message is ${error.message}`); expect(null).assertFail(); }); done(); diff --git a/mock/nlohmann/adl_serializer.hpp b/mock/nlohmann/adl_serializer.hpp index eeaa142574096d686d3906ecc8dbee38d01efb0b..4af1c4bb1d0dea57b26d9326c4850c6ecf48a5fc 100644 --- a/mock/nlohmann/adl_serializer.hpp +++ b/mock/nlohmann/adl_serializer.hpp @@ -37,7 +37,7 @@ struct adl_serializer @param[in,out] j JSON value to write to @param[in] val value to read from */ - template + template static auto to_json(BasicJsonType& j, ValueType&& val) noexcept( noexcept(::nlohmann::to_json(j, std::forward(val)))) -> decltype(::nlohmann::to_json(j, std::forward(val)), void()) diff --git a/mock/nlohmann/byte_container_with_subtype.hpp b/mock/nlohmann/byte_container_with_subtype.hpp new file mode 100644 index 0000000000000000000000000000000000000000..69f9feb21276724c5951d97139c25addf1fc8236 --- /dev/null +++ b/mock/nlohmann/byte_container_with_subtype.hpp @@ -0,0 +1,166 @@ +#pragma once + +#include // uint8_t +#include // tie +#include // move + +namespace nlohmann +{ + +/*! +@brief an internal type for a backed binary type + +This type extends the template parameter @a BinaryType provided to `basic_json` +with a subtype used by BSON and MessagePack. This type exists so that the user +does not have to specify a type themselves with a specific naming scheme in +order to override the binary type. + +@tparam BinaryType container to store bytes (`std::vector` by + default) + +@since version 3.8.0 +*/ +template +class byte_container_with_subtype : public BinaryType +{ + public: + /// the type of the underlying container + using container_type = BinaryType; + + byte_container_with_subtype() noexcept(noexcept(container_type())) + : container_type() + {} + + byte_container_with_subtype(const container_type& b) noexcept(noexcept(container_type(b))) + : container_type(b) + {} + + byte_container_with_subtype(container_type&& b) noexcept(noexcept(container_type(std::move(b)))) + : container_type(std::move(b)) + {} + + byte_container_with_subtype(const container_type& b, std::uint8_t subtype) noexcept(noexcept(container_type(b))) + : container_type(b) + , m_subtype(subtype) + , m_has_subtype(true) + {} + + byte_container_with_subtype(container_type&& b, std::uint8_t subtype) noexcept(noexcept(container_type(std::move(b)))) + : container_type(std::move(b)) + , m_subtype(subtype) + , m_has_subtype(true) + {} + + bool operator==(const byte_container_with_subtype& rhs) const + { + return std::tie(static_cast(*this), m_subtype, m_has_subtype) == + std::tie(static_cast(rhs), rhs.m_subtype, rhs.m_has_subtype); + } + + bool operator!=(const byte_container_with_subtype& rhs) const + { + return !(rhs == *this); + } + + /*! + @brief sets the binary subtype + + Sets the binary subtype of the value, also flags a binary JSON value as + having a subtype, which has implications for serialization. + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this member function never throws + exceptions. + + @sa @ref subtype() -- return the binary subtype + @sa @ref clear_subtype() -- clears the binary subtype + @sa @ref has_subtype() -- returns whether or not the binary value has a + subtype + + @since version 3.8.0 + */ + void set_subtype(std::uint8_t subtype) noexcept + { + m_subtype = subtype; + m_has_subtype = true; + } + + /*! + @brief return the binary subtype + + Returns the numerical subtype of the value if it has a subtype. If it does + not have a subtype, this function will return size_t(-1) as a sentinel + value. + + @return the numerical subtype of the binary value + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this member function never throws + exceptions. + + @sa @ref set_subtype() -- sets the binary subtype + @sa @ref clear_subtype() -- clears the binary subtype + @sa @ref has_subtype() -- returns whether or not the binary value has a + subtype + + @since version 3.8.0 + */ + constexpr std::uint8_t subtype() const noexcept + { + return m_subtype; + } + + /*! + @brief return whether the value has a subtype + + @return whether the value has a subtype + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this member function never throws + exceptions. + + @sa @ref subtype() -- return the binary subtype + @sa @ref set_subtype() -- sets the binary subtype + @sa @ref clear_subtype() -- clears the binary subtype + + @since version 3.8.0 + */ + constexpr bool has_subtype() const noexcept + { + return m_has_subtype; + } + + /*! + @brief clears the binary subtype + + Clears the binary subtype and flags the value as not having a subtype, which + has implications for serialization; for instance MessagePack will prefer the + bin family over the ext family. + + @complexity Constant. + + @exceptionsafety No-throw guarantee: this member function never throws + exceptions. + + @sa @ref subtype() -- return the binary subtype + @sa @ref set_subtype() -- sets the binary subtype + @sa @ref has_subtype() -- returns whether or not the binary value has a + subtype + + @since version 3.8.0 + */ + void clear_subtype() noexcept + { + m_subtype = 0; + m_has_subtype = false; + } + + private: + std::uint8_t m_subtype = 0; + bool m_has_subtype = false; +}; + +} // namespace nlohmann diff --git a/mock/nlohmann/detail/conversions/from_json.hpp b/mock/nlohmann/detail/conversions/from_json.hpp index c389dca7ad37a4b288dd82de66756b95e1391d16..438b84a2e1f1f72312cf08118f751094e6793ef6 100644 --- a/mock/nlohmann/detail/conversions/from_json.hpp +++ b/mock/nlohmann/detail/conversions/from_json.hpp @@ -2,7 +2,6 @@ #include // transform #include // array -#include // and, not #include // forward_list #include // inserter, front_inserter, end #include // map @@ -26,7 +25,7 @@ namespace detail template void from_json(const BasicJsonType& j, typename std::nullptr_t& n) { - if (JSON_HEDLEY_UNLIKELY(not j.is_null())) + if (JSON_HEDLEY_UNLIKELY(!j.is_null())) { JSON_THROW(type_error::create(302, "type must be null, but is " + std::string(j.type_name()))); } @@ -34,10 +33,10 @@ void from_json(const BasicJsonType& j, typename std::nullptr_t& n) } // overloads for basic_json template parameters -template::value and - not std::is_same::value, - int> = 0> +template < typename BasicJsonType, typename ArithmeticType, + enable_if_t < std::is_arithmetic::value&& + !std::is_same::value, + int > = 0 > void get_arithmetic_value(const BasicJsonType& j, ArithmeticType& val) { switch (static_cast(j)) @@ -66,7 +65,7 @@ void get_arithmetic_value(const BasicJsonType& j, ArithmeticType& val) template void from_json(const BasicJsonType& j, typename BasicJsonType::boolean_t& b) { - if (JSON_HEDLEY_UNLIKELY(not j.is_boolean())) + if (JSON_HEDLEY_UNLIKELY(!j.is_boolean())) { JSON_THROW(type_error::create(302, "type must be boolean, but is " + std::string(j.type_name()))); } @@ -76,7 +75,7 @@ void from_json(const BasicJsonType& j, typename BasicJsonType::boolean_t& b) template void from_json(const BasicJsonType& j, typename BasicJsonType::string_t& s) { - if (JSON_HEDLEY_UNLIKELY(not j.is_string())) + if (JSON_HEDLEY_UNLIKELY(!j.is_string())) { JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()))); } @@ -86,13 +85,13 @@ void from_json(const BasicJsonType& j, typename BasicJsonType::string_t& s) template < typename BasicJsonType, typename ConstructibleStringType, enable_if_t < - is_constructible_string_type::value and - not std::is_same::value, + is_constructible_string_type::value&& + !std::is_same::value, int > = 0 > void from_json(const BasicJsonType& j, ConstructibleStringType& s) { - if (JSON_HEDLEY_UNLIKELY(not j.is_string())) + if (JSON_HEDLEY_UNLIKELY(!j.is_string())) { JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()))); } @@ -129,10 +128,10 @@ void from_json(const BasicJsonType& j, EnumType& e) // forward_list doesn't have an insert method template::value, int> = 0> + enable_if_t::value, int> = 0> void from_json(const BasicJsonType& j, std::forward_list& l) { - if (JSON_HEDLEY_UNLIKELY(not j.is_array())) + if (JSON_HEDLEY_UNLIKELY(!j.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); } @@ -146,18 +145,22 @@ void from_json(const BasicJsonType& j, std::forward_list& l) // valarray doesn't have an insert method template::value, int> = 0> + enable_if_t::value, int> = 0> void from_json(const BasicJsonType& j, std::valarray& l) { - if (JSON_HEDLEY_UNLIKELY(not j.is_array())) + if (JSON_HEDLEY_UNLIKELY(!j.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); } l.resize(j.size()); - std::copy(j.begin(), j.end(), std::begin(l)); + std::transform(j.begin(), j.end(), std::begin(l), + [](const BasicJsonType & elem) + { + return elem.template get(); + }); } -template +template auto from_json(const BasicJsonType& j, T (&arr)[N]) -> decltype(j.template get(), void()) { @@ -173,7 +176,7 @@ void from_json_array_impl(const BasicJsonType& j, typename BasicJsonType::array_ arr = *j.template get_ptr(); } -template +template auto from_json_array_impl(const BasicJsonType& j, std::array& arr, priority_tag<2> /*unused*/) -> decltype(j.template get(), void()) @@ -205,7 +208,7 @@ auto from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, p arr = std::move(ret); } -template +template void from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, priority_tag<0> /*unused*/) { @@ -223,20 +226,20 @@ void from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, arr = std::move(ret); } -template ::value and - not is_constructible_object_type::value and - not is_constructible_string_type::value and - not is_basic_json::value, - int > = 0 > - +template < typename BasicJsonType, typename ConstructibleArrayType, + enable_if_t < + is_constructible_array_type::value&& + !is_constructible_object_type::value&& + !is_constructible_string_type::value&& + !std::is_same::value&& + !is_basic_json::value, + int > = 0 > auto from_json(const BasicJsonType& j, ConstructibleArrayType& arr) -> decltype(from_json_array_impl(j, arr, priority_tag<3> {}), j.template get(), void()) { - if (JSON_HEDLEY_UNLIKELY(not j.is_array())) + if (JSON_HEDLEY_UNLIKELY(!j.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); @@ -245,11 +248,22 @@ void()) from_json_array_impl(j, arr, priority_tag<3> {}); } +template +void from_json(const BasicJsonType& j, typename BasicJsonType::binary_t& bin) +{ + if (JSON_HEDLEY_UNLIKELY(!j.is_binary())) + { + JSON_THROW(type_error::create(302, "type must be binary, but is " + std::string(j.type_name()))); + } + + bin = *j.template get_ptr(); +} + template::value, int> = 0> void from_json(const BasicJsonType& j, ConstructibleObjectType& obj) { - if (JSON_HEDLEY_UNLIKELY(not j.is_object())) + if (JSON_HEDLEY_UNLIKELY(!j.is_object())) { JSON_THROW(type_error::create(302, "type must be object, but is " + std::string(j.type_name()))); } @@ -271,14 +285,14 @@ void from_json(const BasicJsonType& j, ConstructibleObjectType& obj) // (BooleanType, etc..); note: Is it really necessary to provide explicit // overloads for boolean_t etc. in case of a custom BooleanType which is not // an arithmetic type? -template::value and - not std::is_same::value and - not std::is_same::value and - not std::is_same::value and - not std::is_same::value, - int> = 0> +template < typename BasicJsonType, typename ArithmeticType, + enable_if_t < + std::is_arithmetic::value&& + !std::is_same::value&& + !std::is_same::value&& + !std::is_same::value&& + !std::is_same::value, + int > = 0 > void from_json(const BasicJsonType& j, ArithmeticType& val) { switch (static_cast(j)) @@ -327,19 +341,19 @@ void from_json(const BasicJsonType& j, std::tuple& t) from_json_tuple_impl(j, t, index_sequence_for {}); } -template ::value>> +template < typename BasicJsonType, typename Key, typename Value, typename Compare, typename Allocator, + typename = enable_if_t < !std::is_constructible < + typename BasicJsonType::string_t, Key >::value >> void from_json(const BasicJsonType& j, std::map& m) { - if (JSON_HEDLEY_UNLIKELY(not j.is_array())) + if (JSON_HEDLEY_UNLIKELY(!j.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); } m.clear(); for (const auto& p : j) { - if (JSON_HEDLEY_UNLIKELY(not p.is_array())) + if (JSON_HEDLEY_UNLIKELY(!p.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name()))); } @@ -347,19 +361,19 @@ void from_json(const BasicJsonType& j, std::map& } } -template ::value>> +template < typename BasicJsonType, typename Key, typename Value, typename Hash, typename KeyEqual, typename Allocator, + typename = enable_if_t < !std::is_constructible < + typename BasicJsonType::string_t, Key >::value >> void from_json(const BasicJsonType& j, std::unordered_map& m) { - if (JSON_HEDLEY_UNLIKELY(not j.is_array())) + if (JSON_HEDLEY_UNLIKELY(!j.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); } m.clear(); for (const auto& p : j) { - if (JSON_HEDLEY_UNLIKELY(not p.is_array())) + if (JSON_HEDLEY_UNLIKELY(!p.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name()))); } diff --git a/mock/nlohmann/detail/conversions/to_chars.hpp b/mock/nlohmann/detail/conversions/to_chars.hpp index d99703a54c1ec9d2f46a3032894c426b8169aef8..c632ff2bea6d8b7b0251031970297baf6921261e 100644 --- a/mock/nlohmann/detail/conversions/to_chars.hpp +++ b/mock/nlohmann/detail/conversions/to_chars.hpp @@ -1,13 +1,12 @@ #pragma once #include // array -#include // assert -#include // or, and, not #include // signbit, isfinite #include // intN_t, uintN_t #include // memcpy, memmove #include // numeric_limits #include // conditional + #include namespace nlohmann @@ -37,7 +36,7 @@ For a detailed description of the algorithm see: namespace dtoa_impl { -template +template Target reinterpret_bits(const Source source) { static_assert(sizeof(Target) == sizeof(Source), "size mismatch"); @@ -62,8 +61,8 @@ struct diyfp // f * 2^e */ static diyfp sub(const diyfp& x, const diyfp& y) noexcept { - assert(x.e == y.e); - assert(x.f >= y.f); + JSON_ASSERT(x.e == y.e); + JSON_ASSERT(x.f >= y.f); return {x.f - y.f, x.e}; } @@ -139,7 +138,7 @@ struct diyfp // f * 2^e */ static diyfp normalize(diyfp x) noexcept { - assert(x.f != 0); + JSON_ASSERT(x.f != 0); while ((x.f >> 63u) == 0) { @@ -158,8 +157,8 @@ struct diyfp // f * 2^e { const int delta = x.e - target_exponent; - assert(delta >= 0); - assert(((x.f << delta) >> delta) == x.f); + JSON_ASSERT(delta >= 0); + JSON_ASSERT(((x.f << delta) >> delta) == x.f); return {x.f << delta, target_exponent}; } @@ -178,11 +177,11 @@ boundaries. @pre value must be finite and positive */ -template +template boundaries compute_boundaries(FloatType value) { - assert(std::isfinite(value)); - assert(value > 0); + JSON_ASSERT(std::isfinite(value)); + JSON_ASSERT(value > 0); // Convert the IEEE representation into a diyfp. // @@ -231,7 +230,7 @@ boundaries compute_boundaries(FloatType value) // -----------------+------+------+-------------+-------------+--- (B) // v- m- v m+ v+ - const bool lower_boundary_is_closer = F == 0 and E > 1; + const bool lower_boundary_is_closer = F == 0 && E > 1; const diyfp m_plus = diyfp(2 * v.f + 1, v.e - 1); const diyfp m_minus = lower_boundary_is_closer ? diyfp(4 * v.f - 1, v.e - 2) // (B) @@ -462,18 +461,18 @@ inline cached_power get_cached_power_for_binary_exponent(int e) // k = ceil((kAlpha - e - 1) * 0.30102999566398114) // for |e| <= 1500, but doesn't require floating-point operations. // NB: log_10(2) ~= 78913 / 2^18 - assert(e >= -1500); - assert(e <= 1500); + JSON_ASSERT(e >= -1500); + JSON_ASSERT(e <= 1500); const int f = kAlpha - e - 1; const int k = (f * 78913) / (1 << 18) + static_cast(f > 0); const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep; - assert(index >= 0); - assert(static_cast(index) < kCachedPowers.size()); + JSON_ASSERT(index >= 0); + JSON_ASSERT(static_cast(index) < kCachedPowers.size()); const cached_power cached = kCachedPowers[static_cast(index)]; - assert(kAlpha <= cached.e + e + 64); - assert(kGamma >= cached.e + e + 64); + JSON_ASSERT(kAlpha <= cached.e + e + 64); + JSON_ASSERT(kGamma >= cached.e + e + 64); return cached; } @@ -541,10 +540,10 @@ inline int find_largest_pow10(const std::uint32_t n, std::uint32_t& pow10) inline void grisu2_round(char* buf, int len, std::uint64_t dist, std::uint64_t delta, std::uint64_t rest, std::uint64_t ten_k) { - assert(len >= 1); - assert(dist <= delta); - assert(rest <= delta); - assert(ten_k > 0); + JSON_ASSERT(len >= 1); + JSON_ASSERT(dist <= delta); + JSON_ASSERT(rest <= delta); + JSON_ASSERT(ten_k > 0); // <--------------------------- delta ----> // <---- dist ---------> @@ -566,10 +565,10 @@ inline void grisu2_round(char* buf, int len, std::uint64_t dist, std::uint64_t d // integer arithmetic. while (rest < dist - and delta - rest >= ten_k - and (rest + ten_k < dist or dist - rest > rest + ten_k - dist)) + && delta - rest >= ten_k + && (rest + ten_k < dist || dist - rest > rest + ten_k - dist)) { - assert(buf[len - 1] != '0'); + JSON_ASSERT(buf[len - 1] != '0'); buf[len - 1]--; rest += ten_k; } @@ -597,8 +596,8 @@ inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent, // Grisu2 generates the digits of M+ from left to right and stops as soon as // V is in [M-,M+]. - assert(M_plus.e >= kAlpha); - assert(M_plus.e <= kGamma); + JSON_ASSERT(M_plus.e >= kAlpha); + JSON_ASSERT(M_plus.e <= kGamma); std::uint64_t delta = diyfp::sub(M_plus, M_minus).f; // (significand of (M+ - M-), implicit exponent is e) std::uint64_t dist = diyfp::sub(M_plus, w ).f; // (significand of (M+ - w ), implicit exponent is e) @@ -619,7 +618,7 @@ inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent, // // Generate the digits of the integral part p1 = d[n-1]...d[1]d[0] - assert(p1 > 0); + JSON_ASSERT(p1 > 0); std::uint32_t pow10; const int k = find_largest_pow10(p1, pow10); @@ -655,7 +654,7 @@ inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent, // M+ = buffer * 10^n + (d * 10^(n-1) + r) + p2 * 2^e // = (buffer * 10 + d) * 10^(n-1) + (r + p2 * 2^e) // - assert(d <= 9); + JSON_ASSERT(d <= 9); buffer[length++] = static_cast('0' + d); // buffer := buffer * 10 + d // // M+ = buffer * 10^(n-1) + (r + p2 * 2^e) @@ -742,7 +741,7 @@ inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent, // // and stop as soon as 10^-m * r * 2^e <= delta * 2^e - assert(p2 > delta); + JSON_ASSERT(p2 > delta); int m = 0; for (;;) @@ -753,7 +752,7 @@ inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent, // = buffer * 10^-m + 10^-m * (1/10 * (10 * p2) ) * 2^e // = buffer * 10^-m + 10^-m * (1/10 * ((10*p2 div 2^-e) * 2^-e + (10*p2 mod 2^-e)) * 2^e // - assert(p2 <= (std::numeric_limits::max)() / 10); + JSON_ASSERT(p2 <= (std::numeric_limits::max)() / 10); p2 *= 10; const std::uint64_t d = p2 >> -one.e; // d = (10 * p2) div 2^-e const std::uint64_t r = p2 & (one.f - 1); // r = (10 * p2) mod 2^-e @@ -762,7 +761,7 @@ inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent, // = buffer * 10^-m + 10^-m * (1/10 * (d + r * 2^e)) // = (buffer * 10 + d) * 10^(-m-1) + 10^(-m-1) * r * 2^e // - assert(d <= 9); + JSON_ASSERT(d <= 9); buffer[length++] = static_cast('0' + d); // buffer := buffer * 10 + d // // M+ = buffer * 10^(-m-1) + 10^(-m-1) * r * 2^e @@ -823,8 +822,8 @@ JSON_HEDLEY_NON_NULL(1) inline void grisu2(char* buf, int& len, int& decimal_exponent, diyfp m_minus, diyfp v, diyfp m_plus) { - assert(m_plus.e == m_minus.e); - assert(m_plus.e == v.e); + JSON_ASSERT(m_plus.e == m_minus.e); + JSON_ASSERT(m_plus.e == v.e); // --------(-----------------------+-----------------------)-------- (A) // m- v m+ @@ -878,15 +877,15 @@ v = buf * 10^decimal_exponent len is the length of the buffer (number of decimal digits) The buffer must be large enough, i.e. >= max_digits10. */ -template +template JSON_HEDLEY_NON_NULL(1) void grisu2(char* buf, int& len, int& decimal_exponent, FloatType value) { static_assert(diyfp::kPrecision >= std::numeric_limits::digits + 3, "internal error: not enough precision"); - assert(std::isfinite(value)); - assert(value > 0); + JSON_ASSERT(std::isfinite(value)); + JSON_ASSERT(value > 0); // If the neighbors (and boundaries) of 'value' are always computed for double-precision // numbers, all float's can be recovered using strtod (and strtof). However, the resulting @@ -922,8 +921,8 @@ JSON_HEDLEY_NON_NULL(1) JSON_HEDLEY_RETURNS_NON_NULL inline char* append_exponent(char* buf, int e) { - assert(e > -1000); - assert(e < 1000); + JSON_ASSERT(e > -1000); + JSON_ASSERT(e < 1000); if (e < 0) { @@ -975,8 +974,8 @@ JSON_HEDLEY_RETURNS_NON_NULL inline char* format_buffer(char* buf, int len, int decimal_exponent, int min_exp, int max_exp) { - assert(min_exp < 0); - assert(max_exp > 0); + JSON_ASSERT(min_exp < 0); + JSON_ASSERT(max_exp > 0); const int k = len; const int n = len + decimal_exponent; @@ -985,40 +984,40 @@ inline char* format_buffer(char* buf, int len, int decimal_exponent, // k is the length of the buffer (number of decimal digits) // n is the position of the decimal point relative to the start of the buffer. - if (k <= n and n <= max_exp) + if (k <= n && n <= max_exp) { // digits[000] // len <= max_exp + 2 - std::memset(buf + k, '0', static_cast(n - k)); + std::memset(buf + k, '0', static_cast(n) - static_cast(k)); // Make it look like a floating-point number (#362, #378) buf[n + 0] = '.'; buf[n + 1] = '0'; - return buf + (n + 2); + return buf + (static_cast(n) + 2); } - if (0 < n and n <= max_exp) + if (0 < n && n <= max_exp) { // dig.its // len <= max_digits10 + 1 - assert(k > n); + JSON_ASSERT(k > n); - std::memmove(buf + (n + 1), buf + n, static_cast(k - n)); + std::memmove(buf + (static_cast(n) + 1), buf + n, static_cast(k) - static_cast(n)); buf[n] = '.'; - return buf + (k + 1); + return buf + (static_cast(k) + 1U); } - if (min_exp < n and n <= 0) + if (min_exp < n && n <= 0) { // 0.[000]digits // len <= 2 + (-min_exp - 1) + max_digits10 - std::memmove(buf + (2 + -n), buf, static_cast(k)); + std::memmove(buf + (2 + static_cast(-n)), buf, static_cast(k)); buf[0] = '0'; buf[1] = '.'; std::memset(buf + 2, '0', static_cast(-n)); - return buf + (2 + (-n) + k); + return buf + (2U + static_cast(-n) + static_cast(k)); } if (k == 1) @@ -1033,9 +1032,9 @@ inline char* format_buffer(char* buf, int len, int decimal_exponent, // d.igitsE+123 // len <= max_digits10 + 1 + 5 - std::memmove(buf + 2, buf + 1, static_cast(k - 1)); + std::memmove(buf + 2, buf + 1, static_cast(k) - 1); buf[1] = '.'; - buf += 1 + k; + buf += 1 + static_cast(k); } *buf++ = 'e'; @@ -1054,13 +1053,13 @@ format. Returns an iterator pointing past-the-end of the decimal representation. @note The buffer must be large enough. @note The result is NOT null-terminated. */ -template +template JSON_HEDLEY_NON_NULL(1, 2) JSON_HEDLEY_RETURNS_NON_NULL char* to_chars(char* first, const char* last, FloatType value) { static_cast(last); // maybe unused - fix warning - assert(std::isfinite(value)); + JSON_ASSERT(std::isfinite(value)); // Use signbit(value) instead of (value < 0) since signbit works for -0. if (std::signbit(value)) @@ -1078,7 +1077,7 @@ char* to_chars(char* first, const char* last, FloatType value) return first; } - assert(last - first >= std::numeric_limits::max_digits10); + JSON_ASSERT(last - first >= std::numeric_limits::max_digits10); // Compute v = buffer * 10^decimal_exponent. // The decimal digits are stored in the buffer, which needs to be interpreted @@ -1088,16 +1087,16 @@ char* to_chars(char* first, const char* last, FloatType value) int decimal_exponent = 0; dtoa_impl::grisu2(first, len, decimal_exponent, value); - assert(len <= std::numeric_limits::max_digits10); + JSON_ASSERT(len <= std::numeric_limits::max_digits10); // Format the buffer like printf("%.*g", prec, value) constexpr int kMinExp = -4; // Use digits10 here to increase compatibility with version 2. constexpr int kMaxExp = std::numeric_limits::digits10; - assert(last - first >= kMaxExp + 2); - assert(last - first >= 2 + (-kMinExp - 1) + std::numeric_limits::max_digits10); - assert(last - first >= std::numeric_limits::max_digits10 + 6); + JSON_ASSERT(last - first >= kMaxExp + 2); + JSON_ASSERT(last - first >= 2 + (-kMinExp - 1) + std::numeric_limits::max_digits10); + JSON_ASSERT(last - first >= std::numeric_limits::max_digits10 + 6); return dtoa_impl::format_buffer(first, len, decimal_exponent, kMinExp, kMaxExp); } diff --git a/mock/nlohmann/detail/conversions/to_json.hpp b/mock/nlohmann/detail/conversions/to_json.hpp index a1def699fd712909e0d94a761c4f74b38120a2a3..b45004fd4283d615b34b973da4a74ede31dbf1aa 100644 --- a/mock/nlohmann/detail/conversions/to_json.hpp +++ b/mock/nlohmann/detail/conversions/to_json.hpp @@ -1,7 +1,6 @@ #pragma once #include // copy -#include // or, and, not #include // begin, end #include // string #include // tuple, get @@ -56,9 +55,9 @@ struct external_constructor j.assert_invariant(); } - template::value, - int> = 0> + template < typename BasicJsonType, typename CompatibleStringType, + enable_if_t < !std::is_same::value, + int > = 0 > static void construct(BasicJsonType& j, const CompatibleStringType& str) { j.m_type = value_t::string; @@ -67,6 +66,28 @@ struct external_constructor } }; +template<> +struct external_constructor +{ + template + static void construct(BasicJsonType& j, const typename BasicJsonType::binary_t& b) + { + j.m_type = value_t::binary; + typename BasicJsonType::binary_t value{b}; + j.m_value = value; + j.assert_invariant(); + } + + template + static void construct(BasicJsonType& j, typename BasicJsonType::binary_t&& b) + { + j.m_type = value_t::binary; + typename BasicJsonType::binary_t value{std::move(b)}; + j.m_value = value; + j.assert_invariant(); + } +}; + template<> struct external_constructor { @@ -122,9 +143,9 @@ struct external_constructor j.assert_invariant(); } - template::value, - int> = 0> + template < typename BasicJsonType, typename CompatibleArrayType, + enable_if_t < !std::is_same::value, + int > = 0 > static void construct(BasicJsonType& j, const CompatibleArrayType& arr) { using std::begin; @@ -181,8 +202,8 @@ struct external_constructor j.assert_invariant(); } - template::value, int> = 0> + template < typename BasicJsonType, typename CompatibleObjectType, + enable_if_t < !std::is_same::value, int > = 0 > static void construct(BasicJsonType& j, const CompatibleObjectType& obj) { using std::begin; @@ -253,19 +274,25 @@ void to_json(BasicJsonType& j, const std::vector& e) external_constructor::construct(j, e); } -template ::value and - not is_compatible_object_type< - BasicJsonType, CompatibleArrayType>::value and - not is_compatible_string_type::value and - not is_basic_json::value, - int> = 0> +template < typename BasicJsonType, typename CompatibleArrayType, + enable_if_t < is_compatible_array_type::value&& + !is_compatible_object_type::value&& + !is_compatible_string_type::value&& + !std::is_same::value&& + !is_basic_json::value, + int > = 0 > void to_json(BasicJsonType& j, const CompatibleArrayType& arr) { external_constructor::construct(j, arr); } +template +void to_json(BasicJsonType& j, const typename BasicJsonType::binary_t& bin) +{ + external_constructor::construct(j, bin); +} + template::value, int> = 0> void to_json(BasicJsonType& j, const std::valarray& arr) @@ -279,8 +306,8 @@ void to_json(BasicJsonType& j, typename BasicJsonType::array_t&& arr) external_constructor::construct(j, std::move(arr)); } -template::value and not is_basic_json::value, int> = 0> +template < typename BasicJsonType, typename CompatibleObjectType, + enable_if_t < is_compatible_object_type::value&& !is_basic_json::value, int > = 0 > void to_json(BasicJsonType& j, const CompatibleObjectType& obj) { external_constructor::construct(j, obj); @@ -294,9 +321,9 @@ void to_json(BasicJsonType& j, typename BasicJsonType::object_t&& obj) template < typename BasicJsonType, typename T, std::size_t N, - enable_if_t::value, - int> = 0 > + enable_if_t < !std::is_constructible::value, + int > = 0 > void to_json(BasicJsonType& j, const T(&arr)[N]) { external_constructor::construct(j, arr); @@ -309,8 +336,8 @@ void to_json(BasicJsonType& j, const std::pair& p) } // for https://github.com/nlohmann/json/pull/1134 -template < typename BasicJsonType, typename T, - enable_if_t>::value, int> = 0> +template>::value, int> = 0> void to_json(BasicJsonType& j, const T& b) { j = { {b.key(), b.value()} }; diff --git a/mock/nlohmann/detail/exceptions.hpp b/mock/nlohmann/detail/exceptions.hpp index ed836188cccea28c416710fbb5ed16cf350eb7bd..dd92897d5ae94ac6b08cfd7b7543abd0dda82589 100644 --- a/mock/nlohmann/detail/exceptions.hpp +++ b/mock/nlohmann/detail/exceptions.hpp @@ -97,6 +97,7 @@ json.exception.parse_error.110 | parse error at 1: cannot read 2 bytes from vect json.exception.parse_error.112 | parse error at 1: error reading CBOR; last byte: 0xF8 | Not all types of CBOR or MessagePack are supported. This exception occurs if an unsupported byte was read. json.exception.parse_error.113 | parse error at 2: expected a CBOR string; last byte: 0x98 | While parsing a map key, a value that is not a string has been read. json.exception.parse_error.114 | parse error: Unsupported BSON record type 0x0F | The parsing of the corresponding BSON record type is not implemented (yet). +json.exception.parse_error.115 | parse error at byte 5: syntax error while parsing UBJSON high-precision number: invalid number text: 1A | A UBJSON high-precision number could not be parsed. @note For an input with n bytes, 1 is the index of the first character and n+1 is the index of the terminating null byte or the end of file. This also @@ -285,7 +286,7 @@ json.exception.out_of_range.403 | key 'foo' not found | The provided key was not json.exception.out_of_range.404 | unresolved reference token 'foo' | A reference token in a JSON Pointer could not be resolved. json.exception.out_of_range.405 | JSON pointer has no parent | The JSON Patch operations 'remove' and 'add' can not be applied to the root element of the JSON value. json.exception.out_of_range.406 | number overflow parsing '10E1000' | A parsed number could not be stored as without changing it to NaN or INF. -json.exception.out_of_range.407 | number overflow serializing '9223372036854775808' | UBJSON and BSON only support integer numbers up to 9223372036854775807. | +json.exception.out_of_range.407 | number overflow serializing '9223372036854775808' | UBJSON and BSON only support integer numbers up to 9223372036854775807. (until version 3.8.0) | json.exception.out_of_range.408 | excessive array size: 8658170730974374167 | The size (following `#`) of an UBJSON array or object exceeds the maximal capacity. | json.exception.out_of_range.409 | BSON key cannot contain code point U+0000 (at byte 2) | Key identifiers to be serialized to BSON cannot contain code point U+0000, since the key is stored as zero-terminated c-string | diff --git a/mock/nlohmann/detail/hash.hpp b/mock/nlohmann/detail/hash.hpp new file mode 100644 index 0000000000000000000000000000000000000000..4094cc94fc37477f1fdbf30597661b53eb759499 --- /dev/null +++ b/mock/nlohmann/detail/hash.hpp @@ -0,0 +1,117 @@ +#pragma once + +#include // size_t, uint8_t +#include // hash + +namespace nlohmann +{ +namespace detail +{ + +// boost::hash_combine +inline std::size_t combine(std::size_t seed, std::size_t h) noexcept +{ + seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U); + return seed; +} + +/*! +@brief hash a JSON value + +The hash function tries to rely on std::hash where possible. Furthermore, the +type of the JSON value is taken into account to have different hash values for +null, 0, 0U, and false, etc. + +@tparam BasicJsonType basic_json specialization +@param j JSON value to hash +@return hash value of j +*/ +template +std::size_t hash(const BasicJsonType& j) +{ + using string_t = typename BasicJsonType::string_t; + using number_integer_t = typename BasicJsonType::number_integer_t; + using number_unsigned_t = typename BasicJsonType::number_unsigned_t; + using number_float_t = typename BasicJsonType::number_float_t; + + const auto type = static_cast(j.type()); + switch (j.type()) + { + case BasicJsonType::value_t::null: + case BasicJsonType::value_t::discarded: + { + return combine(type, 0); + } + + case BasicJsonType::value_t::object: + { + auto seed = combine(type, j.size()); + for (const auto& element : j.items()) + { + const auto h = std::hash {}(element.key()); + seed = combine(seed, h); + seed = combine(seed, hash(element.value())); + } + return seed; + } + + case BasicJsonType::value_t::array: + { + auto seed = combine(type, j.size()); + for (const auto& element : j) + { + seed = combine(seed, hash(element)); + } + return seed; + } + + case BasicJsonType::value_t::string: + { + const auto h = std::hash {}(j.template get_ref()); + return combine(type, h); + } + + case BasicJsonType::value_t::boolean: + { + const auto h = std::hash {}(j.template get()); + return combine(type, h); + } + + case BasicJsonType::value_t::number_integer: + { + const auto h = std::hash {}(j.template get()); + return combine(type, h); + } + + case nlohmann::detail::value_t::number_unsigned: + { + const auto h = std::hash {}(j.template get()); + return combine(type, h); + } + + case nlohmann::detail::value_t::number_float: + { + const auto h = std::hash {}(j.template get()); + return combine(type, h); + } + + case nlohmann::detail::value_t::binary: + { + auto seed = combine(type, j.get_binary().size()); + const auto h = std::hash {}(j.get_binary().has_subtype()); + seed = combine(seed, h); + seed = combine(seed, j.get_binary().subtype()); + for (const auto byte : j.get_binary()) + { + seed = combine(seed, std::hash {}(byte)); + } + return seed; + } + + default: // LCOV_EXCL_LINE + JSON_ASSERT(false); // LCOV_EXCL_LINE + } +} + +} // namespace detail +} // namespace nlohmann diff --git a/mock/nlohmann/detail/input/binary_reader.hpp b/mock/nlohmann/detail/input/binary_reader.hpp index 1b6e0f9b7b3acc672d3079986f14772b45eb2d5f..4c94d1ccfd312aa0e0c2c841586c35b678aa0f6e 100644 --- a/mock/nlohmann/detail/input/binary_reader.hpp +++ b/mock/nlohmann/detail/input/binary_reader.hpp @@ -2,7 +2,6 @@ #include // generate_n #include // array -#include // assert #include // ldexp #include // size_t #include // uint8_t, uint16_t, uint32_t, uint64_t @@ -16,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -24,6 +24,27 @@ namespace nlohmann { namespace detail { + +/// how to treat CBOR tags +enum class cbor_tag_handler_t +{ + error, ///< throw a parse_error exception in case of a tag + ignore ///< ignore tags +}; + +/*! +@brief determine system byte order + +@return true if and only if system's byte order is little endian + +@note from https://stackoverflow.com/a/1001328/266378 +*/ +static inline bool little_endianess(int num = 1) noexcept +{ + return *reinterpret_cast(&num) == 1; +} + + /////////////////// // binary reader // /////////////////// @@ -31,14 +52,17 @@ namespace detail /*! @brief deserialization of CBOR, MessagePack, and UBJSON values */ -template> +template> class binary_reader { using number_integer_t = typename BasicJsonType::number_integer_t; using number_unsigned_t = typename BasicJsonType::number_unsigned_t; using number_float_t = typename BasicJsonType::number_float_t; using string_t = typename BasicJsonType::string_t; + using binary_t = typename BasicJsonType::binary_t; using json_sax_t = SAX; + using char_type = typename InputAdapterType::char_type; + using char_int_type = typename std::char_traits::int_type; public: /*! @@ -46,10 +70,9 @@ class binary_reader @param[in] adapter input adapter to read from */ - explicit binary_reader(input_adapter_t adapter) : ia(std::move(adapter)) + explicit binary_reader(InputAdapterType&& adapter) : ia(std::move(adapter)) { (void)detail::is_sax_static_asserts {}; - assert(ia); } // make class move-only @@ -63,13 +86,15 @@ class binary_reader @param[in] format the binary format to parse @param[in] sax_ a SAX event processor @param[in] strict whether to expect the input to be consumed completed + @param[in] tag_handler how to treat CBOR tags @return */ JSON_HEDLEY_NON_NULL(3) bool sax_parse(const input_format_t format, json_sax_t* sax_, - const bool strict = true) + const bool strict = true, + const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) { sax = sax_; bool result = false; @@ -81,7 +106,7 @@ class binary_reader break; case input_format_t::cbor: - result = parse_cbor_internal(); + result = parse_cbor_internal(true, tag_handler); break; case input_format_t::msgpack: @@ -93,11 +118,11 @@ class binary_reader break; default: // LCOV_EXCL_LINE - assert(false); // LCOV_EXCL_LINE + JSON_ASSERT(false); // LCOV_EXCL_LINE } // strict mode: next byte must be EOF - if (result and strict) + if (result && strict) { if (format == input_format_t::ubjson) { @@ -108,7 +133,7 @@ class binary_reader get(); } - if (JSON_HEDLEY_UNLIKELY(current != std::char_traits::eof())) + if (JSON_HEDLEY_UNLIKELY(current != std::char_traits::eof())) { return sax->parse_error(chars_read, get_token_string(), parse_error::create(110, chars_read, exception_message(format, "expected end of input; last byte: 0x" + get_token_string(), "value"))); @@ -118,18 +143,6 @@ class binary_reader return result; } - /*! - @brief determine system byte order - - @return true if and only if system's byte order is little endian - - @note from http://stackoverflow.com/a/1001328/266378 - */ - static constexpr bool little_endianess(int num = 1) noexcept - { - return *reinterpret_cast(&num) == 1; - } - private: ////////// // BSON // @@ -141,15 +154,15 @@ class binary_reader */ bool parse_bson_internal() { - std::int32_t document_size; + std::int32_t document_size{}; get_number(input_format_t::bson, document_size); - if (JSON_HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1)))) + if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::size_t(-1)))) { return false; } - if (JSON_HEDLEY_UNLIKELY(not parse_bson_element_list(/*is_array*/false))) + if (JSON_HEDLEY_UNLIKELY(!parse_bson_element_list(/*is_array*/false))) { return false; } @@ -170,7 +183,7 @@ class binary_reader while (true) { get(); - if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::bson, "cstring"))) + if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::bson, "cstring"))) { return false; } @@ -178,10 +191,8 @@ class binary_reader { return true; } - *out++ = static_cast(current); + *out++ = static_cast(current); } - - return true; } /*! @@ -204,7 +215,33 @@ class binary_reader return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::bson, "string length must be at least 1, is " + std::to_string(len), "string"))); } - return get_string(input_format_t::bson, len - static_cast(1), result) and get() != std::char_traits::eof(); + return get_string(input_format_t::bson, len - static_cast(1), result) && get() != std::char_traits::eof(); + } + + /*! + @brief Parses a byte array input of length @a len from the BSON input. + @param[in] len The length of the byte array to be read. + @param[in, out] result A reference to the binary variable where the read + array is to be stored. + @tparam NumberType The type of the length @a len + @pre len >= 0 + @return `true` if the byte array was successfully parsed + */ + template + bool get_bson_binary(const NumberType len, binary_t& result) + { + if (JSON_HEDLEY_UNLIKELY(len < 0)) + { + auto last_token = get_token_string(); + return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::bson, "byte array length cannot be negative, is " + std::to_string(len), "binary"))); + } + + // All BSON binary values have a subtype + std::uint8_t subtype{}; + get_number(input_format_t::bson, subtype); + result.set_subtype(subtype); + + return get_binary(input_format_t::bson, len, result); } /*! @@ -217,22 +254,22 @@ class binary_reader Unsupported BSON record type 0x... @return whether a valid BSON-object/array was passed to the SAX parser */ - bool parse_bson_element_internal(const int element_type, + bool parse_bson_element_internal(const char_int_type element_type, const std::size_t element_type_parse_position) { switch (element_type) { case 0x01: // double { - double number; - return get_number(input_format_t::bson, number) and sax->number_float(static_cast(number), ""); + double number{}; + return get_number(input_format_t::bson, number) && sax->number_float(static_cast(number), ""); } case 0x02: // string { - std::int32_t len; + std::int32_t len{}; string_t value; - return get_number(input_format_t::bson, len) and get_bson_string(len, value) and sax->string(value); + return get_number(input_format_t::bson, len) && get_bson_string(len, value) && sax->string(value); } case 0x03: // object @@ -245,6 +282,13 @@ class binary_reader return parse_bson_array(); } + case 0x05: // binary + { + std::int32_t len{}; + binary_t value; + return get_number(input_format_t::bson, len) && get_bson_binary(len, value) && sax->binary(value); + } + case 0x08: // boolean { return sax->boolean(get() != 0); @@ -257,14 +301,14 @@ class binary_reader case 0x10: // int32 { - std::int32_t value; - return get_number(input_format_t::bson, value) and sax->number_integer(value); + std::int32_t value{}; + return get_number(input_format_t::bson, value) && sax->number_integer(value); } case 0x12: // int64 { - std::int64_t value; - return get_number(input_format_t::bson, value) and sax->number_integer(value); + std::int64_t value{}; + return get_number(input_format_t::bson, value) && sax->number_integer(value); } default: // anything else not supported (yet) @@ -291,25 +335,26 @@ class binary_reader bool parse_bson_element_list(const bool is_array) { string_t key; - while (int element_type = get()) + + while (auto element_type = get()) { - if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::bson, "element list"))) + if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::bson, "element list"))) { return false; } const std::size_t element_type_parse_position = chars_read; - if (JSON_HEDLEY_UNLIKELY(not get_bson_cstr(key))) + if (JSON_HEDLEY_UNLIKELY(!get_bson_cstr(key))) { return false; } - if (not is_array and not sax->key(key)) + if (!is_array && !sax->key(key)) { return false; } - if (JSON_HEDLEY_UNLIKELY(not parse_bson_element_internal(element_type, element_type_parse_position))) + if (JSON_HEDLEY_UNLIKELY(!parse_bson_element_internal(element_type, element_type_parse_position))) { return false; } @@ -327,15 +372,15 @@ class binary_reader */ bool parse_bson_array() { - std::int32_t document_size; + std::int32_t document_size{}; get_number(input_format_t::bson, document_size); - if (JSON_HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1)))) + if (JSON_HEDLEY_UNLIKELY(!sax->start_array(std::size_t(-1)))) { return false; } - if (JSON_HEDLEY_UNLIKELY(not parse_bson_element_list(/*is_array*/true))) + if (JSON_HEDLEY_UNLIKELY(!parse_bson_element_list(/*is_array*/true))) { return false; } @@ -349,17 +394,19 @@ class binary_reader /*! @param[in] get_char whether a new character should be retrieved from the - input (true, default) or whether the last read - character should be considered instead + input (true) or whether the last read character should + be considered instead (false) + @param[in] tag_handler how CBOR tags should be treated @return whether a valid CBOR value was passed to the SAX parser */ - bool parse_cbor_internal(const bool get_char = true) + bool parse_cbor_internal(const bool get_char, + const cbor_tag_handler_t tag_handler) { switch (get_char ? get() : current) { // EOF - case std::char_traits::eof(): + case std::char_traits::eof(): return unexpect_eof(input_format_t::cbor, "value"); // Integer 0x00..0x17 (0..23) @@ -391,26 +438,26 @@ class binary_reader case 0x18: // Unsigned integer (one-byte uint8_t follows) { - std::uint8_t number; - return get_number(input_format_t::cbor, number) and sax->number_unsigned(number); + std::uint8_t number{}; + return get_number(input_format_t::cbor, number) && sax->number_unsigned(number); } case 0x19: // Unsigned integer (two-byte uint16_t follows) { - std::uint16_t number; - return get_number(input_format_t::cbor, number) and sax->number_unsigned(number); + std::uint16_t number{}; + return get_number(input_format_t::cbor, number) && sax->number_unsigned(number); } case 0x1A: // Unsigned integer (four-byte uint32_t follows) { - std::uint32_t number; - return get_number(input_format_t::cbor, number) and sax->number_unsigned(number); + std::uint32_t number{}; + return get_number(input_format_t::cbor, number) && sax->number_unsigned(number); } case 0x1B: // Unsigned integer (eight-byte uint64_t follows) { - std::uint64_t number; - return get_number(input_format_t::cbor, number) and sax->number_unsigned(number); + std::uint64_t number{}; + return get_number(input_format_t::cbor, number) && sax->number_unsigned(number); } // Negative integer -1-0x00..-1-0x17 (-1..-24) @@ -442,29 +489,64 @@ class binary_reader case 0x38: // Negative integer (one-byte uint8_t follows) { - std::uint8_t number; - return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast(-1) - number); + std::uint8_t number{}; + return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast(-1) - number); } case 0x39: // Negative integer -1-n (two-byte uint16_t follows) { - std::uint16_t number; - return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast(-1) - number); + std::uint16_t number{}; + return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast(-1) - number); } case 0x3A: // Negative integer -1-n (four-byte uint32_t follows) { - std::uint32_t number; - return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast(-1) - number); + std::uint32_t number{}; + return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast(-1) - number); } case 0x3B: // Negative integer -1-n (eight-byte uint64_t follows) { - std::uint64_t number; - return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast(-1) + std::uint64_t number{}; + return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast(-1) - static_cast(number)); } + // Binary data (0x00..0x17 bytes follow) + case 0x40: + case 0x41: + case 0x42: + case 0x43: + case 0x44: + case 0x45: + case 0x46: + case 0x47: + case 0x48: + case 0x49: + case 0x4A: + case 0x4B: + case 0x4C: + case 0x4D: + case 0x4E: + case 0x4F: + case 0x50: + case 0x51: + case 0x52: + case 0x53: + case 0x54: + case 0x55: + case 0x56: + case 0x57: + case 0x58: // Binary data (one-byte uint8_t for n follows) + case 0x59: // Binary data (two-byte uint16_t for n follow) + case 0x5A: // Binary data (four-byte uint32_t for n follow) + case 0x5B: // Binary data (eight-byte uint64_t for n follow) + case 0x5F: // Binary data (indefinite length) + { + binary_t b; + return get_cbor_binary(b) && sax->binary(b); + } + // UTF-8 string (0x00..0x17 bytes follow) case 0x60: case 0x61: @@ -497,7 +579,7 @@ class binary_reader case 0x7F: // UTF-8 string (indefinite length) { string_t s; - return get_cbor_string(s) and sax->string(s); + return get_cbor_string(s) && sax->string(s); } // array (0x00..0x17 data items follow) @@ -525,34 +607,34 @@ class binary_reader case 0x95: case 0x96: case 0x97: - return get_cbor_array(static_cast(static_cast(current) & 0x1Fu)); + return get_cbor_array(static_cast(static_cast(current) & 0x1Fu), tag_handler); case 0x98: // array (one-byte uint8_t for n follows) { - std::uint8_t len; - return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast(len)); + std::uint8_t len{}; + return get_number(input_format_t::cbor, len) && get_cbor_array(static_cast(len), tag_handler); } case 0x99: // array (two-byte uint16_t for n follow) { - std::uint16_t len; - return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast(len)); + std::uint16_t len{}; + return get_number(input_format_t::cbor, len) && get_cbor_array(static_cast(len), tag_handler); } case 0x9A: // array (four-byte uint32_t for n follow) { - std::uint32_t len; - return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast(len)); + std::uint32_t len{}; + return get_number(input_format_t::cbor, len) && get_cbor_array(static_cast(len), tag_handler); } case 0x9B: // array (eight-byte uint64_t for n follow) { - std::uint64_t len; - return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast(len)); + std::uint64_t len{}; + return get_number(input_format_t::cbor, len) && get_cbor_array(static_cast(len), tag_handler); } case 0x9F: // array (indefinite length) - return get_cbor_array(std::size_t(-1)); + return get_cbor_array(std::size_t(-1), tag_handler); // map (0x00..0x17 pairs of data items follow) case 0xA0: @@ -579,34 +661,101 @@ class binary_reader case 0xB5: case 0xB6: case 0xB7: - return get_cbor_object(static_cast(static_cast(current) & 0x1Fu)); + return get_cbor_object(static_cast(static_cast(current) & 0x1Fu), tag_handler); case 0xB8: // map (one-byte uint8_t for n follows) { - std::uint8_t len; - return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast(len)); + std::uint8_t len{}; + return get_number(input_format_t::cbor, len) && get_cbor_object(static_cast(len), tag_handler); } case 0xB9: // map (two-byte uint16_t for n follow) { - std::uint16_t len; - return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast(len)); + std::uint16_t len{}; + return get_number(input_format_t::cbor, len) && get_cbor_object(static_cast(len), tag_handler); } case 0xBA: // map (four-byte uint32_t for n follow) { - std::uint32_t len; - return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast(len)); + std::uint32_t len{}; + return get_number(input_format_t::cbor, len) && get_cbor_object(static_cast(len), tag_handler); } case 0xBB: // map (eight-byte uint64_t for n follow) { - std::uint64_t len; - return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast(len)); + std::uint64_t len{}; + return get_number(input_format_t::cbor, len) && get_cbor_object(static_cast(len), tag_handler); } case 0xBF: // map (indefinite length) - return get_cbor_object(std::size_t(-1)); + return get_cbor_object(std::size_t(-1), tag_handler); + + case 0xC6: // tagged item + case 0xC7: + case 0xC8: + case 0xC9: + case 0xCA: + case 0xCB: + case 0xCC: + case 0xCD: + case 0xCE: + case 0xCF: + case 0xD0: + case 0xD1: + case 0xD2: + case 0xD3: + case 0xD4: + case 0xD8: // tagged item (1 bytes follow) + case 0xD9: // tagged item (2 bytes follow) + case 0xDA: // tagged item (4 bytes follow) + case 0xDB: // tagged item (8 bytes follow) + { + switch (tag_handler) + { + case cbor_tag_handler_t::error: + { + auto last_token = get_token_string(); + return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::cbor, "invalid byte: 0x" + last_token, "value"))); + } + + case cbor_tag_handler_t::ignore: + { + switch (current) + { + case 0xD8: + { + std::uint8_t len{}; + get_number(input_format_t::cbor, len); + break; + } + case 0xD9: + { + std::uint16_t len{}; + get_number(input_format_t::cbor, len); + break; + } + case 0xDA: + { + std::uint32_t len{}; + get_number(input_format_t::cbor, len); + break; + } + case 0xDB: + { + std::uint64_t len{}; + get_number(input_format_t::cbor, len); + break; + } + default: + break; + } + return parse_cbor_internal(true, tag_handler); + } + + default: // LCOV_EXCL_LINE + JSON_ASSERT(false); // LCOV_EXCL_LINE + } + } case 0xF4: // false return sax->boolean(false); @@ -619,13 +768,13 @@ class binary_reader case 0xF9: // Half-Precision Float (two-byte IEEE 754) { - const int byte1_raw = get(); - if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "number"))) + const auto byte1_raw = get(); + if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "number"))) { return false; } - const int byte2_raw = get(); - if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "number"))) + const auto byte2_raw = get(); + if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "number"))) { return false; } @@ -646,8 +795,8 @@ class binary_reader { const int exp = (half >> 10u) & 0x1Fu; const unsigned int mant = half & 0x3FFu; - assert(0 <= exp and exp <= 32); - assert(mant <= 1024); + JSON_ASSERT(0 <= exp&& exp <= 32); + JSON_ASSERT(mant <= 1024); switch (exp) { case 0: @@ -667,14 +816,14 @@ class binary_reader case 0xFA: // Single-Precision Float (four-byte IEEE 754) { - float number; - return get_number(input_format_t::cbor, number) and sax->number_float(static_cast(number), ""); + float number{}; + return get_number(input_format_t::cbor, number) && sax->number_float(static_cast(number), ""); } case 0xFB: // Double-Precision Float (eight-byte IEEE 754) { - double number; - return get_number(input_format_t::cbor, number) and sax->number_float(static_cast(number), ""); + double number{}; + return get_number(input_format_t::cbor, number) && sax->number_float(static_cast(number), ""); } default: // anything else (0xFF is handled inside the other types) @@ -698,7 +847,7 @@ class binary_reader */ bool get_cbor_string(string_t& result) { - if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "string"))) + if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "string"))) { return false; } @@ -736,26 +885,26 @@ class binary_reader case 0x78: // UTF-8 string (one-byte uint8_t for n follows) { - std::uint8_t len; - return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result); + std::uint8_t len{}; + return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result); } case 0x79: // UTF-8 string (two-byte uint16_t for n follow) { - std::uint16_t len; - return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result); + std::uint16_t len{}; + return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result); } case 0x7A: // UTF-8 string (four-byte uint32_t for n follow) { - std::uint32_t len; - return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result); + std::uint32_t len{}; + return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result); } case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow) { - std::uint64_t len; - return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result); + std::uint64_t len{}; + return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result); } case 0x7F: // UTF-8 string (indefinite length) @@ -763,7 +912,7 @@ class binary_reader while (get() != 0xFF) { string_t chunk; - if (not get_cbor_string(chunk)) + if (!get_cbor_string(chunk)) { return false; } @@ -780,14 +929,115 @@ class binary_reader } } + /*! + @brief reads a CBOR byte array + + This function first reads starting bytes to determine the expected + byte array length and then copies this number of bytes into the byte array. + Additionally, CBOR's byte arrays with indefinite lengths are supported. + + @param[out] result created byte array + + @return whether byte array creation completed + */ + bool get_cbor_binary(binary_t& result) + { + if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "binary"))) + { + return false; + } + + switch (current) + { + // Binary data (0x00..0x17 bytes follow) + case 0x40: + case 0x41: + case 0x42: + case 0x43: + case 0x44: + case 0x45: + case 0x46: + case 0x47: + case 0x48: + case 0x49: + case 0x4A: + case 0x4B: + case 0x4C: + case 0x4D: + case 0x4E: + case 0x4F: + case 0x50: + case 0x51: + case 0x52: + case 0x53: + case 0x54: + case 0x55: + case 0x56: + case 0x57: + { + return get_binary(input_format_t::cbor, static_cast(current) & 0x1Fu, result); + } + + case 0x58: // Binary data (one-byte uint8_t for n follows) + { + std::uint8_t len{}; + return get_number(input_format_t::cbor, len) && + get_binary(input_format_t::cbor, len, result); + } + + case 0x59: // Binary data (two-byte uint16_t for n follow) + { + std::uint16_t len{}; + return get_number(input_format_t::cbor, len) && + get_binary(input_format_t::cbor, len, result); + } + + case 0x5A: // Binary data (four-byte uint32_t for n follow) + { + std::uint32_t len{}; + return get_number(input_format_t::cbor, len) && + get_binary(input_format_t::cbor, len, result); + } + + case 0x5B: // Binary data (eight-byte uint64_t for n follow) + { + std::uint64_t len{}; + return get_number(input_format_t::cbor, len) && + get_binary(input_format_t::cbor, len, result); + } + + case 0x5F: // Binary data (indefinite length) + { + while (get() != 0xFF) + { + binary_t chunk; + if (!get_cbor_binary(chunk)) + { + return false; + } + result.insert(result.end(), chunk.begin(), chunk.end()); + } + return true; + } + + default: + { + auto last_token = get_token_string(); + return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::cbor, "expected length specification (0x40-0x5B) or indefinite binary array type (0x5F); last byte: 0x" + last_token, "binary"))); + } + } + } + /*! @param[in] len the length of the array or std::size_t(-1) for an array of indefinite size + @param[in] tag_handler how CBOR tags should be treated @return whether array creation completed */ - bool get_cbor_array(const std::size_t len) + bool get_cbor_array(const std::size_t len, + const cbor_tag_handler_t tag_handler) { - if (JSON_HEDLEY_UNLIKELY(not sax->start_array(len))) + if (JSON_HEDLEY_UNLIKELY(!sax->start_array(len))) { return false; } @@ -796,7 +1046,7 @@ class binary_reader { for (std::size_t i = 0; i < len; ++i) { - if (JSON_HEDLEY_UNLIKELY(not parse_cbor_internal())) + if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(true, tag_handler))) { return false; } @@ -806,7 +1056,7 @@ class binary_reader { while (get() != 0xFF) { - if (JSON_HEDLEY_UNLIKELY(not parse_cbor_internal(false))) + if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(false, tag_handler))) { return false; } @@ -819,11 +1069,13 @@ class binary_reader /*! @param[in] len the length of the object or std::size_t(-1) for an object of indefinite size + @param[in] tag_handler how CBOR tags should be treated @return whether object creation completed */ - bool get_cbor_object(const std::size_t len) + bool get_cbor_object(const std::size_t len, + const cbor_tag_handler_t tag_handler) { - if (JSON_HEDLEY_UNLIKELY(not sax->start_object(len))) + if (JSON_HEDLEY_UNLIKELY(!sax->start_object(len))) { return false; } @@ -834,12 +1086,12 @@ class binary_reader for (std::size_t i = 0; i < len; ++i) { get(); - if (JSON_HEDLEY_UNLIKELY(not get_cbor_string(key) or not sax->key(key))) + if (JSON_HEDLEY_UNLIKELY(!get_cbor_string(key) || !sax->key(key))) { return false; } - if (JSON_HEDLEY_UNLIKELY(not parse_cbor_internal())) + if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(true, tag_handler))) { return false; } @@ -850,12 +1102,12 @@ class binary_reader { while (get() != 0xFF) { - if (JSON_HEDLEY_UNLIKELY(not get_cbor_string(key) or not sax->key(key))) + if (JSON_HEDLEY_UNLIKELY(!get_cbor_string(key) || !sax->key(key))) { return false; } - if (JSON_HEDLEY_UNLIKELY(not parse_cbor_internal())) + if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(true, tag_handler))) { return false; } @@ -878,7 +1130,7 @@ class binary_reader switch (get()) { // EOF - case std::char_traits::eof(): + case std::char_traits::eof(): return unexpect_eof(input_format_t::msgpack, "value"); // positive fixint @@ -1088,7 +1340,7 @@ class binary_reader case 0xDB: // str 32 { string_t s; - return get_msgpack_string(s) and sax->string(s); + return get_msgpack_string(s) && sax->string(s); } case 0xC0: // nil @@ -1100,88 +1352,104 @@ class binary_reader case 0xC3: // true return sax->boolean(true); + case 0xC4: // bin 8 + case 0xC5: // bin 16 + case 0xC6: // bin 32 + case 0xC7: // ext 8 + case 0xC8: // ext 16 + case 0xC9: // ext 32 + case 0xD4: // fixext 1 + case 0xD5: // fixext 2 + case 0xD6: // fixext 4 + case 0xD7: // fixext 8 + case 0xD8: // fixext 16 + { + binary_t b; + return get_msgpack_binary(b) && sax->binary(b); + } + case 0xCA: // float 32 { - float number; - return get_number(input_format_t::msgpack, number) and sax->number_float(static_cast(number), ""); + float number{}; + return get_number(input_format_t::msgpack, number) && sax->number_float(static_cast(number), ""); } case 0xCB: // float 64 { - double number; - return get_number(input_format_t::msgpack, number) and sax->number_float(static_cast(number), ""); + double number{}; + return get_number(input_format_t::msgpack, number) && sax->number_float(static_cast(number), ""); } case 0xCC: // uint 8 { - std::uint8_t number; - return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number); + std::uint8_t number{}; + return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number); } case 0xCD: // uint 16 { - std::uint16_t number; - return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number); + std::uint16_t number{}; + return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number); } case 0xCE: // uint 32 { - std::uint32_t number; - return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number); + std::uint32_t number{}; + return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number); } case 0xCF: // uint 64 { - std::uint64_t number; - return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number); + std::uint64_t number{}; + return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number); } case 0xD0: // int 8 { - std::int8_t number; - return get_number(input_format_t::msgpack, number) and sax->number_integer(number); + std::int8_t number{}; + return get_number(input_format_t::msgpack, number) && sax->number_integer(number); } case 0xD1: // int 16 { - std::int16_t number; - return get_number(input_format_t::msgpack, number) and sax->number_integer(number); + std::int16_t number{}; + return get_number(input_format_t::msgpack, number) && sax->number_integer(number); } case 0xD2: // int 32 { - std::int32_t number; - return get_number(input_format_t::msgpack, number) and sax->number_integer(number); + std::int32_t number{}; + return get_number(input_format_t::msgpack, number) && sax->number_integer(number); } case 0xD3: // int 64 { - std::int64_t number; - return get_number(input_format_t::msgpack, number) and sax->number_integer(number); + std::int64_t number{}; + return get_number(input_format_t::msgpack, number) && sax->number_integer(number); } case 0xDC: // array 16 { - std::uint16_t len; - return get_number(input_format_t::msgpack, len) and get_msgpack_array(static_cast(len)); + std::uint16_t len{}; + return get_number(input_format_t::msgpack, len) && get_msgpack_array(static_cast(len)); } case 0xDD: // array 32 { - std::uint32_t len; - return get_number(input_format_t::msgpack, len) and get_msgpack_array(static_cast(len)); + std::uint32_t len{}; + return get_number(input_format_t::msgpack, len) && get_msgpack_array(static_cast(len)); } case 0xDE: // map 16 { - std::uint16_t len; - return get_number(input_format_t::msgpack, len) and get_msgpack_object(static_cast(len)); + std::uint16_t len{}; + return get_number(input_format_t::msgpack, len) && get_msgpack_object(static_cast(len)); } case 0xDF: // map 32 { - std::uint32_t len; - return get_number(input_format_t::msgpack, len) and get_msgpack_object(static_cast(len)); + std::uint32_t len{}; + return get_number(input_format_t::msgpack, len) && get_msgpack_object(static_cast(len)); } // negative fixint @@ -1239,7 +1507,7 @@ class binary_reader */ bool get_msgpack_string(string_t& result) { - if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::msgpack, "string"))) + if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::msgpack, "string"))) { return false; } @@ -1285,20 +1553,20 @@ class binary_reader case 0xD9: // str 8 { - std::uint8_t len; - return get_number(input_format_t::msgpack, len) and get_string(input_format_t::msgpack, len, result); + std::uint8_t len{}; + return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result); } case 0xDA: // str 16 { - std::uint16_t len; - return get_number(input_format_t::msgpack, len) and get_string(input_format_t::msgpack, len, result); + std::uint16_t len{}; + return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result); } case 0xDB: // str 32 { - std::uint32_t len; - return get_number(input_format_t::msgpack, len) and get_string(input_format_t::msgpack, len, result); + std::uint32_t len{}; + return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result); } default: @@ -1309,20 +1577,137 @@ class binary_reader } } + /*! + @brief reads a MessagePack byte array + + This function first reads starting bytes to determine the expected + byte array length and then copies this number of bytes into a byte array. + + @param[out] result created byte array + + @return whether byte array creation completed + */ + bool get_msgpack_binary(binary_t& result) + { + // helper function to set the subtype + auto assign_and_return_true = [&result](std::int8_t subtype) + { + result.set_subtype(static_cast(subtype)); + return true; + }; + + switch (current) + { + case 0xC4: // bin 8 + { + std::uint8_t len{}; + return get_number(input_format_t::msgpack, len) && + get_binary(input_format_t::msgpack, len, result); + } + + case 0xC5: // bin 16 + { + std::uint16_t len{}; + return get_number(input_format_t::msgpack, len) && + get_binary(input_format_t::msgpack, len, result); + } + + case 0xC6: // bin 32 + { + std::uint32_t len{}; + return get_number(input_format_t::msgpack, len) && + get_binary(input_format_t::msgpack, len, result); + } + + case 0xC7: // ext 8 + { + std::uint8_t len{}; + std::int8_t subtype{}; + return get_number(input_format_t::msgpack, len) && + get_number(input_format_t::msgpack, subtype) && + get_binary(input_format_t::msgpack, len, result) && + assign_and_return_true(subtype); + } + + case 0xC8: // ext 16 + { + std::uint16_t len{}; + std::int8_t subtype{}; + return get_number(input_format_t::msgpack, len) && + get_number(input_format_t::msgpack, subtype) && + get_binary(input_format_t::msgpack, len, result) && + assign_and_return_true(subtype); + } + + case 0xC9: // ext 32 + { + std::uint32_t len{}; + std::int8_t subtype{}; + return get_number(input_format_t::msgpack, len) && + get_number(input_format_t::msgpack, subtype) && + get_binary(input_format_t::msgpack, len, result) && + assign_and_return_true(subtype); + } + + case 0xD4: // fixext 1 + { + std::int8_t subtype{}; + return get_number(input_format_t::msgpack, subtype) && + get_binary(input_format_t::msgpack, 1, result) && + assign_and_return_true(subtype); + } + + case 0xD5: // fixext 2 + { + std::int8_t subtype{}; + return get_number(input_format_t::msgpack, subtype) && + get_binary(input_format_t::msgpack, 2, result) && + assign_and_return_true(subtype); + } + + case 0xD6: // fixext 4 + { + std::int8_t subtype{}; + return get_number(input_format_t::msgpack, subtype) && + get_binary(input_format_t::msgpack, 4, result) && + assign_and_return_true(subtype); + } + + case 0xD7: // fixext 8 + { + std::int8_t subtype{}; + return get_number(input_format_t::msgpack, subtype) && + get_binary(input_format_t::msgpack, 8, result) && + assign_and_return_true(subtype); + } + + case 0xD8: // fixext 16 + { + std::int8_t subtype{}; + return get_number(input_format_t::msgpack, subtype) && + get_binary(input_format_t::msgpack, 16, result) && + assign_and_return_true(subtype); + } + + default: // LCOV_EXCL_LINE + return false; // LCOV_EXCL_LINE + } + } + /*! @param[in] len the length of the array @return whether array creation completed */ bool get_msgpack_array(const std::size_t len) { - if (JSON_HEDLEY_UNLIKELY(not sax->start_array(len))) + if (JSON_HEDLEY_UNLIKELY(!sax->start_array(len))) { return false; } for (std::size_t i = 0; i < len; ++i) { - if (JSON_HEDLEY_UNLIKELY(not parse_msgpack_internal())) + if (JSON_HEDLEY_UNLIKELY(!parse_msgpack_internal())) { return false; } @@ -1337,7 +1722,7 @@ class binary_reader */ bool get_msgpack_object(const std::size_t len) { - if (JSON_HEDLEY_UNLIKELY(not sax->start_object(len))) + if (JSON_HEDLEY_UNLIKELY(!sax->start_object(len))) { return false; } @@ -1346,12 +1731,12 @@ class binary_reader for (std::size_t i = 0; i < len; ++i) { get(); - if (JSON_HEDLEY_UNLIKELY(not get_msgpack_string(key) or not sax->key(key))) + if (JSON_HEDLEY_UNLIKELY(!get_msgpack_string(key) || !sax->key(key))) { return false; } - if (JSON_HEDLEY_UNLIKELY(not parse_msgpack_internal())) + if (JSON_HEDLEY_UNLIKELY(!parse_msgpack_internal())) { return false; } @@ -1398,7 +1783,7 @@ class binary_reader get(); // TODO(niels): may we ignore N here? } - if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "value"))) + if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson, "value"))) { return false; } @@ -1407,32 +1792,32 @@ class binary_reader { case 'U': { - std::uint8_t len; - return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result); + std::uint8_t len{}; + return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result); } case 'i': { - std::int8_t len; - return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result); + std::int8_t len{}; + return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result); } case 'I': { - std::int16_t len; - return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result); + std::int16_t len{}; + return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result); } case 'l': { - std::int32_t len; - return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result); + std::int32_t len{}; + return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result); } case 'L': { - std::int64_t len; - return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result); + std::int64_t len{}; + return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result); } default: @@ -1451,8 +1836,8 @@ class binary_reader { case 'U': { - std::uint8_t number; - if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) + std::uint8_t number{}; + if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number))) { return false; } @@ -1462,8 +1847,8 @@ class binary_reader case 'i': { - std::int8_t number; - if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) + std::int8_t number{}; + if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number))) { return false; } @@ -1473,8 +1858,8 @@ class binary_reader case 'I': { - std::int16_t number; - if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) + std::int16_t number{}; + if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number))) { return false; } @@ -1484,8 +1869,8 @@ class binary_reader case 'l': { - std::int32_t number; - if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) + std::int32_t number{}; + if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number))) { return false; } @@ -1495,8 +1880,8 @@ class binary_reader case 'L': { - std::int64_t number; - if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) + std::int64_t number{}; + if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number))) { return false; } @@ -1522,7 +1907,7 @@ class binary_reader @return whether pair creation completed */ - bool get_ubjson_size_type(std::pair& result) + bool get_ubjson_size_type(std::pair& result) { result.first = string_t::npos; // size result.second = 0; // type @@ -1532,7 +1917,7 @@ class binary_reader if (current == '$') { result.second = get(); // must not ignore 'N', because 'N' maybe the type - if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "type"))) + if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson, "type"))) { return false; } @@ -1540,7 +1925,7 @@ class binary_reader get_ignore_noop(); if (JSON_HEDLEY_UNLIKELY(current != '#')) { - if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "value"))) + if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson, "value"))) { return false; } @@ -1563,11 +1948,11 @@ class binary_reader @param prefix the previously read or set type prefix @return whether value creation completed */ - bool get_ubjson_value(const int prefix) + bool get_ubjson_value(const char_int_type prefix) { switch (prefix) { - case std::char_traits::eof(): // EOF + case std::char_traits::eof(): // EOF return unexpect_eof(input_format_t::ubjson, "value"); case 'T': // true @@ -1580,50 +1965,55 @@ class binary_reader case 'U': { - std::uint8_t number; - return get_number(input_format_t::ubjson, number) and sax->number_unsigned(number); + std::uint8_t number{}; + return get_number(input_format_t::ubjson, number) && sax->number_unsigned(number); } case 'i': { - std::int8_t number; - return get_number(input_format_t::ubjson, number) and sax->number_integer(number); + std::int8_t number{}; + return get_number(input_format_t::ubjson, number) && sax->number_integer(number); } case 'I': { - std::int16_t number; - return get_number(input_format_t::ubjson, number) and sax->number_integer(number); + std::int16_t number{}; + return get_number(input_format_t::ubjson, number) && sax->number_integer(number); } case 'l': { - std::int32_t number; - return get_number(input_format_t::ubjson, number) and sax->number_integer(number); + std::int32_t number{}; + return get_number(input_format_t::ubjson, number) && sax->number_integer(number); } case 'L': { - std::int64_t number; - return get_number(input_format_t::ubjson, number) and sax->number_integer(number); + std::int64_t number{}; + return get_number(input_format_t::ubjson, number) && sax->number_integer(number); } case 'd': { - float number; - return get_number(input_format_t::ubjson, number) and sax->number_float(static_cast(number), ""); + float number{}; + return get_number(input_format_t::ubjson, number) && sax->number_float(static_cast(number), ""); } case 'D': { - double number; - return get_number(input_format_t::ubjson, number) and sax->number_float(static_cast(number), ""); + double number{}; + return get_number(input_format_t::ubjson, number) && sax->number_float(static_cast(number), ""); + } + + case 'H': + { + return get_ubjson_high_precision_number(); } case 'C': // char { get(); - if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "char"))) + if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson, "char"))) { return false; } @@ -1632,14 +2022,14 @@ class binary_reader auto last_token = get_token_string(); return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "byte after 'C' must be in range 0x00..0x7F; last byte: 0x" + last_token, "char"))); } - string_t s(1, static_cast(current)); + string_t s(1, static_cast(current)); return sax->string(s); } case 'S': // string { string_t s; - return get_ubjson_string(s) and sax->string(s); + return get_ubjson_string(s) && sax->string(s); } case '[': // array @@ -1661,15 +2051,15 @@ class binary_reader */ bool get_ubjson_array() { - std::pair size_and_type; - if (JSON_HEDLEY_UNLIKELY(not get_ubjson_size_type(size_and_type))) + std::pair size_and_type; + if (JSON_HEDLEY_UNLIKELY(!get_ubjson_size_type(size_and_type))) { return false; } if (size_and_type.first != string_t::npos) { - if (JSON_HEDLEY_UNLIKELY(not sax->start_array(size_and_type.first))) + if (JSON_HEDLEY_UNLIKELY(!sax->start_array(size_and_type.first))) { return false; } @@ -1680,7 +2070,7 @@ class binary_reader { for (std::size_t i = 0; i < size_and_type.first; ++i) { - if (JSON_HEDLEY_UNLIKELY(not get_ubjson_value(size_and_type.second))) + if (JSON_HEDLEY_UNLIKELY(!get_ubjson_value(size_and_type.second))) { return false; } @@ -1691,7 +2081,7 @@ class binary_reader { for (std::size_t i = 0; i < size_and_type.first; ++i) { - if (JSON_HEDLEY_UNLIKELY(not parse_ubjson_internal())) + if (JSON_HEDLEY_UNLIKELY(!parse_ubjson_internal())) { return false; } @@ -1700,14 +2090,14 @@ class binary_reader } else { - if (JSON_HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1)))) + if (JSON_HEDLEY_UNLIKELY(!sax->start_array(std::size_t(-1)))) { return false; } while (current != ']') { - if (JSON_HEDLEY_UNLIKELY(not parse_ubjson_internal(false))) + if (JSON_HEDLEY_UNLIKELY(!parse_ubjson_internal(false))) { return false; } @@ -1723,8 +2113,8 @@ class binary_reader */ bool get_ubjson_object() { - std::pair size_and_type; - if (JSON_HEDLEY_UNLIKELY(not get_ubjson_size_type(size_and_type))) + std::pair size_and_type; + if (JSON_HEDLEY_UNLIKELY(!get_ubjson_size_type(size_and_type))) { return false; } @@ -1732,7 +2122,7 @@ class binary_reader string_t key; if (size_and_type.first != string_t::npos) { - if (JSON_HEDLEY_UNLIKELY(not sax->start_object(size_and_type.first))) + if (JSON_HEDLEY_UNLIKELY(!sax->start_object(size_and_type.first))) { return false; } @@ -1741,11 +2131,11 @@ class binary_reader { for (std::size_t i = 0; i < size_and_type.first; ++i) { - if (JSON_HEDLEY_UNLIKELY(not get_ubjson_string(key) or not sax->key(key))) + if (JSON_HEDLEY_UNLIKELY(!get_ubjson_string(key) || !sax->key(key))) { return false; } - if (JSON_HEDLEY_UNLIKELY(not get_ubjson_value(size_and_type.second))) + if (JSON_HEDLEY_UNLIKELY(!get_ubjson_value(size_and_type.second))) { return false; } @@ -1756,11 +2146,11 @@ class binary_reader { for (std::size_t i = 0; i < size_and_type.first; ++i) { - if (JSON_HEDLEY_UNLIKELY(not get_ubjson_string(key) or not sax->key(key))) + if (JSON_HEDLEY_UNLIKELY(!get_ubjson_string(key) || !sax->key(key))) { return false; } - if (JSON_HEDLEY_UNLIKELY(not parse_ubjson_internal())) + if (JSON_HEDLEY_UNLIKELY(!parse_ubjson_internal())) { return false; } @@ -1770,18 +2160,18 @@ class binary_reader } else { - if (JSON_HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1)))) + if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::size_t(-1)))) { return false; } while (current != '}') { - if (JSON_HEDLEY_UNLIKELY(not get_ubjson_string(key, false) or not sax->key(key))) + if (JSON_HEDLEY_UNLIKELY(!get_ubjson_string(key, false) || !sax->key(key))) { return false; } - if (JSON_HEDLEY_UNLIKELY(not parse_ubjson_internal())) + if (JSON_HEDLEY_UNLIKELY(!parse_ubjson_internal())) { return false; } @@ -1793,6 +2183,58 @@ class binary_reader return sax->end_object(); } + // Note, no reader for UBJSON binary types is implemented because they do + // not exist + + bool get_ubjson_high_precision_number() + { + // get size of following number string + std::size_t size{}; + auto res = get_ubjson_size_value(size); + if (JSON_HEDLEY_UNLIKELY(!res)) + { + return res; + } + + // get number string + std::vector number_vector; + for (std::size_t i = 0; i < size; ++i) + { + get(); + if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson, "number"))) + { + return false; + } + number_vector.push_back(static_cast(current)); + } + + // parse number string + auto number_ia = detail::input_adapter(std::forward(number_vector)); + auto number_lexer = detail::lexer(std::move(number_ia), false); + const auto result_number = number_lexer.scan(); + const auto number_string = number_lexer.get_token_string(); + const auto result_remainder = number_lexer.scan(); + + using token_type = typename detail::lexer_base::token_type; + + if (JSON_HEDLEY_UNLIKELY(result_remainder != token_type::end_of_input)) + { + return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read, exception_message(input_format_t::ubjson, "invalid number text: " + number_lexer.get_token_string(), "high-precision number"))); + } + + switch (result_number) + { + case token_type::value_integer: + return sax->number_integer(number_lexer.get_number_integer()); + case token_type::value_unsigned: + return sax->number_unsigned(number_lexer.get_number_unsigned()); + case token_type::value_float: + return sax->number_float(number_lexer.get_number_float(), std::move(number_string)); + default: + return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read, exception_message(input_format_t::ubjson, "invalid number text: " + number_lexer.get_token_string(), "high-precision number"))); + } + } + /////////////////////// // Utility functions // /////////////////////// @@ -1802,20 +2244,20 @@ class binary_reader This function provides the interface to the used input adapter. It does not throw in case the input reached EOF, but returns a -'ve valued - `std::char_traits::eof()` in that case. + `std::char_traits::eof()` in that case. @return character read from the input */ - int get() + char_int_type get() { ++chars_read; - return current = ia->get_character(); + return current = ia.get_character(); } /*! @return character read from the input after ignoring all 'N' entries */ - int get_ignore_noop() + char_int_type get_ignore_noop() { do { @@ -1847,7 +2289,7 @@ class binary_reader for (std::size_t i = 0; i < sizeof(NumberType); ++i) { get(); - if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(format, "number"))) + if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(format, "number"))) { return false; } @@ -1888,15 +2330,49 @@ class binary_reader string_t& result) { bool success = true; - std::generate_n(std::back_inserter(result), len, [this, &success, &format]() + for (NumberType i = 0; i < len; i++) + { + get(); + if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(format, "string"))) + { + success = false; + break; + } + result.push_back(static_cast(current)); + }; + return success; + } + + /*! + @brief create a byte array by reading bytes from the input + + @tparam NumberType the type of the number + @param[in] format the current format (for diagnostics) + @param[in] len number of bytes to read + @param[out] result byte array created by reading @a len bytes + + @return whether byte array creation completed + + @note We can not reserve @a len bytes for the result, because @a len + may be too large. Usually, @ref unexpect_eof() detects the end of + the input before we run out of memory. + */ + template + bool get_binary(const input_format_t format, + const NumberType len, + binary_t& result) + { + bool success = true; + for (NumberType i = 0; i < len; i++) { get(); - if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(format, "string"))) + if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(format, "binary"))) { success = false; + break; } - return static_cast(current); - }); + result.push_back(static_cast(current)); + } return success; } @@ -1908,7 +2384,7 @@ class binary_reader JSON_HEDLEY_NON_NULL(3) bool unexpect_eof(const input_format_t format, const char* context) const { - if (JSON_HEDLEY_UNLIKELY(current == std::char_traits::eof())) + if (JSON_HEDLEY_UNLIKELY(current == std::char_traits::eof())) { return sax->parse_error(chars_read, "", parse_error::create(110, chars_read, exception_message(format, "unexpected end of input", context))); @@ -1957,7 +2433,7 @@ class binary_reader break; default: // LCOV_EXCL_LINE - assert(false); // LCOV_EXCL_LINE + JSON_ASSERT(false); // LCOV_EXCL_LINE } return error_msg + " " + context + ": " + detail; @@ -1965,10 +2441,10 @@ class binary_reader private: /// input adapter - input_adapter_t ia = nullptr; + InputAdapterType ia; /// the current character - int current = std::char_traits::eof(); + char_int_type current = std::char_traits::eof(); /// the number of characters read std::size_t chars_read = 0; diff --git a/mock/nlohmann/detail/input/input_adapters.hpp b/mock/nlohmann/detail/input/input_adapters.hpp index 9512a771eef1f00c5f83b935df2057793da196b8..63921ca55ce9e63dc5174ceda92b3a2aa05e7da1 100644 --- a/mock/nlohmann/detail/input/input_adapters.hpp +++ b/mock/nlohmann/detail/input/input_adapters.hpp @@ -1,7 +1,6 @@ #pragma once #include // array -#include // assert #include // size_t #include //FILE * #include // strlen @@ -27,36 +26,17 @@ enum class input_format_t { json, cbor, msgpack, ubjson, bson }; // input adapters // //////////////////// -/*! -@brief abstract input adapter interface - -Produces a stream of std::char_traits::int_type characters from a -std::istream, a buffer, or some other input type. Accepts the return of -exactly one non-EOF character for future input. The int_type characters -returned consist of all valid char values as positive values (typically -unsigned char), plus an EOF value outside that range, specified by the value -of the function std::char_traits::eof(). This value is typically -1, but -could be any arbitrary value which is not a valid char value. -*/ -struct input_adapter_protocol -{ - /// get a character [0,255] or std::char_traits::eof(). - virtual std::char_traits::int_type get_character() = 0; - virtual ~input_adapter_protocol() = default; -}; - -/// a type to simplify interfaces -using input_adapter_t = std::shared_ptr; - /*! Input adapter for stdio file access. This adapter read only 1 byte and do not use any buffer. This adapter is a very low level adapter. */ -class file_input_adapter : public input_adapter_protocol +class file_input_adapter { public: + using char_type = char; + JSON_HEDLEY_NON_NULL(2) - explicit file_input_adapter(std::FILE* f) noexcept + explicit file_input_adapter(std::FILE* f) noexcept : m_file(f) {} @@ -64,10 +44,9 @@ class file_input_adapter : public input_adapter_protocol file_input_adapter(const file_input_adapter&) = delete; file_input_adapter(file_input_adapter&&) = default; file_input_adapter& operator=(const file_input_adapter&) = delete; - file_input_adapter& operator=(file_input_adapter&&) = default; - ~file_input_adapter() override = default; + file_input_adapter& operator=(file_input_adapter&&) = delete; - std::char_traits::int_type get_character() noexcept override + std::char_traits::int_type get_character() noexcept { return std::fgetc(m_file); } @@ -87,92 +66,111 @@ characters following those used in parsing the JSON input. Clears the std::istream flags; any input errors (e.g., EOF) will be detected by the first subsequent call for input from the std::istream. */ -class input_stream_adapter : public input_adapter_protocol +class input_stream_adapter { public: - ~input_stream_adapter() override + using char_type = char; + + ~input_stream_adapter() { // clear stream flags; we use underlying streambuf I/O, do not // maintain ifstream flags, except eof - is.clear(is.rdstate() & std::ios::eofbit); + if (is != nullptr) + { + is->clear(is->rdstate() & std::ios::eofbit); + } } explicit input_stream_adapter(std::istream& i) - : is(i), sb(*i.rdbuf()) + : is(&i), sb(i.rdbuf()) {} // delete because of pointer members input_stream_adapter(const input_stream_adapter&) = delete; input_stream_adapter& operator=(input_stream_adapter&) = delete; - input_stream_adapter(input_stream_adapter&&) = delete; - input_stream_adapter& operator=(input_stream_adapter&&) = delete; + input_stream_adapter& operator=(input_stream_adapter&& rhs) = delete; + + input_stream_adapter(input_stream_adapter&& rhs) noexcept : is(rhs.is), sb(rhs.sb) + { + rhs.is = nullptr; + rhs.sb = nullptr; + } // std::istream/std::streambuf use std::char_traits::to_int_type, to // ensure that std::char_traits::eof() and the character 0xFF do not // end up as the same value, eg. 0xFFFFFFFF. - std::char_traits::int_type get_character() override + std::char_traits::int_type get_character() { - auto res = sb.sbumpc(); + auto res = sb->sbumpc(); // set eof manually, as we don't use the istream interface. - if (res == EOF) + if (JSON_HEDLEY_UNLIKELY(res == EOF)) { - is.clear(is.rdstate() | std::ios::eofbit); + is->clear(is->rdstate() | std::ios::eofbit); } return res; } private: /// the associated input stream - std::istream& is; - std::streambuf& sb; + std::istream* is = nullptr; + std::streambuf* sb = nullptr; }; -/// input adapter for buffer input -class input_buffer_adapter : public input_adapter_protocol +// General-purpose iterator-based adapter. It might not be as fast as +// theoretically possible for some containers, but it is extremely versatile. +template +class iterator_input_adapter { public: - input_buffer_adapter(const char* b, const std::size_t l) noexcept - : cursor(b), limit(b == nullptr ? nullptr : (b + l)) - {} + using char_type = typename std::iterator_traits::value_type; - // delete because of pointer members - input_buffer_adapter(const input_buffer_adapter&) = delete; - input_buffer_adapter& operator=(input_buffer_adapter&) = delete; - input_buffer_adapter(input_buffer_adapter&&) = delete; - input_buffer_adapter& operator=(input_buffer_adapter&&) = delete; - ~input_buffer_adapter() override = default; + iterator_input_adapter(IteratorType first, IteratorType last) + : current(std::move(first)), end(std::move(last)) {} - std::char_traits::int_type get_character() noexcept override + typename std::char_traits::int_type get_character() { - if (JSON_HEDLEY_LIKELY(cursor < limit)) + if (JSON_HEDLEY_LIKELY(current != end)) { - assert(cursor != nullptr and limit != nullptr); - return std::char_traits::to_int_type(*(cursor++)); + auto result = std::char_traits::to_int_type(*current); + std::advance(current, 1); + return result; + } + else + { + return std::char_traits::eof(); } - - return std::char_traits::eof(); } private: - /// pointer to the current character - const char* cursor; - /// pointer past the last character - const char* const limit; + IteratorType current; + IteratorType end; + + template + friend struct wide_string_input_helper; + + bool empty() const + { + return current == end; + } + }; -template -struct wide_string_input_helper + +template +struct wide_string_input_helper; + +template +struct wide_string_input_helper { // UTF-32 - static void fill_buffer(const WideStringType& str, - size_t& current_wchar, + static void fill_buffer(BaseInputAdapter& input, std::array::int_type, 4>& utf8_bytes, size_t& utf8_bytes_index, size_t& utf8_bytes_filled) { utf8_bytes_index = 0; - if (current_wchar == str.size()) + if (JSON_HEDLEY_UNLIKELY(input.empty())) { utf8_bytes[0] = std::char_traits::eof(); utf8_bytes_filled = 1; @@ -180,7 +178,7 @@ struct wide_string_input_helper else { // get the current character - const auto wc = static_cast(str[current_wchar++]); + const auto wc = input.get_character(); // UTF-32 to UTF-8 encoding if (wc < 0x80) @@ -190,23 +188,23 @@ struct wide_string_input_helper } else if (wc <= 0x7FF) { - utf8_bytes[0] = static_cast::int_type>(0xC0u | ((wc >> 6u) & 0x1Fu)); - utf8_bytes[1] = static_cast::int_type>(0x80u | (wc & 0x3Fu)); + utf8_bytes[0] = static_cast::int_type>(0xC0u | ((static_cast(wc) >> 6u) & 0x1Fu)); + utf8_bytes[1] = static_cast::int_type>(0x80u | (static_cast(wc) & 0x3Fu)); utf8_bytes_filled = 2; } else if (wc <= 0xFFFF) { - utf8_bytes[0] = static_cast::int_type>(0xE0u | ((wc >> 12u) & 0x0Fu)); - utf8_bytes[1] = static_cast::int_type>(0x80u | ((wc >> 6u) & 0x3Fu)); - utf8_bytes[2] = static_cast::int_type>(0x80u | (wc & 0x3Fu)); + utf8_bytes[0] = static_cast::int_type>(0xE0u | ((static_cast(wc) >> 12u) & 0x0Fu)); + utf8_bytes[1] = static_cast::int_type>(0x80u | ((static_cast(wc) >> 6u) & 0x3Fu)); + utf8_bytes[2] = static_cast::int_type>(0x80u | (static_cast(wc) & 0x3Fu)); utf8_bytes_filled = 3; } else if (wc <= 0x10FFFF) { - utf8_bytes[0] = static_cast::int_type>(0xF0u | ((wc >> 18u) & 0x07u)); - utf8_bytes[1] = static_cast::int_type>(0x80u | ((wc >> 12u) & 0x3Fu)); - utf8_bytes[2] = static_cast::int_type>(0x80u | ((wc >> 6u) & 0x3Fu)); - utf8_bytes[3] = static_cast::int_type>(0x80u | (wc & 0x3Fu)); + utf8_bytes[0] = static_cast::int_type>(0xF0u | ((static_cast(wc) >> 18u) & 0x07u)); + utf8_bytes[1] = static_cast::int_type>(0x80u | ((static_cast(wc) >> 12u) & 0x3Fu)); + utf8_bytes[2] = static_cast::int_type>(0x80u | ((static_cast(wc) >> 6u) & 0x3Fu)); + utf8_bytes[3] = static_cast::int_type>(0x80u | (static_cast(wc) & 0x3Fu)); utf8_bytes_filled = 4; } else @@ -219,19 +217,18 @@ struct wide_string_input_helper } }; -template -struct wide_string_input_helper +template +struct wide_string_input_helper { // UTF-16 - static void fill_buffer(const WideStringType& str, - size_t& current_wchar, + static void fill_buffer(BaseInputAdapter& input, std::array::int_type, 4>& utf8_bytes, size_t& utf8_bytes_index, size_t& utf8_bytes_filled) { utf8_bytes_index = 0; - if (current_wchar == str.size()) + if (JSON_HEDLEY_UNLIKELY(input.empty())) { utf8_bytes[0] = std::char_traits::eof(); utf8_bytes_filled = 1; @@ -239,7 +236,7 @@ struct wide_string_input_helper else { // get the current character - const auto wc = static_cast(str[current_wchar++]); + const auto wc = input.get_character(); // UTF-16 to UTF-8 encoding if (wc < 0x80) @@ -249,23 +246,23 @@ struct wide_string_input_helper } else if (wc <= 0x7FF) { - utf8_bytes[0] = static_cast::int_type>(0xC0u | ((wc >> 6u))); - utf8_bytes[1] = static_cast::int_type>(0x80u | (wc & 0x3Fu)); + utf8_bytes[0] = static_cast::int_type>(0xC0u | ((static_cast(wc) >> 6u))); + utf8_bytes[1] = static_cast::int_type>(0x80u | (static_cast(wc) & 0x3Fu)); utf8_bytes_filled = 2; } - else if (0xD800 > wc or wc >= 0xE000) + else if (0xD800 > wc || wc >= 0xE000) { - utf8_bytes[0] = static_cast::int_type>(0xE0u | ((wc >> 12u))); - utf8_bytes[1] = static_cast::int_type>(0x80u | ((wc >> 6u) & 0x3Fu)); - utf8_bytes[2] = static_cast::int_type>(0x80u | (wc & 0x3Fu)); + utf8_bytes[0] = static_cast::int_type>(0xE0u | ((static_cast(wc) >> 12u))); + utf8_bytes[1] = static_cast::int_type>(0x80u | ((static_cast(wc) >> 6u) & 0x3Fu)); + utf8_bytes[2] = static_cast::int_type>(0x80u | (static_cast(wc) & 0x3Fu)); utf8_bytes_filled = 3; } else { - if (current_wchar < str.size()) + if (JSON_HEDLEY_UNLIKELY(!input.empty())) { - const auto wc2 = static_cast(str[current_wchar++]); - const auto charcode = 0x10000u + (((wc & 0x3FFu) << 10u) | (wc2 & 0x3FFu)); + const auto wc2 = static_cast(input.get_character()); + const auto charcode = 0x10000u + (((static_cast(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu)); utf8_bytes[0] = static_cast::int_type>(0xF0u | (charcode >> 18u)); utf8_bytes[1] = static_cast::int_type>(0x80u | ((charcode >> 12u) & 0x3Fu)); utf8_bytes[2] = static_cast::int_type>(0x80u | ((charcode >> 6u) & 0x3Fu)); @@ -274,8 +271,6 @@ struct wide_string_input_helper } else { - // unknown character - ++current_wchar; utf8_bytes[0] = static_cast::int_type>(wc); utf8_bytes_filled = 1; } @@ -284,44 +279,42 @@ struct wide_string_input_helper } }; -template -class wide_string_input_adapter : public input_adapter_protocol +// Wraps another input apdater to convert wide character types into individual bytes. +template +class wide_string_input_adapter { public: - explicit wide_string_input_adapter(const WideStringType& w) noexcept - : str(w) - {} + using char_type = char; - std::char_traits::int_type get_character() noexcept override + wide_string_input_adapter(BaseInputAdapter base) + : base_adapter(base) {} + + typename std::char_traits::int_type get_character() noexcept { // check if buffer needs to be filled if (utf8_bytes_index == utf8_bytes_filled) { - fill_buffer(); + fill_buffer(); - assert(utf8_bytes_filled > 0); - assert(utf8_bytes_index == 0); + JSON_ASSERT(utf8_bytes_filled > 0); + JSON_ASSERT(utf8_bytes_index == 0); } // use buffer - assert(utf8_bytes_filled > 0); - assert(utf8_bytes_index < utf8_bytes_filled); + JSON_ASSERT(utf8_bytes_filled > 0); + JSON_ASSERT(utf8_bytes_index < utf8_bytes_filled); return utf8_bytes[utf8_bytes_index++]; } private: + BaseInputAdapter base_adapter; + template void fill_buffer() { - wide_string_input_helper::fill_buffer(str, current_wchar, utf8_bytes, utf8_bytes_index, utf8_bytes_filled); + wide_string_input_helper::fill_buffer(base_adapter, utf8_bytes, utf8_bytes_index, utf8_bytes_filled); } - /// the wstring to process - const WideStringType& str; - - /// index of the current wchar in str - std::size_t current_wchar = 0; - /// a buffer for UTF-8 bytes std::array::int_type, 4> utf8_bytes = {{0, 0, 0, 0}}; @@ -331,112 +324,131 @@ class wide_string_input_adapter : public input_adapter_protocol std::size_t utf8_bytes_filled = 0; }; -class input_adapter + +template +struct iterator_input_adapter_factory { - public: - // native support - JSON_HEDLEY_NON_NULL(2) - input_adapter(std::FILE* file) - : ia(std::make_shared(file)) {} - /// input adapter for input stream - input_adapter(std::istream& i) - : ia(std::make_shared(i)) {} + using iterator_type = IteratorType; + using char_type = typename std::iterator_traits::value_type; + using adapter_type = iterator_input_adapter; + + static adapter_type create(IteratorType first, IteratorType last) + { + return adapter_type(std::move(first), std::move(last)); + } +}; - /// input adapter for input stream - input_adapter(std::istream&& i) - : ia(std::make_shared(i)) {} +template +struct is_iterator_of_multibyte +{ + using value_type = typename std::iterator_traits::value_type; + enum + { + value = sizeof(value_type) > 1 + }; +}; - input_adapter(const std::wstring& ws) - : ia(std::make_shared>(ws)) {} +template +struct iterator_input_adapter_factory::value>> +{ + using iterator_type = IteratorType; + using char_type = typename std::iterator_traits::value_type; + using base_adapter_type = iterator_input_adapter; + using adapter_type = wide_string_input_adapter; + + static adapter_type create(IteratorType first, IteratorType last) + { + return adapter_type(base_adapter_type(std::move(first), std::move(last))); + } +}; - input_adapter(const std::u16string& ws) - : ia(std::make_shared>(ws)) {} +// General purpose iterator-based input +template +typename iterator_input_adapter_factory::adapter_type input_adapter(IteratorType first, IteratorType last) +{ + using factory_type = iterator_input_adapter_factory; + return factory_type::create(first, last); +} - input_adapter(const std::u32string& ws) - : ia(std::make_shared>(ws)) {} +// Convenience shorthand from container to iterator +template +auto input_adapter(const ContainerType& container) -> decltype(input_adapter(begin(container), end(container))) +{ + // Enable ADL + using std::begin; + using std::end; - /// input adapter for buffer - template::value and - std::is_integral::type>::value and - sizeof(typename std::remove_pointer::type) == 1, - int>::type = 0> - input_adapter(CharT b, std::size_t l) - : ia(std::make_shared(reinterpret_cast(b), l)) {} + return input_adapter(begin(container), end(container)); +} - // derived support +// Special cases with fast paths +inline file_input_adapter input_adapter(std::FILE* file) +{ + return file_input_adapter(file); +} - /// input adapter for string literal - template::value and - std::is_integral::type>::value and - sizeof(typename std::remove_pointer::type) == 1, - int>::type = 0> - input_adapter(CharT b) - : input_adapter(reinterpret_cast(b), - std::strlen(reinterpret_cast(b))) {} +inline input_stream_adapter input_adapter(std::istream& stream) +{ + return input_stream_adapter(stream); +} + +inline input_stream_adapter input_adapter(std::istream&& stream) +{ + return input_stream_adapter(stream); +} + +using contiguous_bytes_input_adapter = decltype(input_adapter(std::declval(), std::declval())); + +// Null-delimited strings, and the like. +template < typename CharT, + typename std::enable_if < + std::is_pointer::value&& + !std::is_array::value&& + std::is_integral::type>::value&& + sizeof(typename std::remove_pointer::type) == 1, + int >::type = 0 > +contiguous_bytes_input_adapter input_adapter(CharT b) +{ + auto length = std::strlen(reinterpret_cast(b)); + const auto* ptr = reinterpret_cast(b); + return input_adapter(ptr, ptr + length); +} + +template +auto input_adapter(T (&array)[N]) -> decltype(input_adapter(array, array + N)) +{ + return input_adapter(array, array + N); +} + +// This class only handles inputs of input_buffer_adapter type. +// It's required so that expressions like {ptr, len} can be implicitely casted +// to the correct adapter. +class span_input_adapter +{ + public: + template < typename CharT, + typename std::enable_if < + std::is_pointer::value&& + std::is_integral::type>::value&& + sizeof(typename std::remove_pointer::type) == 1, + int >::type = 0 > + span_input_adapter(CharT b, std::size_t l) + : ia(reinterpret_cast(b), reinterpret_cast(b) + l) {} - /// input adapter for iterator range with contiguous storage template::iterator_category, std::random_access_iterator_tag>::value, int>::type = 0> - input_adapter(IteratorType first, IteratorType last) - { -#ifndef NDEBUG - // assertion to check that the iterator range is indeed contiguous, - // see http://stackoverflow.com/a/35008842/266378 for more discussion - const auto is_contiguous = std::accumulate( - first, last, std::pair(true, 0), - [&first](std::pair res, decltype(*first) val) - { - res.first &= (val == *(std::next(std::addressof(*first), res.second++))); - return res; - }).first; - assert(is_contiguous); -#endif - - // assertion to check that each element is 1 byte long - static_assert( - sizeof(typename iterator_traits::value_type) == 1, - "each element in the iterator range must have the size of 1 byte"); - - const auto len = static_cast(std::distance(first, last)); - if (JSON_HEDLEY_LIKELY(len > 0)) - { - // there is at least one element: use the address of first - ia = std::make_shared(reinterpret_cast(&(*first)), len); - } - else - { - // the address of first cannot be used: use nullptr - ia = std::make_shared(nullptr, len); - } - } - - /// input adapter for array - template - input_adapter(T (&array)[N]) - : input_adapter(std::begin(array), std::end(array)) {} - - /// input adapter for contiguous container - template::value and - std::is_base_of()))>::iterator_category>::value, - int>::type = 0> - input_adapter(const ContiguousContainer& c) - : input_adapter(std::begin(c), std::end(c)) {} + span_input_adapter(IteratorType first, IteratorType last) + : ia(input_adapter(first, last)) {} - operator input_adapter_t() + contiguous_bytes_input_adapter&& get() { - return ia; + return std::move(ia); } private: - /// the actual adapter - input_adapter_t ia = nullptr; + contiguous_bytes_input_adapter ia; }; } // namespace detail } // namespace nlohmann diff --git a/mock/nlohmann/detail/input/json_sax.hpp b/mock/nlohmann/detail/input/json_sax.hpp index 606b7862ebda3e78306ecc4f72ffeb94bcd2a487..223acd60ebd699b7d24456921ddbd39147584366 100644 --- a/mock/nlohmann/detail/input/json_sax.hpp +++ b/mock/nlohmann/detail/input/json_sax.hpp @@ -1,6 +1,5 @@ #pragma once -#include // assert #include #include // string #include // move @@ -23,14 +22,11 @@ input. template struct json_sax { - /// type for (signed) integers using number_integer_t = typename BasicJsonType::number_integer_t; - /// type for unsigned integers using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - /// type for floating-point numbers using number_float_t = typename BasicJsonType::number_float_t; - /// type for strings using string_t = typename BasicJsonType::string_t; + using binary_t = typename BasicJsonType::binary_t; /*! @brief a null value was read @@ -75,6 +71,14 @@ struct json_sax */ virtual bool string(string_t& val) = 0; + /*! + @brief a binary string was read + @param[in] val binary value + @return whether parsing should proceed + @note It is safe to move the passed binary. + */ + virtual bool binary(binary_t& val) = 0; + /*! @brief the beginning of an object was read @param[in] elements number of object elements or -1 if unknown @@ -149,6 +153,7 @@ class json_sax_dom_parser using number_unsigned_t = typename BasicJsonType::number_unsigned_t; using number_float_t = typename BasicJsonType::number_float_t; using string_t = typename BasicJsonType::string_t; + using binary_t = typename BasicJsonType::binary_t; /*! @param[in, out] r reference to a JSON value that is manipulated while @@ -202,11 +207,17 @@ class json_sax_dom_parser return true; } + bool binary(binary_t& val) + { + handle_value(std::move(val)); + return true; + } + bool start_object(std::size_t len) { ref_stack.push_back(handle_value(BasicJsonType::value_t::object)); - if (JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) + if (JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size())) { JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len))); @@ -232,7 +243,7 @@ class json_sax_dom_parser { ref_stack.push_back(handle_value(BasicJsonType::value_t::array)); - if (JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) + if (JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size())) { JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len))); @@ -247,30 +258,15 @@ class json_sax_dom_parser return true; } + template bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, - const detail::exception& ex) + const Exception& ex) { errored = true; + static_cast(ex); if (allow_exceptions) { - // determine the proper exception type from the id - switch ((ex.id / 100) % 100) - { - case 1: - JSON_THROW(*static_cast(&ex)); - case 4: - JSON_THROW(*static_cast(&ex)); - // LCOV_EXCL_START - case 2: - JSON_THROW(*static_cast(&ex)); - case 3: - JSON_THROW(*static_cast(&ex)); - case 5: - JSON_THROW(*static_cast(&ex)); - default: - assert(false); - // LCOV_EXCL_STOP - } + JSON_THROW(ex); } return false; } @@ -297,7 +293,7 @@ class json_sax_dom_parser return &root; } - assert(ref_stack.back()->is_array() or ref_stack.back()->is_object()); + JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object()); if (ref_stack.back()->is_array()) { @@ -305,8 +301,8 @@ class json_sax_dom_parser return &(ref_stack.back()->m_value.array->back()); } - assert(ref_stack.back()->is_object()); - assert(object_element); + JSON_ASSERT(ref_stack.back()->is_object()); + JSON_ASSERT(object_element); *object_element = BasicJsonType(std::forward(v)); return object_element; } @@ -331,6 +327,7 @@ class json_sax_dom_callback_parser using number_unsigned_t = typename BasicJsonType::number_unsigned_t; using number_float_t = typename BasicJsonType::number_float_t; using string_t = typename BasicJsonType::string_t; + using binary_t = typename BasicJsonType::binary_t; using parser_callback_t = typename BasicJsonType::parser_callback_t; using parse_event_t = typename BasicJsonType::parse_event_t; @@ -385,6 +382,12 @@ class json_sax_dom_callback_parser return true; } + bool binary(binary_t& val) + { + handle_value(std::move(val)); + return true; + } + bool start_object(std::size_t len) { // check callback for object start @@ -395,7 +398,7 @@ class json_sax_dom_callback_parser ref_stack.push_back(val.second); // check object limit - if (ref_stack.back() and JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) + if (ref_stack.back() && JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size())) { JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len))); } @@ -412,7 +415,7 @@ class json_sax_dom_callback_parser key_keep_stack.push_back(keep); // add discarded value at given key and store the reference for later - if (keep and ref_stack.back()) + if (keep && ref_stack.back()) { object_element = &(ref_stack.back()->m_value.object->operator[](val) = discarded); } @@ -422,18 +425,18 @@ class json_sax_dom_callback_parser bool end_object() { - if (ref_stack.back() and not callback(static_cast(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back())) + if (ref_stack.back() && !callback(static_cast(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back())) { // discard object *ref_stack.back() = discarded; } - assert(not ref_stack.empty()); - assert(not keep_stack.empty()); + JSON_ASSERT(!ref_stack.empty()); + JSON_ASSERT(!keep_stack.empty()); ref_stack.pop_back(); keep_stack.pop_back(); - if (not ref_stack.empty() and ref_stack.back() and ref_stack.back()->is_object()) + if (!ref_stack.empty() && ref_stack.back() && ref_stack.back()->is_structured()) { // remove discarded value for (auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it) @@ -458,7 +461,7 @@ class json_sax_dom_callback_parser ref_stack.push_back(val.second); // check array limit - if (ref_stack.back() and JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) + if (ref_stack.back() && JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size())) { JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len))); } @@ -473,20 +476,20 @@ class json_sax_dom_callback_parser if (ref_stack.back()) { keep = callback(static_cast(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back()); - if (not keep) + if (!keep) { // discard array *ref_stack.back() = discarded; } } - assert(not ref_stack.empty()); - assert(not keep_stack.empty()); + JSON_ASSERT(!ref_stack.empty()); + JSON_ASSERT(!keep_stack.empty()); ref_stack.pop_back(); keep_stack.pop_back(); // remove discarded value - if (not keep and not ref_stack.empty() and ref_stack.back()->is_array()) + if (!keep && !ref_stack.empty() && ref_stack.back()->is_array()) { ref_stack.back()->m_value.array->pop_back(); } @@ -494,30 +497,15 @@ class json_sax_dom_callback_parser return true; } + template bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, - const detail::exception& ex) + const Exception& ex) { errored = true; + static_cast(ex); if (allow_exceptions) { - // determine the proper exception type from the id - switch ((ex.id / 100) % 100) - { - case 1: - JSON_THROW(*static_cast(&ex)); - case 4: - JSON_THROW(*static_cast(&ex)); - // LCOV_EXCL_START - case 2: - JSON_THROW(*static_cast(&ex)); - case 3: - JSON_THROW(*static_cast(&ex)); - case 5: - JSON_THROW(*static_cast(&ex)); - default: - assert(false); - // LCOV_EXCL_STOP - } + JSON_THROW(ex); } return false; } @@ -546,11 +534,11 @@ class json_sax_dom_callback_parser template std::pair handle_value(Value&& v, const bool skip_callback = false) { - assert(not keep_stack.empty()); + JSON_ASSERT(!keep_stack.empty()); // do not handle this value if we know it would be added to a discarded // container - if (not keep_stack.back()) + if (!keep_stack.back()) { return {false, nullptr}; } @@ -559,10 +547,10 @@ class json_sax_dom_callback_parser auto value = BasicJsonType(std::forward(v)); // check callback - const bool keep = skip_callback or callback(static_cast(ref_stack.size()), parse_event_t::value, value); + const bool keep = skip_callback || callback(static_cast(ref_stack.size()), parse_event_t::value, value); // do not handle this value if we just learnt it shall be discarded - if (not keep) + if (!keep) { return {false, nullptr}; } @@ -575,13 +563,13 @@ class json_sax_dom_callback_parser // skip this value if we already decided to skip the parent // (https://github.com/nlohmann/json/issues/971#issuecomment-413678360) - if (not ref_stack.back()) + if (!ref_stack.back()) { return {false, nullptr}; } // we now only expect arrays and objects - assert(ref_stack.back()->is_array() or ref_stack.back()->is_object()); + JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object()); // array if (ref_stack.back()->is_array()) @@ -591,18 +579,18 @@ class json_sax_dom_callback_parser } // object - assert(ref_stack.back()->is_object()); + JSON_ASSERT(ref_stack.back()->is_object()); // check if we should store an element for the current key - assert(not key_keep_stack.empty()); + JSON_ASSERT(!key_keep_stack.empty()); const bool store_element = key_keep_stack.back(); key_keep_stack.pop_back(); - if (not store_element) + if (!store_element) { return {false, nullptr}; } - assert(object_element); + JSON_ASSERT(object_element); *object_element = std::move(value); return {true, object_element}; } @@ -635,6 +623,7 @@ class json_sax_acceptor using number_unsigned_t = typename BasicJsonType::number_unsigned_t; using number_float_t = typename BasicJsonType::number_float_t; using string_t = typename BasicJsonType::string_t; + using binary_t = typename BasicJsonType::binary_t; bool null() { @@ -666,7 +655,12 @@ class json_sax_acceptor return true; } - bool start_object(std::size_t /*unused*/ = std::size_t(-1)) + bool binary(binary_t& /*unused*/) + { + return true; + } + + bool start_object(std::size_t /*unused*/ = std::size_t(-1)) { return true; } @@ -681,7 +675,7 @@ class json_sax_acceptor return true; } - bool start_array(std::size_t /*unused*/ = std::size_t(-1)) + bool start_array(std::size_t /*unused*/ = std::size_t(-1)) { return true; } diff --git a/mock/nlohmann/detail/input/lexer.hpp b/mock/nlohmann/detail/input/lexer.hpp index 0843d749d6a6d376ddb1bc2b0629d683a2921b29..0a9601352e49fcd99ef302cc54673cc22692ab01 100644 --- a/mock/nlohmann/detail/input/lexer.hpp +++ b/mock/nlohmann/detail/input/lexer.hpp @@ -22,19 +22,9 @@ namespace detail // lexer // /////////// -/*! -@brief lexical analysis - -This class organizes the lexical analysis during JSON deserialization. -*/ template -class lexer +class lexer_base { - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - using string_t = typename BasicJsonType::string_t; - public: /// token types for the parser enum class token_type @@ -75,9 +65,9 @@ class lexer return "null literal"; case token_type::value_string: return "string literal"; - case lexer::token_type::value_unsigned: - case lexer::token_type::value_integer: - case lexer::token_type::value_float: + case token_type::value_unsigned: + case token_type::value_integer: + case token_type::value_float: return "number literal"; case token_type::begin_array: return "'['"; @@ -103,15 +93,36 @@ class lexer // LCOV_EXCL_STOP } } +}; +/*! +@brief lexical analysis - explicit lexer(detail::input_adapter_t&& adapter) - : ia(std::move(adapter)), decimal_point_char(get_decimal_point()) {} +This class organizes the lexical analysis during JSON deserialization. +*/ +template +class lexer : public lexer_base +{ + using number_integer_t = typename BasicJsonType::number_integer_t; + using number_unsigned_t = typename BasicJsonType::number_unsigned_t; + using number_float_t = typename BasicJsonType::number_float_t; + using string_t = typename BasicJsonType::string_t; + using char_type = typename InputAdapterType::char_type; + using char_int_type = typename std::char_traits::int_type; + + public: + using token_type = typename lexer_base::token_type; + + explicit lexer(InputAdapterType&& adapter, bool ignore_comments_ = false) + : ia(std::move(adapter)) + , ignore_comments(ignore_comments_) + , decimal_point_char(static_cast(get_decimal_point())) + {} // delete because of pointer members lexer(const lexer&) = delete; - lexer(lexer&&) = delete; + lexer(lexer&&) = default; lexer& operator=(lexer&) = delete; - lexer& operator=(lexer&&) = delete; + lexer& operator=(lexer&&) = default; ~lexer() = default; private: @@ -123,8 +134,8 @@ class lexer JSON_HEDLEY_PURE static char get_decimal_point() noexcept { - const auto loc = localeconv(); - assert(loc != nullptr); + const auto* loc = localeconv(); + JSON_ASSERT(loc != nullptr); return (loc->decimal_point == nullptr) ? '.' : *(loc->decimal_point); } @@ -150,7 +161,7 @@ class lexer int get_codepoint() { // this function only makes sense after reading `\u` - assert(current == 'u'); + JSON_ASSERT(current == 'u'); int codepoint = 0; const auto factors = { 12u, 8u, 4u, 0u }; @@ -158,15 +169,15 @@ class lexer { get(); - if (current >= '0' and current <= '9') + if (current >= '0' && current <= '9') { codepoint += static_cast((static_cast(current) - 0x30u) << factor); } - else if (current >= 'A' and current <= 'F') + else if (current >= 'A' && current <= 'F') { codepoint += static_cast((static_cast(current) - 0x37u) << factor); } - else if (current >= 'a' and current <= 'f') + else if (current >= 'a' && current <= 'f') { codepoint += static_cast((static_cast(current) - 0x57u) << factor); } @@ -176,7 +187,7 @@ class lexer } } - assert(0x0000 <= codepoint and codepoint <= 0xFFFF); + JSON_ASSERT(0x0000 <= codepoint && codepoint <= 0xFFFF); return codepoint; } @@ -195,15 +206,15 @@ class lexer @return true if and only if no range violation was detected */ - bool next_byte_in_range(std::initializer_list ranges) + bool next_byte_in_range(std::initializer_list ranges) { - assert(ranges.size() == 2 or ranges.size() == 4 or ranges.size() == 6); + JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6); add(current); for (auto range = ranges.begin(); range != ranges.end(); ++range) { get(); - if (JSON_HEDLEY_LIKELY(*range <= current and current <= *(++range))) + if (JSON_HEDLEY_LIKELY(*range <= current && current <= *(++range))) { add(current); } @@ -238,7 +249,7 @@ class lexer reset(); // we entered the function by reading an open quote - assert(current == '\"'); + JSON_ASSERT(current == '\"'); while (true) { @@ -246,7 +257,7 @@ class lexer switch (get()) { // end of file while parsing string - case std::char_traits::eof(): + case std::char_traits::eof(): { error_message = "invalid string: missing closing quote"; return token_type::parse_error; @@ -309,10 +320,10 @@ class lexer } // check if code point is a high surrogate - if (0xD800 <= codepoint1 and codepoint1 <= 0xDBFF) + if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF) { // expect next \uxxxx entry - if (JSON_HEDLEY_LIKELY(get() == '\\' and get() == 'u')) + if (JSON_HEDLEY_LIKELY(get() == '\\' && get() == 'u')) { const int codepoint2 = get_codepoint(); @@ -323,7 +334,7 @@ class lexer } // check if codepoint2 is a low surrogate - if (JSON_HEDLEY_LIKELY(0xDC00 <= codepoint2 and codepoint2 <= 0xDFFF)) + if (JSON_HEDLEY_LIKELY(0xDC00 <= codepoint2 && codepoint2 <= 0xDFFF)) { // overwrite codepoint codepoint = static_cast( @@ -338,19 +349,19 @@ class lexer } else { - error_message = "invalid string: surrogate U+DC00..U+DFFF must be followed by U+DC00..U+DFFF"; + error_message = "invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF"; return token_type::parse_error; } } else { - error_message = "invalid string: surrogate U+DC00..U+DFFF must be followed by U+DC00..U+DFFF"; + error_message = "invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF"; return token_type::parse_error; } } else { - if (JSON_HEDLEY_UNLIKELY(0xDC00 <= codepoint1 and codepoint1 <= 0xDFFF)) + if (JSON_HEDLEY_UNLIKELY(0xDC00 <= codepoint1 && codepoint1 <= 0xDFFF)) { error_message = "invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF"; return token_type::parse_error; @@ -358,34 +369,34 @@ class lexer } // result of the above calculation yields a proper codepoint - assert(0x00 <= codepoint and codepoint <= 0x10FFFF); + JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF); // translate codepoint into bytes if (codepoint < 0x80) { // 1-byte characters: 0xxxxxxx (ASCII) - add(codepoint); + add(static_cast(codepoint)); } else if (codepoint <= 0x7FF) { // 2-byte characters: 110xxxxx 10xxxxxx - add(static_cast(0xC0u | (static_cast(codepoint) >> 6u))); - add(static_cast(0x80u | (static_cast(codepoint) & 0x3Fu))); + add(static_cast(0xC0u | (static_cast(codepoint) >> 6u))); + add(static_cast(0x80u | (static_cast(codepoint) & 0x3Fu))); } else if (codepoint <= 0xFFFF) { // 3-byte characters: 1110xxxx 10xxxxxx 10xxxxxx - add(static_cast(0xE0u | (static_cast(codepoint) >> 12u))); - add(static_cast(0x80u | ((static_cast(codepoint) >> 6u) & 0x3Fu))); - add(static_cast(0x80u | (static_cast(codepoint) & 0x3Fu))); + add(static_cast(0xE0u | (static_cast(codepoint) >> 12u))); + add(static_cast(0x80u | ((static_cast(codepoint) >> 6u) & 0x3Fu))); + add(static_cast(0x80u | (static_cast(codepoint) & 0x3Fu))); } else { // 4-byte characters: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx - add(static_cast(0xF0u | (static_cast(codepoint) >> 18u))); - add(static_cast(0x80u | ((static_cast(codepoint) >> 12u) & 0x3Fu))); - add(static_cast(0x80u | ((static_cast(codepoint) >> 6u) & 0x3Fu))); - add(static_cast(0x80u | (static_cast(codepoint) & 0x3Fu))); + add(static_cast(0xF0u | (static_cast(codepoint) >> 18u))); + add(static_cast(0x80u | ((static_cast(codepoint) >> 12u) & 0x3Fu))); + add(static_cast(0x80u | ((static_cast(codepoint) >> 6u) & 0x3Fu))); + add(static_cast(0x80u | (static_cast(codepoint) & 0x3Fu))); } break; @@ -725,7 +736,7 @@ class lexer case 0xDE: case 0xDF: { - if (JSON_HEDLEY_UNLIKELY(not next_byte_in_range({0x80, 0xBF}))) + if (JSON_HEDLEY_UNLIKELY(!next_byte_in_range({0x80, 0xBF}))) { return token_type::parse_error; } @@ -735,7 +746,7 @@ class lexer // U+0800..U+0FFF: bytes E0 A0..BF 80..BF case 0xE0: { - if (JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0xA0, 0xBF, 0x80, 0xBF})))) + if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0xA0, 0xBF, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -759,7 +770,7 @@ class lexer case 0xEE: case 0xEF: { - if (JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0xBF, 0x80, 0xBF})))) + if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0xBF, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -769,7 +780,7 @@ class lexer // U+D000..U+D7FF: bytes ED 80..9F 80..BF case 0xED: { - if (JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0x9F, 0x80, 0xBF})))) + if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0x9F, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -779,7 +790,7 @@ class lexer // U+10000..U+3FFFF F0 90..BF 80..BF 80..BF case 0xF0: { - if (JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x90, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) + if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x90, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -791,7 +802,7 @@ class lexer case 0xF2: case 0xF3: { - if (JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) + if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -801,7 +812,7 @@ class lexer // U+100000..U+10FFFF F4 80..8F 80..BF 80..BF case 0xF4: { - if (JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0x8F, 0x80, 0xBF, 0x80, 0xBF})))) + if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0x8F, 0x80, 0xBF, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -818,6 +829,77 @@ class lexer } } + /*! + * @brief scan a comment + * @return whether comment could be scanned successfully + */ + bool scan_comment() + { + switch (get()) + { + // single-line comments skip input until a newline or EOF is read + case '/': + { + while (true) + { + switch (get()) + { + case '\n': + case '\r': + case std::char_traits::eof(): + case '\0': + return true; + + default: + break; + } + } + } + + // multi-line comments skip input until */ is read + case '*': + { + while (true) + { + switch (get()) + { + case std::char_traits::eof(): + case '\0': + { + error_message = "invalid comment; missing closing '*/'"; + return false; + } + + case '*': + { + switch (get()) + { + case '/': + return true; + + default: + { + unget(); + continue; + } + } + } + + default: + continue; + } + } + } + + // unexpected character after reading '/' + default: + { + error_message = "invalid comment; expecting '/' or '*' after '/'"; + return false; + } + } + } + JSON_HEDLEY_NON_NULL(2) static void strtof(float& f, const char* str, char** endptr) noexcept { @@ -853,7 +935,7 @@ class lexer minus | zero | any1 | [error] | [error] | [error] | [error] | [error] zero | done | done | exponent | done | done | decimal1 | done any1 | any1 | any1 | exponent | done | done | decimal1 | done - decimal1 | decimal2 | [error] | [error] | [error] | [error] | [error] | [error] + decimal1 | decimal2 | decimal2 | [error] | [error] | [error] | [error] | [error] decimal2 | decimal2 | decimal2 | exponent | done | done | done | done exponent | any2 | any2 | [error] | sign | sign | [error] | [error] sign | any2 | any2 | [error] | [error] | [error] | [error] | [error] @@ -916,7 +998,7 @@ class lexer // all other characters are rejected outside scan_number() default: // LCOV_EXCL_LINE - assert(false); // LCOV_EXCL_LINE + JSON_ASSERT(false); // LCOV_EXCL_LINE } scan_number_minus: @@ -1163,7 +1245,7 @@ scan_number_done: const auto x = std::strtoull(token_buffer.data(), &endptr, 10); // we checked the number format before - assert(endptr == token_buffer.data() + token_buffer.size()); + JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size()); if (errno == 0) { @@ -1179,7 +1261,7 @@ scan_number_done: const auto x = std::strtoll(token_buffer.data(), &endptr, 10); // we checked the number format before - assert(endptr == token_buffer.data() + token_buffer.size()); + JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size()); if (errno == 0) { @@ -1196,7 +1278,7 @@ scan_number_done: strtof(value_float, token_buffer.data(), &endptr); // we checked the number format before - assert(endptr == token_buffer.data() + token_buffer.size()); + JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size()); return token_type::value_float; } @@ -1207,13 +1289,13 @@ scan_number_done: @param[in] return_type the token type to return on success */ JSON_HEDLEY_NON_NULL(2) - token_type scan_literal(const char* literal_text, const std::size_t length, + token_type scan_literal(const char_type* literal_text, const std::size_t length, token_type return_type) { - assert(current == literal_text[0]); + JSON_ASSERT(std::char_traits::to_char_type(current) == literal_text[0]); for (std::size_t i = 1; i < length; ++i) { - if (JSON_HEDLEY_UNLIKELY(get() != literal_text[i])) + if (JSON_HEDLEY_UNLIKELY(std::char_traits::to_char_type(get()) != literal_text[i])) { error_message = "invalid literal"; return token_type::parse_error; @@ -1231,7 +1313,7 @@ scan_number_done: { token_buffer.clear(); token_string.clear(); - token_string.push_back(std::char_traits::to_char_type(current)); + token_string.push_back(std::char_traits::to_char_type(current)); } /* @@ -1244,7 +1326,7 @@ scan_number_done: @return character read from the input */ - std::char_traits::int_type get() + char_int_type get() { ++position.chars_read_total; ++position.chars_read_current_line; @@ -1256,12 +1338,12 @@ scan_number_done: } else { - current = ia->get_character(); + current = ia.get_character(); } - if (JSON_HEDLEY_LIKELY(current != std::char_traits::eof())) + if (JSON_HEDLEY_LIKELY(current != std::char_traits::eof())) { - token_string.push_back(std::char_traits::to_char_type(current)); + token_string.push_back(std::char_traits::to_char_type(current)); } if (current == '\n') @@ -1300,17 +1382,17 @@ scan_number_done: --position.chars_read_current_line; } - if (JSON_HEDLEY_LIKELY(current != std::char_traits::eof())) + if (JSON_HEDLEY_LIKELY(current != std::char_traits::eof())) { - assert(not token_string.empty()); + JSON_ASSERT(!token_string.empty()); token_string.pop_back(); } } /// add a character to token_buffer - void add(int c) + void add(char_int_type c) { - token_buffer.push_back(std::char_traits::to_char_type(c)); + token_buffer.push_back(static_cast(c)); } public: @@ -1361,7 +1443,7 @@ scan_number_done: std::string result; for (const auto c : token_string) { - if ('\x00' <= c and c <= '\x1F') + if (static_cast(c) <= '\x1F') { // escape control characters std::array cs{{}}; @@ -1371,7 +1453,7 @@ scan_number_done: else { // add character as is - result.push_back(c); + result.push_back(static_cast(c)); } } @@ -1398,7 +1480,7 @@ scan_number_done: if (get() == 0xEF) { // check if we completely parse the BOM - return get() == 0xBB and get() == 0xBF; + return get() == 0xBB && get() == 0xBF; } // the first character is not the beginning of the BOM; unget it to @@ -1407,21 +1489,38 @@ scan_number_done: return true; } + void skip_whitespace() + { + do + { + get(); + } + while (current == ' ' || current == '\t' || current == '\n' || current == '\r'); + } + token_type scan() { // initially, skip the BOM - if (position.chars_read_total == 0 and not skip_bom()) + if (position.chars_read_total == 0 && !skip_bom()) { error_message = "invalid BOM; must be 0xEF 0xBB 0xBF if given"; return token_type::parse_error; } // read next character and ignore whitespace - do + skip_whitespace(); + + // ignore comments + while (ignore_comments && current == '/') { - get(); + if (!scan_comment()) + { + return token_type::parse_error; + } + + // skip following whitespace + skip_whitespace(); } - while (current == ' ' or current == '\t' or current == '\n' or current == '\r'); switch (current) { @@ -1441,11 +1540,20 @@ scan_number_done: // literals case 't': - return scan_literal("true", 4, token_type::literal_true); + { + std::array true_literal = {{'t', 'r', 'u', 'e'}}; + return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true); + } case 'f': - return scan_literal("false", 5, token_type::literal_false); + { + std::array false_literal = {{'f', 'a', 'l', 's', 'e'}}; + return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false); + } case 'n': - return scan_literal("null", 4, token_type::literal_null); + { + std::array null_literal = {{'n', 'u', 'l', 'l'}}; + return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null); + } // string case '\"': @@ -1468,7 +1576,7 @@ scan_number_done: // end of input (the null byte is needed when parsing from // string literals) case '\0': - case std::char_traits::eof(): + case std::char_traits::eof(): return token_type::end_of_input; // error @@ -1480,10 +1588,13 @@ scan_number_done: private: /// input adapter - detail::input_adapter_t ia = nullptr; + InputAdapterType ia; + + /// whether comments should be ignored (true) or signaled as errors (false) + const bool ignore_comments = false; /// the current character - std::char_traits::int_type current = std::char_traits::eof(); + char_int_type current = std::char_traits::eof(); /// whether the next get() call should just return current bool next_unget = false; @@ -1492,7 +1603,7 @@ scan_number_done: position_t position {}; /// raw input token string (for error messages) - std::vector token_string {}; + std::vector token_string {}; /// buffer for variable-length tokens (numbers, strings) string_t token_buffer {}; @@ -1506,7 +1617,7 @@ scan_number_done: number_float_t value_float = 0; /// the decimal point - const char decimal_point_char = '.'; + const char_int_type decimal_point_char = '.'; }; } // namespace detail } // namespace nlohmann diff --git a/mock/nlohmann/detail/input/parser.hpp b/mock/nlohmann/detail/input/parser.hpp index 8d4febcbfabc1297fc348b65ea9ebf068f22bd80..ffe483aa1e737598747e8153b9c13c0720306447 100644 --- a/mock/nlohmann/detail/input/parser.hpp +++ b/mock/nlohmann/detail/input/parser.hpp @@ -1,6 +1,5 @@ #pragma once -#include // assert #include // isfinite #include // uint8_t #include // function @@ -24,46 +23,50 @@ namespace detail // parser // //////////// +enum class parse_event_t : uint8_t +{ + /// the parser read `{` and started to process a JSON object + object_start, + /// the parser read `}` and finished processing a JSON object + object_end, + /// the parser read `[` and started to process a JSON array + array_start, + /// the parser read `]` and finished processing a JSON array + array_end, + /// the parser read a key of a value in an object + key, + /// the parser finished reading a JSON value + value +}; + +template +using parser_callback_t = + std::function; + /*! @brief syntax analysis -This class implements a recursive decent parser. +This class implements a recursive descent parser. */ -template +template class parser { using number_integer_t = typename BasicJsonType::number_integer_t; using number_unsigned_t = typename BasicJsonType::number_unsigned_t; using number_float_t = typename BasicJsonType::number_float_t; using string_t = typename BasicJsonType::string_t; - using lexer_t = lexer; + using lexer_t = lexer; using token_type = typename lexer_t::token_type; public: - enum class parse_event_t : uint8_t - { - /// the parser read `{` and started to process a JSON object - object_start, - /// the parser read `}` and finished processing a JSON object - object_end, - /// the parser read `[` and started to process a JSON array - array_start, - /// the parser read `]` and finished processing a JSON array - array_end, - /// the parser read a key of a value in an object - key, - /// the parser finished reading a JSON value - value - }; - - using parser_callback_t = - std::function; - /// a parser reading from an input adapter - explicit parser(detail::input_adapter_t&& adapter, - const parser_callback_t cb = nullptr, - const bool allow_exceptions_ = true) - : callback(cb), m_lexer(std::move(adapter)), allow_exceptions(allow_exceptions_) + explicit parser(InputAdapterType&& adapter, + const parser_callback_t cb = nullptr, + const bool allow_exceptions_ = true, + const bool skip_comments = false) + : callback(cb) + , m_lexer(std::move(adapter), skip_comments) + , allow_exceptions(allow_exceptions_) { // read first token get_token(); @@ -88,7 +91,7 @@ class parser result.assert_invariant(); // in strict mode, input must be completely read - if (strict and (get_token() != token_type::end_of_input)) + if (strict && (get_token() != token_type::end_of_input)) { sdp.parse_error(m_lexer.get_position(), m_lexer.get_token_string(), @@ -117,7 +120,7 @@ class parser result.assert_invariant(); // in strict mode, input must be completely read - if (strict and (get_token() != token_type::end_of_input)) + if (strict && (get_token() != token_type::end_of_input)) { sdp.parse_error(m_lexer.get_position(), m_lexer.get_token_string(), @@ -146,7 +149,7 @@ class parser return sax_parse(&sax_acceptor, strict); } - template + template JSON_HEDLEY_NON_NULL(2) bool sax_parse(SAX* sax, const bool strict = true) { @@ -154,7 +157,7 @@ class parser const bool result = sax_parse_internal(sax); // strict mode: next byte must be EOF - if (result and strict and (get_token() != token_type::end_of_input)) + if (result && strict && (get_token() != token_type::end_of_input)) { return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), @@ -166,7 +169,7 @@ class parser } private: - template + template JSON_HEDLEY_NON_NULL(2) bool sax_parse_internal(SAX* sax) { @@ -178,14 +181,14 @@ class parser while (true) { - if (not skip_to_state_evaluation) + if (!skip_to_state_evaluation) { // invariant: get_token() was called before each iteration switch (last_token) { case token_type::begin_object: { - if (JSON_HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1)))) + if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::size_t(-1)))) { return false; } @@ -193,7 +196,7 @@ class parser // closing } -> we are done if (get_token() == token_type::end_object) { - if (JSON_HEDLEY_UNLIKELY(not sax->end_object())) + if (JSON_HEDLEY_UNLIKELY(!sax->end_object())) { return false; } @@ -208,7 +211,7 @@ class parser parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string, "object key"))); } - if (JSON_HEDLEY_UNLIKELY(not sax->key(m_lexer.get_string()))) + if (JSON_HEDLEY_UNLIKELY(!sax->key(m_lexer.get_string()))) { return false; } @@ -232,7 +235,7 @@ class parser case token_type::begin_array: { - if (JSON_HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1)))) + if (JSON_HEDLEY_UNLIKELY(!sax->start_array(std::size_t(-1)))) { return false; } @@ -240,7 +243,7 @@ class parser // closing ] -> we are done if (get_token() == token_type::end_array) { - if (JSON_HEDLEY_UNLIKELY(not sax->end_array())) + if (JSON_HEDLEY_UNLIKELY(!sax->end_array())) { return false; } @@ -258,14 +261,14 @@ class parser { const auto res = m_lexer.get_number_float(); - if (JSON_HEDLEY_UNLIKELY(not std::isfinite(res))) + if (JSON_HEDLEY_UNLIKELY(!std::isfinite(res))) { return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), out_of_range::create(406, "number overflow parsing '" + m_lexer.get_token_string() + "'")); } - if (JSON_HEDLEY_UNLIKELY(not sax->number_float(res, m_lexer.get_string()))) + if (JSON_HEDLEY_UNLIKELY(!sax->number_float(res, m_lexer.get_string()))) { return false; } @@ -275,7 +278,7 @@ class parser case token_type::literal_false: { - if (JSON_HEDLEY_UNLIKELY(not sax->boolean(false))) + if (JSON_HEDLEY_UNLIKELY(!sax->boolean(false))) { return false; } @@ -284,7 +287,7 @@ class parser case token_type::literal_null: { - if (JSON_HEDLEY_UNLIKELY(not sax->null())) + if (JSON_HEDLEY_UNLIKELY(!sax->null())) { return false; } @@ -293,7 +296,7 @@ class parser case token_type::literal_true: { - if (JSON_HEDLEY_UNLIKELY(not sax->boolean(true))) + if (JSON_HEDLEY_UNLIKELY(!sax->boolean(true))) { return false; } @@ -302,7 +305,7 @@ class parser case token_type::value_integer: { - if (JSON_HEDLEY_UNLIKELY(not sax->number_integer(m_lexer.get_number_integer()))) + if (JSON_HEDLEY_UNLIKELY(!sax->number_integer(m_lexer.get_number_integer()))) { return false; } @@ -311,7 +314,7 @@ class parser case token_type::value_string: { - if (JSON_HEDLEY_UNLIKELY(not sax->string(m_lexer.get_string()))) + if (JSON_HEDLEY_UNLIKELY(!sax->string(m_lexer.get_string()))) { return false; } @@ -320,7 +323,7 @@ class parser case token_type::value_unsigned: { - if (JSON_HEDLEY_UNLIKELY(not sax->number_unsigned(m_lexer.get_number_unsigned()))) + if (JSON_HEDLEY_UNLIKELY(!sax->number_unsigned(m_lexer.get_number_unsigned()))) { return false; } @@ -370,7 +373,7 @@ class parser // closing ] if (JSON_HEDLEY_LIKELY(last_token == token_type::end_array)) { - if (JSON_HEDLEY_UNLIKELY(not sax->end_array())) + if (JSON_HEDLEY_UNLIKELY(!sax->end_array())) { return false; } @@ -379,7 +382,7 @@ class parser // new value, we need to evaluate the new state first. // By setting skip_to_state_evaluation to false, we // are effectively jumping to the beginning of this if. - assert(not states.empty()); + JSON_ASSERT(!states.empty()); states.pop_back(); skip_to_state_evaluation = true; continue; @@ -404,7 +407,7 @@ class parser exception_message(token_type::value_string, "object key"))); } - if (JSON_HEDLEY_UNLIKELY(not sax->key(m_lexer.get_string()))) + if (JSON_HEDLEY_UNLIKELY(!sax->key(m_lexer.get_string()))) { return false; } @@ -426,7 +429,7 @@ class parser // closing } if (JSON_HEDLEY_LIKELY(last_token == token_type::end_object)) { - if (JSON_HEDLEY_UNLIKELY(not sax->end_object())) + if (JSON_HEDLEY_UNLIKELY(!sax->end_object())) { return false; } @@ -435,7 +438,7 @@ class parser // new value, we need to evaluate the new state first. // By setting skip_to_state_evaluation to false, we // are effectively jumping to the beginning of this if. - assert(not states.empty()); + JSON_ASSERT(!states.empty()); states.pop_back(); skip_to_state_evaluation = true; continue; @@ -459,7 +462,7 @@ class parser { std::string error_msg = "syntax error "; - if (not context.empty()) + if (!context.empty()) { error_msg += "while parsing " + context + " "; } @@ -486,7 +489,7 @@ class parser private: /// callback function - const parser_callback_t callback = nullptr; + const parser_callback_t callback = nullptr; /// the type of the last read token token_type last_token = token_type::uninitialized; /// the lexer diff --git a/mock/nlohmann/detail/iterators/iter_impl.hpp b/mock/nlohmann/detail/iterators/iter_impl.hpp index 3a362971909a31c258f6f3f77d7c2936ae141edf..e9a394d4cc1efef7f9c5ad2664ba8eec70a1bfc2 100644 --- a/mock/nlohmann/detail/iterators/iter_impl.hpp +++ b/mock/nlohmann/detail/iterators/iter_impl.hpp @@ -1,6 +1,5 @@ #pragma once -#include // not #include // iterator, random_access_iterator_tag, bidirectional_iterator_tag, advance, next #include // conditional, is_const, remove_const @@ -85,7 +84,7 @@ class iter_impl */ explicit iter_impl(pointer object) noexcept : m_object(object) { - assert(m_object != nullptr); + JSON_ASSERT(m_object != nullptr); switch (m_object->m_type) { @@ -171,7 +170,7 @@ class iter_impl */ void set_begin() noexcept { - assert(m_object != nullptr); + JSON_ASSERT(m_object != nullptr); switch (m_object->m_type) { @@ -208,7 +207,7 @@ class iter_impl */ void set_end() noexcept { - assert(m_object != nullptr); + JSON_ASSERT(m_object != nullptr); switch (m_object->m_type) { @@ -239,19 +238,19 @@ class iter_impl */ reference operator*() const { - assert(m_object != nullptr); + JSON_ASSERT(m_object != nullptr); switch (m_object->m_type) { case value_t::object: { - assert(m_it.object_iterator != m_object->m_value.object->end()); + JSON_ASSERT(m_it.object_iterator != m_object->m_value.object->end()); return m_it.object_iterator->second; } case value_t::array: { - assert(m_it.array_iterator != m_object->m_value.array->end()); + JSON_ASSERT(m_it.array_iterator != m_object->m_value.array->end()); return *m_it.array_iterator; } @@ -276,19 +275,19 @@ class iter_impl */ pointer operator->() const { - assert(m_object != nullptr); + JSON_ASSERT(m_object != nullptr); switch (m_object->m_type) { case value_t::object: { - assert(m_it.object_iterator != m_object->m_value.object->end()); + JSON_ASSERT(m_it.object_iterator != m_object->m_value.object->end()); return &(m_it.object_iterator->second); } case value_t::array: { - assert(m_it.array_iterator != m_object->m_value.array->end()); + JSON_ASSERT(m_it.array_iterator != m_object->m_value.array->end()); return &*m_it.array_iterator; } @@ -321,7 +320,7 @@ class iter_impl */ iter_impl& operator++() { - assert(m_object != nullptr); + JSON_ASSERT(m_object != nullptr); switch (m_object->m_type) { @@ -364,7 +363,7 @@ class iter_impl */ iter_impl& operator--() { - assert(m_object != nullptr); + JSON_ASSERT(m_object != nullptr); switch (m_object->m_type) { @@ -402,7 +401,7 @@ class iter_impl JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers")); } - assert(m_object != nullptr); + JSON_ASSERT(m_object != nullptr); switch (m_object->m_type) { @@ -423,7 +422,7 @@ class iter_impl */ bool operator!=(const iter_impl& other) const { - return not operator==(other); + return !operator==(other); } /*! @@ -438,7 +437,7 @@ class iter_impl JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers")); } - assert(m_object != nullptr); + JSON_ASSERT(m_object != nullptr); switch (m_object->m_type) { @@ -459,7 +458,7 @@ class iter_impl */ bool operator<=(const iter_impl& other) const { - return not other.operator < (*this); + return !other.operator < (*this); } /*! @@ -468,7 +467,7 @@ class iter_impl */ bool operator>(const iter_impl& other) const { - return not operator<=(other); + return !operator<=(other); } /*! @@ -477,7 +476,7 @@ class iter_impl */ bool operator>=(const iter_impl& other) const { - return not operator<(other); + return !operator<(other); } /*! @@ -486,7 +485,7 @@ class iter_impl */ iter_impl& operator+=(difference_type i) { - assert(m_object != nullptr); + JSON_ASSERT(m_object != nullptr); switch (m_object->m_type) { @@ -557,7 +556,7 @@ class iter_impl */ difference_type operator-(const iter_impl& other) const { - assert(m_object != nullptr); + JSON_ASSERT(m_object != nullptr); switch (m_object->m_type) { @@ -578,7 +577,7 @@ class iter_impl */ reference operator[](difference_type n) const { - assert(m_object != nullptr); + JSON_ASSERT(m_object != nullptr); switch (m_object->m_type) { @@ -609,7 +608,7 @@ class iter_impl */ const typename object_t::key_type& key() const { - assert(m_object != nullptr); + JSON_ASSERT(m_object != nullptr); if (JSON_HEDLEY_LIKELY(m_object->is_object())) { diff --git a/mock/nlohmann/detail/iterators/iteration_proxy.hpp b/mock/nlohmann/detail/iterators/iteration_proxy.hpp index c61d96296ce5e47a45a5e78ed83c6a544a477061..74b4eb347f72154d4bd1c0a90a954e1fd36566c2 100644 --- a/mock/nlohmann/detail/iterators/iteration_proxy.hpp +++ b/mock/nlohmann/detail/iterators/iteration_proxy.hpp @@ -15,9 +15,11 @@ namespace detail template void int_to_string( string_type& target, std::size_t value ) { - target = std::to_string(value); + // For ADL + using std::to_string; + target = to_string(value); } -template class iteration_proxy_value +template class iteration_proxy_value { public: using difference_type = std::ptrdiff_t; @@ -72,7 +74,7 @@ template class iteration_proxy_value /// return key of the iterator const string_type& key() const { - assert(anchor.m_object != nullptr); + JSON_ASSERT(anchor.m_object != nullptr); switch (anchor.m_object->type()) { @@ -131,7 +133,7 @@ template class iteration_proxy // Structured Bindings Support // For further reference see https://blog.tartanllama.xyz/structured-bindings/ // And see https://github.com/nlohmann/json/pull/1391 -template = 0> +template = 0> auto get(const nlohmann::detail::iteration_proxy_value& i) -> decltype(i.key()) { return i.key(); @@ -139,7 +141,7 @@ auto get(const nlohmann::detail::iteration_proxy_value& i) -> decl // Structured Bindings Support // For further reference see https://blog.tartanllama.xyz/structured-bindings/ // And see https://github.com/nlohmann/json/pull/1391 -template = 0> +template = 0> auto get(const nlohmann::detail::iteration_proxy_value& i) -> decltype(i.value()) { return i.value(); @@ -158,11 +160,11 @@ namespace std #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wmismatched-tags" #endif -template +template class tuple_size<::nlohmann::detail::iteration_proxy_value> : public std::integral_constant {}; -template +template class tuple_element> { public: diff --git a/mock/nlohmann/detail/iterators/iterator_traits.hpp b/mock/nlohmann/detail/iterators/iterator_traits.hpp index 4cced80caf4ca17d5f63de8b7d7938ca8f22f266..da5636188f58bc8650e02a00a5b1596efc2ec371 100644 --- a/mock/nlohmann/detail/iterators/iterator_traits.hpp +++ b/mock/nlohmann/detail/iterators/iterator_traits.hpp @@ -9,10 +9,10 @@ namespace nlohmann { namespace detail { -template +template struct iterator_types {}; -template +template struct iterator_types < It, void_t +template struct iterator_traits { }; -template +template struct iterator_traits < T, enable_if_t < !std::is_pointer::value >> : iterator_types { }; -template +template struct iterator_traits::value>> { using iterator_category = std::random_access_iterator_tag; diff --git a/mock/nlohmann/detail/json_pointer.hpp b/mock/nlohmann/detail/json_pointer.hpp index 87af3423315f7260effc31489203d48c782bc6e8..78bc3a3a38da6e11e81a728960f82f5fb8a35a16 100644 --- a/mock/nlohmann/detail/json_pointer.hpp +++ b/mock/nlohmann/detail/json_pointer.hpp @@ -1,8 +1,8 @@ #pragma once #include // all_of -#include // assert #include // isdigit +#include // max #include // accumulate #include // string #include // move @@ -126,8 +126,8 @@ class json_pointer /*! @brief append an array index at the end of this JSON pointer - @param[in] array_index array index to append - @return JSON pointer with @a array_index appended + @param[in] array_idx array index to append + @return JSON pointer with @a array_idx appended @liveexample{The example shows the usage of `operator/=`.,json_pointer__operator_add} @@ -139,9 +139,9 @@ class json_pointer @since version 3.6.0 */ - json_pointer& operator/=(std::size_t array_index) + json_pointer& operator/=(std::size_t array_idx) { - return *this /= std::to_string(array_index); + return *this /= std::to_string(array_idx); } /*! @@ -189,8 +189,8 @@ class json_pointer @brief create a new JSON pointer by appending the array-index-token at the end of the JSON pointer @param[in] ptr JSON pointer - @param[in] array_index array index - @return a new JSON pointer with @a array_index appended to @a ptr + @param[in] array_idx array index + @return a new JSON pointer with @a array_idx appended to @a ptr @liveexample{The example shows the usage of `operator/`.,json_pointer__operator_add_binary} @@ -200,9 +200,9 @@ class json_pointer @since version 3.6.0 */ - friend json_pointer operator/(const json_pointer& ptr, std::size_t array_index) + friend json_pointer operator/(const json_pointer& ptr, std::size_t array_idx) { - return json_pointer(ptr) /= array_index; + return json_pointer(ptr) /= array_idx; } /*! @@ -325,12 +325,39 @@ class json_pointer @return integer representation of @a s + @throw parse_error.106 if an array index begins with '0' + @throw parse_error.109 if an array index begins not with a digit @throw out_of_range.404 if string @a s could not be converted to an integer + @throw out_of_range.410 if an array index exceeds size_type */ - static int array_index(const std::string& s) + static typename BasicJsonType::size_type array_index(const std::string& s) { + using size_type = typename BasicJsonType::size_type; + + // error condition (cf. RFC 6901, Sect. 4) + if (JSON_HEDLEY_UNLIKELY(s.size() > 1 && s[0] == '0')) + { + JSON_THROW(detail::parse_error::create(106, 0, + "array index '" + s + + "' must not begin with '0'")); + } + + // error condition (cf. RFC 6901, Sect. 4) + if (JSON_HEDLEY_UNLIKELY(s.size() > 1 && !(s[0] >= '1' && s[0] <= '9'))) + { + JSON_THROW(detail::parse_error::create(109, 0, "array index '" + s + "' is not a number")); + } + std::size_t processed_chars = 0; - const int res = std::stoi(s, &processed_chars); + unsigned long long res = 0; + JSON_TRY + { + res = std::stoull(s, &processed_chars); + } + JSON_CATCH(std::out_of_range&) + { + JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + s + "'")); + } // check if the string was completely read if (JSON_HEDLEY_UNLIKELY(processed_chars != s.size())) @@ -338,7 +365,14 @@ class json_pointer JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + s + "'")); } - return res; + // only triggered on special platforms (like 32bit), see also + // https://github.com/nlohmann/json/pull/2203 + if (res >= static_cast((std::numeric_limits::max)())) + { + JSON_THROW(detail::out_of_range::create(410, "array index " + s + " exceeds size_type")); // LCOV_EXCL_LINE + } + + return static_cast(res); } json_pointer top() const @@ -363,7 +397,6 @@ class json_pointer */ BasicJsonType& get_and_create(BasicJsonType& j) const { - using size_type = typename BasicJsonType::size_type; auto result = &j; // in case no reference tokens exist, return a reference to the JSON value @@ -397,14 +430,7 @@ class json_pointer case detail::value_t::array: { // create an entry in the array - JSON_TRY - { - result = &result->operator[](static_cast(array_index(reference_token))); - } - JSON_CATCH(std::invalid_argument&) - { - JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number")); - } + result = &result->operator[](array_index(reference_token)); break; } @@ -443,7 +469,6 @@ class json_pointer */ BasicJsonType& get_unchecked(BasicJsonType* ptr) const { - using size_type = typename BasicJsonType::size_type; for (const auto& reference_token : reference_tokens) { // convert null values to arrays or objects before continuing @@ -458,7 +483,7 @@ class json_pointer }); // change value to array for numbers or "-" or to object otherwise - *ptr = (nums or reference_token == "-") + *ptr = (nums || reference_token == "-") ? detail::value_t::array : detail::value_t::object; } @@ -474,14 +499,6 @@ class json_pointer case detail::value_t::array: { - // error condition (cf. RFC 6901, Sect. 4) - if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) - { - JSON_THROW(detail::parse_error::create(106, 0, - "array index '" + reference_token + - "' must not begin with '0'")); - } - if (reference_token == "-") { // explicitly treat "-" as index beyond the end @@ -490,15 +507,7 @@ class json_pointer else { // convert array index to number; unchecked access - JSON_TRY - { - ptr = &ptr->operator[]( - static_cast(array_index(reference_token))); - } - JSON_CATCH(std::invalid_argument&) - { - JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number")); - } + ptr = &ptr->operator[](array_index(reference_token)); } break; } @@ -519,7 +528,6 @@ class json_pointer */ BasicJsonType& get_checked(BasicJsonType* ptr) const { - using size_type = typename BasicJsonType::size_type; for (const auto& reference_token : reference_tokens) { switch (ptr->type()) @@ -541,23 +549,8 @@ class json_pointer ") is out of range")); } - // error condition (cf. RFC 6901, Sect. 4) - if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) - { - JSON_THROW(detail::parse_error::create(106, 0, - "array index '" + reference_token + - "' must not begin with '0'")); - } - // note: at performs range check - JSON_TRY - { - ptr = &ptr->at(static_cast(array_index(reference_token))); - } - JSON_CATCH(std::invalid_argument&) - { - JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number")); - } + ptr = &ptr->at(array_index(reference_token)); break; } @@ -584,7 +577,6 @@ class json_pointer */ const BasicJsonType& get_unchecked(const BasicJsonType* ptr) const { - using size_type = typename BasicJsonType::size_type; for (const auto& reference_token : reference_tokens) { switch (ptr->type()) @@ -606,24 +598,8 @@ class json_pointer ") is out of range")); } - // error condition (cf. RFC 6901, Sect. 4) - if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) - { - JSON_THROW(detail::parse_error::create(106, 0, - "array index '" + reference_token + - "' must not begin with '0'")); - } - // use unchecked array access - JSON_TRY - { - ptr = &ptr->operator[]( - static_cast(array_index(reference_token))); - } - JSON_CATCH(std::invalid_argument&) - { - JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number")); - } + ptr = &ptr->operator[](array_index(reference_token)); break; } @@ -643,7 +619,6 @@ class json_pointer */ const BasicJsonType& get_checked(const BasicJsonType* ptr) const { - using size_type = typename BasicJsonType::size_type; for (const auto& reference_token : reference_tokens) { switch (ptr->type()) @@ -665,23 +640,8 @@ class json_pointer ") is out of range")); } - // error condition (cf. RFC 6901, Sect. 4) - if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) - { - JSON_THROW(detail::parse_error::create(106, 0, - "array index '" + reference_token + - "' must not begin with '0'")); - } - // note: at performs range check - JSON_TRY - { - ptr = &ptr->at(static_cast(array_index(reference_token))); - } - JSON_CATCH(std::invalid_argument&) - { - JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number")); - } + ptr = &ptr->at(array_index(reference_token)); break; } @@ -699,14 +659,13 @@ class json_pointer */ bool contains(const BasicJsonType* ptr) const { - using size_type = typename BasicJsonType::size_type; for (const auto& reference_token : reference_tokens) { switch (ptr->type()) { case detail::value_t::object: { - if (not ptr->contains(reference_token)) + if (!ptr->contains(reference_token)) { // we did not find the key in the object return false; @@ -723,31 +682,36 @@ class json_pointer // "-" always fails the range check return false; } - - // error condition (cf. RFC 6901, Sect. 4) - if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) + if (JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 && !("0" <= reference_token && reference_token <= "9"))) { - JSON_THROW(detail::parse_error::create(106, 0, - "array index '" + reference_token + - "' must not begin with '0'")); + // invalid char + return false; } - - JSON_TRY + if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1)) { - const auto idx = static_cast(array_index(reference_token)); - if (idx >= ptr->size()) + if (JSON_HEDLEY_UNLIKELY(!('1' <= reference_token[0] && reference_token[0] <= '9'))) { - // index out of range + // first char should be between '1' and '9' return false; } - - ptr = &ptr->operator[](idx); - break; + for (std::size_t i = 1; i < reference_token.size(); i++) + { + if (JSON_HEDLEY_UNLIKELY(!('0' <= reference_token[i] && reference_token[i] <= '9'))) + { + // other char should be between '0' and '9' + return false; + } + } } - JSON_CATCH(std::invalid_argument&) + + const auto idx = array_index(reference_token); + if (idx >= ptr->size()) { - JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number")); + // index out of range + return false; } + + ptr = &ptr->operator[](idx); break; } @@ -816,11 +780,11 @@ class json_pointer pos != std::string::npos; pos = reference_token.find_first_of('~', pos + 1)) { - assert(reference_token[pos] == '~'); + JSON_ASSERT(reference_token[pos] == '~'); // ~ must be followed by 0 or 1 - if (JSON_HEDLEY_UNLIKELY(pos == reference_token.size() - 1 or - (reference_token[pos + 1] != '0' and + if (JSON_HEDLEY_UNLIKELY(pos == reference_token.size() - 1 || + (reference_token[pos + 1] != '0' && reference_token[pos + 1] != '1'))) { JSON_THROW(detail::parse_error::create(108, 0, "escape character '~' must be followed with '0' or '1'")); @@ -851,7 +815,7 @@ class json_pointer static void replace_substring(std::string& s, const std::string& f, const std::string& t) { - assert(not f.empty()); + JSON_ASSERT(!f.empty()); for (auto pos = s.find(f); // find first occurrence of f pos != std::string::npos; // make sure f was found s.replace(pos, f.size(), t), // replace with t, and @@ -946,7 +910,7 @@ class json_pointer static BasicJsonType unflatten(const BasicJsonType& value) { - if (JSON_HEDLEY_UNLIKELY(not value.is_object())) + if (JSON_HEDLEY_UNLIKELY(!value.is_object())) { JSON_THROW(detail::type_error::create(314, "only objects can be unflattened")); } @@ -956,7 +920,7 @@ class json_pointer // iterate the JSON object values for (const auto& element : *value.m_value.object) { - if (JSON_HEDLEY_UNLIKELY(not element.second.is_primitive())) + if (JSON_HEDLEY_UNLIKELY(!element.second.is_primitive())) { JSON_THROW(detail::type_error::create(315, "values in object must be primitive")); } @@ -1002,7 +966,7 @@ class json_pointer friend bool operator!=(json_pointer const& lhs, json_pointer const& rhs) noexcept { - return not (lhs == rhs); + return !(lhs == rhs); } /// the reference tokens diff --git a/mock/nlohmann/detail/json_ref.hpp b/mock/nlohmann/detail/json_ref.hpp index c8dec7330f2ce097a45a7f440963aeca2c3a1c14..c9bf6cb228cb10669def3d6853c8eaea73ddb8da 100644 --- a/mock/nlohmann/detail/json_ref.hpp +++ b/mock/nlohmann/detail/json_ref.hpp @@ -16,23 +16,30 @@ class json_ref using value_type = BasicJsonType; json_ref(value_type&& value) - : owned_value(std::move(value)), value_ref(&owned_value), is_rvalue(true) + : owned_value(std::move(value)) + , value_ref(&owned_value) + , is_rvalue(true) {} json_ref(const value_type& value) - : value_ref(const_cast(&value)), is_rvalue(false) + : value_ref(const_cast(&value)) + , is_rvalue(false) {} json_ref(std::initializer_list init) - : owned_value(init), value_ref(&owned_value), is_rvalue(true) + : owned_value(init) + , value_ref(&owned_value) + , is_rvalue(true) {} template < class... Args, enable_if_t::value, int> = 0 > json_ref(Args && ... args) - : owned_value(std::forward(args)...), value_ref(&owned_value), - is_rvalue(true) {} + : owned_value(std::forward(args)...) + , value_ref(&owned_value) + , is_rvalue(true) + {} // class should be movable only json_ref(json_ref&&) = default; @@ -63,7 +70,7 @@ class json_ref private: mutable value_type owned_value = nullptr; value_type* value_ref = nullptr; - const bool is_rvalue; + const bool is_rvalue = true; }; } // namespace detail } // namespace nlohmann diff --git a/mock/nlohmann/detail/macro_scope.hpp b/mock/nlohmann/detail/macro_scope.hpp index 27dddc6be76bfc035422e0158a163ac4e95c614e..8c9f63296bca7dbf9aba07306b34a38ec574012b 100644 --- a/mock/nlohmann/detail/macro_scope.hpp +++ b/mock/nlohmann/detail/macro_scope.hpp @@ -20,7 +20,11 @@ #endif // C++ language standard detection -#if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464 +#if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) + #define JSON_HAS_CPP_20 + #define JSON_HAS_CPP_17 + #define JSON_HAS_CPP_14 +#elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464 #define JSON_HAS_CPP_17 #define JSON_HAS_CPP_14 #elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1) @@ -73,6 +77,12 @@ #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER #endif +// allow to override assert +#if !defined(JSON_ASSERT) + #include // assert + #define JSON_ASSERT(x) assert(x) +#endif + /*! @brief macro to briefly define a mapping between an enum and JSON @def NLOHMANN_JSON_SERIALIZE_ENUM @@ -113,9 +123,174 @@ class StringType, class BooleanType, class NumberIntegerType, \ class NumberUnsignedType, class NumberFloatType, \ template class AllocatorType, \ - template class JSONSerializer> + template class JSONSerializer, \ + class BinaryType> #define NLOHMANN_BASIC_JSON_TPL \ basic_json + AllocatorType, JSONSerializer, BinaryType> + +// Macros to simplify conversion from/to types + +#define NLOHMANN_JSON_EXPAND( x ) x +#define NLOHMANN_JSON_GET_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, NAME,...) NAME +#define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \ + NLOHMANN_JSON_PASTE64, \ + NLOHMANN_JSON_PASTE63, \ + NLOHMANN_JSON_PASTE62, \ + NLOHMANN_JSON_PASTE61, \ + NLOHMANN_JSON_PASTE60, \ + NLOHMANN_JSON_PASTE59, \ + NLOHMANN_JSON_PASTE58, \ + NLOHMANN_JSON_PASTE57, \ + NLOHMANN_JSON_PASTE56, \ + NLOHMANN_JSON_PASTE55, \ + NLOHMANN_JSON_PASTE54, \ + NLOHMANN_JSON_PASTE53, \ + NLOHMANN_JSON_PASTE52, \ + NLOHMANN_JSON_PASTE51, \ + NLOHMANN_JSON_PASTE50, \ + NLOHMANN_JSON_PASTE49, \ + NLOHMANN_JSON_PASTE48, \ + NLOHMANN_JSON_PASTE47, \ + NLOHMANN_JSON_PASTE46, \ + NLOHMANN_JSON_PASTE45, \ + NLOHMANN_JSON_PASTE44, \ + NLOHMANN_JSON_PASTE43, \ + NLOHMANN_JSON_PASTE42, \ + NLOHMANN_JSON_PASTE41, \ + NLOHMANN_JSON_PASTE40, \ + NLOHMANN_JSON_PASTE39, \ + NLOHMANN_JSON_PASTE38, \ + NLOHMANN_JSON_PASTE37, \ + NLOHMANN_JSON_PASTE36, \ + NLOHMANN_JSON_PASTE35, \ + NLOHMANN_JSON_PASTE34, \ + NLOHMANN_JSON_PASTE33, \ + NLOHMANN_JSON_PASTE32, \ + NLOHMANN_JSON_PASTE31, \ + NLOHMANN_JSON_PASTE30, \ + NLOHMANN_JSON_PASTE29, \ + NLOHMANN_JSON_PASTE28, \ + NLOHMANN_JSON_PASTE27, \ + NLOHMANN_JSON_PASTE26, \ + NLOHMANN_JSON_PASTE25, \ + NLOHMANN_JSON_PASTE24, \ + NLOHMANN_JSON_PASTE23, \ + NLOHMANN_JSON_PASTE22, \ + NLOHMANN_JSON_PASTE21, \ + NLOHMANN_JSON_PASTE20, \ + NLOHMANN_JSON_PASTE19, \ + NLOHMANN_JSON_PASTE18, \ + NLOHMANN_JSON_PASTE17, \ + NLOHMANN_JSON_PASTE16, \ + NLOHMANN_JSON_PASTE15, \ + NLOHMANN_JSON_PASTE14, \ + NLOHMANN_JSON_PASTE13, \ + NLOHMANN_JSON_PASTE12, \ + NLOHMANN_JSON_PASTE11, \ + NLOHMANN_JSON_PASTE10, \ + NLOHMANN_JSON_PASTE9, \ + NLOHMANN_JSON_PASTE8, \ + NLOHMANN_JSON_PASTE7, \ + NLOHMANN_JSON_PASTE6, \ + NLOHMANN_JSON_PASTE5, \ + NLOHMANN_JSON_PASTE4, \ + NLOHMANN_JSON_PASTE3, \ + NLOHMANN_JSON_PASTE2, \ + NLOHMANN_JSON_PASTE1)(__VA_ARGS__)) +#define NLOHMANN_JSON_PASTE2(func, v1) func(v1) +#define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2) +#define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3) +#define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4) +#define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5) +#define NLOHMANN_JSON_PASTE7(func, v1, v2, v3, v4, v5, v6) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE6(func, v2, v3, v4, v5, v6) +#define NLOHMANN_JSON_PASTE8(func, v1, v2, v3, v4, v5, v6, v7) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE7(func, v2, v3, v4, v5, v6, v7) +#define NLOHMANN_JSON_PASTE9(func, v1, v2, v3, v4, v5, v6, v7, v8) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE8(func, v2, v3, v4, v5, v6, v7, v8) +#define NLOHMANN_JSON_PASTE10(func, v1, v2, v3, v4, v5, v6, v7, v8, v9) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE9(func, v2, v3, v4, v5, v6, v7, v8, v9) +#define NLOHMANN_JSON_PASTE11(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE10(func, v2, v3, v4, v5, v6, v7, v8, v9, v10) +#define NLOHMANN_JSON_PASTE12(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE11(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) +#define NLOHMANN_JSON_PASTE13(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE12(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) +#define NLOHMANN_JSON_PASTE14(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE13(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) +#define NLOHMANN_JSON_PASTE15(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE14(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) +#define NLOHMANN_JSON_PASTE16(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE15(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) +#define NLOHMANN_JSON_PASTE17(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE16(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) +#define NLOHMANN_JSON_PASTE18(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE17(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) +#define NLOHMANN_JSON_PASTE19(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE18(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) +#define NLOHMANN_JSON_PASTE20(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE19(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) +#define NLOHMANN_JSON_PASTE21(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE20(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) +#define NLOHMANN_JSON_PASTE22(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE21(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) +#define NLOHMANN_JSON_PASTE23(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE22(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) +#define NLOHMANN_JSON_PASTE24(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE23(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) +#define NLOHMANN_JSON_PASTE25(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE24(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) +#define NLOHMANN_JSON_PASTE26(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE25(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) +#define NLOHMANN_JSON_PASTE27(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE26(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) +#define NLOHMANN_JSON_PASTE28(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE27(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) +#define NLOHMANN_JSON_PASTE29(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE28(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) +#define NLOHMANN_JSON_PASTE30(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE29(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) +#define NLOHMANN_JSON_PASTE31(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE30(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) +#define NLOHMANN_JSON_PASTE32(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE31(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) +#define NLOHMANN_JSON_PASTE33(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE32(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) +#define NLOHMANN_JSON_PASTE34(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE33(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) +#define NLOHMANN_JSON_PASTE35(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE34(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) +#define NLOHMANN_JSON_PASTE36(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE35(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) +#define NLOHMANN_JSON_PASTE37(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE36(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) +#define NLOHMANN_JSON_PASTE38(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE37(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) +#define NLOHMANN_JSON_PASTE39(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE38(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) +#define NLOHMANN_JSON_PASTE40(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE39(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) +#define NLOHMANN_JSON_PASTE41(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE40(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) +#define NLOHMANN_JSON_PASTE42(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE41(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) +#define NLOHMANN_JSON_PASTE43(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE42(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) +#define NLOHMANN_JSON_PASTE44(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE43(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) +#define NLOHMANN_JSON_PASTE45(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE44(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) +#define NLOHMANN_JSON_PASTE46(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE45(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) +#define NLOHMANN_JSON_PASTE47(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE46(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) +#define NLOHMANN_JSON_PASTE48(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE47(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) +#define NLOHMANN_JSON_PASTE49(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE48(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) +#define NLOHMANN_JSON_PASTE50(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE49(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) +#define NLOHMANN_JSON_PASTE51(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE50(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) +#define NLOHMANN_JSON_PASTE52(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE51(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) +#define NLOHMANN_JSON_PASTE53(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE52(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) +#define NLOHMANN_JSON_PASTE54(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE53(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) +#define NLOHMANN_JSON_PASTE55(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE54(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) +#define NLOHMANN_JSON_PASTE56(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE55(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) +#define NLOHMANN_JSON_PASTE57(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE56(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) +#define NLOHMANN_JSON_PASTE58(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE57(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) +#define NLOHMANN_JSON_PASTE59(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE58(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) +#define NLOHMANN_JSON_PASTE60(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE59(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) +#define NLOHMANN_JSON_PASTE61(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE60(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) +#define NLOHMANN_JSON_PASTE62(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE61(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) +#define NLOHMANN_JSON_PASTE63(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE62(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) +#define NLOHMANN_JSON_PASTE64(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE63(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) + +#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1; +#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1); + +/*! +@brief macro +@def NLOHMANN_DEFINE_TYPE_INTRUSIVE +@since version 3.9.0 +*/ +#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \ + friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ + friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) } + +/*! +@brief macro +@def NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE +@since version 3.9.0 +*/ +#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \ + inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ + inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) } + +#ifndef JSON_USE_IMPLICIT_CONVERSIONS + #define JSON_USE_IMPLICIT_CONVERSIONS 1 +#endif + +#if JSON_USE_IMPLICIT_CONVERSIONS + #define JSON_EXPLICIT +#else + #define JSON_EXPLICIT explicit +#endif diff --git a/mock/nlohmann/detail/macro_unscope.hpp b/mock/nlohmann/detail/macro_unscope.hpp index 80b293e7d596b80fe059cde2f54945a9728b0cbe..eb7065113db46d5743178c0a54699510a9f25864 100644 --- a/mock/nlohmann/detail/macro_unscope.hpp +++ b/mock/nlohmann/detail/macro_unscope.hpp @@ -9,6 +9,7 @@ #endif // clean up +#undef JSON_ASSERT #undef JSON_INTERNAL_CATCH #undef JSON_CATCH #undef JSON_THROW @@ -17,5 +18,6 @@ #undef JSON_HAS_CPP_17 #undef NLOHMANN_BASIC_JSON_TPL_DECLARATION #undef NLOHMANN_BASIC_JSON_TPL +#undef JSON_EXPLICIT #include diff --git a/mock/nlohmann/detail/meta/cpp_future.hpp b/mock/nlohmann/detail/meta/cpp_future.hpp index 948cd4fb0cbe4eb95df21286c43e94165ffaf792..dd929ee14209becaf264b512e3df35ac03fdecca 100644 --- a/mock/nlohmann/detail/meta/cpp_future.hpp +++ b/mock/nlohmann/detail/meta/cpp_future.hpp @@ -1,6 +1,5 @@ #pragma once -#include // not #include // size_t #include // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type diff --git a/mock/nlohmann/detail/meta/detected.hpp b/mock/nlohmann/detail/meta/detected.hpp index 5b52460acf6dda902fe7b6bc49fa7ba4967d37ea..7b5a003537013060d2e5897280a2f1603882381e 100644 --- a/mock/nlohmann/detail/meta/detected.hpp +++ b/mock/nlohmann/detail/meta/detected.hpp @@ -4,7 +4,7 @@ #include -// http://en.cppreference.com/w/cpp/experimental/is_detected +// https://en.cppreference.com/w/cpp/experimental/is_detected namespace nlohmann { namespace detail @@ -19,39 +19,39 @@ struct nonesuch void operator=(nonesuch&&) = delete; }; -template class Op, - class... Args> +template class Op, + class... Args> struct detector { using value_t = std::false_type; using type = Default; }; -template class Op, class... Args> +template class Op, class... Args> struct detector>, Op, Args...> { using value_t = std::true_type; using type = Op; }; -template