diff --git a/communication/dsoftbus/rpc_server/src/main/js/MainAbility/pages/second/second.js b/storage/storagefileiov9jstest/src/main/js/MainAbility/pages/index/index.js
similarity index 61%
rename from communication/dsoftbus/rpc_server/src/main/js/MainAbility/pages/second/second.js
rename to storage/storagefileiov9jstest/src/main/js/MainAbility/pages/index/index.js
index 694f92fc0e5daefe6ae23cdb88c571a454663488..446cc682b011e7de5a9493990e61ca8f9ce0d6eb 100644
--- a/communication/dsoftbus/rpc_server/src/main/js/MainAbility/pages/second/second.js
+++ b/storage/storagefileiov9jstest/src/main/js/MainAbility/pages/index/index.js
@@ -1,27 +1,33 @@
-/*
- * Copyright (c) 2021 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 router from '@system.router'
-
-export default {
- data: {
- title: 'World'
- },
- onclick: function () {
- router.replace({
- uri: "pages/index/index"
- })
- }
-}
+/*
+ * 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 app from '@system.app'
+
+const injectRef = Object.getPrototypeOf(global) || global
+injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
+
+export default {
+ data: {
+ title: ''
+ },
+ onInit() {
+ this.title = this.$t('strings.world');
+ },
+ onShow() {
+ console.info('onShow finish')
+ },
+ onReady() {
+ },
+}
diff --git a/storage/storagefileiov9jstest/src/main/js/TestAbility/app.js b/storage/storagefileiov9jstest/src/main/js/TestAbility/app.js
new file mode 100644
index 0000000000000000000000000000000000000000..d5ee271df29e516d1c8929054283e5f2bf5c981c
--- /dev/null
+++ b/storage/storagefileiov9jstest/src/main/js/TestAbility/app.js
@@ -0,0 +1,31 @@
+/*
+ * 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
+import { Hypium } from '@ohos/hypium'
+import testsuite from '../test/List.test'
+
+export default {
+ onCreate() {
+ console.info('TestApplication onCreate')
+ var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
+ var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
+ console.info('start run testcase!!!')
+ Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
+ },
+ onDestroy() {
+ console.info("TestApplication onDestroy");
+ }
+};
diff --git a/storage/storagefileiov9jstest/src/main/js/TestAbility/i18n/en-US.json b/storage/storagefileiov9jstest/src/main/js/TestAbility/i18n/en-US.json
new file mode 100644
index 0000000000000000000000000000000000000000..55561b83737c3c31d082fbfa11e5fc987a351104
--- /dev/null
+++ b/storage/storagefileiov9jstest/src/main/js/TestAbility/i18n/en-US.json
@@ -0,0 +1,8 @@
+{
+ "strings": {
+ "hello": "Hello",
+ "world": "World"
+ },
+ "Files": {
+ }
+}
\ No newline at end of file
diff --git a/storage/storagefileiov9jstest/src/main/js/TestAbility/i18n/zh-CN.json b/storage/storagefileiov9jstest/src/main/js/TestAbility/i18n/zh-CN.json
new file mode 100644
index 0000000000000000000000000000000000000000..cce1af06761a42add0cac1a0567aa3237eda8cb4
--- /dev/null
+++ b/storage/storagefileiov9jstest/src/main/js/TestAbility/i18n/zh-CN.json
@@ -0,0 +1,8 @@
+{
+ "strings": {
+ "hello": "您好",
+ "world": "世界"
+ },
+ "Files": {
+ }
+}
\ No newline at end of file
diff --git a/communication/dsoftbus/rpc_server/src/main/js/MainAbility/pages/index/index.css b/storage/storagefileiov9jstest/src/main/js/TestAbility/pages/index/index.css
similarity index 55%
rename from communication/dsoftbus/rpc_server/src/main/js/MainAbility/pages/index/index.css
rename to storage/storagefileiov9jstest/src/main/js/TestAbility/pages/index/index.css
index 87b92cb0fa66fabbd552fc73804aab915f79c22e..b21c92c6290ea747bd891e2ab673721afc5521ed 100644
--- a/communication/dsoftbus/rpc_server/src/main/js/MainAbility/pages/index/index.css
+++ b/storage/storagefileiov9jstest/src/main/js/TestAbility/pages/index/index.css
@@ -1,24 +1,30 @@
-.container {
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- left: 0px;
- top: 0px;
- width: 100%;
- height: 100%;
-}
-
-.title {
- font-size: 60px;
- text-align: center;
- width: 100%;
- height: 40%;
- margin: 10px;
-}
-
-.btn {
- width: 50%;
- height: 100px;
- font-size: 40px;
-}
+.container {
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+ left: 0px;
+ top: 0px;
+ width: 100%;
+ height: 100%;
+}
+
+.title {
+ font-size: 60px;
+ text-align: center;
+ width: 100%;
+ height: 40%;
+ margin: 10px;
+}
+
+@media screen and (device-type: phone) and (orientation: landscape) {
+ .title {
+ font-size: 60px;
+ }
+}
+
+@media screen and (device-type: tablet) and (orientation: landscape) {
+ .title {
+ font-size: 100px;
+ }
+}
\ No newline at end of file
diff --git a/storage/storagefileiov9jstest/src/main/js/TestAbility/pages/index/index.hml b/storage/storagefileiov9jstest/src/main/js/TestAbility/pages/index/index.hml
new file mode 100644
index 0000000000000000000000000000000000000000..f64b040a5ae394dbaa5e185e1ecd4f4556b92184
--- /dev/null
+++ b/storage/storagefileiov9jstest/src/main/js/TestAbility/pages/index/index.hml
@@ -0,0 +1,5 @@
+
+
+ {{ $t('strings.hello') }} {{ title }}
+
+
diff --git a/communication/dsoftbus/rpc_server/src/main/js/MainAbility/pages/index/index.js b/storage/storagefileiov9jstest/src/main/js/TestAbility/pages/index/index.js
similarity index 75%
rename from communication/dsoftbus/rpc_server/src/main/js/MainAbility/pages/index/index.js
rename to storage/storagefileiov9jstest/src/main/js/TestAbility/pages/index/index.js
index dc1588bf19750fbfc3cdf94b27acd30c60487029..e7cd2973f81dfe6ca5f3a93aae440cdcfdba3188 100644
--- a/communication/dsoftbus/rpc_server/src/main/js/MainAbility/pages/index/index.js
+++ b/storage/storagefileiov9jstest/src/main/js/TestAbility/pages/index/index.js
@@ -1,32 +1,23 @@
-/*
- * Copyright (c) 2021 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 router from '@system.router'
-
-export default {
- data: {
- title: ""
- },
- onInit() {
- this.title = this.$t('strings.world');
- },
- onclick: function () {
- router.replace({
- uri: "pages/second/second"
- })
- }
-}
-
-
+/*
+ * 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.
+ */
+
+export default {
+ data: {
+ title: ""
+ },
+ onInit() {
+ this.title = this.$t('strings.world');
+ }
+}
diff --git a/storage/storagefileiov9jstest/src/main/js/TestRunner/OpenHarmonyTestRunner.js b/storage/storagefileiov9jstest/src/main/js/TestRunner/OpenHarmonyTestRunner.js
new file mode 100644
index 0000000000000000000000000000000000000000..b9e78ce7cf73f1ade6ba52a408a44e33f5430f0d
--- /dev/null
+++ b/storage/storagefileiov9jstest/src/main/js/TestRunner/OpenHarmonyTestRunner.js
@@ -0,0 +1,59 @@
+/*
+ * 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
+
+function translateParamsToString(parameters) {
+ const keySet = new Set([
+ '-s class', '-s notClass', '-s suite', '-s itName',
+ '-s level', '-s testType', '-s size', '-s timeout',
+ '-s package', '-s dryRun'
+ ])
+ let targetParams = '';
+ for (const key in parameters) {
+ if (keySet.has(key)) {
+ targetParams += ' ' + key + ' ' + parameters[key]
+ }
+ }
+ return targetParams.trim()
+}
+
+ export default {
+ onPrepare() {
+ console.info('OpenHarmonyTestRunner OnPrepare')
+ },
+ onRun() {
+ console.log('OpenHarmonyTestRunner onRun run')
+ var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
+ var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
+
+ var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility'
+
+ var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
+ cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters)
+ var debug = abilityDelegatorArguments.parameters["-D"]
+ console.info('debug value : '+debug)
+ if (debug == 'true')
+ {
+ cmd += ' -D'
+ }
+ console.info('cmd : '+cmd)
+ abilityDelegator.executeShellCommand(cmd, (err, data) => {
+ console.info('executeShellCommand : err : ' + JSON.stringify(err));
+ console.info('executeShellCommand : data : ' + data.stdResult);
+ console.info('executeShellCommand : data : ' + data.exitCode);
+ })
+ }
+};
diff --git a/storage/storagefileiov9jstest/src/main/js/test/Common.js b/storage/storagefileiov9jstest/src/main/js/test/Common.js
new file mode 100644
index 0000000000000000000000000000000000000000..ad39b9337736ad91332ddc0620cfa461906dc158
--- /dev/null
+++ b/storage/storagefileiov9jstest/src/main/js/test/Common.js
@@ -0,0 +1,142 @@
+/*
+ * 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 fileio from '@ohos.fileio';
+import fileIO from '@ohos.file.fs';
+import featureAbility from '@ohos.ability.featureAbility';
+
+export const FILE_CONTENT = 'hello world';
+
+import {
+ describe, it, expect
+}
+from '@ohos/hypium'
+
+export function prepareFile(fpath, content) {
+ try {
+ let file = fileIO.openSync(fpath, fileIO.OpenMode.CREATE | fileIO.OpenMode.READ_WRITE)
+ fileIO.truncateSync(file.fd)
+ fileIO.writeSync(file.fd, content)
+ fileio.fsyncSync(file.fd)
+ fileio.closeSync(file.fd)
+ return true
+ }
+ catch (e) {
+ console.log('Failed to prepareFile for ' + e)
+ return false
+ }
+}
+
+export function prepareEmptyFile(fpath) {
+ try {
+ let file = fileIO.openSync(fpath, fileIO.OpenMode.CREATE | fileIO.OpenMode.READ_WRITE)
+ fileio.closeSync(file.fd)
+ return true
+ }
+ catch (e) {
+ console.log('Failed to prepareFile for ' + e)
+ return false
+ }
+}
+
+export function fileToReadOnly(fpath) {
+ try {
+ let file = fileio.openSync(fpath, fileIO.OpenMode.CREATE)
+ fileio.fchmodSync(file.fd, 0o444)
+ fileio.fsyncSync(file.fd)
+ fileio.closeSync(file.fd)
+ return true
+ }
+ catch (e) {
+ console.log('Failed to fileToReadOnly for ' + e);
+ return false
+ }
+}
+
+export function fileToWriteOnly(fpath) {
+ try {
+ let file = fileio.openSync(fpath, fileIO.OpenMode.CREATE | fileIO.OpenMode.WRITE_ONLY)
+ fileio.fchmodSync(file.fd, 0o222)
+ fileio.fsyncSync(file.fd)
+ fileio.closeSync(file.fd)
+ return true
+ }
+ catch (e) {
+ console.log('Failed to fileToWriteOnly ' + e)
+ return false
+ }
+}
+
+export async function nextFileName(testName) {
+ let context = featureAbility.getContext();
+ let data = await context.getCacheDir();
+ let BASE_PATH = data + '/';
+ return BASE_PATH + testName + '_' + randomString(testName.length);
+}
+
+export async function fileName(testName) {
+ let context = featureAbility.getContext();
+ let data = await context.getFilesDir();
+ let BASE_PATH = data + '/';
+ return BASE_PATH + testName + '_' + randomString(testName.length);
+}
+
+export function randomString(num) {
+ let len= num;
+ var $chars = 'aaaabbbbcccc';
+ var maxPos = $chars.length;
+ var pwd = '';
+ for (var i = 0; i < len; i++) {
+ pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
+ }
+ return pwd;
+}
+
+export function forceRemoveDir(path, num) {
+ for (let i = num; i >= 0; i--) {
+ if (i < num) {
+ path = path.replace(`/d${i}`, "");
+ }
+ fileio.rmdirSync(path);
+ }
+}
+
+function isIntNum(val) {
+ return typeof val === 'number' && val % 1 === 0;
+}
+
+function isString(str) {
+ return (typeof str == 'string') && str.constructor == String;
+}
+
+function isBoolean(val) {
+ return typeof val == 'boolean';
+}
+
+function isInclude(error, message) {
+ return error.toString().indexOf(message) != -1;
+}
+
+export {
+ fileio,
+ fileIO,
+ isIntNum,
+ isString,
+ isBoolean,
+ isInclude,
+ describe,
+ it,
+ expect
+};
\ No newline at end of file
diff --git a/storage/storagefileiov9jstest/src/main/js/test/List.test.js b/storage/storagefileiov9jstest/src/main/js/test/List.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..fe3fc11330093e40ca9cf29b6ecfb39c22c49787
--- /dev/null
+++ b/storage/storagefileiov9jstest/src/main/js/test/List.test.js
@@ -0,0 +1,27 @@
+/*
+ * 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 fileIOOpen from './members/open.test.js'
+import fileIORead from './members/read.test.js'
+import fileIOStat from './members/stat.test.js'
+import fileIOTruncate from './members/truncate.test.js'
+import fileIOWrite from './members/write.test.js'
+export default function testsuite() {
+ fileIOOpen()
+ fileIORead()
+ fileIOStat()
+ fileIOTruncate()
+ fileIOWrite()
+}
diff --git a/storage/storagefileiov9jstest/src/main/js/test/members/open.test.js b/storage/storagefileiov9jstest/src/main/js/test/members/open.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..9589c56b5aaad02a0a6352f43bd86f7f4bcf55d0
--- /dev/null
+++ b/storage/storagefileiov9jstest/src/main/js/test/members/open.test.js
@@ -0,0 +1,738 @@
+/*
+ * 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 {
+ fileio, fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum,
+ describe, it, expect,
+ } from '../Common';
+
+ export default function fileIOOpen() {
+ describe('fileIO_fs_open', function () {
+
+ /**
+ * @tc.number SUB_DF_FILEIO_OPEN_SYNC_0000
+ * @tc.name fileIO_test_open_sync_000
+ * @tc.desc Test openSync() interfaces. mode=0o0.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_open_sync_000', 0, async function () {
+ let fpath = await nextFileName('fileIO_test_open_sync_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY);
+ expect(isIntNum(file.fd)).assertTrue();
+ let readlen = fileIO.readSync(file.fd, new ArrayBuffer(4096));
+ expect(readlen == FILE_CONTENT.length).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_test_open_sync_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_OPEN_SYNC_0100
+ * @tc.name fileIO_test_open_sync_001
+ * @tc.desc Test openSync() interfaces. mode=0o1.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_open_sync_001', 0, async function () {
+ let fpath = await nextFileName('fileIO_test_open_sync_001');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
+ expect(isIntNum(file.fd)).assertTrue();
+ let length = 20;
+ let num = fileIO.writeSync(file.fd, new ArrayBuffer(length));
+ expect(num == length).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_test_open_sync_001 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_OPEN_SYNC_0200
+ * @tc.name fileIO_test_open_sync_002
+ * @tc.desc Test openSync() interfaces. mode=0o2.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_open_sync_002', 0, async function () {
+ let fpath = await nextFileName('fileIO_test_open_sync_002');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
+ expect(isIntNum(file.fd)).assertTrue();
+ let readlen = fileIO.readSync(file.fd, new ArrayBuffer(4096));
+ expect(readlen == FILE_CONTENT.length).assertTrue();
+ let length = 20;
+ let num = fileIO.writeSync(file.fd, new ArrayBuffer(length));
+ expect(num == length).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_test_open_sync_002 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_OPEN_SYNC_0300
+ * @tc.name fileIO_test_open_sync_003
+ * @tc.desc Test openSync() interfaces. Missing Parameter.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_open_sync_003', 0, function () {
+ try {
+ fileIO.openSync();
+ expect(false).assertTrue();
+ } catch (e) {
+ console.log('fileIO_test_open_sync_003 has failed for ' + e.message + ', code: ' + e.code);
+ expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue;
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_OPEN_SYNC_0400
+ * @tc.name fileIO_test_open_sync_004
+ * @tc.desc Test openSync() interfaces. mode=0o102.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_open_sync_004', 0, async function () {
+ let fpath = await nextFileName('fileIO_test_open_sync_004');
+
+ try {
+ let file = fileIO.openSync(fpath, fileIO.OpenMode.CREATE | fileIO.OpenMode.READ_WRITE);
+ expect(isIntNum(file.fd)).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_test_open_sync_004 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_OPEN_SYNC_0500
+ * @tc.name fileIO_test_open_sync_005
+ * @tc.desc Test openSync() interfaces. mode=0o1002.
+ * If the file exists and the file is opened for write-only or read-write, trim its length to zero.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_open_sync_005', 0, async function () {
+ let fpath = await nextFileName('fileIO_test_open_sync_005');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = fileIO.openSync(fpath, fileIO.OpenMode.TRUNC | fileIO.OpenMode.READ_WRITE);
+ expect(isIntNum(file.fd)).assertTrue();
+ let number = fileIO.readSync(file.fd, new ArrayBuffer(4096));
+ expect(number == 0).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_test_open_sync_005 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_OPEN_SYNC_0600
+ * @tc.name fileIO_test_open_sync_006
+ * @tc.desc Test openSync() interfaces. mode=0o2002.
+ * Open as append, subsequent writes will append to the end of the file.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_open_sync_006', 0, async function () {
+ let fpath = await nextFileName('fileIO_test_open_sync_006');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = fileIO.openSync(fpath, fileIO.OpenMode.APPEND | fileIO.OpenMode.READ_WRITE);
+ expect(isIntNum(file.fd)).assertTrue();
+ let length = 100;
+ let num = fileIO.writeSync(file.fd, new ArrayBuffer(length));
+ expect(num == length).assertTrue();
+ let number = fileIO.readSync(file.fd, new ArrayBuffer(4096), { offset: 0 });
+ expect(number == length + FILE_CONTENT.length).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_test_open_sync_006 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_OPEN_SYNC_0700
+ * @tc.name fileIO_test_open_sync_007
+ * @tc.desc Test openSync() interfaces. mode=0o4002.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_open_sync_007', 0, async function () {
+ let fpath = await nextFileName('fileIO_test_open_sync_007');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = fileIO.openSync(fpath, fileIO.OpenMode.NONBLOCK | fileIO.OpenMode.READ_WRITE);
+ expect(isIntNum(file.fd)).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_test_open_sync_007 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_OPEN_SYNC_0800
+ * @tc.name fileIO_test_open_sync_008
+ * @tc.desc Test openSync() interfaces. mode=0o200000.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_open_sync_008', 0, async function () {
+ let dpath = await nextFileName('fileIO_test_open_sync_008');
+ fileio.mkdirSync(dpath);
+
+ try {
+ let file = fileIO.openSync(dpath, fileIO.OpenMode.DIR);
+ expect(isIntNum(file.fd)).assertTrue();
+ fileio.rmdirSync(dpath);
+ } catch (e) {
+ console.log('fileIO_test_open_sync_008 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_OPEN_SYNC_0900
+ * @tc.name fileIO_test_open_sync_009
+ * @tc.desc Test openSync() interfaces. mode=0o200000. Not a directory.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_open_sync_009', 0, async function () {
+ let fpath = await nextFileName('fileIO_test_open_sync_009');
+ expect(prepareFile(fpath, '')).assertTrue();
+
+ try {
+ fileIO.openSync(fpath, fileIO.OpenMode.DIR);
+ expect(false).assertTrue();
+ } catch (e) {
+ console.log('fileIO_test_open_sync_009 has failed for ' + e.message + ', code: ' + e.code);
+ expect(e.code == 13900002 && e.message == 'No such file or directory').assertTrue;
+ fileio.unlinkSync(fpath);
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_OPEN_SYNC_1000
+ * @tc.name fileIO_test_open_sync_010
+ * @tc.desc Test openSync() interfaces. mode=0o400002.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_open_sync_010', 0, async function () {
+ let fpath = await nextFileName('fileIO_test_open_sync_010');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = fileIO.openSync(fpath, fileIO.OpenMode.NOFOLLOW | fileIO.OpenMode.READ_WRITE);
+ expect(isIntNum(file.fd)).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_test_open_sync_010 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_OPEN_SYNC_1100
+ * @tc.name fileIO_test_open_sync_011
+ * @tc.desc Test openSync() interfaces. mode=0o400002. Shouldn't be Symbolic link.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_open_sync_011', 0, async function () {
+ let fpath = await nextFileName('fileIO_test_open_sync_011');
+ let ffpath = fpath + 'aaaa';
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ fileio.symlinkSync(fpath, ffpath);
+ fileIO.openSync(ffpath, fileIO.OpenMode.NOFOLLOW | fileIO.OpenMode.READ_WRITE);
+ expect(false).assertTrue();
+ } catch (e) {
+ console.log('fileIO_test_open_sync_011 has failed for ' + e.message + ', code: ' + e.code);
+ expect(e.code == 13900033 && e.message == 'Too many symbolic links encountered').assertTrue;
+ fileio.unlinkSync(fpath);
+ fileio.unlinkSync(ffpath);
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_OPEN_SYNC_1200
+ * @tc.name fileIO_test_open_sync_012
+ * @tc.desc Test openSync() interfaces. mode=0o4010002.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_open_sync_012', 0, async function () {
+ let fpath = await nextFileName('fileIO_test_open_sync_012');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = fileIO.openSync(fpath, fileIO.OpenMode.SYNC | fileIO.OpenMode.READ_WRITE);
+ expect(isIntNum(file.fd)).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_test_open_sync_012 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_OPEN_ASYNC_0000
+ * @tc.name fileIO_test_open_async_000
+ * @tc.desc Test open() interfaces. mode=0o0.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_open_async_000', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_test_open_async_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ fileIO.open(fpath, fileIO.OpenMode.READ_ONLY, function (err, file) {
+ fileIO.read(file.fd, new ArrayBuffer(4096))
+ .then(function (res) {
+ expect(res == FILE_CONTENT.length).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ });
+ });
+ } catch (e) {
+ console.log('fileIO_test_open_async_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_OPEN_ASYNC_0100
+ * @tc.name fileIO_test_open_async_001
+ * @tc.desc Test open() interfaces. mode=0o2. No such file.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_open_async_001', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_test_open_async_001');
+
+ try {
+ await fileIO.open(fpath, fileIO.OpenMode.READ_WRITE);
+ expect(false).assertTrue();
+ } catch (e) {
+ console.log('fileIO_test_open_async_001 has failed for ' + e.message + ', code: ' + e.code);
+ expect(e.code == 13900002 && e.message == 'No such file or directory').assertTrue;
+ done();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_OPEN_ASYNC_0200
+ * @tc.name fileIO_test_open_async_002
+ * @tc.desc Test open() interfaces. Invalid fp.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_open_async_002', 0, async function (done) {
+ try {
+ await fileIO.open(-1, fileIO.OpenMode.READ_WRITE);
+ expect(false).assertTrue();
+ } catch (e) {
+ console.log('fileIO_test_open_async_002 has failed for ' + e.message + ', code: ' + e.code);
+ expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
+ done();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_OPEN_ASYNC_0300
+ * @tc.name fileIO_test_open_async_003
+ * @tc.desc Test open() interfaces. mode=0o1.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_open_async_003', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_test_open_async_003');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = await fileIO.open(fpath, fileIO.OpenMode.WRITE_ONLY);
+ expect(isIntNum(file.fd)).assertTrue();
+ let length = 20;
+ let num = fileIO.writeSync(file.fd, new ArrayBuffer(length));
+ expect(num == length).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_test_open_async_003 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_OPEN_ASYNC_0400
+ * @tc.name fileIO_test_open_async_004
+ * @tc.desc Test open() interfaces. mode=0o2.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_open_async_004', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_test_open_async_004');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = await fileIO.open(fpath, fileIO.OpenMode.READ_WRITE);
+ expect(isIntNum(file.fd)).assertTrue();
+ let readlen = fileIO.readSync(file.fd, new ArrayBuffer(4096));
+ expect(readlen == FILE_CONTENT.length).assertTrue();
+ let length = 20;
+ let num = fileIO.writeSync(file.fd, new ArrayBuffer(length));
+ expect(num == length).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_test_open_async_004 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_OPEN_ASYNC_0500
+ * @tc.name fileIO_test_open_async_005
+ * @tc.desc Test open() interfaces. mode=0o102. Promise.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_open_async_005', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_test_open_async_005');
+
+ try {
+ let file = await fileIO.open(fpath, fileIO.OpenMode.CREATE | fileIO.OpenMode.READ_WRITE);
+ expect(isIntNum(file.fd)).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_test_open_async_005 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_OPEN_ASYNC_0600
+ * @tc.name fileIO_test_open_async_006
+ * @tc.desc Test open() interfaces. mode=0o102. Callback.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_open_async_006', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_test_open_async_006');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ fileIO.open(fpath, fileIO.OpenMode.CREATE | fileIO.OpenMode.READ_WRITE, function (err, file) {
+ expect(isIntNum(file.fd)).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ });
+ } catch (e) {
+ console.log('fileIO_test_open_async_006 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_OPEN_ASYNC_0700
+ * @tc.name fileIO_test_open_async_007
+ * @tc.desc Test open() interfaces. mode=0o1002.
+ * If the file exists and the file is opened for write-only or read-write, trim its length to zero.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_open_async_007', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_test_open_async_007');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = await fileIO.open(fpath, fileIO.OpenMode.TRUNC | fileIO.OpenMode.READ_WRITE);
+ expect(isIntNum(file.fd)).assertTrue();
+ let number = fileIO.readSync(file.fd, new ArrayBuffer(4096));
+ expect(number == 0).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_test_open_async_007 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_OPEN_ASYNC_0800
+ * @tc.name fileIO_test_open_async_008
+ * @tc.desc Test open() interfaces. mode=0o2002.
+ * Open as append, subsequent writes will append to the end of the file.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_open_async_008', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_test_open_async_008');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = await fileIO.open(fpath, fileIO.OpenMode.APPEND | fileIO.OpenMode.READ_WRITE);
+ expect(isIntNum(file.fd)).assertTrue();
+ let length = 100;
+ let num = fileIO.writeSync(file.fd, new ArrayBuffer(length));
+ expect(num == length).assertTrue();
+ let number = fileIO.readSync(file.fd, new ArrayBuffer(4096), { offset: 0 });
+ expect(number == length + FILE_CONTENT.length).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_test_open_async_008 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_OPEN_ASYNC_0900
+ * @tc.name fileIO_test_open_async_009
+ * @tc.desc Test open() interfaces. mode=0o4002.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_open_async_009', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_test_open_async_009');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = await fileIO.open(fpath, fileIO.OpenMode.NONBLOCK | fileIO.OpenMode.READ_WRITE);
+ expect(isIntNum(file.fd)).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_test_open_async_009 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_OPEN_ASYNC_1000
+ * @tc.name fileIO_test_open_async_010
+ * @tc.desc Test open() interfaces. mode=0o200000.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_open_async_010', 0, async function (done) {
+ let dpath = await nextFileName('fileIO_test_open_async_010');
+ fileio.mkdirSync(dpath);
+
+ try {
+ let file = await fileIO.open(dpath, fileIO.OpenMode.DIR);
+ expect(isIntNum(file.fd)).assertTrue();
+ fileio.rmdirSync(dpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_test_open_async_010 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_OPEN_ASYNC_1100
+ * @tc.name fileIO_test_open_async_011
+ * @tc.desc Test open() interfaces. mode=0o200000. Not a directory.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_open_async_011', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_test_open_async_011');
+ expect(prepareFile(fpath, '')).assertTrue();
+
+ try {
+ await fileIO.open(fpath, fileIO.OpenMode.DIR | fileIO.OpenMode.READ_WRITE);
+ expect(false).assertTrue();
+ } catch (e) {
+ fileio.unlinkSync(fpath);
+ console.log('fileIO_test_open_async_011 has failed for ' + e.message + ', code: ' + e.code);
+ expect(e.code == 13900002 && e.message == 'No such file or directory').assertTrue;
+ done();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_OPEN_ASYNC_1200
+ * @tc.name fileIO_test_open_async_012
+ * @tc.desc Test open() interfaces. mode=0o400002.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_open_async_012', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_test_open_async_012');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = await fileIO.open(fpath, fileIO.OpenMode.NOFOLLOW | fileIO.OpenMode.READ_WRITE);
+ expect(isIntNum(file.fd)).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_test_open_async_012 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_OPEN_ASYNC_1300
+ * @tc.name fileIO_test_open_async_013
+ * @tc.desc Test open() interfaces. mode=0o400002. Shouldn't be Symbolic link.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_open_async_013', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_test_open_async_013');
+ let ffpath = fpath + 'aaaa';
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ fileio.symlinkSync(fpath, ffpath);
+ await fileIO.open(ffpath, fileIO.OpenMode.NOFOLLOW | fileIO.OpenMode.READ_WRITE);
+ expect(false).assertTrue();
+ } catch (e) {
+ console.log('fileIO_test_open_async_013 has failed for ' + e.message + ', code: ' + e.code);
+ expect(e.code == 13900033 && e.message == 'Too many symbolic links encountered').assertTrue;
+ fileio.unlinkSync(fpath);
+ fileio.unlinkSync(ffpath);
+ done();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_OPEN_ASYNC_1400
+ * @tc.name fileIO_test_open_async_014
+ * @tc.desc Test open() interfaces. mode=0o4010002.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_open_async_014', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_test_open_async_014');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ fileIO.open(fpath, fileIO.OpenMode.SYNC | fileIO.OpenMode.READ_WRITE, function(err, file) {
+ expect(isIntNum(file.fd)).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ });
+ } catch (err) {
+ console.log('fileIO_test_open_async_014 has failed for ' + err.message + ', code: ' + err.code);
+ expect(false).assertTrue();
+ }
+ });
+});
+}
diff --git a/storage/storagefileiov9jstest/src/main/js/test/members/read.test.js b/storage/storagefileiov9jstest/src/main/js/test/members/read.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..9fc47763d483822e29d96d80f2373bf1d84eec2c
--- /dev/null
+++ b/storage/storagefileiov9jstest/src/main/js/test/members/read.test.js
@@ -0,0 +1,372 @@
+/*
+ * 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 {
+ fileio, fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum,
+ describe, it, expect,
+} from '../Common';
+
+ export default function fileIORead() {
+ describe('fileIO_fs_read', function () {
+
+ /**
+ * @tc.number SUB_DF_FILEIO_READ_SYNC_0000
+ * @tc.name fileIO_test_read_sync_000
+ * @tc.desc Test readSync() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_read_sync_000', 0, async function () {
+ let fpath = await nextFileName('fileIO_test_read_sync_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY);
+ expect(isIntNum(file.fd)).assertTrue();
+ let len = fileIO.readSync(file.fd, new ArrayBuffer(4096));
+ expect(len == FILE_CONTENT.length).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_test_read_sync_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_READ_SYNC_0100
+ * @tc.name fileIO_test_read_sync_001
+ * @tc.desc Test readSync() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_read_sync_001', 0, async function () {
+ let fpath = await nextFileName('fileIO_test_read_sync_001');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY);
+ expect(isIntNum(file.fd)).assertTrue();
+ let len = fileIO.readSync(file.fd, new ArrayBuffer(4096), {
+ length: 1,
+ });
+ expect(len == 1).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_test_read_sync_001 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_READ_SYNC_0200
+ * @tc.name fileIO_test_read_sync_002
+ * @tc.desc Test readSync() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_read_sync_002', 0, async function () {
+ let fpath = await nextFileName('fileIO_test_read_sync_002');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY);
+ expect(isIntNum(file.fd)).assertTrue();
+ let len = fileIO.readSync(file.fd, new ArrayBuffer(4096), {
+ offset: 1,
+ });
+ expect(len == FILE_CONTENT.length - 1).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_test_read_sync_002 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_READ_SYNC_0300
+ * @tc.name fileIO_test_read_sync_003
+ * @tc.desc Test readSync() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_read_sync_003', 0, async function () {
+ let fpath = await nextFileName('fileIO_test_read_sync_003');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+ let file;
+ const invalidLength = 9999;
+
+ try {
+ file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY);
+ expect(isIntNum(file.fd)).assertTrue();
+ fileIO.readSync(file.fd, new ArrayBuffer(4096), {length: invalidLength});
+ expect(false).assertTrue();
+ } catch (e) {
+ console.log('fileIO_test_read_sync_003 has failed for ' + e.message + ', code: ' + e.code);
+ expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_READ_SYNC_0400
+ * @tc.name fileIO_test_read_sync_004
+ * @tc.desc Test readSync() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_read_sync_004', 0, async function () {
+
+ try {
+ fileIO.readSync(-1, new ArrayBuffer(4096));
+ expect(false).assertTrue();
+ } catch (e) {
+ console.log('fileIO_test_read_sync_004 has failed for ' + e.message + ', code: ' + e.code);
+ expect(e.code == 13900008 && e.message == 'Bad file descriptor').assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_READ_SYNC_0500
+ * @tc.name fileIO_test_read_sync_005
+ * @tc.desc Test readSync() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_read_sync_005', 0, async function () {
+ let fpath = await nextFileName('fileIO_test_read_sync_005');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY);
+ expect(isIntNum(file.fd)).assertTrue();
+ let invalidPos = FILE_CONTENT.length + 1;
+ let len = fileIO.readSync(file.fd, new ArrayBuffer(4096), {
+ offset: invalidPos,
+ });
+ expect(len == 0).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_test_read_sync_005 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_READ_ASYNC_0000
+ * @tc.name fileIO_test_read_async_000
+ * @tc.desc Test read() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_read_async_000', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_test_read_async_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY);
+ expect(isIntNum(file.fd)).assertTrue();
+ let res = await fileIO.read(file.fd, new ArrayBuffer(4096));
+ expect(res == FILE_CONTENT.length).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_test_read_async_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_READ_ASYNC_0100
+ * @tc.name fileIO_test_read_async_001
+ * @tc.desc Test read() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_read_async_001', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_test_read_async_001');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY);
+ expect(isIntNum(file.fd)).assertTrue();
+ fileIO.read(file.fd, new ArrayBuffer(4096), async function (err, readlen) {
+ expect(readlen == FILE_CONTENT.length).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ });
+ } catch (e) {
+ console.log('fileIO_test_read_async_001 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_READ_ASYNC_0200
+ * @tc.name fileIO_test_read_async_002
+ * @tc.desc Test read() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_read_async_002', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_test_read_async_002');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY);
+ expect(isIntNum(file.fd)).assertTrue();
+ let readlen = await fileIO.read(file.fd, new ArrayBuffer(4096));
+ expect(readlen == FILE_CONTENT.length).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_test_read_async_002 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_READ_ASYNC_0300
+ * @tc.name fileIO_test_read_async_003
+ * @tc.desc Test read() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_read_async_003', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_test_read_async_003');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY);
+ expect(isIntNum(file.fd)).assertTrue();
+ let readlen = await fileIO.read(file.fd, new ArrayBuffer(4096), {
+ offset: 1,
+ });
+ expect(readlen == FILE_CONTENT.length - 1).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_test_read_async_003 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_READ_ASYNC_0400
+ * @tc.name fileIO_test_read_async_004
+ * @tc.desc Test read() interface.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_read_async_004', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_test_read_async_004');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY);
+ expect(isIntNum(file.fd)).assertTrue();
+ let readlen = await fileIO.read(file.fd, new ArrayBuffer(4096), {
+ length: 3,
+ });
+ expect(readlen == 3).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_test_read_async_004 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_READ_ASYNC_0500
+ * @tc.name fileIO_test_read_async_005
+ * @tc.desc Test read() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_read_async_005', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_test_read_async_005');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY);
+ expect(isIntNum(file.fd)).assertTrue();
+ let len = await fileIO.read(file.fd, new ArrayBuffer(4096), {
+ offset: FILE_CONTENT.length + 1,
+ });
+ expect(isIntNum(len)).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_test_read_async_005 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_READ_ASYNC_0600
+ * @tc.name fileIO_test_read_async_006
+ * @tc.desc Test read() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_read_async_006', 0, async function (done) {
+ try {
+ await fileIO.read(-1, new ArrayBuffer(4096));
+ expect(false).assertTrue();
+ } catch (e) {
+ console.log('fileIO_test_read_async_006 has failed for ' + e.message + ', code: ' + e.code);
+ expect(e.code == 13900008 && e.message == 'Bad file descriptor').assertTrue();
+ done();
+ }
+ });
+});
+}
diff --git a/storage/storagefileiov9jstest/src/main/js/test/members/stat.test.js b/storage/storagefileiov9jstest/src/main/js/test/members/stat.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..23f4b14091c88087482a5f8b2c369ee3c19f5d3d
--- /dev/null
+++ b/storage/storagefileiov9jstest/src/main/js/test/members/stat.test.js
@@ -0,0 +1,2013 @@
+/*
+ * 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 {
+ fileio, fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum, isBoolean,
+ describe, it, expect,
+ } from '../Common';
+
+export default function fileIOStat() {
+describe('fileIO_fs_stat', function () {
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_0000
+ * @tc.name fileIO_stat_sync_000
+ * @tc.desc Test Stat.statSync() interfaces.
+ * This interface shall work properly in normal case.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_000', 0, async function () {
+ let fpath = await nextFileName('fileIO_stat_sync_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = fileIO.statSync(fpath);
+ expect(stat !== null).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = fileIO.statSync(file.fd);
+ expect(stat2 !== null).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_stat_sync_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_0100
+ * @tc.name fileIO_stat_sync_001
+ * @tc.desc Test Stat.statSync() interfaces.
+ * This interface shall throw an exception when the file isnt's exist.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_001', 0, async function () {
+ let fpath = await nextFileName('fileIO_stat_sync_001');
+
+ try {
+ fileIO.statSync(fpath);
+ expect(false).assertTrue();
+ } catch (e) {
+ expect(e.code == 13900002 && e.message == 'No such file or directory').assertTrue();
+ console.log('fileIO_stat_sync_001 has failed for ' + e.message + ', code: ' + e.code);
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_0200
+ * @tc.name fileIO_stat_sync_002
+ * @tc.desc Test Stat.statSync() interfaces.
+ * This interface shall throw an exception when the file isnt's exist.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_002', 0, async function () {
+ let fpath = await nextFileName('fileIO_stat_sync_002');
+
+ try {
+ fileIO.statSync();
+ expect(false).assertTrue();
+ } catch (e) {
+ expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
+ console.log('fileIO_stat_sync_002 has failed for ' + e.message + ', code: ' + e.code);
+ }
+ });
+
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_INO_0000
+ * @tc.name fileIO_stat_sync_ino_000
+ * @tc.desc Test Stat.statSync_Ino() interfaces.
+ * @tc.desc Test the ino member of class Stat
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_ino_000', 0, async function () {
+ let fpath = await nextFileName('fileIO_stat_sync_ino_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = fileIO.statSync(fpath);
+ expect(isIntNum(stat.ino)).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = fileIO.statSync(file.fd);
+ expect(isIntNum(stat2.ino)).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.info('fileIO_stat_sync_ino_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_MODE_0000
+ * @tc.name fileIO_stat_sync_mode_000
+ * @tc.desc Test Stat.statSync_Mode() interfaces.
+ * @tc.desc Test the mode member of class Stat
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_mode_000', 0, async function () {
+ let fpath = await nextFileName('fileIO_stat_sync_mode_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = fileIO.statSync(fpath);
+ expect(isIntNum(stat.mode)).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = fileIO.statSync(file.fd);
+ expect(isIntNum(stat2.mode)).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.info('fileIO_stat_sync_mode_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_UID_0000
+ * @tc.name fileIO_stat_sync_uid_000
+ * @tc.desc Test Stat.statSync_Uid() interfaces.
+ * @tc.desc Test the uid member of class Stat
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_uid_000', 0, async function () {
+ let fpath = await nextFileName('fileIO_stat_sync_uid_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = fileIO.statSync(fpath);
+ expect(isIntNum(stat.uid)).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = fileIO.statSync(file.fd);
+ expect(isIntNum(stat2.uid)).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_stat_sync_uid_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_GID_0000
+ * @tc.name fileIO_stat_sync_gid_000
+ * @tc.desc Test Stat.statSync_Gid() interfaces.
+ * @tc.desc Test the gid member of class Stat
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_gid_000', 0, async function () {
+ let fpath = await nextFileName('fileIO_stat_sync_gid_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = fileIO.statSync(fpath);
+ expect(isIntNum(stat.gid)).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = fileIO.statSync(file.fd);
+ expect(isIntNum(stat2.gid)).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_stat_sync_gid_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_SIZE_0000
+ * @tc.name fileIO_stat_sync_size_000
+ * @tc.desc Test Stat.statSync_Size() interfaces.
+ * @tc.desc Test the size member of class Stat
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_size_000', 0, async function () {
+ let fpath = await nextFileName('fileIO_stat_sync_size_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = fileIO.statSync(fpath);
+ expect(isIntNum(stat.size)).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = fileIO.statSync(file.fd);
+ expect(isIntNum(stat2.size)).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_stat_sync_size_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_BLKSIZE_0000
+ * @tc.name fileIO_stat_sync_blksize_000
+ * @tc.desc Test Stat.statSync_Blksize() interfaces.
+ * @tc.desc Test the blksize member of class Stat
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_blksize_000', 0, async function () {
+ let fpath = await nextFileName('fileIO_stat_sync_blksize_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = fileIO.statSync(fpath);
+ expect(isIntNum(stat.blksize)).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = fileIO.statSync(file.fd);
+ expect(isIntNum(stat2.blksize)).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_stat_sync_blksize_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_ATIME_0000
+ * @tc.name fileIO_stat_sync_atime_000
+ * @tc.desc Test Stat.statSync_Atime() interfaces.
+ * @tc.desc Test the atime member of class Stat
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_atime_000', 0, async function () {
+ let fpath = await nextFileName('fileIO_stat_sync_atime_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = fileIO.statSync(fpath);
+ expect(isIntNum(stat.atime)).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = fileIO.statSync(file.fd);
+ expect(isIntNum(stat2.atime)).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_stat_sync_atime_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_MTIME_0000
+ * @tc.name fileIO_stat_sync_mtime_000
+ * @tc.desc Test Stat.statSync_Mtime() interfaces.
+ * @tc.desc Test the mtime member of class Stat
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_mtime_000', 0, async function () {
+ let fpath = await nextFileName('fileIO_stat_sync_mtime_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = fileIO.statSync(fpath);
+ expect(isIntNum(stat.mtime)).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = fileIO.statSync(file.fd);
+ expect(isIntNum(stat2.mtime)).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_stat_sync_mtime_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_CTIME_0000
+ * @tc.name fileIO_stat_sync_ctime_000
+ * @tc.desc Test Stat.statSync_Ctime() interfaces.
+ * @tc.desc Test the ctime member of class Stat
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_ctime_000', 0, async function () {
+ let fpath = await nextFileName('fileIO_stat_sync_ctime_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = fileIO.statSync(fpath);
+ expect(isIntNum(stat.ctime)).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = fileIO.statSync(file.fd);
+ expect(isIntNum(stat2.ctime)).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_stat_sync_ctime_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_ISBLOCKDEVICE_0000
+ * @tc.name fileIO_stat_sync_is_block_device_000
+ * @tc.desc Test Stat.statSync_IsBlockDevice() interfaces.
+ * @tc.desc Test the isBlockDevice() method of class Stat.
+ * This interface shall return a boolean variable.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_is_block_device_000', 0, async function () {
+ let fpath = await nextFileName('fileIO_stat_sync_is_block_device_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = fileIO.statSync(fpath);
+ expect(isBoolean(stat.isBlockDevice())).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = fileIO.statSync(file.fd);
+ expect(isBoolean(stat2.isBlockDevice())).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_stat_sync_is_block_device_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_ISBLOCKDEVICE_0100
+ * @tc.name fileIO_stat_sync_is_block_device_001
+ * @tc.desc Test Stat.statSync_IsBlockDevice() interfaces.
+ * @tc.desc Test the isBlockDevice() method of class Stat.
+ * This interface shall not treat a normal file as a block special device.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_is_block_device_001', 0, async function () {
+ let fpath = await nextFileName('fileIO_stat_sync_is_block_device_001');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = fileIO.statSync(fpath);
+ expect(stat.isBlockDevice() === false).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = fileIO.statSync(file.fd);
+ expect(stat2.isBlockDevice() === false).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_stat_sync_is_block_device_001 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_ISBLOCKDEVICE_0200
+ * @tc.name fileIO_stat_sync_is_block_device_002
+ * @tc.desc Test Stat.statSync_IsBlockDevice() interfaces.
+ * @tc.desc Test the isBlockDevice() method of class Stat.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_is_block_device_002', 0, async function () {
+ let fpath = await nextFileName('fileIO_stat_sync_is_block_device_002');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = fileIO.statSync(fpath);
+ expect(stat.isBlockDevice(-1) === false).assertTrue();
+ expect(false).assertTrue();
+ } catch (e) {
+ console.info('fileIO_stat_sync_is_block_device_002 has failed for ' + e.message + ', code: ' + e.code);
+ expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
+ fileio.unlinkSync(fpath);
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_ISBLOCKDEVICE_0300
+ * @tc.name fileIO_stat_sync_is_block_device_003
+ * @tc.desc Test Stat.statSync_IsBlockDevice() interfaces.
+ * @tc.desc Test the isBlockDevice() method of class Stat.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_is_block_device_003', 0, async function () {
+ let fpath = await nextFileName('fileIO_stat_sync_is_block_device_003');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+ let file;
+
+ try {
+ file = fileIO.openSync(fpath);
+ let stat2 = fileIO.statSync(file.fd);
+ expect(stat2.isBlockDevice(-1) === false).assertTrue();
+ expect(false).assertTrue();
+ } catch (e) {
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ console.info('fileIO_stat_sync_is_block_device_003 has failed for ' + e.message + ', code: ' + e.code);
+ expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
+
+ }
+ });
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_ISCHARACTER_DEVICE_0000
+ * @tc.name fileIO_stat_sync_is_character_device_000
+ * @tc.desc Test Stat.statsync_IsCharacterDevice() interfaces.
+ * This interface shall return a boolean variable.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_is_character_device_000', 0, async function () {
+ let fpath = await nextFileName('fileIO_stat_sync_is_character_device_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = fileIO.statSync(fpath);
+ expect(isBoolean(stat.isCharacterDevice())).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = fileIO.statSync(file.fd);
+ expect(isBoolean(stat2.isCharacterDevice())).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_stat_sync_is_character_device_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_ISCHARACTER_DEVICE_0100
+ * @tc.name fileIO_stat_sync_is_character_device_001
+ * @tc.desc Test Stat.statsync_IsCharacterDevice() interfaces.
+ * This interface shall not treat a normal file as a character special device.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_is_character_device_001', 0, async function () {
+ let fpath = await nextFileName('fileIO_stat_sync_is_character_device_001');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = fileIO.statSync(fpath);
+ expect(stat.isCharacterDevice() === false).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = fileIO.statSync(file.fd);
+ expect(stat2.isCharacterDevice() === false).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_stat_sync_is_character_device_001 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_ISCHARACTER_DEVICE_0200
+ * @tc.name fileIO_stat_sync_is_character_device_002
+ * @tc.desc Test Stat.statsync_IsCharacterDevice() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_is_character_device_002', 0, async function () {
+ let fpath = await nextFileName('fileIO_stat_sync_is_character_device_002');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = fileIO.statSync(fpath);
+ expect(stat.isCharacterDevice(-1) === false).assertTrue();
+ expect(false).assertTrue();
+ } catch (e) {
+ fileio.unlinkSync(fpath);
+ expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_ISCHARACTER_DEVICE_0300
+ * @tc.name fileIO_stat_sync_is_character_device_003
+ * @tc.desc Test Stat.statsync_IsCharacterDevice() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_is_character_device_003', 0, async function () {
+ let fpath = await nextFileName('fileIO_stat_sync_is_character_device_003');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+ let file;
+
+ try {
+ file = fileIO.openSync(fpath);
+ let stat2 = fileIO.statSync(file.fd);
+ expect(stat2.isCharacterDevice(-1) === false).assertTrue();
+ expect(false).assertTrue();
+ } catch (e) {
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_ISDIRECTORY_0000
+ * @tc.name fileIO_stat_sync_is_directory_000
+ * @tc.desc Test Stat.statsync_isDirectory() interfaces.
+ * This interface shall return a boolean variable.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_is_directory_000', 0, async function () {
+ let fpath = await nextFileName('fileIO_stat_sync_is_directory_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = fileIO.statSync(fpath);
+ expect(isBoolean(stat.isDirectory())).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = fileIO.statSync(file.fd);
+ expect(isBoolean(stat2.isDirectory())).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_stat_sync_is_directory_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_ISDIRECTORY_0100
+ * @tc.name fileIO_stat_sync_is_directory_001
+ * @tc.desc Test Stat.statsync_isDirectory() interfaces.
+ * This interface shall not treat a normal file as a directory.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_is_directory_001', 0, async function () {
+ let fpath = await nextFileName('fileIO_stat_sync_is_directory_001');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = fileIO.statSync(fpath);
+ expect(stat.isDirectory() === false).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = fileIO.statSync(file.fd);
+ expect(stat2.isDirectory() === false).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_stat_sync_is_directory_001 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_ISDIRECTORY_0200
+ * @tc.name fileIO_stat_sync_is_directory_002
+ * @tc.desc Test Stat.statsync_isDirectory() interfaces.
+ * This interface shall treat a directory as a directory.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_is_directory_002', 0, async function () {
+ let dpath = await nextFileName('fileIO_stat_sync_is_directory_002');
+
+ try {
+ fileio.mkdirSync(dpath);
+ let stat = fileIO.statSync(dpath);
+ expect(stat.isDirectory()).assertTrue();
+
+ let file = fileIO.openSync(dpath);
+ let stat2 = fileIO.statSync(file.fd);
+ expect(stat2.isDirectory()).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.rmdirSync(dpath);
+ } catch (e) {
+ console.log('fileIO_stat_sync_is_directory_002 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_ISDIRECTORY_0300
+ * @tc.name fileIO_stat_sync_is_directory_003
+ * @tc.desc Test Stat.statsync_isDirectory() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_is_directory_003', 0, async function () {
+ let dpath = await nextFileName('fileIO_stat_sync_is_directory_003') + 'd';
+
+ try {
+ fileio.mkdirSync(dpath);
+ let stat = fileIO.statSync(dpath);
+ expect(stat.isDirectory(-1) === false).assertTrue();
+ expect(false).assertTrue();
+ } catch (e) {
+ fileio.rmdirSync(dpath);
+ expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_ISDIRECTORY_0400
+ * @tc.name fileIO_stat_sync_is_directory_004
+ * @tc.desc Test Stat.statsync_isDirectory() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_is_directory_004', 0, async function () {
+ let dpath = await nextFileName('fileIO_stat_sync_is_directory_004') + 'd';
+ let file;
+
+ try {
+ fileio.mkdirSync(dpath);
+ file = fileIO.openSync(dpath);
+ let stat2 = fileIO.statSync(file.fd);
+ expect(stat2.isDirectory(-1) === false).assertTrue();
+ expect(false).assertTrue();
+ } catch (e) {
+ fileio.closeSync(file.fd);
+ fileio.rmdirSync(dpath);
+ expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_ISFIFO_0000
+ * @tc.name fileIO_stat_sync_is_fifo_000
+ * @tc.desc Test Stat.statsync_isFIFO() interfaces.
+ * This interface shall return a boolean variable.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_is_fifo_000', 0, async function () {
+ let fpath = await nextFileName('fileIO_stat_sync_is_fifo_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = fileIO.statSync(fpath);
+ expect(isBoolean(stat.isFIFO())).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = fileIO.statSync(file.fd);
+ expect(isBoolean(stat2.isFIFO())).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_stat_sync_is_fifo_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_ISFIFO_0100
+ * @tc.name fileIO_stat_sync_is_fifo_001
+ * @tc.desc Test Stat.statsync_isFIFO() interfaces.
+ * This interface shall not treat a normal file as a FIFO.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_is_fifo_001', 0, async function () {
+ let fpath = await nextFileName('fileIO_stat_sync_is_fifo_001');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = fileIO.statSync(fpath);
+ expect(stat.isFIFO() === false).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = fileIO.statSync(file.fd);
+ expect(stat2.isFIFO() === false).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_stat_sync_is_fifo_001 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_ISFIFO_0200
+ * @tc.name fileIO_stat_sync_is_fifo_002
+ * @tc.desc Test Stat.statsync_isFIFO() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_is_fifo_002', 0, async function () {
+ let fpath = await nextFileName('fileIO_stat_sync_is_fifo_002');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = fileIO.statSync(fpath);
+ expect(stat.isFile(-1) === false).assertTrue();
+ expect(false).assertTrue();
+ } catch (e) {
+ fileio.unlinkSync(fpath);
+ expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_ISFIFO_0300
+ * @tc.name fileIO_stat_sync_is_fifo_003
+ * @tc.desc Test Stat.statsync_isFIFO() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_is_fifo_003', 0, async function () {
+ let fpath = await nextFileName('fileIO_stat_sync_is_fifo_003');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = fileIO.openSync(fpath);
+ let stat2 = fileIO.statSync(file.fd);
+ expect(stat2.isFile(-1) === false).assertTrue();
+ fileio.closeSync(file.fd);
+ expect(false).assertTrue();
+ } catch (e) {
+ fileio.unlinkSync(fpath);
+ expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
+ }
+ });
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_ISFILE_0000
+ * @tc.name fileIO_stat_sync_is_file_000
+ * @tc.desc Test Stat.statsync_isFile() interfaces.
+ * This interface shall return a boolean variable.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_is_file_000', 0, async function () {
+ let fpath = await nextFileName('fileIO_stat_sync_is_file_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = fileIO.statSync(fpath);
+ expect(isBoolean(stat.isFile())).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = fileIO.statSync(file.fd);
+ expect(isBoolean(stat2.isFile())).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_stat_sync_is_file_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_ISFILE_0100
+ * @tc.name fileIO_stat_sync_is_file_001
+ * @tc.desc Test Stat.statsync_isFile() interfaces.
+ * This interface shall treat a normal file as a normal file.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_is_file_001', 0, async function () {
+ let fpath = await nextFileName('fileIO_stat_sync_is_file_001');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = fileIO.statSync(fpath);
+ expect(stat.isFile()).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = fileIO.statSync(file.fd);
+ expect(stat2.isFile()).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_stat_sync_is_file_001 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_ISFILE_0200
+ * @tc.name fileIO_stat_sync_is_file_002
+ * @tc.desc Test Stat.statsync_isFile() interfaces.
+ * This interface shall not treat a directory as a normal file.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_is_file_002', 0, async function () {
+ let dpath = await nextFileName('fileIO_stat_sync_is_file_002');
+
+ try {
+ fileio.mkdirSync(dpath);
+ let stat = fileIO.statSync(dpath);
+ expect(stat.isFile() === false).assertTrue();
+
+ let file = fileIO.openSync(dpath);
+ let stat2 = fileIO.statSync(file.fd);
+ expect(stat2.isFile() === false).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.rmdirSync(dpath);
+ } catch (e) {
+ console.log('fileIO_stat_sync_is_file_002 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_ISFILE_0300
+ * @tc.name fileIO_stat_sync_is_file_003
+ * @tc.desc Test Stat.statsync_isFile() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_is_file_003', 0, async function () {
+ let dpath = await nextFileName('fileIO_stat_sync_is_file_003');
+
+ try {
+ fileio.mkdirSync(dpath);
+ let stat = fileIO.statSync(dpath);
+ expect(stat.isFile(-1) === false).assertTrue();
+ expect(false).assertTrue();
+ } catch (e) {
+ fileio.rmdirSync(dpath);
+ expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_ISFILE_0400
+ * @tc.name fileIO_stat_sync_is_file_004
+ * @tc.desc Test Stat.statsync_isFile() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_is_file_004', 0, async function () {
+ let dpath = await nextFileName('fileIO_stat_sync_is_file_004');
+ let file;
+
+ try {
+ fileio.mkdirSync(dpath);
+ file = fileIO.openSync(dpath);
+ let stat2 = fileIO.statSync(file.fd);
+ expect(stat2.isFile(-1) === false).assertTrue();
+ expect(false).assertTrue();
+ } catch (e) {
+ fileio.closeSync(file.fd);
+ fileio.rmdirSync(dpath);
+ expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
+ }
+ });
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_ISSOCKET_0000
+ * @tc.name fileIO_stat_sync_is_socket_000
+ * @tc.desc Test Stat.statsync_isSocket() interfaces.
+ * This interface shall return a boolean variable.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_is_socket_000', 0, async function () {
+ let fpath = await nextFileName('fileIO_stat_sync_is_socket_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = fileIO.statSync(fpath);
+ expect(isBoolean(stat.isSocket())).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = fileIO.statSync(file.fd);
+ expect(isBoolean(stat2.isSocket())).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_stat_sync_is_socket_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_ISSOCKET_0100
+ * @tc.name fileIO_stat_sync_is_socket_001
+ * @tc.desc Test Stat.statsync_isSocket() interfaces.
+ * This interface shall not treat a file as a socket.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_is_socket_001', 0, async function () {
+ let fpath = await nextFileName('fileIO_stat_sync_is_socket_001');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = fileIO.statSync(fpath);
+ expect(stat.isSocket() === false).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = fileIO.statSync(file.fd);
+ expect(stat2.isSocket() === false).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_stat_sync_is_socket_001 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_ISSOCKET_0200
+ * @tc.name fileIO_stat_sync_is_socket_002
+ * @tc.desc Test Stat.statsync_isSocket() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_is_socket_002', 0, async function () {
+ let fpath = await nextFileName('fileIO_stat_sync_is_socket_002');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = fileIO.statSync(fpath);
+ expect(stat.isSocket(-1) === false).assertTrue();
+ expect(false).assertTrue();
+ } catch (e) {
+ fileio.unlinkSync(fpath);
+ expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_ISSOCKET_0300
+ * @tc.name fileIO_stat_sync_is_socket_003
+ * @tc.desc Test Stat.statsync_isSocket() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_is_socket_003', 0, async function () {
+ let fpath = await nextFileName('fileIO_stat_sync_is_socket_003');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+ let file;
+
+ try {
+ file = fileIO.openSync(fpath);
+ let stat2 = fileIO.statSync(file.fd);
+ expect(stat2.isSocket(-1) === false).assertTrue();
+ expect(false).assertTrue();
+ } catch (e) {
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
+ }
+ });
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_ISSYMBOLICLINK_0000
+ * @tc.name fileIO_stat_sync_is_symbolic_link_000
+ * @tc.desc Test Stat.statasync_isSymbolicLink() interfaces.
+ * This interface shall return a boolean variable.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_is_symbolic_link_000', 0, async function () {
+ let fpath = await nextFileName('fileIO_stat_sync_is_symbolic_link_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = fileIO.statSync(fpath);
+ expect(isBoolean(stat.isSymbolicLink())).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = fileIO.statSync(file.fd);
+ expect(isBoolean(stat2.isSymbolicLink())).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_stat_sync_is_symbolic_link_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_ISSYMBOLICLINK_0100
+ * @tc.name fileIO_stat_sync_is_symbolic_link_001
+ * @tc.desc Test Stat.statasync_isSymbolicLink() interfaces.
+ * This interface shall not treat a normal file as a symbolic link.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_is_symbolic_link_001', 0, async function () {
+ let fpath = await nextFileName('fileIO_stat_sync_is_symbolic_link_001');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = fileIO.statSync(fpath);
+ expect(stat.isSymbolicLink() === false).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = fileIO.statSync(file.fd);
+ expect(stat2.isSymbolicLink() === false).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_stat_sync_is_symbolic_link_001 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_ISSYMBOLICLINK_0200
+ * @tc.name fileIO_stat_sync_is_symbolic_link_002
+ * @tc.desc Test Stat.isSymbolicLink() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_is_symbolic_link_002', 0, async function () {
+ let fpath = await nextFileName('fileIO_stat_sync_is_symbolic_link_002');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = fileIO.statSync(fpath);
+ expect(stat.isSymbolicLink(-1) === false).assertTrue();
+ expect(false).assertTrue();
+ } catch (e) {
+ fileio.unlinkSync(fpath);
+ expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_ISSYMBOLICLINK_0300
+ * @tc.name fileIO_stat_sync_is_symbolic_link_003
+ * @tc.desc Test Stat.isSymbolicLink() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_sync_is_symbolic_link_003', 0, async function () {
+ let fpath = await nextFileName('fileIO_stat_sync_is_symbolic_link_003');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+ let file;
+
+ try {
+ file = fileIO.openSync(fpath);
+ let stat2 = fileIO.statSync(file.fd);
+ expect(stat2.isSymbolicLink(-1) === false).assertTrue();
+ expect(false).assertTrue();
+ } catch (e) {
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
+ }
+ });
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_ASYNC_0000
+ * @tc.name fileIO_stat_async_000
+ * @tc.desc Test Stat.statAsync() interface.
+ * This interface shall work properly in normal case when providing the promise async model.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_async_000', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_stat_async_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ fileIO.stat(fpath).then((stat) => {
+ expect(stat !== null).assertTrue();
+ });
+
+ let file = fileIO.openSync(fpath);
+ fileIO.stat(file.fd).then((stat2) => {
+ expect(stat2 !== null).assertTrue();
+ fileio.closeSync(file.fd);
+ });
+ fileio.unlinkSync(fpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_stat_async_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_ASYNC_0100
+ * @tc.name fileIO_stat_async_001
+ * @tc.desc Test Stat.statAsync() interface.
+ * This interface shall work properly in normal case when providing the callback async model.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_async_001', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_stat_async_001');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ fileIO.stat(fpath, function (error) {
+ fileio.unlinkSync(fpath);
+ done();
+ });
+ } catch (e) {
+ console.log('fileIO_stat_async_001 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_ASYNC_0200
+ * @tc.name fileIO_stat_async_002
+ * @tc.desc Test Stat.statAsync() interface.
+ * This interface shall work properly in normal case when providing the callback async model.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_async_002', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_stat_async_002');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = fileIO.openSync(fpath);
+ fileIO.stat(file.fd, function (error) {
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ });
+ } catch (e) {
+ console.log('fileIO_stat_async_002 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_ASYNC_INO_0000
+ * @tc.name fileIO_stat_async_ino_000
+ * @tc.desc Test the ino member of class Stat.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_async_ino_000', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_stat_async_ino_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = await fileIO.stat(fpath);
+ expect(isIntNum(stat.ino)).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = await fileIO.stat(file.fd);
+ expect(isIntNum(stat2.ino)).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_stat_async_ino_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_ASYNC_MODE_0000
+ * @tc.name fileIO_stat_async_mode_000
+ * @tc.desc Test the mode member of class Stat.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_async_mode_000', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_stat_async_mode_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = await fileIO.stat(fpath);
+ expect(isIntNum(stat.mode)).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = await fileIO.stat(file.fd);
+ expect(isIntNum(stat2.mode)).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_stat_async_mode_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_ASYNC_UID_0000
+ * @tc.name fileIO_stat_async_uid_000
+ * @tc.desc Test the uid member of class Stat.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_async_uid_000', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_stat_async_uid_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = await fileIO.stat(fpath);
+ expect(isIntNum(stat.uid)).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = await fileIO.stat(file.fd);
+ expect(isIntNum(stat2.uid)).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_stat_async_uid_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_ASYNC_GID_0000
+ * @tc.name fileIO_stat_async_gid_000
+ * @tc.desc Test the gid member of class Stat.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_async_gid_000', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_stat_async_gid_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = await fileIO.stat(fpath);
+ expect(isIntNum(stat.gid)).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = await fileIO.stat(file.fd);
+ expect(isIntNum(stat2.gid)).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_stat_async_gid_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_ASYNC_SIZE_0000
+ * @tc.name fileIO_stat_async_size_000
+ * @tc.desc Test the size member of class Stat.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_async_size_000', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_stat_async_size_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = await fileIO.stat(fpath);
+ expect(isIntNum(stat.size)).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = await fileIO.stat(file.fd);
+ expect(isIntNum(stat2.size)).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_stat_async_size_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_ASYNC_ATIME_0000
+ * @tc.name fileIO_stat_async_atime_000
+ * @tc.desc Test Stat.atime() interface.
+ * @tc.desc Test the atime member of class Stat.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_async_atime_000', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_stat_async_atime_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = await fileIO.stat(fpath);
+ expect(isIntNum(stat.atime)).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = await fileIO.stat(file.fd);
+ expect(isIntNum(stat2.atime)).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_stat_async_atime_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_ASYNC_MTIME_0000
+ * @tc.name fileIO_stat_async_mtime_000
+ * @tc.desc Test Stat.mtime() interface.
+ * @tc.desc Test the mtime member of class Stat.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_async_mtime_000', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_stat_async_mtime_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = await fileIO.stat(fpath);
+ expect(isIntNum(stat.mtime)).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = await fileIO.stat(file.fd);
+ expect(isIntNum(stat2.mtime)).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_stat_async_mtime_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_ASYNC_CTIME_0000
+ * @tc.name fileIO_stat_async_ctime_000
+ * @tc.desc Test the ctime member of class Stat.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_async_ctime_000', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_stat_async_ctime_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = await fileIO.stat(fpath);
+ expect(isIntNum(stat.ctime)).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = await fileIO.stat(file.fd);
+ expect(isIntNum(stat2.ctime)).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_stat_async_ctime_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISBLOCKDEVICE_0000
+ * @tc.name fileIO_stat_async_is_block_device_000
+ * @tc.desc Test the isBlockDevice method of class Stat.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_async_is_block_device_000', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_stat_async_is_block_device_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = await fileIO.stat(fpath);
+ expect(isBoolean(stat.isBlockDevice())).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = await fileIO.stat(file.fd);
+ expect(isBoolean(stat2.isBlockDevice())).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_stat_async_is_block_device_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISBLOCKDEVICE_0100
+ * @tc.name fileIO_stat_async_is_block_device_001
+ * @tc.desc Test the isBlockDevice method of class Stat.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_async_is_block_device_001', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_stat_async_is_block_device_001');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = await fileIO.stat(fpath);
+ expect(stat.isBlockDevice() === false).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = await fileIO.stat(file.fd);
+ expect(stat2.isBlockDevice() === false).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_stat_async_is_block_device_001 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISCHARACTERDEVICE_0000
+ * @tc.name fileIO_stat_async_is_character_device_000
+ * @tc.desc Test the isCharacterDevice method of class Stat.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_async_is_character_device_000', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_stat_async_is_character_device_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = await fileIO.stat(fpath);
+ expect(isBoolean(stat.isCharacterDevice())).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = await fileIO.stat(file.fd);
+ expect(isBoolean(stat2.isCharacterDevice())).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_stat_async_is_character_device_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISCHARACTERDEVICE_0100
+ * @tc.name fileIO_stat_async_is_character_device_001
+ * @tc.desc Test the isCharacterDevice method of class Stat.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_async_is_character_device_001', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_stat_async_is_character_device_001');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = await fileIO.stat(fpath);
+ expect(stat.isCharacterDevice() === false).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = await fileIO.stat(file.fd);
+ expect(stat2.isCharacterDevice() === false).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_stat_async_is_character_device_001 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISDIRECTORY_0000
+ * @tc.name fileIO_stat_async_is_directory_000
+ * @tc.desc Test Stat.isDirectory() interface.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_async_is_directory_000', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_stat_async_is_directory_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = await fileIO.stat(fpath);
+ expect(isBoolean(stat.isDirectory())).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = await fileIO.stat(file.fd);
+ expect(isBoolean(stat2.isDirectory())).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_stat_async_is_directory_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISDIRECTORY_0100
+ * @tc.name fileIO_stat_async_is_directory_001
+ * @tc.desc Test Stat.isDirectory() interface.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_async_is_directory_001', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_stat_async_is_directory_001');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = await fileIO.stat(fpath);
+ expect(stat.isDirectory() === false).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = await fileIO.stat(file.fd);
+ expect(stat2.isDirectory() === false).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_stat_async_is_directory_001 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISDIRECTORY_0200
+ * @tc.name fileIO_stat_async_is_directory_002
+ * @tc.desc Test Stat.isDirectory() interface.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_async_is_directory_002', 0, async function (done) {
+ let dpath = await nextFileName('fileIO_stat_async_is_directory_002') + 'd';
+
+ try {
+ fileio.mkdirSync(dpath);
+ let stat = await fileIO.stat(dpath);
+ expect(stat.isDirectory()).assertTrue();
+
+ let file = fileIO.openSync(dpath);
+ let stat2 = await fileIO.stat(file.fd);
+ expect(stat2.isDirectory()).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.rmdirSync(dpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_stat_async_is_directory_002 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISFIFO_0000
+ * @tc.name fileIO_stat_async_is_fifo_000
+ * @tc.desc Test Stat.isFIFO() interface.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_async_is_fifo_000', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_stat_async_is_fifo_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = await fileIO.stat(fpath);
+ expect(isBoolean(stat.isFIFO())).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = await fileIO.stat(file.fd);
+ expect(isBoolean(stat2.isFIFO())).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_stat_async_is_fifo_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISFIFO_0100
+ * @tc.name fileIO_stat_async_is_fifo_001
+ * @tc.desc Test Stat.isFIFO() interface.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_async_is_fifo_001', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_stat_async_is_fifo_001');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = await fileIO.stat(fpath);
+ expect(stat.isFIFO() === false).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = await fileIO.stat(file.fd);
+ expect(stat2.isFIFO() === false).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_stat_async_is_fifo_001 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISFILE_0000
+ * @tc.name fileIO_stat_async_is_file_000
+ * @tc.desc Test Stat.isFile() interface.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_async_is_file_000', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_stat_async_is_file_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = await fileIO.stat(fpath);
+ expect(isBoolean(stat.isFile())).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = await fileIO.stat(file.fd);
+ expect(isBoolean(stat2.isFile())).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_stat_async_is_file_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISFILE_0100
+ * @tc.name fileIO_stat_async_is_file_001
+ * @tc.desc Test Stat.isFile() interface.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_async_is_file_001', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_stat_async_is_file_001');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = await fileIO.stat(fpath);
+ expect(stat.isFile()).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = await fileIO.stat(file.fd);
+ expect(stat2.isFile()).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_stat_async_is_file_001 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISFILE_0200
+ * @tc.name fileIO_stat_async_is_file_002
+ * @tc.desc Test Stat.isFile() interface.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_async_is_file_002', 0, async function (done) {
+ let dpath = await nextFileName('fileIO_stat_async_is_file_002');
+
+ try {
+ fileio.mkdirSync(dpath);
+ let stat = await fileIO.stat(dpath);
+ expect(stat.isFile() === false).assertTrue();
+
+ let file = fileIO.openSync(dpath);
+ let stat2 = await fileIO.stat(file.fd);
+ expect(stat2.isFile() === false).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.rmdirSync(dpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_stat_async_is_file_002 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISSOCKET_0000
+ * @tc.name fileIO_stat_async_is_socket_000
+ * @tc.desc Test Stat.isSocket() interface.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_async_is_socket_000', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_stat_async_is_socket_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = await fileIO.stat(fpath);
+ expect(isBoolean(stat.isSocket())).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = await fileIO.stat(file.fd);
+ expect(isBoolean(stat2.isSocket())).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_stat_async_is_socket_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISSOCKET_0100
+ * @tc.name fileIO_stat_async_is_socket_001
+ * @tc.desc Test Stat.isSocket() interface.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_async_is_socket_001', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_stat_async_is_socket_001');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = await fileIO.stat(fpath);
+ expect(stat.isSocket() === false).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = await fileIO.stat(file.fd);
+ expect(stat2.isSocket() === false).assertTrue();
+ fileio.closeSync(file.fd);
+ done();
+ } catch (e) {
+ console.log('fileIO_stat_async_is_socket_001 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISSYMBOLICLINK_0000
+ * @tc.name fileIO_stat_async_is_symbolic_link_000
+ * @tc.desc Test Stat.isSymbolicLink() interface.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_async_is_symbolic_link_000', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_stat_async_is_symbolic_link_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = await fileIO.stat(fpath);
+ expect(isBoolean(stat.isSymbolicLink())).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = await fileIO.stat(file.fd);
+ expect(isBoolean(stat2.isSymbolicLink())).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_stat_async_is_symbolic_link_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISSYMBOLICLINK_0100
+ * @tc.name fileIO_stat_async_is_symbolic_link_001
+ * @tc.desc Test Stat.isSymbolicLink() interface.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_stat_async_is_symbolic_link_001', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_stat_async_is_symbolic_link_001');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = await fileIO.stat(fpath);
+ expect(stat.isSymbolicLink() === false).assertTrue();
+
+ let file = fileIO.openSync(fpath);
+ let stat2 = await fileIO.stat(file.fd);
+ expect(stat2.isSymbolicLink() === false).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_stat_async_is_symbolic_link_001 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_APPEND_FILE_SYNC_0000
+ * @tc.name fileIO_stat_sync_append_file_sync_000
+ * @tc.desc Test Stat.statSync() interface.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_append_file_sync_000', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_test_append_file_sync_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let stat = fileIO.statSync(fpath);
+ expect(isIntNum(stat.size)).assertTrue();
+
+ let file = fileIO.openSync(fpath, fileIO.OpenMode.APPEND | fileIO.OpenMode.READ_WRITE);
+ expect(isIntNum(file.fd)).assertTrue();
+ expect(fileIO.writeSync(file.fd, FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
+ fileio.closeSync(file.fd);
+
+ stat = fileIO.statSync(fpath);
+ expect(stat.size == FILE_CONTENT.length * 2).assertTrue();
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_test_append_file_sync_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ done();
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_STAT_SYNC_APPEND_FILE_SYNC_0100
+ * @tc.name fileIO_stat_sync_append_file_sync_001
+ * @tc.desc Test Stat.statSync() interface.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_append_file_sync_001', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_test_append_file_sync_001');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = fileIO.openSync(fpath, fileIO.OpenMode.APPEND | fileIO.OpenMode.READ_WRITE);
+ let stat = fileIO.statSync(file.fd);
+ expect(isIntNum(stat.size)).assertTrue();
+ expect(isIntNum(file.fd)).assertTrue();
+ expect(fileIO.writeSync(file.fd, FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
+ fileio.closeSync(file.fd);
+
+ let file2 = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
+ stat = fileIO.statSync(file2.fd);
+ expect(stat.size == FILE_CONTENT.length * 2).assertTrue();
+ fileio.closeSync(file2.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_test_append_file_sync_001 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ done();
+ });
+});
+}
diff --git a/storage/storagefileiov9jstest/src/main/js/test/members/truncate.test.js b/storage/storagefileiov9jstest/src/main/js/test/members/truncate.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..ad6002eca25323d1713fc309ec42602eb0d70596
--- /dev/null
+++ b/storage/storagefileiov9jstest/src/main/js/test/members/truncate.test.js
@@ -0,0 +1,322 @@
+/*
+ * 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 {
+ fileio, fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum,
+ describe, it, expect,
+} from '../Common';
+
+ export default function fileIOTruncate() {
+ describe('fileIO_fs_truncate', function () {
+
+ /**
+ * @tc.number SUB_DF_FILEIO_TRUNCATE_ASYNC_0000
+ * @tc.name fileIO_truncate_async_000
+ * @tc.desc Test the truncate() interface that receives the fpath parameter.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_truncate_async_000', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_truncate_async_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+ let truncateLen = 5;
+
+ try {
+ await fileIO.truncate(fpath, truncateLen);
+ let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
+ expect(isIntNum(file.fd)).assertTrue();
+ let len = fileIO.readSync(file.fd, new ArrayBuffer(4096));
+ expect(len == truncateLen).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ } catch (e) {
+ console.info('fileIO_truncate_async_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_TRUNCATE_ASYNC_0100
+ * @tc.name fileIO_truncate_async_001
+ * @tc.desc Test the truncate() interface that receives the fd parameter.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_truncate_async_001', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_truncate_async_001');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+ let file;
+ let truncateLen = 5;
+
+ try {
+ file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
+ expect(isIntNum(file.fd)).assertTrue();
+ fileIO.truncate(file.fd, truncateLen, function (err) {
+ let len = fileIO.readSync(file.fd, new ArrayBuffer(4096));
+ expect(len == truncateLen).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ })
+ } catch (e) {
+ console.log('fileIO_truncate_async_001 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_TRUNCATE_ASYNC_0200
+ * @tc.name fileIO_truncate_async_002
+ * @tc.desc Test the truncate() interface that receives the fpath parameter.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_truncate_async_002', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_truncate_async_002');
+ expect(prepareFile(fpath, 'truncate')).assertTrue();
+ let truncateLen = 2;
+
+ try {
+ fileIO
+ .truncate(fpath, truncateLen)
+ .then(function (err) {
+ expect(err == null).assertTrue();
+ let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
+ expect(isIntNum(file.fd)).assertTrue();
+ let len = fileIO.readSync(file.fd, new ArrayBuffer(4096));
+ expect(len == truncateLen).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ })
+ .catch(function (e) {
+ console.log('catch ' + e.message + ', code: ' + e.code);
+ });
+ } catch(e) {
+ console.log('fileIO_truncate_async_002 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_TRUNCATE_ASYNC_0300
+ * @tc.name fileIO_truncate_async_003
+ * @tc.desc Test the truncate() interface that receives the fd parameter.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_truncate_async_003', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_truncate_async_003');
+ expect(prepareFile(fpath, 'truncate')).assertTrue();
+ let file;
+ let truncateLen = 2;
+
+ try {
+ file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
+ expect(isIntNum(file.fd)).assertTrue();
+ fileIO.truncate(file.fd, truncateLen)
+ .then(function (err) {
+ expect(err == null).assertTrue();
+ let len = fileIO.readSync(file.fd, new ArrayBuffer(4096));
+ expect(len == truncateLen).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ })
+ .catch(function (e) {
+ console.log('catch ' + e.message + ', code: ' + e.code);
+ })
+ } catch(e) {
+ console.log('fileIO_truncate_async_003 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_TRUNCATE_ASYNC_0400
+ * @tc.name fileIO_truncate_async_004
+ * @tc.desc Test the truncate() interface that receives the fpath parameter.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_truncate_async_004', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_truncate_async_004');
+ let truncateLen = 2;
+
+ try {
+ fileIO.truncate(fpath, truncateLen, function (err) {
+ done();
+ });
+ } catch (e) {
+ console.log('fileIO_truncate_async_004 has failed for ' + e.message + ', code: ' + e.code);
+ expect(!!e).assertTrue();
+ expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
+ done();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_TRUNCATE_SYNC_0000
+ * @tc.name fileIO_test_truncate_sync_000
+ * @tc.desc Test the truncateSync() interface that receives the fpath parameter.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_truncate_sync_000', 0, async function () {
+ let fpath = await nextFileName('fileIO_test_truncate_sync_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ fileIO.truncateSync(fpath);
+ expect(fileIO.statSync(fpath).size == 0).assertTrue();
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_test_truncate_sync_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_TRUNCATE_SYNC_0100
+ * @tc.name fileIO_test_truncate_sync_001
+ * @tc.desc Test the truncateSync() interface that receives the fd parameter.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_truncate_sync_001', 0, async function () {
+ let fpath = await nextFileName('fileIO_test_truncate_sync_001');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+ let file;
+ let truncateLen = 5;
+
+ try {
+ file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
+ expect(isIntNum(file.fd)).assertTrue();
+ fileIO.truncateSync(file.fd, truncateLen);
+ let len = fileIO.readSync(file.fd, new ArrayBuffer(4096));
+ expect(len == truncateLen).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_test_truncate_sync_001 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_TRUNCATE_SYNC_0200
+ * @tc.name fileIO_test_truncate_sync_002
+ * @tc.desc Test the truncateSync() interface that receives the fpath parameter.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_truncate_sync_002', 0, async function () {
+ let fpath = await nextFileName('fileIO_test_truncate_sync_002');
+
+ try {
+ let stat = fileIO.truncateSync(fpath);
+ console.info('fileIO_test_truncate_sync_002 = ' + stat);
+ expect(false).assertTrue();
+ } catch (e) {
+ expect(e.code == 13900002 && e.message == 'No such file or directory').assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_TRUNCATE_SYNC_0300
+ * @tc.name fileIO_test_truncate_sync_003
+ * @tc.desc Test the truncateSync() interface that receives the fd parameter.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_truncate_sync_003', 0, async function () {
+ let fpath = await nextFileName('fileIO_test_truncate_sync_003');
+ expect(prepareFile(fpath, 'truncate')).assertTrue();
+ let file;
+ let truncateLen = 2;
+ try {
+ file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
+ expect(isIntNum(file.fd)).assertTrue();
+ fileIO.truncateSync(file.fd, truncateLen);
+ let len = fileIO.readSync(file.fd, new ArrayBuffer(4096));
+ expect(len == truncateLen).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_test_truncate_sync_003 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_TRUNCATE_SYNC_0400
+ * @tc.name fileIO_test_truncate_sync_004
+ * @tc.desc Test truncateSync() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_truncate_sync_004', 0, function () {
+ try {
+ let stat = fileIO.truncateSync();
+ console.info('fileIO_test_truncate_sync_004 = ' + stat);
+ expect(false).assertTrue();
+ } catch (e) {
+ expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_TRUNCATE_SYNC_0500
+ * @tc.name fileIO_test_truncate_sync_005
+ * @tc.desc Test truncateSync() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_truncate_sync_005', 0, async function () {
+ let fpath = await nextFileName('fileIO_test_truncate_sync_005');
+ let truncateLen = 2;
+ try {
+ fileIO.truncateSync(fpath, truncateLen);
+ } catch (e) {
+ console.log('fileIO_test_truncate_sync_005 has failed for ' + e.message + ', code: ' + e.code);
+ expect(!!e).assertTrue();
+ }
+ });
+});
+}
+
diff --git a/storage/storagefileiov9jstest/src/main/js/test/members/write.test.js b/storage/storagefileiov9jstest/src/main/js/test/members/write.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..38c9767dfa16f054e1ee1158baa6803428ed8988
--- /dev/null
+++ b/storage/storagefileiov9jstest/src/main/js/test/members/write.test.js
@@ -0,0 +1,465 @@
+/*
+ * 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 {
+ fileio, fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum,
+ describe, it, expect,
+} from '../Common';
+
+ export default function fileIOWrite() {
+ describe('fileIO_fs_write', function () {
+
+ /**
+ * @tc.number SUB_DF_FILEIO_WRITE_SYNC_0000
+ * @tc.name fileIO_test_write_sync_000
+ * @tc.desc Test writeSync() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_write_sync_000', 0, async function () {
+ let fpath = await nextFileName('fileIO_test_write_sync_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
+ expect(isIntNum(file.fd)).assertTrue();
+ expect(fileIO.writeSync(file.fd, FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_test_write_sync_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_WRITE_SYNC_0100
+ * @tc.name fileIO_test_write_sync_001
+ * @tc.desc Test writeSync() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_write_sync_001', 0, async function () {
+ let fpath = await nextFileName('fileIO_test_write_sync_001');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
+ expect(isIntNum(file.fd)).assertTrue();
+ expect(
+ fileIO.writeSync(file.fd, FILE_CONTENT, {
+ encoding: 'utf-8',
+ })
+ == FILE_CONTENT.length).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_test_write_sync_001 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+
+ /**
+ * @tc.number SUB_DF_FILEIO_WRITE_SYNC_0200
+ * @tc.name fileIO_test_write_sync_002
+ * @tc.desc Test writeSync() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_write_sync_002', 0, async function () {
+ let fpath = await nextFileName('fileIO_test_write_sync_002');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
+ expect(isIntNum(file.fd)).assertTrue();
+ expect(
+ fileIO.writeSync(file.fd, FILE_CONTENT, {
+ length: FILE_CONTENT.length - 1,
+ })
+ == FILE_CONTENT.length - 1).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_test_write_sync_002 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_WRITE_SYNC_0300
+ * @tc.name fileIO_test_write_sync_003
+ * @tc.desc Test writeSync() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_write_sync_003', 0, async function () {
+ let fpath = await nextFileName('fileIO_test_write_sync_003');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
+ expect(isIntNum(file.fd)).assertTrue();
+ expect(
+ fileIO.writeSync(file.fd, FILE_CONTENT, {
+ length: 1,
+ })
+ == 1).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_test_write_sync_003 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_WRITE_SYNC_0400
+ * @tc.name fileIO_test_write_sync_004
+ * @tc.desc Test writeSync() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_write_sync_004', 0, async function () {
+ let fpath = await nextFileName('fileIO_test_write_sync_004');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+ const invalidLength = 9999;
+ let file;
+
+ try {
+ file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
+ expect(isIntNum(file.fd)).assertTrue();
+ fileIO.writeSync(file.fd, FILE_CONTENT, {
+ length: invalidLength,
+ })
+ expect(false).assertTrue();
+ } catch (e) {
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ console.info('fileIO_test_write_sync_004 has failed for ' + e.message + ', code: ' + e.code);
+ expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_WRITE_SYNC_0500
+ * @tc.name fileIO_test_write_sync_005
+ * @tc.desc Test writeSync() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_write_sync_005', 0, function () {
+ try {
+ fileIO.writeSync(-1, FILE_CONTENT);
+ expect(false).assertTrue();
+ } catch (e) {
+ console.log('fileIO_test_write_sync_005 has failed for ' + e.message + ', code: ' + e.code);
+ expect(e.code == 13900008 && e.message == 'Bad file descriptor').assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_WRITE_SYNC_0600
+ * @tc.name fileIO_test_write_sync_006
+ * @tc.desc Test writeSync() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_write_sync_006', 0, async function () {
+ let fpath = await nextFileName('fileIO_test_write_sync_006');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
+ expect(isIntNum(file.fd)).assertTrue();
+ let writeNum = fileIO.writeSync(file.fd, new ArrayBuffer(4096));
+ expect(writeNum == 4096).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ } catch (e) {
+ console.log('fileIO_test_write_sync_006 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_WRITE_ASYNC_0000
+ * @tc.name fileIO_test_write_async_000
+ * @tc.desc Test write() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_write_async_000', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_write_async_000');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
+ expect(isIntNum(file.fd)).assertTrue();
+ expect(await fileIO.write(file.fd, FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_write_async_000 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_WRITE_ASYNC_0100
+ * @tc.name fileIO_test_write_async_001
+ * @tc.desc Test write() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_write_async_001', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_test_write_async_001');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
+ expect(isIntNum(file.fd)).assertTrue();
+ let writeNum = await fileIO.write(file.fd, FILE_CONTENT, {
+ length: 3,
+ });
+ expect(writeNum == 3).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_test_write_async_001 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_WRITE_ASYNC_0200
+ * @tc.name fileIO_test_write_async_002
+ * @tc.desc Test write() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_write_async_002', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_test_write_async_002');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
+ expect(isIntNum(file.fd)).assertTrue();
+ let writeNum = await fileIO.write(file.fd, FILE_CONTENT, {
+ length: 3,
+ offset: 5,
+ });
+ expect(writeNum == 3).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_test_write_async_002 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_WRITE_ASYNC_0300
+ * @tc.name fileIO_test_write_async_003
+ * @tc.desc Test write() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_write_async_003', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_test_write_async_003');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
+ expect(isIntNum(file.fd)).assertTrue();
+ let writeNum = await fileIO.write(file.fd, FILE_CONTENT, {
+ length: 4,
+ offset: 5,
+ encoding: 'utf-8',
+ });
+ expect(writeNum == 4).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ } catch (e) {
+ console.log('fileIO_test_write_async_003 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_WRITE_ASYNC_0400
+ * @tc.name fileIO_test_write_async_004
+ * @tc.desc Test write() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_write_async_004', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_test_write_async_004');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
+ expect(isIntNum(file.fd)).assertTrue();
+ await fileIO.write(file.fd, new ArrayBuffer(4096), function (
+ error,
+ bytesWritten
+ ) {
+ expect(bytesWritten == 4096).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ }
+ );
+ done();
+ } catch (e) {
+ console.log('fileIO_test_write_async_004 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_WRITE_ASYNC_0500
+ * @tc.name fileIO_test_write_async_005
+ * @tc.desc Test write() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_write_async_005', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_test_write_async_005');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
+ expect(isIntNum(file.fd)).assertTrue();
+ await fileIO.write(
+ file.fd,
+ FILE_CONTENT,
+ {
+ length: 5,
+ }, function (error, bytesWritten) {
+ expect(bytesWritten == 5).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ }
+ );
+ } catch (e) {
+ console.log('fileIO_test_write_async_005 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_WRITE_ASYNC_0600
+ * @tc.name fileIO_test_write_async_006
+ * @tc.desc Test write() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_write_async_006', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_test_write_async_006');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
+ expect(isIntNum(file.fd)).assertTrue();
+ await fileIO.write(
+ file.fd,
+ FILE_CONTENT,
+ {
+ length: 5,
+ offset: 5,
+ }, function (error, bytesWritten) {
+ expect(bytesWritten == 5).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ }
+ );
+ } catch (e) {
+ console.log('fileIO_test_write_async_006 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+
+ /**
+ * @tc.number SUB_DF_FILEIO_WRITE_ASYNC_0700
+ * @tc.name fileIO_test_write_async_007
+ * @tc.desc Test write() interfaces.
+ * @tc.size MEDIUM
+ * @tc.type Functoin
+ * @tc.level Level 0
+ * @tc.require
+ */
+ it('fileIO_test_write_async_007', 0, async function (done) {
+ let fpath = await nextFileName('fileIO_test_write_async_007');
+ expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
+
+ try {
+ let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
+ expect(isIntNum(file.fd)).assertTrue();
+ await fileIO.write(
+ file.fd,
+ FILE_CONTENT,
+ {
+ length: 5,
+ offset: 5,
+ encoding: 'utf-8',
+ }, function (error, bytesWritten) {
+ expect(bytesWritten == 5).assertTrue();
+ fileio.closeSync(file.fd);
+ fileio.unlinkSync(fpath);
+ done();
+ }
+ );
+ } catch (e) {
+ console.log('fileIO_test_write_async_007 has failed for ' + e.message + ', code: ' + e.code);
+ expect(false).assertTrue();
+ }
+ });
+});
+}
diff --git a/storage/storagefileiov9jstest/src/main/resources/base/element/string.json b/storage/storagefileiov9jstest/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..ce37a9309f48bf729150ad091ab4f0e8863a8652
--- /dev/null
+++ b/storage/storagefileiov9jstest/src/main/resources/base/element/string.json
@@ -0,0 +1,28 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "storagefilefsjstest"
+ },
+ {
+ "name": "mainability_description",
+ "value": "JS_Phone_Empty Feature Ability"
+ },
+ {
+ "name": "MainAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "MainAbility_label",
+ "value": "label"
+ },
+ {
+ "name": "TestAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "TestAbility_label",
+ "value": "label"
+ }
+ ]
+}
diff --git a/communication/dsoftbus/rpc_server/src/main/resources/base/media/icon.png b/storage/storagefileiov9jstest/src/main/resources/base/media/icon.png
similarity index 100%
rename from communication/dsoftbus/rpc_server/src/main/resources/base/media/icon.png
rename to storage/storagefileiov9jstest/src/main/resources/base/media/icon.png
diff --git a/time/timeTest/entry/src/main/ets/test/systemTimeTest.ets b/time/timeTest/entry/src/main/ets/test/systemTimeTest.ets
index f62cc6d90021bba76be4a80aee0cd1f469dff5f8..f17668493681f56f785b520dc914d51f4a73ed2e 100644
--- a/time/timeTest/entry/src/main/ets/test/systemTimeTest.ets
+++ b/time/timeTest/entry/src/main/ets/test/systemTimeTest.ets
@@ -19,7 +19,7 @@ import systemTime from "@ohos.systemTime";
export default function systemTimeJsunit() {
describe('systemTimeTest', function () {
- console.info('--------------------systemTimeTest start-----------------------');
+ console.info('====>---------------systemTimeTest start-----------------------');
/**
* @tc.number SUB_systemTime_getCurrentTime_JS_API_0001
* @tc.name Test systemTime.getCurrentTime
@@ -29,7 +29,7 @@ export default function systemTimeJsunit() {
* @tc.level : Level 1
*/
it("SUB_systemTime_getCurrentTime_JS_API_0001", 0, async function (done) {
- console.info("---------------UB_systemTime_getCurrentTime_JS_API_0001 start----------------");
+ console.info("====>----------UB_systemTime_getCurrentTime_JS_API_0001 start----------------");
systemTime.getCurrentTime(true, (error, data) => {
if (error) {
console.error(`failed to systemTime.getCurrentTime because ` + JSON.stringify(error));
@@ -39,7 +39,7 @@ export default function systemTimeJsunit() {
expect(data != null).assertEqual(true);
});
- console.info("---------------SUB_systemTime_getRealActiveTime_JS_API_0100 end-----------------");
+ console.info("====>----------SUB_systemTime_getRealActiveTime_JS_API_0100 end-----------------");
done();
});
@@ -52,15 +52,15 @@ export default function systemTimeJsunit() {
* @tc.level : Level 1
*/
it("SUB_systemTime_getCurrentTime_JS_API_0002", 0, async function (done) {
- console.info("----------SUB_systemTime_getCurrentTime_JS_API_0002 start----------------");
+ console.info("====>-----SUB_systemTime_getCurrentTime_JS_API_0002 start----------------");
systemTime.getCurrentTime(true).then((data) => {
- console.info(`systemTime.getCurrentTime promise success data : ` + JSON.stringify(data));
+ console.info(`SUB_systemTime_getCurrentTime_JS_API_0002 data : ` + JSON.stringify(data));
expect(data != null).assertEqual(true);
}).catch(err => {
- console.error(`failed to systemTime.getCurrentTime promise because ` + JSON.stringify(error));
+ console.error(`SUB_systemTime_getCurrentTime_JS_API_0002 err: ` + JSON.stringify(error));
expect().assertFail()
});
- console.info("----------SUB_systemTime_getCurrentTime_JS_API_0002 end------------");
+ console.info("====>-----SUB_systemTime_getCurrentTime_JS_API_0002 end------------");
done();
});
@@ -73,17 +73,17 @@ export default function systemTimeJsunit() {
* @tc.level : Level 1
*/
it("SUB_systemTime_getRealActiveTime_JS_API_0001", 0, async function (done) {
- console.info("---------------SUB_systemTime_getRealActiveTime_JS_API_0001 start----------------");
+ console.info("====>----------SUB_systemTime_getRealActiveTime_JS_API_0001 start----------------");
systemTime.getRealActiveTime(true, (error, data) => {
if (error) {
- console.error(`failed to systemTime.getRealActiveTime because ` + JSON.stringify(error));
+ console.error(`SUB_systemTime_getRealActiveTime_JS_API_0001 err: ` + JSON.stringify(error));
expect().assertFail()
};
- console.info(`systemTime.getRealActiveTime success data : ` + JSON.stringify(data));
+ console.info(`SUB_systemTime_getRealActiveTime_JS_API_0001 data : ` + JSON.stringify(data));
expect(data != null).assertEqual(true);
});
- console.info("---------------SUB_systemTime_getRealActiveTime_JS_API_0001 end-----------------");
+ console.info("====>----------SUB_systemTime_getRealActiveTime_JS_API_0001 end-----------------");
done();
});
@@ -96,15 +96,15 @@ export default function systemTimeJsunit() {
* @tc.level : Level 1
*/
it("SUB_systemTime_getRealActiveTime_JS_API_0002", 0, async function (done) {
- console.info("----------SUB_systemTime_getRealActiveTime_JS_API_0002 start----------------");
+ console.info("====>-----SUB_systemTime_getRealActiveTime_JS_API_0002 start----------------");
systemTime.getRealActiveTime(true).then((data) => {
- onsole.log(`systemTime.getRealActiveTime promise success data : ` + JSON.stringify(data));
+ onsole.log(`SUB_systemTime_getRealActiveTime_JS_API_0002 data : ` + JSON.stringify(data));
expect(data != null).assertEqual(true);
}).catch(err => {
- console.error(`failed to systemTime.getRealActiveTime promise because ` + JSON.stringify(error));
+ console.error(`SUB_systemTime_getRealActiveTime_JS_API_0002 err: ` + JSON.stringify(error));
expect().assertFail()
});
- console.info("----------SUB_systemTime_getRealActiveTime_JS_API_0002 end------------");
+ console.info("====>-----SUB_systemTime_getRealActiveTime_JS_API_0002 end------------");
done();
});
@@ -117,17 +117,17 @@ export default function systemTimeJsunit() {
* @tc.level : Level 1
*/
it("SUB_systemTime_getRealTime_JS_API_0001", 0, async function (done) {
- console.info("---------------SUB_systemTime_getRealTime_JS_API_0001 start----------------");
+ console.info("====>----------SUB_systemTime_getRealTime_JS_API_0001 start----------------");
systemTime.getRealTime(true, (error, data) => {
if (error) {
- console.error(`failed to systemTime.getRealTime because ` + JSON.stringify(error));
+ console.error(`SUB_systemTime_getRealTime_JS_API_0001 err: ` + JSON.stringify(error));
expect().assertFail()
};
- console.info(`systemTime.getRealTime success data : ` + JSON.stringify(data));
+ console.info(`SUB_systemTime_getRealTime_JS_API_0001 data : ` + JSON.stringify(data));
expect(data != null).assertEqual(true);
});
- console.info("---------------SUB_systemTime_getRealTime_JS_API_0001 end-----------------");
+ console.info("====>----------SUB_systemTime_getRealTime_JS_API_0001 end-----------------");
done();
});
@@ -140,15 +140,15 @@ export default function systemTimeJsunit() {
* @tc.level : Level 1
*/
it("SUB_systemTime_getRealTime_JS_API_0002", 0, async function (done) {
- console.info("----------SUB_systemTime_getRealTime_JS_API_0002 start----------------");
+ console.info("====>-----SUB_systemTime_getRealTime_JS_API_0002 start----------------");
systemTime.getRealTime(true).then((data) => {
- console.info(`systemTime.getRealTime promise success data : ` + JSON.stringify(data));
+ console.info(`SUB_systemTime_getRealTime_JS_API_0002 data : ` + JSON.stringify(data));
expect(data != null).assertEqual(true);
}).catch(err => {
- console.error(`failed to systemTime.getRealTime promise because ` + JSON.stringify(error));
+ console.error(`SUB_systemTime_getRealTime_JS_API_0002 err: ` + JSON.stringify(error));
expect().assertFail();
});
- console.info("----------SUB_systemTime_getRealTime_JS_API_0002 end------------");
+ console.info("====>-----SUB_systemTime_getRealTime_JS_API_0002 end------------");
done();
});
@@ -161,17 +161,17 @@ export default function systemTimeJsunit() {
* @tc.level : Level 0
*/
it('SUB_systemTime_setTime_JS_API_0100', 0, async function (done) {
- console.info("SUB_systemTime_setTime_JS_API_0100 start");
- systemTime.setTime(1526003846000)
- .then(data =>{
- console.info("setTime ===data " + data);
- expect(data).assertEqual(true)
- }).catch(error => {
- console.info("setTime ===error " + error);
- expect(0).assertLarger(1)
- });
- console.info('SUB_systemTime_setTime_JS_API_0100 end');
- done();
+ console.info("====>SUB_systemTime_setTime_JS_API_0100 start");
+ let currentTime = new Date().getTime() + 2000
+ try{
+ await systemTime.setTime(currentTime)
+ expect(true).assertTrue();
+ done();
+ }catch(err){
+ console.info("====>SUB_systemTime_setTime_JS_API_0100 error " + err);
+ expect().assertFail();
+ done();
+ }
});
/**
@@ -183,17 +183,23 @@ export default function systemTimeJsunit() {
* @tc.level : Level 0
*/
it('SUB_systemTime_setTime_JS_API_0200', 0, async function (done) {
- console.info("SUB_systemTime_setTime_JS_API_0200 start");
- systemTime.setTime(15222)
- .then(data => {
- console.info("setTime ===data " + data);
+ console.info("====>SUB_systemTime_setTime_JS_API_0200 start");
+ try{
+ systemTime.setTime(15222).then(() => {
+ console.debug('SUB_systemTime_setTime_JS_API_0200 setTime fail')
+ expect().assertFail();
+ done();
+ }).catch((err)=>{
+ console.debug('SUB_systemTime_setTime_JS_API_0200 setTime err:' + JSON.stringify(err))
expect(true).assertTrue();
- }).catch(error => {
- console.info("setTime ===error " + error);
- expect(0).assertLarger(1)
- });
- console.info('SUB_systemTime_setTime_JS_API_0200 end');
- done();
+ console.debug('SUB_systemTime_setTime_JS_API_0200 end');
+ done();
+ })
+ }catch(err){
+ console.debug('SUB_systemTime_setTime_JS_API_0200 setTime throw_err' + JSON.stringify(err))
+ expect(err.code).assertEqual('401');
+ done();
+ }
});
/**
@@ -205,18 +211,19 @@ export default function systemTimeJsunit() {
* @tc.level : Level 0
*/
it('SUB_systemTime_setTime_JS_API_0300', 0, async function (done) {
- console.info("SUB_systemTime_setTime_JS_API_0300 start");
- systemTime.setTime(1597156246000, (err, data) => {
- if (err) {
- console.info("setTime ===error: " + err);
- expect().assertFail()
- }else{
- console.info("setTime ===data: " + data);
- expect(true).assertTrue();
- };
+ console.info("====>SUB_systemTime_setTime_JS_API_0300 start");
+ let currentTime = new Date().getTime() + 2000
+ systemTime.setTime(currentTime, (err) => {
+ try{
+ expect(true).assertTrue();
+ console.info('SUB_systemTime_setTime_JS_API_0300 end');
+ done();
+ }catch(err){
+ console.info("====>SUB_systemTime_setTime_JS_API_0300 error: " + err);
+ expect().assertFail();
+ done();
+ }
});
- console.info('SUB_systemTime_setTime_JS_API_0300 end');
- done();
});
/**
@@ -228,11 +235,11 @@ export default function systemTimeJsunit() {
* @tc.level : Level 0
*/
it('SUB_systemTime_setTime_JS_API_0400', 0, async function (done) {
- console.info("SUB_systemTime_setTime_JS_API_0400 start");
+ console.info("====>SUB_systemTime_setTime_JS_API_0400 start");
try{
systemTime.setTime(18, (err, data) => {
- console.info("setTime ===data: " + data);
- console.info("setTime ===error: " + err);
+ console.info("====>SUB_systemTime_setTime_JS_API_0400 data: " + data);
+ console.info("====>SUB_systemTime_setTime_JS_API_0400 error: " + err);
expect(true).assertTrue();
})}catch(error) {error => {
expect(1).assertLarger(0);
@@ -251,13 +258,13 @@ export default function systemTimeJsunit() {
* @tc.level : Level 0
*/
it('SUB_systemTime_setDate_JS_API_0100', 0, async function (done) {
- console.info("SUB_systemTime_setDate_JS_API_0100 start");
+ console.info("====>SUB_systemTime_setDate_JS_API_0100 start");
var data = new Date("October 13, 2020 11:13:00");
systemTime.setDate(1).then(data => {
- console.info("setTime ===data " + data);
+ console.info("====>SUB_systemTime_setDate_JS_API_0100 data " + data);
expect(true).assertTrue();
}).catch(error => {
- console.info("setTime ===error " + error);
+ console.info("====>SUB_systemTime_setDate_JS_API_0100 error " + error);
expect().assertFail();
});
done();
@@ -272,12 +279,12 @@ export default function systemTimeJsunit() {
* @tc.level : Level 0
*/
it('SUB_systemTime_setDate_JS_API_0200', 0, async function (done) {
- console.info("SUB_systemTime_setDate_JS_API_0200 start");
+ console.info("====>SUB_systemTime_setDate_JS_API_0200 start");
systemTime.setDate(0).then(data => {
- console.info("setTime ===data " + data);
+ console.info("====>SUB_systemTime_setDate_JS_API_0200 data " + data);
expect(true).assertTrue();
}).catch(error => {
- console.info("setTime ===error " + error);
+ console.info("====>SUB_systemTime_setDate_JS_API_0200 error " + error);
expect().assertFail();
});
done();
@@ -292,14 +299,14 @@ export default function systemTimeJsunit() {
* @tc.level : Level 0
*/
it('SUB_systemTime_setDate_JS_API_0300', 0, async function (done) {
- console.info("SUB_systemTime_setDate_JS_API_0300 start");
+ console.info("====>SUB_systemTime_setDate_JS_API_0300 start");
var data = new Date("October 13, 2020 11:13:00");
systemTime.setDate(data, (error, data) => {
if(error){
- console.info("setTime ===error " + error);
+ console.info("====>SUB_systemTime_setDate_JS_API_0300 error " + error);
expect().assertFail();
}else{
- console.info("setTime ===data " + data);
+ console.info("====>SUB_systemTime_setDate_JS_API_0300 data " + data);
expect(true).assertTrue();
};
});
@@ -315,12 +322,12 @@ export default function systemTimeJsunit() {
* @tc.level : Level 0
*/
it('SUB_systemTime_setTimezone_JS_API_0100', 0, async function (done) {
- console.info("SUB_systemTime_setTimezone_JS_API_0100 start");
+ console.info("====>SUB_systemTime_setTimezone_JS_API_0100 start");
systemTime.setTimezone('Asia, Shanghai').then(data => {
- console.info("setTime ===data " + data);
+ console.info("====>SUB_systemTime_setTimezone_JS_API_0100 data " + data);
expect().assertFail();
}).catch(error => {
- console.info("setTime ===error " + error);
+ console.info("====>SUB_systemTime_setTimezone_JS_API_0100 error " + error);
expect(true).assertTrue();
});
done();
@@ -335,12 +342,12 @@ export default function systemTimeJsunit() {
* @tc.level : Level 0
*/
it('SUB_systemTime_setTimezone_JS_API_0200', 0, async function (done) {
- console.info("SUB_systemTime_setTimezone_JS_API_0200 start");
+ console.info("====>SUB_systemTime_setTimezone_JS_API_0200 start");
systemTime.setTimezone('Beijing,China').then(data => {
- console.info("setTime ===data " + data);
+ console.info("====>SUB_systemTime_setTimezone_JS_API_0200 data " + data);
expect().assertFail();
}).catch(error => {
- console.info("setTime ===error " + error);
+ console.info("====>SUB_systemTime_setTimezone_JS_API_0200 error " + error);
expect(true).assertTrue();
});
done();
@@ -355,12 +362,12 @@ export default function systemTimeJsunit() {
* @tc.level : Level 0
*/
it('SUB_systemTime_setTimezone_JS_API_0300', 0, async function (done) {
- console.info("SUB_systemTime_setTimezone_JS_API_0300 start");
+ console.info("====>SUB_systemTime_setTimezone_JS_API_0300 start");
systemTime.setTimezone('Baker Island, U.S.A.').then(data => {
- console.info("setTime ===data " + data);
+ console.info("====>SUB_systemTime_setTimezone_JS_API_0300 data " + data);
expect().assertFail();
}).catch(error => {
- console.info("setTime ===error " + error);
+ console.info("====>SUB_systemTime_setTimezone_JS_API_0300 error " + error);
expect(true).assertTrue();
});
done();
diff --git a/time/timeTest/entry/src/main/ets/test/systemTimer.test.ets b/time/timeTest/entry/src/main/ets/test/systemTimer.test.ets
index 8cc91d65bf5373ce9757542326a753af6a920f0a..6a55866ce80ba80975916869549384438a1b7a7e 100644
--- a/time/timeTest/entry/src/main/ets/test/systemTimer.test.ets
+++ b/time/timeTest/entry/src/main/ets/test/systemTimer.test.ets
@@ -19,7 +19,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
export default function systemTimerTest() {
describe('systemTimerTest', function () {
- console.info('systemTimer Test start');
+ console.info('====>systemTimer Test start');
//wantAgent对象
var wantAgent;
@@ -43,11 +43,11 @@ export default function systemTimerTest() {
* beforeAll: Prerequisites at the test suite level, which are executed before the test suite is executed.
*/
beforeAll(function () {
- console.info('beforeAll: Prerequisites are executed.');
+ console.info('====>beforeAll: Prerequisites are executed.');
WantAgent.getWantAgent(wantAgentInfo)
.then((data) => {
if ( data != undefined || data != null) {
- console.info('beforeAll: success to get wantAgent: ' + typeof(data));
+ console.info('====>beforeAll: success to get wantAgent: ' + typeof(data));
wantAgent = data;
}
})
@@ -60,21 +60,21 @@ export default function systemTimerTest() {
* beforeEach: Prerequisites at the test case level, which are executed before each test case is executed.
*/
beforeEach(function () {
- console.info('beforeEach: Prerequisites is executed.');
+ console.info('====>beforeEach: Prerequisites is executed.');
});
/**
* afterEach: Test case-level clearance conditions, which are executed after each test case is executed.
*/
afterEach(function () {
- console.info('afterEach: Test case-level clearance conditions is executed.');
+ console.info('====>afterEach: Test case-level clearance conditions is executed.');
});
/**
* afterAll: Test suite-level cleanup condition, which is executed after the test suite is executed.
*/
afterAll(function () {
- console.info('afterAll: Test suite-level cleanup condition is executed.');
+ console.info('====>afterAll: Test suite-level cleanup condition is executed.');
});
/**
@@ -86,27 +86,27 @@ export default function systemTimerTest() {
* @tc.level Level 0
*/
it('SUB_time_systemTimer_createTimer_0000', 0, async function (done) {
- console.info('SUB_time_systemTimer_createTimer_0000 start.');
+ console.info('====>SUB_time_systemTimer_createTimer_0000 start.');
let options = {
type: systemTimer.TIMER_TYPE_REALTIME,
repeat: false
};
try {
- console.info('SUB_time_systemTimer_createTimer_0000 create timer.');
+ console.info('====>SUB_time_systemTimer_createTimer_0000 create timer.');
systemTimer.createTimer(options, function (err, timerID) {
if (err) {
// 处理业务逻辑错误
expect().assertTrue();
done();
}
- console.info('SUB_time_systemTimer_createTimer_0000 timerID: ' + timerID);
+ console.info('====>SUB_time_systemTimer_createTimer_0000 timerID: ' + timerID);
globalTimerID = timerID;
expect(Number.isInteger(timerID)).assertTrue();
done();
});
} catch (err) {
// 捕获参数错误
- console.info('SUB_time_systemTimer_createTimer_0000 has failed for ' + err);
+ console.info('====>SUB_time_systemTimer_createTimer_0000 has failed for ' + err);
expect().assertTrue();
done();
};
@@ -121,7 +121,7 @@ export default function systemTimerTest() {
* @tc.level Level 0
*/
it('SUB_time_systemTimer_createTimer_0001', 0, async function (done) {
- console.info('SUB_time_systemTimer_createTimer_0001 start.');
+ console.info('====>SUB_time_systemTimer_createTimer_0001 start.');
let options = {
type: systemTimer.TIMER_TYPE_IDLE,
repeat: false
@@ -129,16 +129,16 @@ export default function systemTimerTest() {
try {
systemTimer.createTimer(options, function (err, timerID) {
if (err) {
- console.info('SUB_time_systemTimer_createTimer_0001 wrong since ' + err.code);
+ console.info('====>SUB_time_systemTimer_createTimer_0001 wrong since ' + err.code);
expect().assertTrue();
done();
};
- console.info('SUB_time_systemTimer_createTimer_0001 timerID: ' + timerID);
+ console.info('====>SUB_time_systemTimer_createTimer_0001 timerID: ' + timerID);
expect(Number.isInteger(timerID)).assertTrue();
done();
});
} catch (e) {
- console.info('SUB_time_systemTimer_createTimer_0001 arv wrong since ' + e.code);
+ console.info('====>SUB_time_systemTimer_createTimer_0001 arv wrong since ' + e.code);
expect().assertTrue();
done();
};
@@ -153,9 +153,9 @@ export default function systemTimerTest() {
* @tc.level Level 2
*/
it('SUB_time_systemTimer_createTimer_0002', 2, async function (done) {
- console.info("SUB_time_systemTimer_createTimer_0002 start");
+ console.info("====>SUB_time_systemTimer_createTimer_0002 start");
WantAgent.getBundleName(wantAgent, (err, data)=>{
- console.info('SUB_time_systemTimer_createTimer_0002 BundleName: ' + data);
+ console.info('====>SUB_time_systemTimer_createTimer_0002 BundleName: ' + data);
})
let options = {
type: systemTimer.TIMER_TYPE_WAKEUP,
@@ -164,19 +164,19 @@ export default function systemTimerTest() {
interval: interval_time
};
try {
- console.info("SUB_time_systemTimer_createTimer_0002 create timer")
+ console.info("====>SUB_time_systemTimer_createTimer_0002 create timer")
systemTimer.createTimer(options, function (err, timerID) {
if (err) {
- console.info('SUB_time_systemTimer_createTimer_0002 wrong since ' + err.code);
+ console.info('====>SUB_time_systemTimer_createTimer_0002 wrong since ' + err.code);
expect().assertTrue();
done();
}
- console.info('SUB_time_systemTimer_createTimer_0002 timerID: ' + timerID);
+ console.info('====>SUB_time_systemTimer_createTimer_0002 timerID: ' + timerID);
expect(Number.isInteger(timerID)).assertTrue();
done();
});
} catch (e) {
- console.info('SUB_time_systemTimer_createTimer_0002 arv wrong since ' + e);
+ console.info('====>SUB_time_systemTimer_createTimer_0002 arv wrong since ' + e);
expect().assertTrue();
done();
};
@@ -191,16 +191,16 @@ export default function systemTimerTest() {
* @tc.level Level 2
*/
it('SUB_time_systemTimer_createTimer_0003', 2, async function (done) {
- console.info("SUB_time_systemTimer_createTimer_0003 start");
+ console.info("====>SUB_time_systemTimer_createTimer_0003 start");
let options = {
type: systemTimer.TIMER_TYPE_EXACT,
repeat: false
};
try {
- console.info("SUB_time_systemTimer_createTimer_0003 create timer")
+ console.info("====>SUB_time_systemTimer_createTimer_0003 create timer")
systemTimer.createTimer(options, function (err, timerID) {
if (err) {
- console.info('SUB_time_systemTimer_createTimer_0003 wrong since ' + err.code);
+ console.info('====>SUB_time_systemTimer_createTimer_0003 wrong since ' + err.code);
expect().assertTrue();
done();
}
@@ -208,7 +208,7 @@ export default function systemTimerTest() {
done();
});
} catch (e) {
- console.info('SUB_time_systemTimer_createTimer_0002 arv wrong since ' + e);
+ console.info('====>SUB_time_systemTimer_createTimer_0002 arv wrong since ' + e);
expect().assertTrue();
done();
};
@@ -223,9 +223,9 @@ export default function systemTimerTest() {
* @tc.level Level 2
*/
it('SUB_time_systemTimer_createTimer_0004', 2, async function (done) {
- console.info("SUB_time_systemTimer_createTimer_0004 start");
+ console.info("====>SUB_time_systemTimer_createTimer_0004 start");
WantAgent.getBundleName(wantAgent, (err, data)=>{
- console.info("SUB_time_systemTimer_createTimer_0004 BundleName: " + data);
+ console.info("====>SUB_time_systemTimer_createTimer_0004 BundleName: " + data);
});
let options = {
type: systemTimer.TIMER_TYPE_REALTIME,
@@ -234,7 +234,7 @@ export default function systemTimerTest() {
interval: interval_time
};
try {
- console.info("SUB_time_systemTimer_createTimer_0004 create timer")
+ console.info("====>SUB_time_systemTimer_createTimer_0004 create timer")
systemTimer.createTimer(options, function (err, timerID) {
if (err) {
expect().assertTrue();
@@ -244,7 +244,7 @@ export default function systemTimerTest() {
done();
});
} catch (e) {
- console.info('SUB_time_systemTimer_createTimer_0004 has failed for ' + e);
+ console.info('====>SUB_time_systemTimer_createTimer_0004 has failed for ' + e);
expect().assertTrue();
done();
};
@@ -260,24 +260,24 @@ export default function systemTimerTest() {
* @tc.level Level 0
*/
it('SUB_time_systemTimer_createTimer_0005', 0, async function (done) {
- console.info('SUB_time_systemTimer_createTimer_0005 start.');
+ console.info('====>SUB_time_systemTimer_createTimer_0005 start.');
let options = {
type: systemTimer.TIMER_TYPE_REALTIME,
repeat: false
};
try {
- console.info('SUB_time_systemTimer_createTimer_0005 create timer.');
+ console.info('====>SUB_time_systemTimer_createTimer_0005 create timer.');
systemTimer.createTimer(options).then((timerID) =>{
- console.info('SUB_time_systemTimer_createTimer_0005 timerID: ' + timerID);
+ console.info('====>SUB_time_systemTimer_createTimer_0005 timerID: ' + timerID);
expect(Number.isInteger(timerID)).assertTrue();
done();
}).catch(err => {
- console.info('SUB_time_systemTimer_createTimer_0005 promise failed ' + err);
+ console.info('====>SUB_time_systemTimer_createTimer_0005 promise failed ' + err);
expect().assertTrue();
done();
});
} catch (err) {
- console.info('SUB_time_systemTimer_createTimer_0005 has failed for ' + err);
+ console.info('====>SUB_time_systemTimer_createTimer_0005 has failed for ' + err);
expect().assertTrue();
done();
};
@@ -292,23 +292,23 @@ export default function systemTimerTest() {
* @tc.level Level 0
*/
it('SUB_time_systemTimer_createTimer_0006', 0, async function (done) {
- console.info('SUB_time_systemTimer_createTimer_0006 start.');
+ console.info('====>SUB_time_systemTimer_createTimer_0006 start.');
let options = {
type: systemTimer.TIMER_TYPE_IDLE,
repeat: false
};
try {
systemTimer.createTimer(options).then((timerID) => {
- console.info('SUB_time_systemTimer_createTimer_0006 timerID: ' + timerID);
+ console.info('====>SUB_time_systemTimer_createTimer_0006 timerID: ' + timerID);
expect(Number.isInteger(timerID)).assertTrue();
done();
}).catch(err => {
- console.info('SUB_time_systemTimer_createTimer_0006 promise failed ' + err);
+ console.info('====>SUB_time_systemTimer_createTimer_0006 promise failed ' + err);
expect().assertTrue();
done();
});
} catch (e) {
- console.info('SUB_time_systemTimer_createTimer_0006 arv wrong since ' + e.code);
+ console.info('====>SUB_time_systemTimer_createTimer_0006 arv wrong since ' + e.code);
expect().assertTrue();
done();
};
@@ -323,9 +323,9 @@ export default function systemTimerTest() {
* @tc.level Level 2
*/
it('SUB_time_systemTimer_createTimer_0007', 2, async function (done) {
- console.info("SUB_time_systemTimer_createTimer_0007 start");
+ console.info("====>SUB_time_systemTimer_createTimer_0007 start");
WantAgent.getBundleName(wantAgent, (err, data)=>{
- console.info('SUB_time_systemTimer_createTimer_0007 BundleName: ' + data);
+ console.info('====>SUB_time_systemTimer_createTimer_0007 BundleName: ' + data);
})
let options = {
type: systemTimer.TIMER_TYPE_WAKEUP,
@@ -334,18 +334,18 @@ export default function systemTimerTest() {
interval: interval_time
};
try {
- console.info("SUB_time_systemTimer_createTimer_0007 create timer");
+ console.info("====>SUB_time_systemTimer_createTimer_0007 create timer");
systemTimer.createTimer(options).then((timerID) => {
- console.info('SUB_time_systemTimer_createTimer_0007 timerID: ' + timerID);
+ console.info('====>SUB_time_systemTimer_createTimer_0007 timerID: ' + timerID);
expect(Number.isInteger(timerID)).assertTrue();
done();
}).catch(err => {
- console.info('SUB_time_systemTimer_createTimer_0007 promise failed ' + err);
+ console.info('====>SUB_time_systemTimer_createTimer_0007 promise failed ' + err);
expect().assertTrue();
done();
});
} catch (e) {
- console.info('SUB_time_systemTimer_createTimer_0007 arv wrong since ' + e);
+ console.info('====>SUB_time_systemTimer_createTimer_0007 arv wrong since ' + e);
expect().assertTrue();
done();
};
@@ -360,23 +360,23 @@ export default function systemTimerTest() {
* @tc.level Level 2
*/
it('SUB_time_systemTimer_createTimer_0008', 2, async function (done) {
- console.info("SUB_time_systemTimer_createTimer_0008 start");
+ console.info("====>SUB_time_systemTimer_createTimer_0008 start");
let options = {
type: systemTimer.TIMER_TYPE_EXACT,
repeat: false
};
try {
- console.info("SUB_time_systemTimer_createTimer_0008 create timer")
+ console.info("====>SUB_time_systemTimer_createTimer_0008 create timer")
systemTimer.createTimer(options).then((timerID) => {
expect(Number.isInteger(timerID)).assertTrue();
done();
}).catch(err => {
- console.info('SUB_time_systemTimer_createTimer_0008 promise failed ' + err);
+ console.info('====>SUB_time_systemTimer_createTimer_0008 promise failed ' + err);
expect().assertTrue();
done();
});
} catch (e) {
- console.info('SUB_time_systemTimer_createTimer_0008 arv wrong since ' + e);
+ console.info('====>SUB_time_systemTimer_createTimer_0008 arv wrong since ' + e);
expect().assertTrue();
done();
};
@@ -391,9 +391,9 @@ export default function systemTimerTest() {
* @tc.level Level 2
*/
it('SUB_time_systemTimer_createTimer_0009', 2, async function (done) {
- console.info("SUB_time_systemTimer_createTimer_0009 start");
+ console.info("====>SUB_time_systemTimer_createTimer_0009 start");
WantAgent.getBundleName(wantAgent, (err, data)=>{
- console.info("SUB_time_systemTimer_createTimer_0009 BundleName: " + data);
+ console.info("====>SUB_time_systemTimer_createTimer_0009 BundleName: " + data);
});
let options = {
type: systemTimer.TIMER_TYPE_REALTIME,
@@ -402,17 +402,17 @@ export default function systemTimerTest() {
interval: interval_time
};
try {
- console.info("SUB_time_systemTimer_createTimer_0009 create timer")
+ console.info("====>SUB_time_systemTimer_createTimer_0009 create timer")
systemTimer.createTimer(options).then((timerID) => {
expect(Number.isInteger(timerID)).assertTrue();
done();
}).catch(err => {
- console.info('SUB_time_systemTimer_createTimer_0009 promise failed ' + err);
+ console.info('====>SUB_time_systemTimer_createTimer_0009 promise failed ' + err);
expect().assertTrue();
done();
});
} catch (e) {
- console.info('SUB_time_systemTimer_createTimer_0009 has failed for ' + e);
+ console.info('====>SUB_time_systemTimer_createTimer_0009 has failed for ' + e);
expect().assertTrue();
done();
};
@@ -427,21 +427,21 @@ export default function systemTimerTest() {
* @tc.level Level 0
*/
it('SUB_time_systemTimer_startTimer_0001', 0, async function (done) {
- console.info("SUB_time_systemTimer_startTimer_0001 start");
+ console.info("====>SUB_time_systemTimer_startTimer_0001 start");
try {
- console.info("SUB_time_systemTimer_startTimer_0001 start timer, timerID: " + globalTimerID)
+ console.info("====>SUB_time_systemTimer_startTimer_0001 start timer, timerID: " + globalTimerID)
let triggerTime = new Date().getTime() + interval_time * 1.2;
systemTimer.startTimer(globalTimerID, triggerTime, function (err, data) {
if (err) {
- console.info('SUB_time_systemTimer_startTimer_0001 wrong since ' + err.code);
+ console.info('====>SUB_time_systemTimer_startTimer_0001 wrong since ' + err.code);
expect().assertTrue();
done();
}
- console.info("SUB_time_systemTimer_startTimer_0001 success to start timerID: " + globalTimerID);
+ console.info("====>SUB_time_systemTimer_startTimer_0001 success to start timerID: " + globalTimerID);
done();
});
} catch (e) {
- console.info('SUB_time_systemTimer_startTimer_0001 has failed for ' + e);
+ console.info('====>SUB_time_systemTimer_startTimer_0001 has failed for ' + e);
expect().assertTrue();
done();
};
@@ -456,19 +456,19 @@ export default function systemTimerTest() {
* @tc.level Level 0
*/
it('SUB_time_systemTimer_stopTimer_0001', 0, async function (done) {
- console.info("SUB_time_systemTimer_stopTimer_0001 start");
+ console.info("====>SUB_time_systemTimer_stopTimer_0001 start");
try {
- console.info("SUB_time_systemTimer_stopTimer_0001 stop timer, timerID: " + globalTimerID)
+ console.info("====>SUB_time_systemTimer_stopTimer_0001 stop timer, timerID: " + globalTimerID)
systemTimer.stopTimer(globalTimerID, function (err, data) {
if (err) {
expect().assertTrue();
done();
};
- console.info("SUB_time_systemTimer_stopTimer_0001 success to stop timerID: " + globalTimerID);
+ console.info("====>SUB_time_systemTimer_stopTimer_0001 success to stop timerID: " + globalTimerID);
done();
});
} catch (e) {
- console.info('SUB_time_systemTimer_stopTimer_0001 has failed for ' + e);
+ console.info('====>SUB_time_systemTimer_stopTimer_0001 has failed for ' + e);
expect().assertTrue();
done();
};
@@ -483,19 +483,19 @@ export default function systemTimerTest() {
* @tc.level Level 0
*/
it('SUB_time_systemTimer_destroyTimer_0001', 0, async function (done) {
- console.info("SUB_time_systemTimer_destroyTimer_0001 start");
+ console.info("====>SUB_time_systemTimer_destroyTimer_0001 start");
try {
- console.info("SUB_time_systemTimer_destroyTimer_0001 destroy timer, timerID: " + globalTimerID)
+ console.info("====>SUB_time_systemTimer_destroyTimer_0001 destroy timer, timerID: " + globalTimerID)
systemTimer.destroyTimer(globalTimerID, function (err, data) {
if (err) {
expect().assertTrue();
done();
};
- console.info("SUB_time_systemTimer_destroyTimer_0001 success to destroy timerID: " + globalTimerID);
+ console.info("====>SUB_time_systemTimer_destroyTimer_0001 success to destroy timerID: " + globalTimerID);
done();
});
} catch (e) {
- console.info('SUB_time_systemTimer_destroyTimer_0001 has failed for ' + e);
+ console.info('====>SUB_time_systemTimer_destroyTimer_0001 has failed for ' + e);
expect().assertTrue();
done();
};
@@ -510,27 +510,27 @@ export default function systemTimerTest() {
* @tc.level Level 0
*/
it('SUB_time_systemTimer_createTimer_0002', 0, async function (done) {
- console.info('SUB_time_systemTimer_createTimer_0002 start.');
+ console.info('====>SUB_time_systemTimer_createTimer_0002 start.');
let options = {
type: systemTimer.TIMER_TYPE_REALTIME,
repeat: false
};
try {
- console.info('SUB_time_systemTimer_createTimer_0002 create timer.');
+ console.info('====>SUB_time_systemTimer_createTimer_0002 create timer.');
systemTimer.createTimer(options).then((timerID)=>{
- console.info('SUB_time_systemTimer_createTimer_0002 timerID:' + timerID);
+ console.info('====>SUB_time_systemTimer_createTimer_0002 timerID:' + timerID);
expect(Number.isInteger(timerID)).assertTrue();
globalTimerID = timerID;
done();
}).catch( error => {
// 捕获业务逻辑错误
- console.info('SUB_time_systemTimer_createTimer_0002 failed to create timer.');
+ console.info('====>SUB_time_systemTimer_createTimer_0002 failed to create timer.');
expect().assertTrue();
done();
});
} catch (err) {
// 捕获参数错误
- console.info('SUB_time_systemTimer_createTimer_0002 has failed for ' + err);
+ console.info('====>SUB_time_systemTimer_createTimer_0002 has failed for ' + err);
expect().assertTrue();
done();
};
@@ -545,23 +545,23 @@ export default function systemTimerTest() {
* @tc.level Level 0
*/
it('SUB_time_systemTimer_startTimer_0002', 0, async function (done) {
- console.info('SUB_time_systemTimer_startTimer_0002 start.');
+ console.info('====>SUB_time_systemTimer_startTimer_0002 start.');
try {
- console.info('SUB_time_systemTimer_startTimer_0002 start timer, timerID: ' + globalTimerID);
+ console.info('====>SUB_time_systemTimer_startTimer_0002 start timer, timerID: ' + globalTimerID);
let triggerTime = new Date().getTime() + interval_time * 2;
systemTimer.startTimer(globalTimerID, triggerTime)
.then(()=>{
- console.info('SUB_time_systemTimer_startTimer_0002 timerID:' + globalTimerID);
+ console.info('====>SUB_time_systemTimer_startTimer_0002 timerID:' + globalTimerID);
done();
}).catch(()=>{
// 捕获业务逻辑错误
- console.info('SUB_time_systemTimer_startTimer_0002 failed to start timer.');
+ console.info('====>SUB_time_systemTimer_startTimer_0002 failed to start timer.');
expect().assertTrue();
done();
});
} catch (err) {
// 捕获参数错误
- console.info('SUB_time_systemTimer_startTimer_0002 has failed for ' + err);
+ console.info('====>SUB_time_systemTimer_startTimer_0002 has failed for ' + err);
expect().assertTrue();
done();
}
@@ -576,22 +576,22 @@ export default function systemTimerTest() {
* @tc.level Level 0
*/
it('SUB_time_systemTimer_stopTimer_0002', 0, async function (done) {
- console.info('SUB_time_systemTimer_stopTimer_0002 start.');
+ console.info('====>SUB_time_systemTimer_stopTimer_0002 start.');
try {
- console.info('SUB_time_systemTimer_stopTimer_0002 stop timer, timerID: ' + globalTimerID);
+ console.info('====>SUB_time_systemTimer_stopTimer_0002 stop timer, timerID: ' + globalTimerID);
systemTimer.stopTimer(globalTimerID)
.then(()=>{
- console.info('SUB_time_systemTimer_stopTimer_0002 timerID:' + globalTimerID);
+ console.info('====>SUB_time_systemTimer_stopTimer_0002 timerID:' + globalTimerID);
done();
}).catch(()=>{
// 捕获业务逻辑错误
- console.info('SUB_time_systemTimer_stopTimer_0002 failed to stop timer.');
+ console.info('====>SUB_time_systemTimer_stopTimer_0002 failed to stop timer.');
expect().assertTrue();
done();
});
} catch (err) {
// 捕获参数错误
- console.info('SUB_time_systemTimer_stopTimer_0002 has failed for ' + err);
+ console.info('====>SUB_time_systemTimer_stopTimer_0002 has failed for ' + err);
expect().assertTrue();
done();
};
@@ -606,22 +606,22 @@ export default function systemTimerTest() {
* @tc.level Level 0
*/
it('SUB_time_systemTimer_destroyTimer_0002', 0, async function (done) {
- console.info('SUB_time_systemTimer_destroyTimer_0002 start.');
+ console.info('====>SUB_time_systemTimer_destroyTimer_0002 start.');
try {
- console.info('SUB_time_systemTimer_destroyTimer_0002 destroy timer, timerID: ' + globalTimerID);
+ console.info('====>SUB_time_systemTimer_destroyTimer_0002 destroy timer, timerID: ' + globalTimerID);
systemTimer.destroyTimer(globalTimerID)
.then(()=>{
- console.info('SUB_time_systemTimer_destroyTimer_0002 timerID:' + globalTimerID);
+ console.info('====>SUB_time_systemTimer_destroyTimer_0002 timerID:' + globalTimerID);
done();
}).catch(()=>{
// 捕获业务逻辑错误
- console.info('SUB_time_systemTimer_destroyTimer_0002 failed to destroy timer.');
+ console.info('====>SUB_time_systemTimer_destroyTimer_0002 failed to destroy timer.');
expect().assertTrue();
done();
});
} catch (err) {
// 捕获参数错误
- console.info('SUB_time_systemTimer_stopTimer_0002 has failed for ' + err);
+ console.info('====>SUB_time_systemTimer_stopTimer_0002 has failed for ' + err);
expect().assertTrue();
done();
};
@@ -636,65 +636,65 @@ export default function systemTimerTest() {
* @tc.level Level 0
*/
it('SUB_time_systemTimer_ALL_Promise_0008', 0, async function (done) {
- console.info('SUB_time_systemTimer_ALL_Promise_0008 start.');
+ console.info('====>SUB_time_systemTimer_ALL_Promise_0008 start.');
let options = {
type: systemTimer.TIMER_TYPE_WAKEUP,
repeat: false
};
try {
- console.info('SUB_time_systemTimer_ALL_Promise_0008 create timer.');
+ console.info('====>SUB_time_systemTimer_ALL_Promise_0008 create timer.');
systemTimer.createTimer(options)
.then((timerID)=>{
- console.info('SUB_time_systemTimer_ALL_Promise_0008 timerID:' + timerID);
+ console.info('====>SUB_time_systemTimer_ALL_Promise_0008 timerID:' + timerID);
expect(Number.isInteger(timerID)).assertTrue();
try {
let triggerTime = new Date().getTime() + interval_time * 1.2;
systemTimer.startTimer(timerID, triggerTime)
.then(()=>{
- console.info('SUB_time_systemTimer_ALL_Promise_0008 start timerID: ' + timerID);
+ console.info('====>SUB_time_systemTimer_ALL_Promise_0008 start timerID: ' + timerID);
try {
systemTimer.stopTimer(timerID)
.then(()=>{
systemTimer.destroyTimer(timerID, function (err, data) {
- console.info('SUB_time_systemTimer_ALL_Promise_0008 destroyTimer: ' + timerID);
+ console.info('====>SUB_time_systemTimer_ALL_Promise_0008 destroyTimer: ' + timerID);
done();
});
})
.catch(()=>{
// 捕获stopTimer业务逻辑错误
- console.info('SUB_time_systemTimer_ALL_Promise_0008 failed to stop timer.');
+ console.info('====>SUB_time_systemTimer_ALL_Promise_0008 failed to stop timer.');
expect().assertTrue();
done();
})
} catch (err) {
// 捕获stopTimer参数错误
- console.info('SUB_time_systemTimer_ALL_Promise_0008 stopTimer with wrong arg: ' + err);
+ console.info('====>SUB_time_systemTimer_ALL_Promise_0008 stopTimer with wrong arg: ' + err);
expect().assertTrue();
done();
}
})
.catch(()=>{
// 捕获startTimer业务逻辑错误
- console.info('SUB_time_systemTimer_ALL_Promise_0008 failed to stop timer.');
+ console.info('====>SUB_time_systemTimer_ALL_Promise_0008 failed to stop timer.');
expect().assertTrue();
done();
});
} catch (err) {
// 捕获参数错误
- console.info('SUB_time_systemTimer_ALL_Promise_0008 startTimer with wrong arg: ' + err);
+ console.info('====>SUB_time_systemTimer_ALL_Promise_0008 startTimer with wrong arg: ' + err);
expect().assertTrue();
done();
}
})
.catch(()=>{
// 捕获业务逻辑错误
- console.info('SUB_time_systemTimer_ALL_Promise_0008 failed to create timer.');
+ console.info('====>SUB_time_systemTimer_ALL_Promise_0008 failed to create timer.');
expect().assertTrue();
done();
});
} catch (err) {
// 捕获参数错误
- console.info('SUB_time_systemTimer_ALL_Promise_0008 createTimer with wrong arg: ' + err);
+ console.info('====>SUB_time_systemTimer_ALL_Promise_0008 createTimer with wrong arg: ' + err);
expect().assertTrue();
done();
}
@@ -709,42 +709,42 @@ export default function systemTimerTest() {
* @tc.level Level 0
*/
it('SUB_time_systemTimer_ALL_Callback_0009', 0, async function (done) {
- console.info('SUB_time_systemTimer_ALL_Callback_0009 start.');
+ console.info('====>SUB_time_systemTimer_ALL_Callback_0009 start.');
let options = {
type: systemTimer.TIMER_TYPE_WAKEUP,
repeat: false
};
try {
- console.info('SUB_time_systemTimer_ALL_Callback_0009 create timer.');
+ console.info('====>SUB_time_systemTimer_ALL_Callback_0009 create timer.');
systemTimer.createTimer(options)
.then((timerID)=>{
- console.info('SUB_time_systemTimer_ALL_Callback_0009 timerID:' + timerID);
+ console.info('====>SUB_time_systemTimer_ALL_Callback_0009 timerID:' + timerID);
expect(Number.isInteger(timerID)).assertTrue();
try {
let triggerTime = new Date().getTime() + interval_time * 1.2;
systemTimer.startTimer(timerID, triggerTime, ()=>{
- console.info('SUB_time_systemTimer_ALL_Callback_0009 start timerID: ' + timerID);
+ console.info('====>SUB_time_systemTimer_ALL_Callback_0009 start timerID: ' + timerID);
try {
systemTimer.stopTimer(timerID, ()=>{
systemTimer.destroyTimer(timerID, function (err, data) {
- console.info('SUB_time_systemTimer_ALL_Callback_0009 destroyTimer: ' + timerID);
+ console.info('====>SUB_time_systemTimer_ALL_Callback_0009 destroyTimer: ' + timerID);
done();
});
})
} catch (err) {
- console.info('SUB_time_systemTimer_ALL_Callback_0009 stopTimer with wrong arg: ' + err);
+ console.info('====>SUB_time_systemTimer_ALL_Callback_0009 stopTimer with wrong arg: ' + err);
expect().assertTrue();
done();
}
})
} catch (err) {
- console.info('SUB_time_systemTimer_ALL_Callback_0009 startTimer with wrong arg: ' + err);
+ console.info('====>SUB_time_systemTimer_ALL_Callback_0009 startTimer with wrong arg: ' + err);
expect().assertTrue();
done();
}
})
} catch (err) {
- console.info('SUB_time_systemTimer_ALL_Callback_0009 createTimer with wrong arg: ' + err);
+ console.info('====>SUB_time_systemTimer_ALL_Callback_0009 createTimer with wrong arg: ' + err);
expect().assertTrue();
done();
}