diff --git a/storage/storagefileiov9jstest/src/main/js/test/Common.js b/storage/storagefileiov9jstest/src/main/js/test/Common.js index 9ca52d041fa8a463c5f2d8f1daa98352ffd5f2db..407eb27aa0de5f82f47059b5cb337638d6fdea5c 100644 --- a/storage/storagefileiov9jstest/src/main/js/test/Common.js +++ b/storage/storagefileiov9jstest/src/main/js/test/Common.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Huawei Device Co., Ltd. + * Copyright (C) 2022-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the 'License'); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -13,7 +13,6 @@ * limitations under the License. */ -import fileio from '@ohos.fileio'; import fileIO from '@ohos.file.fs'; import util from '@ohos.util'; import featureAbility from '@ohos.ability.featureAbility'; @@ -30,8 +29,8 @@ export function prepareFile(fpath, content) { 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) + fileIO.fsyncSync(file.fd) + fileIO.closeSync(file) return true } catch (e) { @@ -40,46 +39,6 @@ export function prepareFile(fpath, content) { } } -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(); @@ -105,15 +64,6 @@ export function randomString(num) { 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; } @@ -126,22 +76,11 @@ 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, isBigInt, isString, - isBoolean, - isInclude, describe, it, expect, diff --git a/storage/storagefileiov9jstest/src/main/js/test/class_stream/close.test.js b/storage/storagefileiov9jstest/src/main/js/test/class_stream/close.test.js index 6ae3fd491a7af8b88420f83d1b6abc1e6800a99c..f529d0775e284e55bb3b710f34e469486d4c8e6d 100644 --- a/storage/storagefileiov9jstest/src/main/js/test/class_stream/close.test.js +++ b/storage/storagefileiov9jstest/src/main/js/test/class_stream/close.test.js @@ -21,7 +21,7 @@ export default function fileIOStreamClose() { describe('fileIO_fs_stream_close', function () { /** - * @tc.number SUB_DF_FILEIO_STREAM_CLOSESYNC_0000 + * @tc.number SUB_DF_FILEIO_STREAM_CLOSE_SYNC_0000 * @tc.name fileIO_test_stream_close_sync_000 * @tc.desc Test the closeSync() interface of class Stream. * Open a file stream, close file stream. @@ -35,9 +35,9 @@ describe('fileIO_fs_stream_close', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r'); - expect(ss !== null).assertTrue(); - ss.closeSync(); + let sr = fileIO.createStreamSync(fpath, 'r'); + expect(sr !== null).assertTrue(); + sr.closeSync(); fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_stream_close_sync_000 has failed for ' + e.message + ', code: ' + e.code); @@ -46,7 +46,7 @@ describe('fileIO_fs_stream_close', function () { }) /** - * @tc.number SUB_DF_FILEIO_STREAM_CLOSESYNC_0100 + * @tc.number SUB_DF_FILEIO_STREAM_CLOSE_SYNC_0100 * @tc.name fileIO_test_stream_close_sync_001 * @tc.desc Test the closeSync() interface of class Stream. * Invalid parameter, don't requrie any parameters. @@ -58,14 +58,14 @@ describe('fileIO_fs_stream_close', function () { it('fileIO_test_stream_close_sync_001', 0, async function () { let fpath = await nextFileName('fileIO_test_stream_close_sync_001'); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - let ss = fileIO.createStreamSync(fpath, 'r'); + let sr = fileIO.createStreamSync(fpath, 'r'); try { - expect(ss !== null).assertTrue(); - ss.closeSync(1); + expect(sr !== null).assertTrue(); + sr.closeSync(1); expect(false).assertTrue(); } catch (e) { - ss.closeSync(); + sr.closeSync(); fileIO.unlinkSync(fpath); console.log('fileIO_test_stream_close_sync_001 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); @@ -73,7 +73,7 @@ describe('fileIO_fs_stream_close', function () { }) /** - * @tc.number SUB_DF_FILEIO_STREAM_CLOSESYNC_0200 + * @tc.number SUB_DF_FILEIO_STREAM_CLOSE_SYNC_0200 * @tc.name fileIO_test_stream_close_sync_002 * @tc.desc Test the closeSync() interface of class Stream. * The file stream has been closed. @@ -85,12 +85,12 @@ describe('fileIO_fs_stream_close', function () { it('fileIO_test_stream_close_sync_002', 0, async function () { let fpath = await nextFileName('fileIO_test_stream_close_sync_002'); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - let ss = fileIO.createStreamSync(fpath, 'r'); + let sr = fileIO.createStreamSync(fpath, 'r'); try { - expect(ss !== null).assertTrue(); - ss.closeSync(); - ss.closeSync(); + expect(sr !== null).assertTrue(); + sr.closeSync(); + sr.closeSync(); expect(false).assertTrue(); } catch (e) { fileIO.unlinkSync(fpath); @@ -100,7 +100,7 @@ describe('fileIO_fs_stream_close', function () { }) /** - * @tc.number SUB_DF_FILEIO_STREAM_CLOSEASYNC_0000 + * @tc.number SUB_DF_FILEIO_STREAM_CLOSE_ASYNC_0000 * @tc.name fileIO_test_stream_close_async_000 * @tc.desc Test the close() interface of class Stream. Promise. * Open a file stream, close file stream. @@ -114,9 +114,9 @@ describe('fileIO_fs_stream_close', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r'); - expect(ss !== null).assertTrue(); - await ss.close(); + let sr = fileIO.createStreamSync(fpath, 'r'); + expect(sr !== null).assertTrue(); + await sr.close(); fileIO.unlinkSync(fpath); done(); } catch (e) { @@ -126,7 +126,7 @@ describe('fileIO_fs_stream_close', function () { }); /** - * @tc.number SUB_DF_FILEIO_STREAM_CLOSEASYNC_0100 + * @tc.number SUB_DF_FILEIO_STREAM_CLOSE_ASYNC_0100 * @tc.name fileIO_test_stream_close_async_001 * @tc.desc Test the close() interface of class Stream. Callback. * Open a file stream, close file stream. @@ -140,9 +140,9 @@ describe('fileIO_fs_stream_close', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r'); - expect(ss !== null).assertTrue(); - ss.close((err) => { + let sr = fileIO.createStreamSync(fpath, 'r'); + expect(sr !== null).assertTrue(); + sr.close((err) => { if (err) { console.log('fileIO_test_stream_close_async_001 error package: ' + JSON.stringify(err)); expect(false).assertTrue(); @@ -157,7 +157,7 @@ describe('fileIO_fs_stream_close', function () { }); /** - * @tc.number SUB_DF_FILEIO_STREAM_CLOSEASYNC_0200 + * @tc.number SUB_DF_FILEIO_STREAM_CLOSE_ASYNC_0200 * @tc.name fileIO_test_stream_close_async_002 * @tc.desc Test the close() interface of class Stream. Promise. * The file stream has been closed. @@ -171,10 +171,10 @@ describe('fileIO_fs_stream_close', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r'); - expect(ss !== null).assertTrue(); - await ss.close(); - await ss.close(); + let sr = fileIO.createStreamSync(fpath, 'r'); + expect(sr !== null).assertTrue(); + await sr.close(); + await sr.close(); expect(false).assertTrue(); } catch (e) { fileIO.unlinkSync(fpath); @@ -185,7 +185,7 @@ describe('fileIO_fs_stream_close', function () { }); /** - * @tc.number SUB_DF_FILEIO_STREAM_CLOSEASYNC_0300 + * @tc.number SUB_DF_FILEIO_STREAM_CLOSE_ASYNC_0300 * @tc.name fileIO_test_stream_close_async_003 * @tc.desc Test the close() interface of class Stream. Promise. * Invalid parameter, don't requrie any parameters. @@ -199,9 +199,9 @@ describe('fileIO_fs_stream_close', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r'); - expect(ss !== null).assertTrue(); - await ss.close(1); + let sr = fileIO.createStreamSync(fpath, 'r'); + expect(sr !== null).assertTrue(); + await sr.close(1); expect(false).assertTrue(); } catch (e) { fileIO.unlinkSync(fpath); diff --git a/storage/storagefileiov9jstest/src/main/js/test/class_stream/flush.test.js b/storage/storagefileiov9jstest/src/main/js/test/class_stream/flush.test.js index 00aa58a482d4c12d7b0ad19ba8148b89d15dfcde..701a24f0457247fcc97e1cdd1076cb40cc223d5b 100644 --- a/storage/storagefileiov9jstest/src/main/js/test/class_stream/flush.test.js +++ b/storage/storagefileiov9jstest/src/main/js/test/class_stream/flush.test.js @@ -21,7 +21,7 @@ export default function fileIOStreamFlush() { describe('fileIO_fs_stream_flush', function () { /** - * @tc.number SUB_DF_FILEIO_STREAM_FLUSHSYNC_0000 + * @tc.number SUB_DF_FILEIO_STREAM_FLUSH_SYNC_0000 * @tc.name fileIO_test_stream_flush_sync_000 * @tc.desc Test the flushSync() interface of class Stream. * Refresh file stream. @@ -35,11 +35,11 @@ describe('fileIO_fs_stream_flush', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); - ss.flushSync(); - ss.closeSync(); + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + expect(sr.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); + sr.flushSync(); + sr.closeSync(); fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_stream_flush_sync_000 has failed for ' + e.message + ', code: ' + e.code); @@ -48,7 +48,7 @@ describe('fileIO_fs_stream_flush', function () { }); /** - * @tc.number SUB_DF_FILEIO_STREAM_FLUSHSYNC_0100 + * @tc.number SUB_DF_FILEIO_STREAM_FLUSH_SYNC_0100 * @tc.name fileIO_test_stream_flush_sync_001 * @tc.desc Test the flushSync() interface of class Stream. * Invalid parameter, don't requrie any parameters. @@ -60,14 +60,14 @@ describe('fileIO_fs_stream_flush', function () { it('fileIO_test_stream_flush_sync_001', 0, async function () { let fpath = await nextFileName('fileIO_test_stream_flush_sync_001'); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - let ss = fileIO.createStreamSync(fpath, 'r+'); + let sr = fileIO.createStreamSync(fpath, 'r+'); try { - expect(ss !== null).assertTrue(); - ss.flushSync(1); + expect(sr !== null).assertTrue(); + sr.flushSync(1); expect(false).assertTrue(); } catch (e) { - ss.closeSync(); + sr.closeSync(); fileIO.unlinkSync(fpath); console.log('fileIO_test_stream_flush_sync_001 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); @@ -75,7 +75,7 @@ describe('fileIO_fs_stream_flush', function () { }); /** - * @tc.number SUB_DF_FILEIO_STREAM_FLUSHASYNC_0000 + * @tc.number SUB_DF_FILEIO_STREAM_FLUSH_ASYNC_0000 * @tc.name fileIO_test_stream_flush_async_000 * @tc.desc Test the flush() interface of class Stream. Promise.then().catch() * Refresh the file stream. @@ -89,11 +89,11 @@ describe('fileIO_fs_stream_flush', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = await fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); - ss.flush().then(() => { - ss.closeSync(); + let sr = await fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + expect(sr.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); + sr.flush().then(() => { + sr.closeSync(); fileIO.unlinkSync(fpath); done(); }).catch((err) => { @@ -107,7 +107,7 @@ describe('fileIO_fs_stream_flush', function () { }); /** - * @tc.number SUB_DF_FILEIO_STREAM_FLUSHASYNC_0100 + * @tc.number SUB_DF_FILEIO_STREAM_FLUSH_ASYNC_0100 * @tc.name fileIO_test_stream_flush_async_001 * @tc.desc Test the flush() interface of class Stream. Callback. * Refresh the file stream. @@ -121,15 +121,15 @@ describe('fileIO_fs_stream_flush', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = await fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); - ss.flush((err) => { + let sr = await fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + expect(sr.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); + sr.flush((err) => { if (err) { console.log('fileIO_test_stream_flush_async_001 error package' + JSON.stringify(err)); expect(false).assertTrue(); } - ss.closeSync(); + sr.closeSync(); fileIO.unlinkSync(fpath); done(); }) @@ -140,7 +140,7 @@ describe('fileIO_fs_stream_flush', function () { }); /** - * @tc.number SUB_DF_FILEIO_STREAM_FLUSHASYNC_0100 + * @tc.number SUB_DF_FILEIO_STREAM_FLUSH_ASYNC_0100 * @tc.name fileIO_test_stream_flush_async_001 * @tc.desc Test the flush() interface of class Stream. Promise. * Refresh the file stream. @@ -153,14 +153,14 @@ describe('fileIO_fs_stream_flush', function () { it('fileIO_test_stream_flush_sync_001', 0, async function (done) { let fpath = await nextFileName('fileIO_test_stream_flush_sync_001'); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - let ss = fileIO.createStreamSync(fpath, 'r+'); - + let sr = fileIO.createStreamSync(fpath, 'r+'); + try { - expect(ss !== null).assertTrue(); - await ss.flush(1); + expect(sr !== null).assertTrue(); + await sr.flush(1); expect(false).assertTrue(); } catch (e) { - ss.closeSync(); + sr.closeSync(); fileIO.unlinkSync(fpath); console.log('fileIO_test_stream_flush_sync_001 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); diff --git a/storage/storagefileiov9jstest/src/main/js/test/class_stream/read.test.js b/storage/storagefileiov9jstest/src/main/js/test/class_stream/read.test.js index 12f24575fea738c0149fecbacae2378faa05707c..484395fde9e1f95fb0860ab08a77b6b0bdb6060e 100644 --- a/storage/storagefileiov9jstest/src/main/js/test/class_stream/read.test.js +++ b/storage/storagefileiov9jstest/src/main/js/test/class_stream/read.test.js @@ -35,11 +35,11 @@ describe('fileIO_fs_stream_read', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - let readout = ss.readSync(new ArrayBuffer(4096)); - expect(readout == FILE_CONTENT.length).assertTrue(); - ss.closeSync(); + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + let readLen = sr.readSync(new ArrayBuffer(4096)); + expect(readLen == FILE_CONTENT.length).assertTrue(); + sr.closeSync(); fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_stream_read_sync_000 has failed for ' + e.message + ', code: ' + e.code); @@ -62,11 +62,11 @@ describe('fileIO_fs_stream_read', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - let readout = ss.readSync(new ArrayBuffer(4096), { length: 2 }); - expect(readout == 2).assertTrue(); - ss.closeSync(); + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + let readLen = sr.readSync(new ArrayBuffer(4096), { length: 2 }); + expect(readLen == 2).assertTrue(); + sr.closeSync(); fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_stream_read_sync_001 has failed for ' + e.message + ', code: ' + e.code); @@ -89,11 +89,11 @@ describe('fileIO_fs_stream_read', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - let readout = ss.readSync(new ArrayBuffer(4096), { offset: 2 }); - expect(readout == FILE_CONTENT.length - 2).assertTrue(); - ss.closeSync(); + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + let readLen = sr.readSync(new ArrayBuffer(4096), { offset: 2 }); + expect(readLen == FILE_CONTENT.length - 2).assertTrue(); + sr.closeSync(); fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_stream_read_sync_002 has failed for ' + e.message + ', code: ' + e.code); @@ -116,14 +116,14 @@ describe('fileIO_fs_stream_read', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - let readout = ss.readSync(new ArrayBuffer(4096), { + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + let readLen = sr.readSync(new ArrayBuffer(4096), { offset: 1, length: FILE_CONTENT.length }); - expect(readout == FILE_CONTENT.length - 1).assertTrue(); - ss.closeSync(); + expect(readLen == FILE_CONTENT.length - 1).assertTrue(); + sr.closeSync(); fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_stream_read_sync_003 has failed for ' + e.message + ', code: ' + e.code); @@ -144,14 +144,14 @@ describe('fileIO_fs_stream_read', function () { it('fileIO_test_stream_read_sync_004', 0, async function () { let fpath = await nextFileName('fileIO_test_stream_read_sync_004'); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - let ss = fileIO.createStreamSync(fpath, 'r+'); + let sr = fileIO.createStreamSync(fpath, 'r+'); try { - expect(ss !== null).assertTrue(); - ss.readSync(""); + expect(sr !== null).assertTrue(); + sr.readSync(""); expect(false).assertTrue(); } catch (e) { - ss.closeSync(); + sr.closeSync(); fileIO.unlinkSync(fpath); console.log('fileIO_test_stream_read_sync_004 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); @@ -171,15 +171,15 @@ describe('fileIO_fs_stream_read', function () { it('fileIO_test_stream_read_sync_005', 0, async function () { let fpath = await nextFileName('fileIO_test_stream_read_sync_005'); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - let ss = fileIO.createStreamSync(fpath, 'r+'); - + let sr = fileIO.createStreamSync(fpath, 'r+'); + const invalidLength = 4097; + try { - expect(ss !== null).assertTrue(); - const invalidLength = 4097; - ss.readSync(new ArrayBuffer(4096), { length: invalidLength }); + expect(sr !== null).assertTrue(); + sr.readSync(new ArrayBuffer(4096), { length: invalidLength }); expect(false).assertTrue(); } catch (e) { - ss.closeSync(); + sr.closeSync(); fileIO.unlinkSync(fpath); console.log('fileIO_test_stream_read_sync_005 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); @@ -199,15 +199,15 @@ describe('fileIO_fs_stream_read', function () { it('fileIO_test_stream_read_sync_006', 0, async function () { let fpath = await nextFileName('fileIO_test_stream_read_sync_006'); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - let ss = fileIO.createStreamSync(fpath, 'r+'); - + let sr = fileIO.createStreamSync(fpath, 'r+'); + const invalidOffset = -1; + try { - expect(ss !== null).assertTrue(); - const invalidOffset = -1; - ss.readSync(new ArrayBuffer(4096), { offset: invalidOffset }); + expect(sr !== null).assertTrue(); + sr.readSync(new ArrayBuffer(4096), { offset: invalidOffset }); expect(false).assertTrue(); } catch (e) { - ss.closeSync(); + sr.closeSync(); fileIO.unlinkSync(fpath); console.log('fileIO_test_stream_read_sync_006 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); @@ -229,11 +229,11 @@ describe('fileIO_fs_stream_read', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - let readout = await ss.read(new ArrayBuffer(4096)); - expect(readout == FILE_CONTENT.length).assertTrue(); - ss.closeSync(); + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + let readLen = await sr.read(new ArrayBuffer(4096)); + expect(readLen == FILE_CONTENT.length).assertTrue(); + sr.closeSync(); fileIO.unlinkSync(fpath); done(); } catch (e) { @@ -257,15 +257,15 @@ describe('fileIO_fs_stream_read', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - ss.read(new ArrayBuffer(4096), (err, readout) => { + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + sr.read(new ArrayBuffer(4096), (err, readLen) => { if (err) { console.log('fileIO_test_stream_read_async_001 error package: ' + JSON.stringify(err)); expect(false).assertTrue(); } - expect(readout == FILE_CONTENT.length).assertTrue(); - ss.closeSync(); + expect(readLen == FILE_CONTENT.length).assertTrue(); + sr.closeSync(); fileIO.unlinkSync(fpath); done(); }); @@ -290,13 +290,13 @@ describe('fileIO_fs_stream_read', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - let readout = await ss.read(new ArrayBuffer(4096), { + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + let readLen = await sr.read(new ArrayBuffer(4096), { length: 5 }); - expect(readout == 5).assertTrue(); - ss.closeSync(); + expect(readLen == 5).assertTrue(); + sr.closeSync(); fileIO.unlinkSync(fpath); done(); } catch (e) { @@ -320,17 +320,17 @@ describe('fileIO_fs_stream_read', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - ss.read(new ArrayBuffer(4096), { + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + sr.read(new ArrayBuffer(4096), { length: 5 - }, (err, readout) => { + }, (err, readLen) => { if (err) { console.log('fileIO_test_stream_read_async_003 error package: ' + JSON.stringify(err)); expect(false).assertTrue(); } - expect(readout == 5).assertTrue(); - ss.closeSync(); + expect(readLen == 5).assertTrue(); + sr.closeSync(); fileIO.unlinkSync(fpath); done(); }); @@ -355,13 +355,13 @@ describe('fileIO_fs_stream_read', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - let readout = await ss.read(new ArrayBuffer(4096), { + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + let readLen = await sr.read(new ArrayBuffer(4096), { offset: 5 }); - expect(readout == FILE_CONTENT.length - 5).assertTrue(); - ss.closeSync(); + expect(readLen == FILE_CONTENT.length - 5).assertTrue(); + sr.closeSync(); fileIO.unlinkSync(fpath); done(); } catch (e) { @@ -385,17 +385,17 @@ describe('fileIO_fs_stream_read', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - ss.read(new ArrayBuffer(4096), { + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + sr.read(new ArrayBuffer(4096), { offset: 5 - }, (err, readout) => { + }, (err, readLen) => { if (err) { console.log('fileIO_test_stream_read_async_005 error package: ' + JSON.stringify(err)); expect(false).assertTrue(); } - expect(readout == FILE_CONTENT.length - 5).assertTrue(); - ss.closeSync(); + expect(readLen == FILE_CONTENT.length - 5).assertTrue(); + sr.closeSync(); fileIO.unlinkSync(fpath); done(); }); @@ -418,15 +418,15 @@ describe('fileIO_fs_stream_read', function () { it('fileIO_test_stream_read_async_006', 0, async function (done) { let fpath = await nextFileName('fileIO_test_stream_read_async_006'); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - let ss = fileIO.createStreamSync(fpath, 'r+'); + let sr = fileIO.createStreamSync(fpath, 'r+'); try { - expect(ss !== null).assertTrue(); + expect(sr !== null).assertTrue(); const invalidLength = 4097; - await ss.read(new ArrayBuffer(4096), { length: invalidLength }); + await sr.read(new ArrayBuffer(4096), { length: invalidLength }); expect(false).assertTrue(); } catch (e) { - ss.closeSync(); + sr.closeSync(); fileIO.unlinkSync(fpath); console.log('fileIO_test_stream_read_async_006 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); @@ -447,18 +447,18 @@ describe('fileIO_fs_stream_read', function () { it('fileIO_test_stream_read_async_007', 0, async function (done) { let fpath = await nextFileName('fileIO_test_stream_read_async_007'); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - let ss = fileIO.createStreamSync(fpath, 'r+'); + let sr = fileIO.createStreamSync(fpath, 'r+'); try { - expect(ss !== null).assertTrue(); + expect(sr !== null).assertTrue(); const invalidOffset = -1; - ss.read(new ArrayBuffer(4096), { + sr.read(new ArrayBuffer(4096), { offset: invalidOffset }, (err) => { expect(false).assertTrue(); }); } catch (e) { - ss.closeSync(); + sr.closeSync(); fileIO.unlinkSync(fpath); console.log('fileIO_test_stream_read_async_007 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); @@ -481,14 +481,14 @@ describe('fileIO_fs_stream_read', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - let readout = await ss.read(new ArrayBuffer(4096), { + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + let readLen = await sr.read(new ArrayBuffer(4096), { offset: 1, length: FILE_CONTENT.length }); - expect(readout == FILE_CONTENT.length - 1).assertTrue(); - ss.closeSync(); + expect(readLen == FILE_CONTENT.length - 1).assertTrue(); + sr.closeSync(); fileIO.unlinkSync(fpath); done(); } catch (e) { @@ -512,18 +512,18 @@ describe('fileIO_fs_stream_read', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - ss.read(new ArrayBuffer(4096), { + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + sr.read(new ArrayBuffer(4096), { offset: 1, length: FILE_CONTENT.length - }, (err, readout) => { + }, (err, readLen) => { if (err) { console.log('fileIO_test_stream_read_async_009 error package: ' + JSON.stringify(err)); expect(false).assertTrue(); } - expect(readout == FILE_CONTENT.length - 1).assertTrue(); - ss.closeSync(); + expect(readLen == FILE_CONTENT.length - 1).assertTrue(); + sr.closeSync(); fileIO.unlinkSync(fpath); done(); }); @@ -548,11 +548,11 @@ describe('fileIO_fs_stream_read', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - let readout = await ss.read(new ArrayBuffer(4096), {}); - expect(readout == FILE_CONTENT.length).assertTrue(); - ss.closeSync(); + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + let readLen = await sr.read(new ArrayBuffer(4096), {}); + expect(readLen == FILE_CONTENT.length).assertTrue(); + sr.closeSync(); fileIO.unlinkSync(fpath); done(); } catch (e) { @@ -576,16 +576,16 @@ describe('fileIO_fs_stream_read', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - ss.read(new ArrayBuffer(4096), { - }, (err, readout) => { + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + sr.read(new ArrayBuffer(4096), { + }, (err, readLen) => { if (err) { console.log('fileIO_test_stream_read_async_011 error package: ' + JSON.stringify(err)); expect(false).assertTrue(); } - expect(readout == FILE_CONTENT.length).assertTrue(); - ss.closeSync(); + expect(readLen == FILE_CONTENT.length).assertTrue(); + sr.closeSync(); fileIO.unlinkSync(fpath); done(); }); @@ -607,14 +607,14 @@ describe('fileIO_fs_stream_read', function () { it('fileIO_test_stream_read_async_012', 0, async function (done) { let fpath = await nextFileName('fileIO_test_stream_read_async_012'); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - let ss = fileIO.createStreamSync(fpath, 'r+'); + let sr = fileIO.createStreamSync(fpath, 'r+'); try { - expect(ss !== null).assertTrue(); - await ss.read(); + expect(sr !== null).assertTrue(); + await sr.read(); expect(false).assertTrue(); } catch (e) { - ss.closeSync(); + sr.closeSync(); fileIO.unlinkSync(fpath); console.log('fileIO_test_stream_read_async_012 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); @@ -635,13 +635,14 @@ describe('fileIO_fs_stream_read', function () { it('fileIO_test_stream_read_async_013', 0, async function (done) { let fpath = await nextFileName('fileIO_test_stream_read_async_013'); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); + let sr = fileIO.createStreamSync(fpath, 'r+'); + try { - await ss.read(""); + expect(sr !== null).assertTrue(); + await sr.read(""); expect(false).assertTrue(); } catch (e) { - ss.closeSync(); + sr.closeSync(); fileIO.unlinkSync(fpath); console.log('fileIO_test_stream_read_async_013 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); @@ -662,15 +663,15 @@ describe('fileIO_fs_stream_read', function () { it('fileIO_test_stream_read_async_014', 0, async function (done) { let fpath = await nextFileName('fileIO_test_stream_read_async_014'); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - let ss = fileIO.createStreamSync(fpath, 'r+'); + let sr = fileIO.createStreamSync(fpath, 'r+'); try { - expect(ss !== null).assertTrue(); - ss.read("", (err) => { + expect(sr !== null).assertTrue(); + sr.read("", (err) => { expect(false).assertTrue(); }); } catch (e) { - ss.closeSync(); + sr.closeSync(); fileIO.unlinkSync(fpath); console.log('fileIO_test_stream_read_async_014 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); diff --git a/storage/storagefileiov9jstest/src/main/js/test/class_stream/write.test.js b/storage/storagefileiov9jstest/src/main/js/test/class_stream/write.test.js index c2bfbea54d03cdb40f3e35f0ba461512c30ec980..7ca204ef5f3b191b5947bdcdffba495393592787 100644 --- a/storage/storagefileiov9jstest/src/main/js/test/class_stream/write.test.js +++ b/storage/storagefileiov9jstest/src/main/js/test/class_stream/write.test.js @@ -35,11 +35,11 @@ describe('fileIO_fs_stream_write', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - let writenLen = ss.writeSync(new ArrayBuffer(4096)); - expect(writenLen == 4096).assertTrue(); - ss.closeSync(); + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + let bytesWritten = sr.writeSync(new ArrayBuffer(4096)); + expect(bytesWritten == 4096).assertTrue(); + sr.closeSync(); fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_stream_write_sync_000 has failed for ' + e.message + ', code: ' + e.code); @@ -62,11 +62,11 @@ describe('fileIO_fs_stream_write', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - let writenLen = ss.writeSync(FILE_CONTENT); - expect(writenLen == FILE_CONTENT.length).assertTrue(); - ss.closeSync(); + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + let bytesWritten = sr.writeSync(FILE_CONTENT); + expect(bytesWritten == FILE_CONTENT.length).assertTrue(); + sr.closeSync(); fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_stream_write_sync_001 has failed for ' + e.message + ', code: ' + e.code); @@ -89,11 +89,11 @@ describe('fileIO_fs_stream_write', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - let len = ss.writeSync(FILE_CONTENT, { offset: 1 }); - expect(len == FILE_CONTENT.length).assertTrue(); - ss.closeSync(); + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + let bytesWritten = sr.writeSync(FILE_CONTENT, { offset: 1 }); + expect(bytesWritten == FILE_CONTENT.length).assertTrue(); + sr.closeSync(); fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_stream_write_sync_002 has failed for ' + e.message + ', code: ' + e.code); @@ -114,15 +114,15 @@ describe('fileIO_fs_stream_write', function () { it('fileIO_test_stream_write_sync_003', 0, async function () { let fpath = await nextFileName('fileIO_test_stream_write_sync_003'); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - let ss = fileIO.createStreamSync(fpath, 'r+'); + let sr = fileIO.createStreamSync(fpath, 'r+'); + const invalidOffset = -1; try { - expect(ss !== null).assertTrue(); - const invalidOffset = -1; - ss.writeSync(new ArrayBuffer(4096), { offset: invalidOffset }); + expect(sr !== null).assertTrue(); + sr.writeSync(new ArrayBuffer(4096), { offset: invalidOffset }); expect(false).assertTrue(); } catch (e) { - ss.closeSync(); + sr.closeSync(); fileIO.unlinkSync(fpath); console.log('fileIO_test_stream_write_sync_003 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); @@ -144,11 +144,11 @@ describe('fileIO_fs_stream_write', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - let bytesWritten = ss.writeSync(FILE_CONTENT, { encoding: 'utf-8' }); + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + let bytesWritten = sr.writeSync(FILE_CONTENT, { encoding: 'utf-8' }); expect(bytesWritten == FILE_CONTENT.length).assertTrue(); - ss.closeSync(); + sr.closeSync(); fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_stream_write_sync_004 has failed for ' + e.message + ', code: ' + e.code); @@ -171,11 +171,11 @@ describe('fileIO_fs_stream_write', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - let bytesWritten = ss.writeSync(FILE_CONTENT, { length: 5 }); + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + let bytesWritten = sr.writeSync(FILE_CONTENT, { length: 5 }); expect(bytesWritten == 5).assertTrue(); - ss.closeSync(); + sr.closeSync(); fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_stream_write_sync_005 has failed for ' + e.message + ', code: ' + e.code); @@ -196,15 +196,15 @@ describe('fileIO_fs_stream_write', function () { it('fileIO_test_stream_write_sync_006', 0, async function () { let fpath = await nextFileName('fileIO_test_stream_write_sync_006'); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - let ss = fileIO.createStreamSync(fpath, 'r+'); + let sr = fileIO.createStreamSync(fpath, 'r+'); try { - expect(ss !== null).assertTrue(); + expect(sr !== null).assertTrue(); const invalidLength = 4097; - ss.writeSync(new ArrayBuffer(4096), { length: invalidLength }); + sr.writeSync(new ArrayBuffer(4096), { length: invalidLength }); expect(false).assertTrue(); } catch (e) { - ss.closeSync(); + sr.closeSync(); fileIO.unlinkSync(fpath); console.log('fileIO_test_stream_write_sync_006 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); @@ -224,15 +224,15 @@ describe('fileIO_fs_stream_write', function () { it('fileIO_test_stream_write_sync_007', 0, async function () { let fpath = await nextFileName('fileIO_test_stream_write_sync_007'); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - let ss = fileIO.createStreamSync(fpath, 'r+'); + let sr = fileIO.createStreamSync(fpath, 'r+'); + const invalidLength = 9999; try { - expect(ss !== null).assertTrue(); - const invalidLength = 9999; - ss.writeSync(FILE_CONTENT, { length: invalidLength }); + expect(sr !== null).assertTrue(); + sr.writeSync(FILE_CONTENT, { length: invalidLength }); expect(false).assertTrue(); } catch (e) { - ss.closeSync(); + sr.closeSync(); fileIO.unlinkSync(fpath); console.log('fileIO_test_stream_write_sync_007 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); @@ -254,15 +254,15 @@ describe('fileIO_fs_stream_write', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - let bytesWritten = ss.writeSync(new ArrayBuffer(4096), { + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + let bytesWritten = sr.writeSync(new ArrayBuffer(4096), { offset: 1, length: 4096, encoding: 'utf-8' }); expect(bytesWritten == 4096).assertTrue(); - ss.closeSync(); + sr.closeSync(); fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_stream_write_sync_008 has failed for ' + e.message + ', code: ' + e.code); @@ -285,15 +285,15 @@ describe('fileIO_fs_stream_write', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - let bytesWritten = ss.writeSync(FILE_CONTENT, { + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + let bytesWritten = sr.writeSync(FILE_CONTENT, { offset: 1, length: FILE_CONTENT.length, encoding: 'utf-8' }); expect(bytesWritten == FILE_CONTENT.length).assertTrue(); - ss.closeSync(); + sr.closeSync(); fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_stream_write_sync_009 has failed for ' + e.message + ', code: ' + e.code); @@ -316,11 +316,11 @@ describe('fileIO_fs_stream_write', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - let bytesWritten = ss.writeSync(FILE_CONTENT, {}); + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + let bytesWritten = sr.writeSync(FILE_CONTENT, {}); expect(bytesWritten == FILE_CONTENT.length).assertTrue(); - ss.closeSync(); + sr.closeSync(); fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_stream_write_sync_010 has failed for ' + e.message + ', code: ' + e.code); @@ -341,14 +341,14 @@ describe('fileIO_fs_stream_write', function () { it('fileIO_test_stream_write_sync_011', 0, async function () { let fpath = await nextFileName('fileIO_test_stream_write_sync_011'); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - let ss = fileIO.createStreamSync(fpath, 'r+'); + let sr = fileIO.createStreamSync(fpath, 'r+'); try { - expect(ss !== null).assertTrue(); - ss.writeSync(); + expect(sr !== null).assertTrue(); + sr.writeSync(); expect(false).assertTrue(); } catch (e) { - ss.closeSync(); + sr.closeSync(); fileIO.unlinkSync(fpath); console.log('fileIO_test_stream_write_sync_011 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); @@ -370,11 +370,11 @@ describe('fileIO_fs_stream_write', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - let writenLen = await ss.write(new ArrayBuffer(4096)); - expect(writenLen == 4096).assertTrue(); - ss.closeSync(); + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + let bytesWritten = await sr.write(new ArrayBuffer(4096)); + expect(bytesWritten == 4096).assertTrue(); + sr.closeSync(); fileIO.unlinkSync(fpath); done(); } catch (e) { @@ -398,15 +398,15 @@ describe('fileIO_fs_stream_write', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - ss.write(new ArrayBuffer(4096), (err, writenLen) => { + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + sr.write(new ArrayBuffer(4096), (err, bytesWritten) => { if (err) { console.log('fileIO_test_stream_write_async_001 err package: ' + JSON.stringify(err)); expect(false).assertTrue(); } - expect(writenLen == 4096).assertTrue(); - ss.closeSync(); + expect(bytesWritten == 4096).assertTrue(); + sr.closeSync(); fileIO.unlinkSync(fpath); done(); }); @@ -431,11 +431,11 @@ describe('fileIO_fs_stream_write', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - let writenLen = await ss.write(FILE_CONTENT); - expect(writenLen == FILE_CONTENT.length).assertTrue(); - ss.closeSync(); + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + let bytesWritten = await sr.write(FILE_CONTENT); + expect(bytesWritten == FILE_CONTENT.length).assertTrue(); + sr.closeSync(); fileIO.unlinkSync(fpath); done(); } catch (e) { @@ -459,15 +459,15 @@ describe('fileIO_fs_stream_write', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - ss.write(FILE_CONTENT, (err, writenLen) => { + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + sr.write(FILE_CONTENT, (err, bytesWritten) => { if (err) { console.log('fileIO_test_stream_write_async_003 err package: ' + JSON.stringify(err)); expect(false).assertTrue(); } - expect(writenLen == FILE_CONTENT.length).assertTrue(); - ss.closeSync(); + expect(bytesWritten == FILE_CONTENT.length).assertTrue(); + sr.closeSync(); fileIO.unlinkSync(fpath); done(); }); @@ -492,11 +492,11 @@ describe('fileIO_fs_stream_write', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - let len = await ss.write(FILE_CONTENT, { offset: 1 }); - expect(len == FILE_CONTENT.length).assertTrue(); - ss.closeSync(); + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + let bytesWritten = await sr.write(FILE_CONTENT, { offset: 1 }); + expect(bytesWritten == FILE_CONTENT.length).assertTrue(); + sr.closeSync(); fileIO.unlinkSync(fpath); done(); } catch (e) { @@ -520,17 +520,17 @@ describe('fileIO_fs_stream_write', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - ss.write(FILE_CONTENT, { + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + sr.write(FILE_CONTENT, { offset: 1 - }, (err, len) => { + }, (err, bytesWritten) => { if (err) { console.log('fileIO_test_stream_write_async_005 err package: ' + JSON.stringify(err)); expect(false).assertTrue(); } - expect(len == FILE_CONTENT.length).assertTrue(); - ss.closeSync(); + expect(bytesWritten == FILE_CONTENT.length).assertTrue(); + sr.closeSync(); fileIO.unlinkSync(fpath); done(); }); @@ -553,18 +553,18 @@ describe('fileIO_fs_stream_write', function () { it('fileIO_test_stream_write_async_006', 0, async function (done) { let fpath = await nextFileName('fileIO_test_stream_write_async_006'); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - let ss = fileIO.createStreamSync(fpath, 'r+'); + let sr = fileIO.createStreamSync(fpath, 'r+'); + const invalidOffset = -1; try { - expect(ss !== null).assertTrue(); - const invalidOffset = -1; - ss.write(new ArrayBuffer(4096), { + expect(sr !== null).assertTrue(); + sr.write(new ArrayBuffer(4096), { offset: invalidOffset }, (err) => { expect(false).assertTrue(); }); } catch (e) { - ss.closeSync(); + sr.closeSync(); fileIO.unlinkSync(fpath); console.log('fileIO_test_stream_write_async_006 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); @@ -587,11 +587,11 @@ describe('fileIO_fs_stream_write', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - let bytesWritten = await ss.write(FILE_CONTENT, { encoding: 'utf-8' }); + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + let bytesWritten = await sr.write(FILE_CONTENT, { encoding: 'utf-8' }); expect(bytesWritten == FILE_CONTENT.length).assertTrue(); - ss.closeSync(); + sr.closeSync(); fileIO.unlinkSync(fpath); done(); } catch (e) { @@ -615,9 +615,9 @@ describe('fileIO_fs_stream_write', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - ss.write(FILE_CONTENT, { + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + sr.write(FILE_CONTENT, { encoding: 'utf-8' }, (err, bytesWritten) => { if (err) { @@ -625,7 +625,7 @@ describe('fileIO_fs_stream_write', function () { expect(false).assertTrue(); } expect(bytesWritten == FILE_CONTENT.length).assertTrue(); - ss.closeSync(); + sr.closeSync(); fileIO.unlinkSync(fpath); done(); }); @@ -651,11 +651,11 @@ describe('fileIO_fs_stream_write', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - let bytesWritten = await ss.write(FILE_CONTENT, { length: 5 }); + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + let bytesWritten = await sr.write(FILE_CONTENT, { length: 5 }); expect(bytesWritten == 5).assertTrue(); - ss.closeSync(); + sr.closeSync(); fileIO.unlinkSync(fpath); done(); } catch (e) { @@ -679,9 +679,9 @@ describe('fileIO_fs_stream_write', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - ss.write(FILE_CONTENT, { + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + sr.write(FILE_CONTENT, { length: 5 }, (err, bytesWritten) => { if (err) { @@ -689,7 +689,7 @@ describe('fileIO_fs_stream_write', function () { expect(false).assertTrue(); } expect(bytesWritten == 5).assertTrue(); - ss.closeSync(); + sr.closeSync(); fileIO.unlinkSync(fpath); done(); }); @@ -712,18 +712,18 @@ describe('fileIO_fs_stream_write', function () { it('fileIO_test_stream_write_async_011', 0, async function (done) { let fpath = await nextFileName('fileIO_test_stream_write_async_011'); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - let ss = fileIO.createStreamSync(fpath, 'r+'); - + let sr = fileIO.createStreamSync(fpath, 'r+'); + const invalidLength = 4097; + try { - expect(ss !== null).assertTrue(); - const invalidLength = 4097; - ss.write(new ArrayBuffer(4096), { + expect(sr !== null).assertTrue(); + sr.write(new ArrayBuffer(4096), { length: invalidLength }, (err) => { expect(false).assertTrue(); }); } catch (e) { - ss.closeSync(); + sr.closeSync(); fileIO.unlinkSync(fpath); console.log('fileIO_test_stream_write_async_011 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); @@ -744,18 +744,18 @@ describe('fileIO_fs_stream_write', function () { it('fileIO_test_stream_write_async_012', 0, async function (done) { let fpath = await nextFileName('fileIO_test_stream_write_async_012'); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - let ss = fileIO.createStreamSync(fpath, 'r+'); - + let sr = fileIO.createStreamSync(fpath, 'r+'); + const invalidLength = 9999; + try { - expect(ss !== null).assertTrue(); - const invalidLength = 9999; - ss.write(FILE_CONTENT, { + expect(sr !== null).assertTrue(); + sr.write(FILE_CONTENT, { length: invalidLength }, (err) => { expect(false).assertTrue(); }); } catch (e) { - ss.closeSync(); + sr.closeSync(); fileIO.unlinkSync(fpath); console.log('fileIO_test_stream_write_async_012 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); @@ -778,15 +778,15 @@ describe('fileIO_fs_stream_write', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - let bytesWritten = await ss.write(new ArrayBuffer(4096), { + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + let bytesWritten = await sr.write(new ArrayBuffer(4096), { offset: 1, length: 4096, encoding: 'utf-8' }); expect(bytesWritten == 4096).assertTrue(); - ss.closeSync(); + sr.closeSync(); fileIO.unlinkSync(fpath); done(); } catch (e) { @@ -810,9 +810,9 @@ describe('fileIO_fs_stream_write', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - ss.write(new ArrayBuffer(4096), { + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + sr.write(new ArrayBuffer(4096), { offset: 1, length: 4096, encoding: 'utf-8' @@ -822,7 +822,7 @@ describe('fileIO_fs_stream_write', function () { expect(false).assertTrue(); } expect(bytesWritten == 4096).assertTrue(); - ss.closeSync(); + sr.closeSync(); fileIO.unlinkSync(fpath); done(); }); @@ -847,15 +847,15 @@ describe('fileIO_fs_stream_write', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - let bytesWritten = await ss.write(FILE_CONTENT, { + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + let bytesWritten = await sr.write(FILE_CONTENT, { offset: 1, length: FILE_CONTENT.length, encoding: 'utf-8' }); expect(bytesWritten == FILE_CONTENT.length).assertTrue(); - ss.closeSync(); + sr.closeSync(); fileIO.unlinkSync(fpath); done(); } catch (e) { @@ -879,9 +879,9 @@ describe('fileIO_fs_stream_write', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - ss.write(FILE_CONTENT, { + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + sr.write(FILE_CONTENT, { offset: 1, length: FILE_CONTENT.length, encoding: 'utf-8' @@ -891,7 +891,7 @@ describe('fileIO_fs_stream_write', function () { expect(false).assertTrue(); } expect(bytesWritten == FILE_CONTENT.length).assertTrue(); - ss.closeSync(); + sr.closeSync(); fileIO.unlinkSync(fpath); done(); }); @@ -916,11 +916,11 @@ describe('fileIO_fs_stream_write', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - let bytesWritten = await ss.write(FILE_CONTENT, {}); + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + let bytesWritten = await sr.write(FILE_CONTENT, {}); expect(bytesWritten == FILE_CONTENT.length).assertTrue(); - ss.closeSync(); + sr.closeSync(); fileIO.unlinkSync(fpath); done(); } catch (e) { @@ -944,16 +944,16 @@ describe('fileIO_fs_stream_write', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - ss.write(FILE_CONTENT, { + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + sr.write(FILE_CONTENT, { }, (err, bytesWritten) => { if (err) { console.log('fileIO_test_stream_write_async_018 err package: ' + JSON.stringify(err)); expect(false).assertTrue(); } expect(bytesWritten == FILE_CONTENT.length).assertTrue(); - ss.closeSync(); + sr.closeSync(); fileIO.unlinkSync(fpath); done(); }); @@ -976,14 +976,14 @@ describe('fileIO_fs_stream_write', function () { it('fileIO_test_stream_write_async_019', 0, async function (done) { let fpath = await nextFileName('fileIO_test_stream_write_async_019'); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - let ss = fileIO.createStreamSync(fpath, 'r+'); + let sr = fileIO.createStreamSync(fpath, 'r+'); try { - expect(ss !== null).assertTrue(); - await ss.write(); + expect(sr !== null).assertTrue(); + await sr.write(); expect(false).assertTrue(); } catch (e) { - ss.closeSync(); + sr.closeSync(); fileIO.unlinkSync(fpath); console.log('fileIO_test_stream_write_async_019 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); diff --git a/storage/storagefileiov9jstest/src/main/js/test/members/access.test.js b/storage/storagefileiov9jstest/src/main/js/test/members/access.test.js index f47143946350d4804f704e98ec4e39330cf6d557..5c79db65e94e28a9c62eabb3b226f64fa5ecb7c3 100644 --- a/storage/storagefileiov9jstest/src/main/js/test/members/access.test.js +++ b/storage/storagefileiov9jstest/src/main/js/test/members/access.test.js @@ -21,7 +21,7 @@ export default function fileIOAccess() { describe('fileIO_fs_access', function () { /** - * @tc.number SUB_DF_FILEIO_ACCESSSYNC_0000 + * @tc.number SUB_DF_FILEIO_ACCESS_SYNC_0000 * @tc.name fileIO_test_access_sync_000 * @tc.desc Test accessSync() interface. * This interface shall work properly in normal case. @@ -49,7 +49,7 @@ describe('fileIO_fs_access', function () { }); /** - * @tc.number SUB_DF_FILEIO_ACCESSSYNC_0100 + * @tc.number SUB_DF_FILEIO_ACCESS_SYNC_0100 * @tc.name fileIO_test_access_sync_001 * @tc.desc Test accessSync() interface. * The test file is not exist. @@ -71,7 +71,7 @@ describe('fileIO_fs_access', function () { }); /** - * @tc.number SUB_DF_FILEIO_ACCESSSYNC_0200 + * @tc.number SUB_DF_FILEIO_ACCESS_SYNC_0200 * @tc.name fileIO_test_access_sync_002 * @tc.desc Test accessSync() interface. * The test file path is illegal. @@ -92,7 +92,7 @@ describe('fileIO_fs_access', function () { }); /** - * @tc.number SUB_DF_FILEIO_ACCESSASYNC_0000 + * @tc.number SUB_DF_FILEIO_ACCESS_ASYNC_0000 * @tc.name fileIO_test_access_async_000 * @tc.desc Test access() interface. Promise. * Use promise to test that the file is exist. Sync method reads data from file. @@ -122,7 +122,7 @@ describe('fileIO_fs_access', function () { }); /** - * @tc.number SUB_DF_FILEIO_ACCESSASYNC_0100 + * @tc.number SUB_DF_FILEIO_ACCESS_ASYNC_0100 * @tc.name fileIO_test_access_async_001 * @tc.desc Test access() interface. Callback. * Use callback to test that the file is exist. Sync method reads data from file. @@ -157,7 +157,7 @@ describe('fileIO_fs_access', function () { }); /** - * @tc.number SUB_DF_FILEIO_ACCESSASYNC_0200 + * @tc.number SUB_DF_FILEIO_ACCESS_ASYNC_0200 * @tc.name fileIO_test_access_async_002 * @tc.desc Test access() interface. Promise. * Async test file does not exist. @@ -180,7 +180,7 @@ describe('fileIO_fs_access', function () { }); /** - * @tc.number SUB_DF_FILEIO_ACCESSASYNC_0300 + * @tc.number SUB_DF_FILEIO_ACCESS_ASYNC_0300 * @tc.name fileIO_test_access_async_003 * @tc.desc Test access() interface. Callback. * Async test file does not exist. @@ -208,7 +208,7 @@ describe('fileIO_fs_access', function () { }); /** - * @tc.number SUB_DF_FILEIO_ACCESSASYNC_0400 + * @tc.number SUB_DF_FILEIO_ACCESS_ASYNC_0400 * @tc.name fileIO_test_access_async_004 * @tc.desc Test access() interface. Promise. * Invalid path parameter. @@ -230,7 +230,7 @@ describe('fileIO_fs_access', function () { }); /** - * @tc.number SUB_DF_FILEIO_ACCESSASYNC_0500 + * @tc.number SUB_DF_FILEIO_ACCESS_ASYNC_0500 * @tc.name fileIO_test_access_async_005 * @tc.desc Test access() interface. Callback. * Invalid path parameter. diff --git a/storage/storagefileiov9jstest/src/main/js/test/members/close.test.js b/storage/storagefileiov9jstest/src/main/js/test/members/close.test.js index d02dba932f809d39f73b191aa98c7bb3ea72b356..a40a3905d9ae2bb9a5ec8053700b57e348c3f988 100644 --- a/storage/storagefileiov9jstest/src/main/js/test/members/close.test.js +++ b/storage/storagefileiov9jstest/src/main/js/test/members/close.test.js @@ -14,15 +14,14 @@ */ import { - fileIO, FILE_CONTENT, nextFileName, prepareFile, - describe, it, expect, + fileIO, FILE_CONTENT, nextFileName, prepareFile, describe, it, expect, } from '../Common'; export default function fileIOClose() { describe('fileIO_fs_close', function () { /** - * @tc.number SUB_DF_FILEIO_CLOSESYNC_0000 + * @tc.number SUB_DF_FILEIO_CLOSE_SYNC_0000 * @tc.name fileIO_test_close_sync_000 * @tc.desc Test closeSync() interfaces. * Open file and close file by fd. @@ -45,7 +44,7 @@ describe('fileIO_fs_close', function () { }); /** - * @tc.number SUB_DF_FILEIO_CLOSESYNC_0100 + * @tc.number SUB_DF_FILEIO_CLOSE_SYNC_0100 * @tc.name fileIO_test_close_sync_001 * @tc.desc Test closeSync() interfaces. * Open file and close file by file object. @@ -68,7 +67,7 @@ describe('fileIO_fs_close', function () { }); /** - * @tc.number SUB_DF_FILEIO_CLOSESYNC_0200 + * @tc.number SUB_DF_FILEIO_CLOSE_SYNC_0200 * @tc.name fileIO_test_close_sync_002 * @tc.desc Test closeSync() interfaces. * Test fd has been closed. @@ -94,7 +93,7 @@ describe('fileIO_fs_close', function () { }); /** - * @tc.number SUB_DF_FILEIO_CLOSESYNC_0300 + * @tc.number SUB_DF_FILEIO_CLOSE_SYNC_0300 * @tc.name fileIO_test_close_sync_003 * @tc.desc Test closeSync() interfaces. * Test file has been closed. @@ -120,7 +119,7 @@ describe('fileIO_fs_close', function () { }); /** - * @tc.number SUB_DF_FILEIO_CLOSESYNC_0400 + * @tc.number SUB_DF_FILEIO_CLOSE_SYNC_0400 * @tc.name fileIO_test_close_sync_004 * @tc.desc Test closeSync() interfaces. * No parameters. @@ -141,7 +140,7 @@ describe('fileIO_fs_close', function () { }); /** - * @tc.number SUB_DF_FILEIO_CLOSESYNC_0500 + * @tc.number SUB_DF_FILEIO_CLOSE_SYNC_0500 * @tc.name fileIO_test_close_sync_005 * @tc.desc Test closeSync() interfaces. * Illegal type of parameter. @@ -301,7 +300,7 @@ describe('fileIO_fs_close', function () { /** * @tc.number SUB_DF_FILEIO_CLOSE_ASYNC_0500 * @tc.name fileIO_test_close_async_005 - * @tc.desc Test close() interfaces. Promise. + * @tc.desc Test close() interfaces. Promise. * Test file has been closed. * @tc.size MEDIUM * @tc.type Function @@ -315,12 +314,12 @@ describe('fileIO_fs_close', function () { try { let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); await fileIO.close(file); - fileIO.close(file); + await fileIO.close(file); expect(false).assertTrue(); } catch (e) { + fileIO.unlinkSync(fpath); console.log('fileIO_test_close_async_005 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); - fileIO.unlinkSync(fpath); done(); } }); @@ -335,7 +334,7 @@ describe('fileIO_fs_close', function () { * @tc.level Level 3 * @tc.require */ - it('fileIO_test_close_async_006', 0, async function (done) { + it('fileIO_test_close_async_006', 0, async function (done) { let fpath = await nextFileName('fileIO_test_close_async_006'); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); diff --git a/storage/storagefileiov9jstest/src/main/js/test/members/createStream.test.js b/storage/storagefileiov9jstest/src/main/js/test/members/createStream.test.js index 221c0e54fd28826086090f125834e6f0dd71e9d1..139e53376ff6c695d5b110a032d76d2c091e342d 100644 --- a/storage/storagefileiov9jstest/src/main/js/test/members/createStream.test.js +++ b/storage/storagefileiov9jstest/src/main/js/test/members/createStream.test.js @@ -33,15 +33,15 @@ describe('fileIO_fs_createStream', function () { it('fileIO_test_create_stream_sync_000', 0, async function () { let fpath = await nextFileName('fileIO_test_create_stream_sync_000'); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - let ss = fileIO.createStreamSync(fpath, 'r'); + let sr = fileIO.createStreamSync(fpath, 'r'); try { - expect(ss !== null).assertTrue(); - expect(ss.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); - ss.writeSync(FILE_CONTENT); + expect(sr !== null).assertTrue(); + expect(sr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); + sr.writeSync(FILE_CONTENT); expect(false).assertTrue(); } catch (e) { - ss.closeSync(); + sr.closeSync(); fileIO.unlinkSync(fpath); console.log('fileIO_test_create_stream_sync_000 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900005 && e.message == 'I/O error').assertTrue(); @@ -85,11 +85,11 @@ describe('fileIO_fs_createStream', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'r+'); - expect(ss !== null).assertTrue(); - expect(ss.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); - expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); - ss.closeSync(); + let sr = fileIO.createStreamSync(fpath, 'r+'); + expect(sr !== null).assertTrue(); + expect(sr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); + expect(sr.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); + sr.closeSync(); fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_create_stream_sync_002 has failed for ' + e.message + ', code: ' + e.code); @@ -263,11 +263,11 @@ describe('fileIO_fs_createStream', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'w+'); - expect(ss !== null).assertTrue(); - expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); - expect(ss.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); - ss.closeSync(); + let sw = fileIO.createStreamSync(fpath, 'w+'); + expect(sw !== null).assertTrue(); + expect(sw.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); + expect(sw.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); + sw.closeSync(); fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_create_stream_sync_009 has failed for ' + e.message + ', code: ' + e.code); @@ -289,11 +289,11 @@ describe('fileIO_fs_createStream', function () { let fpath = await nextFileName('fileIO_test_create_stream_sync_010'); try { - let ss = fileIO.createStreamSync(fpath, 'w+'); - expect(ss !== null).assertTrue(); - expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); - expect(ss.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); - ss.closeSync(); + let sw = fileIO.createStreamSync(fpath, 'w+'); + expect(sw !== null).assertTrue(); + expect(sw.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); + expect(sw.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); + sw.closeSync(); fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_create_stream_sync_010 has failed for ' + e.message + ', code: ' + e.code); @@ -316,10 +316,10 @@ describe('fileIO_fs_createStream', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'a'); - expect(ss !== null).assertTrue(); - expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); - ss.closeSync(); + let sa = fileIO.createStreamSync(fpath, 'a'); + expect(sa !== null).assertTrue(); + expect(sa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); + sa.closeSync(); let sr = fileIO.createStreamSync(fpath, 'r'); expect(sr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue(); @@ -345,10 +345,10 @@ describe('fileIO_fs_createStream', function () { let fpath = await nextFileName('fileIO_test_create_stream_sync_012'); try { - let ss = fileIO.createStreamSync(fpath, 'a'); - expect(ss !== null).assertTrue(); - expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); - ss.closeSync(); + let sa = fileIO.createStreamSync(fpath, 'a'); + expect(sa !== null).assertTrue(); + expect(sa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); + sa.closeSync(); fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_create_stream_sync_012 has failed for ' + e.message + ', code: ' + e.code); @@ -369,15 +369,15 @@ describe('fileIO_fs_createStream', function () { it('fileIO_test_create_stream_sync_013', 0, async function () { let fpath = await nextFileName('fileIO_test_create_stream_sync_013'); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - let ss = fileIO.createStreamSync(fpath, 'a'); + let sa = fileIO.createStreamSync(fpath, 'a'); try { - expect(ss !== null).assertTrue(); - expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); - ss.readSync(new ArrayBuffer(4096)); + expect(sa !== null).assertTrue(); + expect(sa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); + sa.readSync(new ArrayBuffer(4096)); expect(false).assertTrue(); } catch (e) { - ss.closeSync(); + sa.closeSync(); fileIO.unlinkSync(fpath); console.log('fileIO_test_create_stream_sync_013 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900005 && e.message == 'I/O error').assertTrue(); @@ -399,11 +399,11 @@ describe('fileIO_fs_createStream', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = fileIO.createStreamSync(fpath, 'a+'); - expect(ss !== null).assertTrue(); - expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); - expect(ss.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue(); - ss.closeSync(); + let sa = fileIO.createStreamSync(fpath, 'a+'); + expect(sa !== null).assertTrue(); + expect(sa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); + expect(sa.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue(); + sa.closeSync(); fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_create_stream_sync_014 has failed for ' + e.message + ', code: ' + e.code); @@ -425,11 +425,11 @@ describe('fileIO_fs_createStream', function () { let fpath = await nextFileName('fileIO_test_create_stream_sync_015'); try { - let ss = fileIO.createStreamSync(fpath, 'a+'); - expect(ss !== null).assertTrue(); - expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); - expect(ss.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); - ss.closeSync(); + let sa = fileIO.createStreamSync(fpath, 'a+'); + expect(sa !== null).assertTrue(); + expect(sa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); + expect(sa.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); + sa.closeSync(); fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_create_stream_sync_015 has failed for ' + e.message + ', code: ' + e.code); @@ -450,15 +450,15 @@ describe('fileIO_fs_createStream', function () { it('fileIO_test_create_stream_async_000', 0, async function (done) { let fpath = await nextFileName('fileIO_test_create_stream_async_000'); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - let ss = await fileIO.createStream(fpath, 'r'); + let sr = await fileIO.createStream(fpath, 'r'); try { - expect(ss !== null).assertTrue(); - expect(ss.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); - ss.writeSync(FILE_CONTENT); + expect(sr !== null).assertTrue(); + expect(sr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); + sr.writeSync(FILE_CONTENT); expect(false).assertTrue(); } catch (e) { - ss.closeSync(); + sr.closeSync(); fileIO.unlinkSync(fpath); console.log('fileIO_test_create_stream_async_000 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900005 && e.message == 'I/O error').assertTrue(); @@ -481,16 +481,16 @@ describe('fileIO_fs_createStream', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - fileIO.createStream(fpath, 'r', (err, ss) => { + fileIO.createStream(fpath, 'r', (err, sr) => { if (err) { console.log('fileIO_test_create_stream_async_001 error package: ' + JSON.stringify(err)); expect(false).assertTrue(); } - expect(ss !== null).assertTrue(); - expect(ss.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); - ss.write(FILE_CONTENT, (err) => { + expect(sr !== null).assertTrue(); + expect(sr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); + sr.write(FILE_CONTENT, (err) => { if (err) { - ss.closeSync(); + sr.closeSync(); fileIO.unlinkSync(fpath); console.log( 'fileIO_test_create_stream_async_001 error: {message: ' + err.message + ', code: ' + err.code + '}' @@ -573,11 +573,11 @@ describe('fileIO_fs_createStream', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = await fileIO.createStream(fpath, 'r+'); - expect(ss !== null).assertTrue(); - expect(ss.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); - expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); - ss.closeSync(); + let sr = await fileIO.createStream(fpath, 'r+'); + expect(sr !== null).assertTrue(); + expect(sr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); + expect(sr.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); + sr.closeSync(); fileIO.unlinkSync(fpath); done(); } catch (e) { @@ -601,15 +601,15 @@ describe('fileIO_fs_createStream', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - fileIO.createStream(fpath, 'r+', (err, ss) => { + fileIO.createStream(fpath, 'r+', (err, sr) => { if (err) { console.log('fileIO_test_create_stream_async_005 error package: ' + JSON.stringify(err)); expect(false).assertTrue(); } - expect(ss !== null).assertTrue(); - expect(ss.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); - expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); - ss.closeSync(); + expect(sr !== null).assertTrue(); + expect(sr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); + expect(sr.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); + sr.closeSync(); fileIO.unlinkSync(fpath); done(); }); @@ -829,11 +829,11 @@ describe('fileIO_fs_createStream', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - let ss = await fileIO.createStream(fpath, 'w+'); - expect(ss !== null).assertTrue(); - expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); - expect(ss.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); - ss.closeSync(); + let sw = await fileIO.createStream(fpath, 'w+'); + expect(sw !== null).assertTrue(); + expect(sw.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); + expect(sw.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); + sw.closeSync(); fileIO.unlinkSync(fpath); done(); } catch (e) { @@ -856,11 +856,11 @@ describe('fileIO_fs_createStream', function () { let fpath = await nextFileName('fileIO_test_create_stream_async_014'); try { - let ss = await fileIO.createStream(fpath, 'w+'); - expect(ss !== null).assertTrue(); - expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); - expect(ss.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); - ss.closeSync(); + let sw = await fileIO.createStream(fpath, 'w+'); + expect(sw !== null).assertTrue(); + expect(sw.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); + expect(sw.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); + sw.closeSync(); fileIO.unlinkSync(fpath); done(); } catch (e) { @@ -884,15 +884,15 @@ describe('fileIO_fs_createStream', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - fileIO.createStream(fpath, 'w+', (err, ss) => { + fileIO.createStream(fpath, 'w+', (err, sw) => { if (err) { console.log('fileIO_test_create_stream_async_015 error package: ' + JSON.stringify(err)); expect(false).assertTrue(); } - expect(ss !== null).assertTrue(); - expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); - expect(ss.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); - ss.closeSync(); + expect(sw !== null).assertTrue(); + expect(sw.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); + expect(sw.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); + sw.closeSync(); fileIO.unlinkSync(fpath); done(); }); diff --git a/storage/storagefileiov9jstest/src/main/js/test/members/fdatasync.test.js b/storage/storagefileiov9jstest/src/main/js/test/members/fdatasync.test.js index 09fd0be6993d072cf7f813761a83e40cafd95417..688e82a1220aa73873cbcf00d5a1f4b2a133c729 100644 --- a/storage/storagefileiov9jstest/src/main/js/test/members/fdatasync.test.js +++ b/storage/storagefileiov9jstest/src/main/js/test/members/fdatasync.test.js @@ -14,8 +14,7 @@ */ import { - fileio, fileIO, FILE_CONTENT, prepareFile, nextFileName, - describe, it, expect, + fileIO, FILE_CONTENT, prepareFile, nextFileName, describe, it, expect, } from '../Common'; export default function fileIOFdatasync() { @@ -38,8 +37,8 @@ export default function fileIOFdatasync() { try { let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); fileIO.fdatasyncSync(file.fd); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_fdatasync_sync_000 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -47,12 +46,12 @@ export default function fileIOFdatasync() { }); /** - * @tc.number SUB_DF_FILEIO_FDATASYNC_SYNC_0010 + * @tc.number SUB_DF_FILEIO_FDATASYNC_SYNC_0100 * @tc.name fileIO_test_fdatasync_sync_001 * @tc.desc Test fdatasyncSync() interfaces. Invalid fd parameter. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_fdatasync_sync_001', 0, async function () { @@ -67,12 +66,12 @@ export default function fileIOFdatasync() { }); /** - * @tc.number SUB_DF_FILEIO_FDATASYNC_SYNC_0020 + * @tc.number SUB_DF_FILEIO_FDATASYNC_SYNC_0200 * @tc.name fileIO_test_fdatasync_sync_002 * @tc.desc Test fdatasyncSync() interfaces. Missing parameter. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_fdatasync_sync_002', 0, async function () { @@ -107,8 +106,8 @@ export default function fileIOFdatasync() { console.log('fileIO_test_fdatasync_async_000 error package: ' + JSON.stringify(err)); expect(false).assertTrue(); } - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); }); } catch (e) { @@ -118,13 +117,13 @@ export default function fileIOFdatasync() { }); /** - * @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0010 + * @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0100 * @tc.name fileIO_test_fdatasync_async_001 * @tc.desc Test fdatasync() interfaces. Promise.then().catch(). * Open the file in read-write mode, and synchronize the file content data. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_fdatasync_async_001', 0, async function (done) { @@ -133,9 +132,9 @@ export default function fileIOFdatasync() { try { let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); - fileio.fdatasync(file.fd).then(() => { - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.fdatasync(file.fd).then(() => { + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); }).catch((err) => { console.log('fileIO_test_fdatasync_async_001 error package: ' + JSON.stringify(err)); @@ -148,13 +147,13 @@ export default function fileIOFdatasync() { }); /** - * @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0020 + * @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0200 * @tc.name fileIO_test_fdatasync_async_002 * @tc.desc Test fdatasync() interfaces. await Promise. * Open the file in read-write mode, and synchronize the file content data. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_fdatasync_async_002', 0, async function (done) { @@ -163,9 +162,9 @@ export default function fileIOFdatasync() { try { let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); - await fileio.fdatasync(file.fd); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + await fileIO.fdatasync(file.fd); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); } catch (e) { console.log('fileIO_test_fdatasync_async_002 has failed for ' + e.message + ', code: ' + e.code); @@ -174,13 +173,13 @@ export default function fileIOFdatasync() { }); /** - * @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0030 + * @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0300 * @tc.name fileIO_test_fdatasync_async_003 * @tc.desc Test fdatasync() interfaces. await Promise. * Invalid fd parameter. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_fdatasync_async_003', 0, async function (done) { @@ -196,13 +195,13 @@ export default function fileIOFdatasync() { }); /** - * @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0040 + * @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0400 * @tc.name fileIO_test_fdatasync_async_004 * @tc.desc Test fdatasync() interfaces. Callback. * Invalid fd parameter. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_fdatasync_async_004', 0, async function (done) { @@ -210,7 +209,7 @@ export default function fileIOFdatasync() { try { fileIO.fdatasync(-1, (err) => { if (err) { - console.log('fileIO_test_fdatasync_async_004 error package: {' + err.message + ', code: ' + err.code + '}'); + console.log('fileIO_test_fdatasync_async_004 error: {message: ' + err.message + ', code: ' + err.code + '}'); expect(err.code == 13900008 && err.message == 'Bad file descriptor').assertTrue(); done(); } @@ -222,13 +221,13 @@ export default function fileIOFdatasync() { }); /** - * @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0050 + * @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0500 * @tc.name fileIO_test_fdatasync_async_005 * @tc.desc Test fdatasync() interfaces. Promise.then().catch() * Invalid fd parameter. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_fdatasync_async_005', 0, async function (done) { @@ -237,7 +236,7 @@ export default function fileIOFdatasync() { fileIO.fdatasync(-1).then(() => { expect(false).assertTrue(); }).catch((err) => { - console.log('fileIO_test_fdatasync_async_005 error package: {' + err.message + ', code: ' + err.code + '}'); + console.log('fileIO_test_fdatasync_async_005 error: {message: ' + err.message + ', code: ' + err.code + '}'); expect(err.code == 13900008 && err.message == 'Bad file descriptor').assertTrue(); done(); }); @@ -248,13 +247,13 @@ export default function fileIOFdatasync() { }); /** - * @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0060 + * @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0600 * @tc.name fileIO_test_fdatasync_async_006 * @tc.desc Test fdatasync() interfaces. Promise. * Missing parameter. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_fdatasync_async_006', 0, async function (done) { @@ -270,19 +269,19 @@ export default function fileIOFdatasync() { }); /** - * @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0070 + * @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0700 * @tc.name fileIO_test_fdatasync_async_007 * @tc.desc Test fdatasync() interfaces. Callback. * Missing parameter. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_fdatasync_async_007', 0, async function (done) { try { - fileIO.fdatasync(() => { + fileIO.fdatasync((err) => { expect(false).assertTrue(); }); } catch (e) { diff --git a/storage/storagefileiov9jstest/src/main/js/test/members/fdopenStream.test.js b/storage/storagefileiov9jstest/src/main/js/test/members/fdopenStream.test.js index 17d315fc1e6830bc4b5ac74c3fc668ccd85ee17e..0afc661e0bca31635d58c72cf3d8f0e6c2838b46 100644 --- a/storage/storagefileiov9jstest/src/main/js/test/members/fdopenStream.test.js +++ b/storage/storagefileiov9jstest/src/main/js/test/members/fdopenStream.test.js @@ -35,15 +35,15 @@ describe('fileIO_fs_FdOpenStream', async function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); expect(isIntNum(file.fd)).assertTrue(); - let fp = fileIO.fdopenStreamSync(file.fd, 'r'); + let fpr = fileIO.fdopenStreamSync(file.fd, 'r'); try { - expect(fp !== null).assertTrue(); - expect(fp.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); - fp.writeSync(FILE_CONTENT); + expect(fpr !== null).assertTrue(); + expect(fpr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); + fpr.writeSync(FILE_CONTENT); expect(false).assertTrue(); } catch (e) { - fp.closeSync(); + fpr.closeSync(); fileIO.unlinkSync(fpath); console.log('fileIO_test_fdopenstream_sync_000 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900005 && e.message == 'I/O error').assertTrue(); @@ -88,11 +88,11 @@ describe('fileIO_fs_FdOpenStream', async function () { try { expect(isIntNum(file.fd)).assertTrue(); - let fp = fileIO.fdopenStreamSync(file.fd, 'r+'); - expect(fp !== null).assertTrue(); - expect(fp.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); - expect(fp.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); - fp.closeSync(); + let fpr = fileIO.fdopenStreamSync(file.fd, 'r+'); + expect(fpr !== null).assertTrue(); + expect(fpr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); + expect(fpr.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); + fpr.closeSync(); fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_fdopenstream_sync_002 has failed for ' + e.message + ', code: ' + e.code); @@ -224,9 +224,9 @@ describe('fileIO_fs_FdOpenStream', async function () { fpw.closeSync(); let file2 = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY); - let sr = fileIO.fdopenStreamSync(file2.fd, 'r'); - expect(sr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); - sr.closeSync(); + let fpr = fileIO.fdopenStreamSync(file2.fd, 'r'); + expect(fpr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); + fpr.closeSync(); fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_fdopenstream_sync_007 has failed for ' + e.message + ', code: ' + e.code); @@ -280,15 +280,15 @@ describe('fileIO_fs_FdOpenStream', async function () { try { let file1 = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); expect(isIntNum(file1.fd)).assertTrue(); - let fpw = fileIO.fdopenStreamSync(file1.fd, 'a'); - expect(fpw !== null).assertTrue(); - expect(fpw.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); - fpw.closeSync(); + let fpa = fileIO.fdopenStreamSync(file1.fd, 'a'); + expect(fpa !== null).assertTrue(); + expect(fpa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); + fpa.closeSync(); let file2 = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); - let sr = fileIO.fdopenStreamSync(file2.fd, 'r'); - expect(sr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue(); - sr.closeSync(); + let fpr = fileIO.fdopenStreamSync(file2.fd, 'r'); + expect(fpr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue(); + fpr.closeSync(); fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_fdopenstream_sync_009 has failed for ' + e.message + ', code: ' + e.code); @@ -311,15 +311,15 @@ describe('fileIO_fs_FdOpenStream', async function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); expect(isIntNum(file.fd)).assertTrue(); - let sa = fileIO.fdopenStreamSync(file.fd, 'a'); + let fpa = fileIO.fdopenStreamSync(file.fd, 'a'); try { - expect(sa !== null).assertTrue(); - expect(sa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); - sa.readSync(new ArrayBuffer(4096)); + expect(fpa !== null).assertTrue(); + expect(fpa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); + fpa.readSync(new ArrayBuffer(4096)); expect(false).assertTrue(); } catch (e) { - sa.closeSync(); + fpa.closeSync(); fileIO.unlinkSync(fpath); console.log('fileIO_test_fdopenstream_sync_010 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900005 && e.message == 'I/O error').assertTrue(); @@ -343,11 +343,11 @@ describe('fileIO_fs_FdOpenStream', async function () { try { expect(isIntNum(file.fd)).assertTrue(); - let sa = fileIO.fdopenStreamSync(file.fd, 'a+'); - expect(sa !== null).assertTrue(); - expect(sa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); - expect(sa.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue(); - sa.closeSync(); + let fpa = fileIO.fdopenStreamSync(file.fd, 'a+'); + expect(fpa !== null).assertTrue(); + expect(fpa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); + expect(fpa.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue(); + fpa.closeSync(); fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_fdopenstream_sync_011 has failed for ' + e.message + ', code: ' + e.code); @@ -369,16 +369,16 @@ describe('fileIO_fs_FdOpenStream', async function () { let fpath = await nextFileName('fileIO_test_fdopenstream_async_000'); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); - let fp = await fileIO.fdopenStream(file.fd, 'r'); + let fpr = await fileIO.fdopenStream(file.fd, 'r'); try { expect(isIntNum(file.fd)).assertTrue(); - expect(fp !== null).assertTrue(); - expect(fp.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); - fp.writeSync(FILE_CONTENT); + expect(fpr !== null).assertTrue(); + expect(fpr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); + fpr.writeSync(FILE_CONTENT); expect(false).assertTrue(); } catch (e) { - fp.closeSync(); + fpr.closeSync(); fileIO.unlinkSync(fpath); console.log('fileIO_test_fdopenstream_async_000 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900005 && e.message == 'I/O error').assertTrue(); @@ -403,16 +403,16 @@ describe('fileIO_fs_FdOpenStream', async function () { try { expect(isIntNum(file.fd)).assertTrue(); - fileIO.fdopenStream(file.fd, 'r', (err, fp) => { + fileIO.fdopenStream(file.fd, 'r', (err, fpr) => { if (err) { console.log('fileIO_test_fdopenstream_async_001 error package: ' + JSON.stringify(err)); expect(false).assertTrue(); } - expect(fp !== null).assertTrue(); - expect(fp.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); - fp.write(FILE_CONTENT, (err) => { + expect(fpr !== null).assertTrue(); + expect(fpr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); + fpr.write(FILE_CONTENT, (err) => { if (err) { - fp.closeSync(); + fpr.closeSync(); fileIO.unlinkSync(fpath); console.log( 'fileIO_test_fdopenstream_async_001 error: {message: ' + err.message + ', code: ' + err.code + '}' @@ -492,11 +492,11 @@ describe('fileIO_fs_FdOpenStream', async function () { try { expect(isIntNum(file.fd)).assertTrue(); - let fp = await fileIO.fdopenStream(file.fd, 'r+'); - expect(fp !== null).assertTrue(); - expect(fp.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); - expect(fp.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); - fp.closeSync(); + let fpr = await fileIO.fdopenStream(file.fd, 'r+'); + expect(fpr !== null).assertTrue(); + expect(fpr.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); + expect(fpr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); + fpr.closeSync(); fileIO.unlinkSync(fpath); done(); } catch (e) { @@ -522,15 +522,15 @@ describe('fileIO_fs_FdOpenStream', async function () { try { expect(isIntNum(file.fd)).assertTrue(); - fileIO.fdopenStream(file.fd, 'r+', (err, fp) => { + fileIO.fdopenStream(file.fd, 'r+', (err, fpr) => { if (err) { console.log('fileIO_test_fdopenstream_async_005 error package: ' + JSON.stringify(err)); expect(false).assertTrue(); } - expect(fp !== null).assertTrue(); - expect(fp.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); - expect(fp.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); - fp.closeSync(); + expect(fpr !== null).assertTrue(); + expect(fpr.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); + expect(fpr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); + fpr.closeSync(); fileIO.unlinkSync(fpath); done(); }); @@ -689,9 +689,9 @@ describe('fileIO_fs_FdOpenStream', async function () { fpw.closeSync(); let file2 = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); - let sr = await fileIO.fdopenStream(file2.fd, 'r'); - expect(sr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); - sr.closeSync(); + let fpr = await fileIO.fdopenStream(file2.fd, 'r'); + expect(fpr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); + fpr.closeSync(); fileIO.unlinkSync(fpath); done(); } catch (e) { @@ -781,15 +781,15 @@ describe('fileIO_fs_FdOpenStream', async function () { try { let file1 = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); - let fpw = await fileIO.fdopenStream(file1.fd, 'a'); - expect(fpw !== null).assertTrue(); - expect(fpw.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); - fpw.closeSync(); + let fpa = await fileIO.fdopenStream(file1.fd, 'a'); + expect(fpa !== null).assertTrue(); + expect(fpa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); + fpa.closeSync(); let file2 = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); - let sr = await fileIO.fdopenStream(file2.fd, 'r'); - expect(sr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue(); - sr.closeSync(); + let fpr = await fileIO.fdopenStream(file2.fd, 'r'); + expect(fpr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue(); + fpr.closeSync(); fileIO.unlinkSync(fpath); done(); } catch (e) { @@ -813,15 +813,15 @@ describe('fileIO_fs_FdOpenStream', async function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); expect(isIntNum(file.fd)).assertTrue(); - let sa = await fileIO.fdopenStream(file.fd, 'a'); + let fpa = await fileIO.fdopenStream(file.fd, 'a'); try { - expect(sa !== null).assertTrue(); - expect(sa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); - sa.readSync(new ArrayBuffer(4096)); + expect(fpa !== null).assertTrue(); + expect(fpa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); + fpa.readSync(new ArrayBuffer(4096)); expect(false).assertTrue(); } catch (e) { - sa.closeSync(); + fpa.closeSync(); fileIO.unlinkSync(fpath); console.log('fileIO_test_fdopenstream_async_014 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900005 && e.message == 'I/O error').assertTrue(); @@ -846,16 +846,16 @@ describe('fileIO_fs_FdOpenStream', async function () { expect(isIntNum(file.fd)).assertTrue(); try { - fileIO.fdopenStream(file.fd, 'a', (err, sa) => { + fileIO.fdopenStream(file.fd, 'a', (err, fpa) => { if (err) { console.log('fileIO_test_fdopenstream_async_015 error package: ' + JSON.stringify(err)); expect(false).assertTrue(); } - expect(sa !== null).assertTrue(); - expect(sa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); - sa.read(new ArrayBuffer(4096), (err) => { + expect(fpa !== null).assertTrue(); + expect(fpa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); + fpa.read(new ArrayBuffer(4096), (err) => { if (err) { - sa.closeSync(); + fpa.closeSync(); fileIO.unlinkSync(fpath); console.log( 'fileIO_test_fdopenstream_async_015 error: {message: ' + err.message + ', code: ' + err.code + '}' @@ -890,11 +890,11 @@ describe('fileIO_fs_FdOpenStream', async function () { try { expect(isIntNum(file.fd)).assertTrue(); - let sa = await fileIO.fdopenStream(file.fd, 'a+'); - expect(sa !== null).assertTrue(); - expect(sa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); - expect(sa.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue(); - sa.closeSync(); + let fpa = await fileIO.fdopenStream(file.fd, 'a+'); + expect(fpa !== null).assertTrue(); + expect(fpa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); + expect(fpa.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue(); + fpa.closeSync(); fileIO.unlinkSync(fpath); done(); } catch (e) { @@ -920,15 +920,15 @@ describe('fileIO_fs_FdOpenStream', async function () { try { expect(isIntNum(file.fd)).assertTrue(); - fileIO.fdopenStream(file.fd, 'a+', (err, sa) => { + fileIO.fdopenStream(file.fd, 'a+', (err, fpa) => { if (err) { console.log('fileIO_test_fdopenstream_async_017 error package: ' + JSON.stringify(err)); expect(false).assertTrue(); } - expect(sa !== null).assertTrue(); - expect(sa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); - expect(sa.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue(); - sa.closeSync(); + expect(fpa !== null).assertTrue(); + expect(fpa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); + expect(fpa.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue(); + fpa.closeSync(); fileIO.unlinkSync(fpath); done(); }); diff --git a/storage/storagefileiov9jstest/src/main/js/test/members/fileLock.test.js b/storage/storagefileiov9jstest/src/main/js/test/members/fileLock.test.js index c8668bc736767a5f0e81e9bce72a0e9eaed3b62e..d4126247fe49c63698fbed72e63d95931c22ff0a 100644 --- a/storage/storagefileiov9jstest/src/main/js/test/members/fileLock.test.js +++ b/storage/storagefileiov9jstest/src/main/js/test/members/fileLock.test.js @@ -14,633 +14,632 @@ */ import { - fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum, - describe, it, expect, + fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum, describe, it, expect, } from '../Common'; export default function fileIOFileLock() { - describe('fileIO_fs_file_lock', function () { - - /** - * @tc.number FILE_TEST_FILELOCK_PROMISE_0000 - * @tc.name fileIO_test_filelock_promise_000 - * @tc.desc Test lock() interfaces. argument is : default. - * Open the file, file lock() and unlock() - * @tc.size MEDIUM - * @tc.type Functoin - * @tc.level Level 0 - * @tc.require - */ - it('fileIO_test_filelock_promise_000', 0, async function (done) { - let fpath = await nextFileName('fileIO_test_filelock_promise_000'); - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - - try { - let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); - expect(isIntNum(file.fd)).assertTrue(); - await file.lock(); - file.unlock(); - expect(true).assertTrue(); - fileIO.closeSync(file.fd); - fileIO.unlinkSync(fpath); - done(); - } catch (e) { - console.log('fileIO_test_filelock_promise_000 has failed for ' + e.message + ', code: ' + e.code); - expect(false).assertTrue(); - } - }); - - /** - * @tc.number FILE_TEST_FILELOCK_PROMISE_0100 - * @tc.name fileIO_test_filelock_promise_001 - * @tc.desc Test lock() interfaces. argument is : true. - * Open the file, file lock(true) and unlock() - * @tc.size MEDIUM - * @tc.type Functoin - * @tc.level Level 0 - * @tc.require - */ - it('fileIO_test_filelock_promise_001', 0, async function (done) { - let fpath = await nextFileName('fileIO_test_filelock_promise_001'); - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - - try { - let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); - expect(isIntNum(file.fd)).assertTrue(); - await file.lock(true); - file.unlock(); - expect(true).assertTrue(); - fileIO.closeSync(file.fd); - fileIO.unlinkSync(fpath); - done(); - } catch (e) { - console.log('fileIO_test_filelock_promise_001 has failed for ' + e.message + ', code: ' + e.code); - expect(false).assertTrue(); - } - }); - - /** - * @tc.number FILE_TEST_FILELOCK_PROMISE_0200 - * @tc.name fileIO_test_filelock_promise_002 - * @tc.desc Test lock() interfaces. argument is : false. - * Open the file, file lock(false) and unlock() - * @tc.size MEDIUM - * @tc.type Functoin - * @tc.level Level 0 - * @tc.require - */ - it('fileIO_test_filelock_promise_002', 0, async function (done) { - let fpath = await nextFileName('fileIO_test_filelock_promise_002'); - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - - try { - let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); - expect(isIntNum(file.fd)).assertTrue(); - await file.lock(false); - file.unlock(); - expect(true).assertTrue(); - fileIO.closeSync(file.fd); - fileIO.unlinkSync(fpath); - done(); - } catch (e) { - console.log('fileIO_test_filelock_promise_002 has failed for ' + e.message + ', code: ' + e.code); - expect(false).assertTrue(); - } - }); - - /** - * @tc.number FILE_TEST_FILELOCK_PROMISE_0300 - * @tc.name fileIO_test_filelock_promise_003 - * @tc.desc Test tryLock() interfaces. argument is : default. - * Open the file, file lock() ,tryLock() and unlock() - * @tc.size MEDIUM - * @tc.type Functoin - * @tc.level Level 0 - * @tc.require - */ - it('fileIO_test_filelock_promise_003', 0, async function (done) { - let fpath = await nextFileName('fileIO_test_filelock_promise_003'); - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - - try { - let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); - expect(isIntNum(file.fd)).assertTrue(); - await file.lock(); - file.tryLock(); - file.unlock(); - expect(true).assertTrue(); - fileIO.closeSync(file.fd); - fileIO.unlinkSync(fpath); - done(); - } catch (e) { - console.log('fileIO_test_filelock_promise_003 has failed for ' + e.message + ', code: ' + e.code); - expect(false).assertTrue(); - } - }); - - /** - * @tc.number FILE_TEST_FILELOCK_PROMISE_0400 - * @tc.name fileIO_test_filelock_promise_004 - * @tc.desc Test tryLock() interfaces. argument is : true. - * Open the file, file lock() ,tryLock(true) and unlock() - * @tc.size MEDIUM - * @tc.type Functoin - * @tc.level Level 0 - * @tc.require - */ - it('fileIO_test_filelock_promise_004', 0, async function (done) { - let fpath = await nextFileName('fileIO_test_filelock_promise_004'); - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - - try { - let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); - expect(isIntNum(file.fd)).assertTrue(); - await file.lock(); - file.tryLock(true); - file.unlock(); - expect(true).assertTrue(); - fileIO.closeSync(file.fd); - fileIO.unlinkSync(fpath); - done(); - } catch (e) { - console.log('fileIO_test_filelock_promise_004 has failed for ' + e.message + ', code: ' + e.code); - expect(false).assertTrue(); - } - }); - - /** - * @tc.number FILE_TEST_FILELOCK_PROMISE_0500 - * @tc.name fileIO_test_filelock_promise_005 - * @tc.desc Test tryLock() interfaces. argument is : false. - * Open the file, file lock() ,tryLock(false) and unlock() - * @tc.size MEDIUM - * @tc.type Functoin - * @tc.level Level 0 - * @tc.require - */ - it('fileIO_test_filelock_promise_005', 0, async function (done) { - let fpath = await nextFileName('fileIO_test_filelock_promise_005'); - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - - try { - let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); - expect(isIntNum(file.fd)).assertTrue(); - await file.lock(); - file.tryLock(false); - file.unlock(); - expect(true).assertTrue(); - fileIO.closeSync(file.fd); - fileIO.unlinkSync(fpath); - done(); - } catch (e) { - console.log('fileIO_test_filelock_promise_005 has failed for ' + e.message + ', code: ' + e.code); - expect(false).assertTrue(); - } - }); - - /** - * @tc.number FILE_TEST_FILELOCK_PROMISE_0600 - * @tc.name fileIO_test_filelock_promise_006 - * @tc.desc Open the file, no file lock(), tryLock(), unlock(), - * @tc.size MEDIUM - * @tc.type Functoin - * @tc.level Level 0 - * @tc.require - */ - it('fileIO_test_filelock_promise_006', 0, async function (done) { - let fpath = await nextFileName('fileIO_test_filelock_promise_006'); - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - - try { - let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); - expect(isIntNum(file.fd)).assertTrue(); - file.tryLock(); - file.unlock(); - expect(true).assertTrue(); - fileIO.closeSync(file.fd); - fileIO.unlinkSync(fpath); - done(); - } catch (e) { - console.log('fileIO_test_filelock_promise_006 has failed for ' + e.message + ', code: ' + e.code); - expect(false).assertTrue(); - } - }); - - /** - * @tc.number FILE_TEST_FILELOCK_PROMISE_0700 - * @tc.name fileIO_test_filelock_promise_007 - * @tc.desc Open the file, no file lock(), no tryLock(), unlock(), - * @tc.size MEDIUM - * @tc.type Functoin - * @tc.level Level 0 - * @tc.require - */ - it('fileIO_test_filelock_promise_007', 0, async function (done) { - let fpath = await nextFileName('fileIO_test_filelock_promise_007'); - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - - try { - let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); - expect(isIntNum(file.fd)).assertTrue(); - file.unlock(); - expect(true).assertTrue(); - fileIO.closeSync(file.fd); - fileIO.unlinkSync(fpath); - done(); - } catch (e) { - console.log('fileIO_test_filelock_promise_007 has failed for ' + e.message + ', code: ' + e.code); - expect(false).assertTrue(); - } - }); - - /** - * @tc.number FILE_TEST_FILELOCK_PROMISE_ABNORMAL_0000 - * @tc.name fileIO_test_filelock_promise_abnormal_000 - * @tc.desc Test lock() interfaces. argument is : null. - * Open the file, file lock(null). - * @tc.size MEDIUM - * @tc.type Functoin - * @tc.level Level 0 - * @tc.require - */ - it('fileIO_test_filelock_promise_abnormal_000', 0, async function (done) { - let fpath = await nextFileName('fileIO_test_filelock_promise_abnormal_000'); - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - let file; - try { - file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); - expect(isIntNum(file.fd)).assertTrue(); - await file.lock(null); - expect(false).assertTrue(); - } catch (e) { - fileIO.closeSync(file.fd); - fileIO.unlinkSync(fpath); - console.log('fileIO_test_filelock_promise_abnormal_000 has failed for ' + e.message + ', code: ' + e.code); - expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); - done(); - } - }); - - /** - * @tc.number FILE_TEST_FILELOCK_PROMISE_ABNORMAL_0100 - * @tc.name fileIO_test_filelock_promise_abnormal_001 - * @tc.desc Test lock() interfaces. argument is : true, true. - * Open the file, file lock(true, true). - * @tc.size MEDIUM - * @tc.type Functoin - * @tc.level Level 0 - * @tc.require - */ - it('fileIO_test_filelock_promise_abnormal_001', 0, async function (done) { - let fpath = await nextFileName('fileIO_test_filelock_promise_abnormal_001'); - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - let file; - try { - file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); - expect(isIntNum(file.fd)).assertTrue(); - await file.lock(true, true); - expect(false).assertTrue(); - } catch (e) { - fileIO.closeSync(file.fd); - fileIO.unlinkSync(fpath); - console.log('fileIO_test_filelock_promise_abnormal_001 has failed for ' + e.message + ', code: ' + e.code); - expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); - done(); - } - }); - - /** - * @tc.number FILE_TEST_FILELOCK_PROMISE_ABNORMAL_0200 - * @tc.name fileIO_test_filelock_promise_abnormal_002 - * @tc.desc Test lock() interfaces. argument is : -1. - * Open the file, file lock(-1). - * @tc.size MEDIUM - * @tc.type Functoin - * @tc.level Level 0 - * @tc.require - */ - it('fileIO_test_filelock_promise_abnormal_002', 0, async function (done) { - let fpath = await nextFileName('fileIO_test_filelock_promise_abnormal_002'); - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - let file; - try { - file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); - expect(isIntNum(file.fd)).assertTrue(); - await file.lock(-1); - expect(false).assertTrue(); - } catch (e) { - fileIO.closeSync(file.fd); - fileIO.unlinkSync(fpath); - console.log('fileIO_test_filelock_promise_abnormal_002 has failed for ' + e.message + ', code: ' + e.code); - expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); - done(); - } - }); - - /** - * @tc.number FILE_TEST_FILELOCK_PROMISE_ABNORMAL_0300 - * @tc.name fileIO_test_filelock_promise_abnormal_003 - * @tc.desc Test tryLock() interfaces. argument is : null. - * Open the file, file lock(), tryLock(null). - * @tc.size MEDIUM - * @tc.type Functoin - * @tc.level Level 0 - * @tc.require - */ - it('fileIO_test_filelock_promise_abnormal_003', 0, async function (done) { - let fpath = await nextFileName('fileIO_test_filelock_promise_abnormal_003'); - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - let file; - try { - file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); - expect(isIntNum(file.fd)).assertTrue(); - await file.lock(); - file.tryLock(null); - expect(false).assertTrue(); - } catch (e) { - fileIO.closeSync(file.fd); - fileIO.unlinkSync(fpath); - console.log('fileIO_test_filelock_promise_abnormal_003 has failed for ' + e.message + ', code: ' + e.code); - expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); - done(); - } - }); - - /** - * @tc.number FILE_TEST_FILELOCK_PROMISE_ABNORMAL_0400 - * @tc.name fileIO_test_filelock_promise_abnormal_004 - * @tc.desc Test tryLock() interfaces. argument is : true, true. - * Open the file, file lock(), tryLock(true, true). - * @tc.size MEDIUM - * @tc.type Functoin - * @tc.level Level 0 - * @tc.require - */ - it('fileIO_test_filelock_promise_abnormal_004', 0, async function (done) { - let fpath = await nextFileName('fileIO_test_filelock_promise_abnormal_004'); - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - let file; - try { - file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); - expect(isIntNum(file.fd)).assertTrue(); - await file.lock(); - file.tryLock(true, true); - expect(false).assertTrue(); - } catch (e) { - fileIO.closeSync(file.fd); - fileIO.unlinkSync(fpath); - console.log('fileIO_test_filelock_promise_abnormal_004 has failed for ' + e.message + ', code: ' + e.code); - expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); - done(); - } - }); - - /** - * @tc.number FILE_TEST_FILELOCK_PROMISE_ABNORMAL_0500 - * @tc.name fileIO_test_filelock_promise_abnormal_005 - * @tc.desc Test tryLock() interfaces. argument is : -1. - * Open the file, file lock(), tryLock(-1). - * @tc.size MEDIUM - * @tc.type Functoin - * @tc.level Level 0 - * @tc.require - */ - it('fileIO_test_filelock_promise_abnormal_005', 0, async function (done) { - let fpath = await nextFileName('fileIO_test_filelock_promise_abnormal_005'); - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - let file; - try { - file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); - expect(isIntNum(file.fd)).assertTrue(); - await file.lock(); - file.tryLock(-1); - expect(false).assertTrue(); - } catch (e) { - fileIO.closeSync(file.fd); - fileIO.unlinkSync(fpath); - console.log('fileIO_test_filelock_promise_abnormal_005 has failed for ' + e.message + ', code: ' + e.code); - expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); - done(); - } - }); - - /** - * @tc.number FILE_TEST_FILELOCK_PROMISE_ABNORMAL_0600 - * @tc.name fileIO_test_filelock_promise_abnormal_006 - * @tc.desc Test unlock() interfaces. argument is : true. - * Open the file, file lock(), tryLock(), unlock(true), - * @tc.size MEDIUM - * @tc.type Functoin - * @tc.level Level 0 - * @tc.require - */ - it('fileIO_test_filelock_promise_abnormal_006', 0, async function (done) { - let fpath = await nextFileName('fileIO_test_filelock_promise_abnormal_006'); - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - let file; - try { - file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); - expect(isIntNum(file.fd)).assertTrue(); - await file.lock(); - file.tryLock(); - file.unlock(true); - expect(false).assertTrue(); - } catch (e) { - fileIO.closeSync(file.fd); - fileIO.unlinkSync(fpath); - console.log('fileIO_test_filelock_promise_abnormal_006 has failed for ' + e.message + ', code: ' + e.code); - expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); - done(); - } - }); - - /** - * @tc.number FILE_TEST_FILELOCK_CALLBACK_0000 - * @tc.name fileIO_test_filelock_callback_000 - * @tc.desc Test lock() interfaces. argument is : default. - * Open the file, file lock() and unlock() - * @tc.size MEDIUM - * @tc.type Functoin - * @tc.level Level 0 - * @tc.require - */ - it('fileIO_test_filelock_callback_000', 0, async function (done) { - let fpath = await nextFileName('fileIO_test_filelock_callback_000'); - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - - try { - let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); - expect(isIntNum(file.fd)).assertTrue(); - file.lock((err) => { - if (err) { - console.log('fileIO_test_filelock_callback_000 err ' + JSON.stringify(err)); - expect(false).assertTrue(); - } - file.unlock(); - expect(true).assertTrue(); - fileIO.closeSync(file.fd); - fileIO.unlinkSync(fpath); - done(); - }); - } catch (e) { - console.log('fileIO_test_filelock_callback_000 has failed for ' + e.message + ', code: ' + e.code); - expect(false).assertTrue(); - } - }); - - /** - * @tc.number FILE_TEST_FILELOCK_CALLBACK_0100 - * @tc.name fileIO_test_filelock_callback_001 - * @tc.desc Test lock() interfaces. argument is : true. - * Open the file, file lock(true) and unlock() - * @tc.size MEDIUM - * @tc.type Functoin - * @tc.level Level 0 - * @tc.require - */ - it('fileIO_test_filelock_callback_001', 0, async function (done) { - let fpath = await nextFileName('fileIO_test_filelock_callback_001'); - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - - try { - let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); - expect(isIntNum(file.fd)).assertTrue(); - file.lock(true, (err) => { - if (err) { - console.log('fileIO_test_filelock_callback_001 err ' + JSON.stringify(err)); - expect(false).assertTrue(); - } - file.unlock(); - expect(true).assertTrue(); - fileIO.closeSync(file.fd); - fileIO.unlinkSync(fpath); - done(); - }); - } catch (e) { - console.log('fileIO_test_filelock_callback_001 has failed for ' + e.message + ', code: ' + e.code); - expect(false).assertTrue(); - } - }); - - /** - * @tc.number FILE_TEST_FILELOCK_CALLBACK_0200 - * @tc.name fileIO_test_filelock_callback_002 - * @tc.desc Test lock() interfaces. argument is : false. - * Open the file, file lock(false) and unlock() - * @tc.size MEDIUM - * @tc.type Functoin - * @tc.level Level 0 - * @tc.require - */ - it('fileIO_test_filelock_callback_002', 0, async function (done) { - let fpath = await nextFileName('fileIO_test_filelock_callback_002'); - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - - try { - let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); - expect(isIntNum(file.fd)).assertTrue(); - file.lock(false, (err) => { - if (err) { - console.log('fileIO_test_filelock_callback_002 err ' + JSON.stringify(err)); - expect(false).assertTrue(); - } - file.unlock(); - expect(true).assertTrue(); - fileIO.closeSync(file.fd); - fileIO.unlinkSync(fpath); - done(); - }); - } catch (e) { - console.log('fileIO_test_filelock_callback_002 has failed for ' + e.message + ', code: ' + e.code); - expect(false).assertTrue(); - } - }); - - /** - * @tc.number FILE_TEST_FILELOCK_CALLBACK_ABNORMAL_0000 - * @tc.name fileIO_test_filelock_callback_abnormal_000 - * @tc.desc Test lock() interfaces. argument is : null. - * Open the file, file lock(null). - * @tc.size MEDIUM - * @tc.type Functoin - * @tc.level Level 0 - * @tc.require - */ - it('fileIO_test_filelock_callback_abnormal_000', 0, async function (done) { - let fpath = await nextFileName('fileIO_test_filelock_callback_abnormal_000'); - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - let file; - try { - file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); - expect(isIntNum(file.fd)).assertTrue(); - file.lock(null, (err) => { - expect(false).assertTrue(); - }); - } catch (e) { - fileIO.closeSync(file.fd); - fileIO.unlinkSync(fpath); - console.log('fileIO_test_filelock_callback_abnormal_000 has failed for ' + e.message + ', code: ' + e.code); - expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); - done(); - } - }); - - /** - * @tc.number FILE_TEST_FILELOCK_CALLBACK_ABNORMAL_0100 - * @tc.name fileIO_test_filelock_callback_abnormal_001 - * @tc.desc Test lock() interfaces. argument is : true, true. - * Open the file, file lock(true, true). - * @tc.size MEDIUM - * @tc.type Functoin - * @tc.level Level 0 - * @tc.require - */ - it('fileIO_test_filelock_callback_abnormal_001', 0, async function (done) { - let fpath = await nextFileName('fileIO_test_filelock_callback_abnormal_001'); - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - let file; - try { - file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); - expect(isIntNum(file.fd)).assertTrue(); - file.lock(true, true, (err) => { - expect(false).assertTrue(); - }); - } catch (e) { - fileIO.closeSync(file.fd); - fileIO.unlinkSync(fpath); - console.log('fileIO_test_filelock_callback_abnormal_001 has failed for ' + e.message + ', code: ' + e.code); - expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); - done(); - } - }); - - /** - * @tc.number FILE_TEST_FILELOCK_CALLBACK_ABNORMAL_0200 - * @tc.name fileIO_test_filelock_callback_abnormal_002 - * @tc.desc Test lock() interfaces. argument is : -1. - * Open the file, file lock(-1). - * @tc.size MEDIUM - * @tc.type Functoin - * @tc.level Level 0 - * @tc.require - */ - it('fileIO_test_filelock_callback_abnormal_002', 0, async function (done) { - let fpath = await nextFileName('fileIO_test_filelock_callback_abnormal_002'); - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - let file; - try { - file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); - expect(isIntNum(file.fd)).assertTrue(); - file.lock(-1, (err) => { - expect(false).assertTrue(); - }); - } catch (e) { - fileIO.closeSync(file.fd); - fileIO.unlinkSync(fpath); - console.log('fileIO_test_filelock_callback_abnormal_002 has failed for ' + e.message + ', code: ' + e.code); - expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); - done(); - } - }); - }); + describe('fileIO_fs_file_lock', function () { + + /** + * @tc.number FILE_TEST_FILELOCK_PROMISE_0000 + * @tc.name fileIO_test_filelock_promise_000 + * @tc.desc Test lock() interfaces. argument is : default. + * Open the file, file lock() and unlock() + * @tc.size MEDIUM + * @tc.type Functoin + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_test_filelock_promise_000', 0, async function (done) { + let fpath = await nextFileName('fileIO_test_filelock_promise_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); + expect(isIntNum(file.fd)).assertTrue(); + await file.lock(); + file.unlock(); + expect(true).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + done(); + } catch (e) { + console.log('fileIO_test_filelock_promise_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number FILE_TEST_FILELOCK_PROMISE_0100 + * @tc.name fileIO_test_filelock_promise_001 + * @tc.desc Test lock() interfaces. argument is : true. + * Open the file, file lock(true) and unlock() + * @tc.size MEDIUM + * @tc.type Functoin + * @tc.level Level 3 + * @tc.require + */ + it('fileIO_test_filelock_promise_001', 0, async function (done) { + let fpath = await nextFileName('fileIO_test_filelock_promise_001'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); + expect(isIntNum(file.fd)).assertTrue(); + await file.lock(true); + file.unlock(); + expect(true).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + done(); + } catch (e) { + console.log('fileIO_test_filelock_promise_001 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number FILE_TEST_FILELOCK_PROMISE_0200 + * @tc.name fileIO_test_filelock_promise_002 + * @tc.desc Test lock() interfaces. argument is : false. + * Open the file, file lock(false) and unlock() + * @tc.size MEDIUM + * @tc.type Functoin + * @tc.level Level 3 + * @tc.require + */ + it('fileIO_test_filelock_promise_002', 0, async function (done) { + let fpath = await nextFileName('fileIO_test_filelock_promise_002'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); + expect(isIntNum(file.fd)).assertTrue(); + await file.lock(false); + file.unlock(); + expect(true).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + done(); + } catch (e) { + console.log('fileIO_test_filelock_promise_002 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number FILE_TEST_FILELOCK_PROMISE_0300 + * @tc.name fileIO_test_filelock_promise_003 + * @tc.desc Test tryLock() interfaces. argument is : default. + * Open the file, file lock() ,tryLock() and unlock() + * @tc.size MEDIUM + * @tc.type Functoin + * @tc.level Level 3 + * @tc.require + */ + it('fileIO_test_filelock_promise_003', 0, async function (done) { + let fpath = await nextFileName('fileIO_test_filelock_promise_003'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); + expect(isIntNum(file.fd)).assertTrue(); + await file.lock(); + file.tryLock(); + file.unlock(); + expect(true).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + done(); + } catch (e) { + console.log('fileIO_test_filelock_promise_003 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number FILE_TEST_FILELOCK_PROMISE_0400 + * @tc.name fileIO_test_filelock_promise_004 + * @tc.desc Test tryLock() interfaces. argument is : true. + * Open the file, file lock() ,tryLock(true) and unlock() + * @tc.size MEDIUM + * @tc.type Functoin + * @tc.level Level 3 + * @tc.require + */ + it('fileIO_test_filelock_promise_004', 0, async function (done) { + let fpath = await nextFileName('fileIO_test_filelock_promise_004'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); + expect(isIntNum(file.fd)).assertTrue(); + await file.lock(); + file.tryLock(true); + file.unlock(); + expect(true).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + done(); + } catch (e) { + console.log('fileIO_test_filelock_promise_004 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number FILE_TEST_FILELOCK_PROMISE_0500 + * @tc.name fileIO_test_filelock_promise_005 + * @tc.desc Test tryLock() interfaces. argument is : false. + * Open the file, file lock() ,tryLock(false) and unlock() + * @tc.size MEDIUM + * @tc.type Functoin + * @tc.level Level 3 + * @tc.require + */ + it('fileIO_test_filelock_promise_005', 0, async function (done) { + let fpath = await nextFileName('fileIO_test_filelock_promise_005'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); + expect(isIntNum(file.fd)).assertTrue(); + await file.lock(); + file.tryLock(false); + file.unlock(); + expect(true).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + done(); + } catch (e) { + console.log('fileIO_test_filelock_promise_005 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number FILE_TEST_FILELOCK_PROMISE_0600 + * @tc.name fileIO_test_filelock_promise_006 + * @tc.desc Open the file, no file lock(), tryLock(), unlock(), + * @tc.size MEDIUM + * @tc.type Functoin + * @tc.level Level 3 + * @tc.require + */ + it('fileIO_test_filelock_promise_006', 0, async function (done) { + let fpath = await nextFileName('fileIO_test_filelock_promise_006'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); + expect(isIntNum(file.fd)).assertTrue(); + file.tryLock(); + file.unlock(); + expect(true).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + done(); + } catch (e) { + console.log('fileIO_test_filelock_promise_006 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number FILE_TEST_FILELOCK_PROMISE_0700 + * @tc.name fileIO_test_filelock_promise_007 + * @tc.desc Open the file, no file lock(), no tryLock(), unlock(), + * @tc.size MEDIUM + * @tc.type Functoin + * @tc.level Level 3 + * @tc.require + */ + it('fileIO_test_filelock_promise_007', 0, async function (done) { + let fpath = await nextFileName('fileIO_test_filelock_promise_007'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); + expect(isIntNum(file.fd)).assertTrue(); + file.unlock(); + expect(true).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + done(); + } catch (e) { + console.log('fileIO_test_filelock_promise_007 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number FILE_TEST_FILELOCK_PROMISE_ABNORMAL_0000 + * @tc.name fileIO_test_filelock_promise_abnormal_000 + * @tc.desc Test lock() interfaces. argument is : null. + * Open the file, file lock(null). + * @tc.size MEDIUM + * @tc.type Functoin + * @tc.level Level 3 + * @tc.require + */ + it('fileIO_test_filelock_promise_abnormal_000', 0, async function (done) { + let fpath = await nextFileName('fileIO_test_filelock_promise_abnormal_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); + + try { + expect(isIntNum(file.fd)).assertTrue(); + await file.lock(null); + expect(false).assertTrue(); + } catch (e) { + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + console.log('fileIO_test_filelock_promise_abnormal_000 has failed for ' + e.message + ', code: ' + e.code); + expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); + done(); + } + }); + + /** + * @tc.number FILE_TEST_FILELOCK_PROMISE_ABNORMAL_0100 + * @tc.name fileIO_test_filelock_promise_abnormal_001 + * @tc.desc Test lock() interfaces. argument is : true, true. + * Open the file, file lock(true, true). + * @tc.size MEDIUM + * @tc.type Functoin + * @tc.level Level 3 + * @tc.require + */ + it('fileIO_test_filelock_promise_abnormal_001', 0, async function (done) { + let fpath = await nextFileName('fileIO_test_filelock_promise_abnormal_001'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); + + try { + expect(isIntNum(file.fd)).assertTrue(); + await file.lock(true, true); + expect(false).assertTrue(); + } catch (e) { + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + console.log('fileIO_test_filelock_promise_abnormal_001 has failed for ' + e.message + ', code: ' + e.code); + expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); + done(); + } + }); + + /** + * @tc.number FILE_TEST_FILELOCK_PROMISE_ABNORMAL_0200 + * @tc.name fileIO_test_filelock_promise_abnormal_002 + * @tc.desc Test lock() interfaces. argument is : -1. + * Open the file, file lock(-1). + * @tc.size MEDIUM + * @tc.type Functoin + * @tc.level Level 3 + * @tc.require + */ + it('fileIO_test_filelock_promise_abnormal_002', 0, async function (done) { + let fpath = await nextFileName('fileIO_test_filelock_promise_abnormal_002'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); + + try { + expect(isIntNum(file.fd)).assertTrue(); + await file.lock(-1); + expect(false).assertTrue(); + } catch (e) { + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + console.log('fileIO_test_filelock_promise_abnormal_002 has failed for ' + e.message + ', code: ' + e.code); + expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); + done(); + } + }); + + /** + * @tc.number FILE_TEST_FILELOCK_PROMISE_ABNORMAL_0300 + * @tc.name fileIO_test_filelock_promise_abnormal_003 + * @tc.desc Test tryLock() interfaces. argument is : null. + * Open the file, file lock(), tryLock(null). + * @tc.size MEDIUM + * @tc.type Functoin + * @tc.level Level 3 + * @tc.require + */ + it('fileIO_test_filelock_promise_abnormal_003', 0, async function (done) { + let fpath = await nextFileName('fileIO_test_filelock_promise_abnormal_003'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); + + try { + expect(isIntNum(file.fd)).assertTrue(); + await file.lock(); + file.tryLock(null); + expect(false).assertTrue(); + } catch (e) { + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + console.log('fileIO_test_filelock_promise_abnormal_003 has failed for ' + e.message + ', code: ' + e.code); + expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); + done(); + } + }); + + /** + * @tc.number FILE_TEST_FILELOCK_PROMISE_ABNORMAL_0400 + * @tc.name fileIO_test_filelock_promise_abnormal_004 + * @tc.desc Test tryLock() interfaces. argument is : true, true. + * Open the file, file lock(), tryLock(true, true). + * @tc.size MEDIUM + * @tc.type Functoin + * @tc.level Level 3 + * @tc.require + */ + it('fileIO_test_filelock_promise_abnormal_004', 0, async function (done) { + let fpath = await nextFileName('fileIO_test_filelock_promise_abnormal_004'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); + + try { + expect(isIntNum(file.fd)).assertTrue(); + await file.lock(); + file.tryLock(true, true); + expect(false).assertTrue(); + } catch (e) { + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + console.log('fileIO_test_filelock_promise_abnormal_004 has failed for ' + e.message + ', code: ' + e.code); + expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); + done(); + } + }); + + /** + * @tc.number FILE_TEST_FILELOCK_PROMISE_ABNORMAL_0500 + * @tc.name fileIO_test_filelock_promise_abnormal_005 + * @tc.desc Test tryLock() interfaces. argument is : -1. + * Open the file, file lock(), tryLock(-1). + * @tc.size MEDIUM + * @tc.type Functoin + * @tc.level Level 3 + * @tc.require + */ + it('fileIO_test_filelock_promise_abnormal_005', 0, async function (done) { + let fpath = await nextFileName('fileIO_test_filelock_promise_abnormal_005'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); + + try { + expect(isIntNum(file.fd)).assertTrue(); + await file.lock(); + file.tryLock(-1); + expect(false).assertTrue(); + } catch (e) { + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + console.log('fileIO_test_filelock_promise_abnormal_005 has failed for ' + e.message + ', code: ' + e.code); + expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); + done(); + } + }); + + /** + * @tc.number FILE_TEST_FILELOCK_PROMISE_ABNORMAL_0600 + * @tc.name fileIO_test_filelock_promise_abnormal_006 + * @tc.desc Test unlock() interfaces. argument is : true. + * Open the file, file lock(), tryLock(), unlock(true), + * @tc.size MEDIUM + * @tc.type Functoin + * @tc.level Level 3 + * @tc.require + */ + it('fileIO_test_filelock_promise_abnormal_006', 0, async function (done) { + let fpath = await nextFileName('fileIO_test_filelock_promise_abnormal_006'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); + + try { + expect(isIntNum(file.fd)).assertTrue(); + await file.lock(); + file.tryLock(); + file.unlock(true); + expect(false).assertTrue(); + } catch (e) { + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + console.log('fileIO_test_filelock_promise_abnormal_006 has failed for ' + e.message + ', code: ' + e.code); + expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); + done(); + } + }); + + /** + * @tc.number FILE_TEST_FILELOCK_CALLBACK_0000 + * @tc.name fileIO_test_filelock_callback_000 + * @tc.desc Test lock() interfaces. argument is : default. + * Open the file, file lock() and unlock() + * @tc.size MEDIUM + * @tc.type Functoin + * @tc.level Level 3 + * @tc.require + */ + it('fileIO_test_filelock_callback_000', 0, async function (done) { + let fpath = await nextFileName('fileIO_test_filelock_callback_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); + expect(isIntNum(file.fd)).assertTrue(); + file.lock((err) => { + if (err) { + console.log('fileIO_test_filelock_callback_000 err ' + JSON.stringify(err)); + expect(false).assertTrue(); + } + file.unlock(); + expect(true).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + done(); + }); + } catch (e) { + console.log('fileIO_test_filelock_callback_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number FILE_TEST_FILELOCK_CALLBACK_0100 + * @tc.name fileIO_test_filelock_callback_001 + * @tc.desc Test lock() interfaces. argument is : true. + * Open the file, file lock(true) and unlock() + * @tc.size MEDIUM + * @tc.type Functoin + * @tc.level Level 3 + * @tc.require + */ + it('fileIO_test_filelock_callback_001', 0, async function (done) { + let fpath = await nextFileName('fileIO_test_filelock_callback_001'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); + expect(isIntNum(file.fd)).assertTrue(); + file.lock(true, (err) => { + if (err) { + console.log('fileIO_test_filelock_callback_001 err ' + JSON.stringify(err)); + expect(false).assertTrue(); + } + file.unlock(); + expect(true).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + done(); + }); + } catch (e) { + console.log('fileIO_test_filelock_callback_001 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number FILE_TEST_FILELOCK_CALLBACK_0200 + * @tc.name fileIO_test_filelock_callback_002 + * @tc.desc Test lock() interfaces. argument is : false. + * Open the file, file lock(false) and unlock() + * @tc.size MEDIUM + * @tc.type Functoin + * @tc.level Level 3 + * @tc.require + */ + it('fileIO_test_filelock_callback_002', 0, async function (done) { + let fpath = await nextFileName('fileIO_test_filelock_callback_002'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); + expect(isIntNum(file.fd)).assertTrue(); + file.lock(false, (err) => { + if (err) { + console.log('fileIO_test_filelock_callback_002 err ' + JSON.stringify(err)); + expect(false).assertTrue(); + } + file.unlock(); + expect(true).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + done(); + }); + } catch (e) { + console.log('fileIO_test_filelock_callback_002 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number FILE_TEST_FILELOCK_CALLBACK_ABNORMAL_0000 + * @tc.name fileIO_test_filelock_callback_abnormal_000 + * @tc.desc Test lock() interfaces. argument is : null. + * Open the file, file lock(null). + * @tc.size MEDIUM + * @tc.type Functoin + * @tc.level Level 3 + * @tc.require + */ + it('fileIO_test_filelock_callback_abnormal_000', 0, async function (done) { + let fpath = await nextFileName('fileIO_test_filelock_callback_abnormal_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); + + try { + expect(isIntNum(file.fd)).assertTrue(); + file.lock(null, (err) => { + expect(false).assertTrue(); + }); + } catch (e) { + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + console.log('fileIO_test_filelock_callback_abnormal_000 has failed for ' + e.message + ', code: ' + e.code); + expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); + done(); + } + }); + + /** + * @tc.number FILE_TEST_FILELOCK_CALLBACK_ABNORMAL_0100 + * @tc.name fileIO_test_filelock_callback_abnormal_001 + * @tc.desc Test lock() interfaces. argument is : true, true. + * Open the file, file lock(true, true). + * @tc.size MEDIUM + * @tc.type Functoin + * @tc.level Level 3 + * @tc.require + */ + it('fileIO_test_filelock_callback_abnormal_001', 0, async function (done) { + let fpath = await nextFileName('fileIO_test_filelock_callback_abnormal_001'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); + + try { + expect(isIntNum(file.fd)).assertTrue(); + file.lock(true, true, (err) => { + expect(false).assertTrue(); + }); + } catch (e) { + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + console.log('fileIO_test_filelock_callback_abnormal_001 has failed for ' + e.message + ', code: ' + e.code); + expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); + done(); + } + }); + + /** + * @tc.number FILE_TEST_FILELOCK_CALLBACK_ABNORMAL_0200 + * @tc.name fileIO_test_filelock_callback_abnormal_002 + * @tc.desc Test lock() interfaces. argument is : -1. + * Open the file, file lock(-1). + * @tc.size MEDIUM + * @tc.type Functoin + * @tc.level Level 3 + * @tc.require + */ + it('fileIO_test_filelock_callback_abnormal_002', 0, async function (done) { + let fpath = await nextFileName('fileIO_test_filelock_callback_abnormal_002'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); + + try { + expect(isIntNum(file.fd)).assertTrue(); + file.lock(-1, (err) => { + expect(false).assertTrue(); + }); + } catch (e) { + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + console.log('fileIO_test_filelock_callback_abnormal_002 has failed for ' + e.message + ', code: ' + e.code); + expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); + done(); + } + }); +}); } \ No newline at end of file diff --git a/storage/storagefileiov9jstest/src/main/js/test/members/fsync.test.js b/storage/storagefileiov9jstest/src/main/js/test/members/fsync.test.js index 3df5683f758b0684c74690fca95094dddc894f6e..b5c8fdec86ec2acf8eff7e41fd77896ff2ca64df 100644 --- a/storage/storagefileiov9jstest/src/main/js/test/members/fsync.test.js +++ b/storage/storagefileiov9jstest/src/main/js/test/members/fsync.test.js @@ -14,8 +14,7 @@ */ import { - fileio, fileIO, FILE_CONTENT, prepareFile, nextFileName, - describe, it, expect, + fileIO, FILE_CONTENT, prepareFile, nextFileName, describe, it, expect, } from '../Common'; export default function fileIOFsync() { @@ -38,8 +37,8 @@ describe('fileIO_fs_fsync', function () { try { let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); fileIO.fsyncSync(file.fd); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_fsync_sync_000 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -47,12 +46,12 @@ describe('fileIO_fs_fsync', function () { }); /** - * @tc.number SUB_DF_FILEIO_FSYNC_SYNC_0010 + * @tc.number SUB_DF_FILEIO_FSYNC_SYNC_0100 * @tc.name fileIO_test_fsync_sync_001 * @tc.desc Test fsyncSync() interface. Invalid fd parameter. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_fsync_sync_001', 0, function () { @@ -67,12 +66,12 @@ describe('fileIO_fs_fsync', function () { }); /** - * @tc.number SUB_DF_FILEIO_FSYNC_SYNC_0020 + * @tc.number SUB_DF_FILEIO_FSYNC_SYNC_0200 * @tc.name fileIO_test_fsync_sync_002 * @tc.desc Test fsyncSync() interface. Missing parameter. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_fsync_sync_002', 0, function () { @@ -103,8 +102,8 @@ describe('fileIO_fs_fsync', function () { try { let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); await fileIO.fsync(file.fd); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); } catch (e) { console.log('fileIO_test_fsync_async_000 has failed for ' + e.message + ', code: ' + e.code); @@ -113,13 +112,13 @@ describe('fileIO_fs_fsync', function () { }); /** - * @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_0010 + * @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_0100 * @tc.name fileIO_test_fsync_async_001 * @tc.desc Test fsync() interface. Promise.then().catch() * Open the file in read-write mode, and synchronize the file content data. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_fsync_async_001', 0, async function (done) { @@ -129,8 +128,8 @@ describe('fileIO_fs_fsync', function () { try { let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); fileIO.fsync(file.fd).then(() => { - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); }).catch((err) => { console.log('fileIO_test_fsync_async_001 error package: ' + JSON.stringify(err)); @@ -143,13 +142,13 @@ describe('fileIO_fs_fsync', function () { }); /** - * @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_002 + * @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_0200 * @tc.name fileIO_test_fsync_async_002 * @tc.desc Test fsync() interface. Callback. * Open the file in read-write mode, and synchronize the file content data. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_fsync_async_002', 0, async function (done) { @@ -163,8 +162,8 @@ describe('fileIO_fs_fsync', function () { console.log('fileIO_test_fsync_async_002 error package: ' + JSON.stringify(err)); expect(false).assertTrue(); } - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); }); done(); } catch (e) { @@ -174,13 +173,13 @@ describe('fileIO_fs_fsync', function () { }); /** - * @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_003 + * @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_0300 * @tc.name fileIO_test_fsync_async_003 * @tc.desc Test fsync() interface. await Promise. * Invalid fd parameter. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_fsync_async_003', 0, async function (done) { @@ -196,13 +195,13 @@ describe('fileIO_fs_fsync', function () { }); /** - * @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_004 + * @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_0400 * @tc.name fileIO_test_fsync_async_004 * @tc.desc Test fsync() interface. Callback. * Invalid fd parameter. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_fsync_async_004', 0, async function (done) { @@ -210,7 +209,7 @@ describe('fileIO_fs_fsync', function () { try { fileIO.fsync(-1, (err) => { if (err) { - console.log('fileIO_test_fsync_async_004 error package: {' + err.message + ', code: ' + err.code + '}'); + console.log('fileIO_test_fsync_async_004 error: {message: ' + err.message + ', code: ' + err.code + '}'); expect(err.code == 13900008 && err.message == 'Bad file descriptor').assertTrue(); done(); } @@ -222,13 +221,13 @@ describe('fileIO_fs_fsync', function () { }); /** - * @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_005 + * @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_0500 * @tc.name fileIO_test_fsync_async_005 * @tc.desc Test fsync() interface. Promise.then().catch() * Missing parameter. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_fsync_async_005', 0, async function (done) { @@ -237,7 +236,7 @@ describe('fileIO_fs_fsync', function () { fileIO.fsync(-1).then(() => { expect(false).assertTrue(); }).catch((err) => { - console.log('fileIO_test_fsync_async_005 error package: {' + err.message + ', code: ' + err.code + '}'); + console.log('fileIO_test_fsync_async_005 error: {message: ' + err.message + ', code: ' + err.code + '}'); expect(err.code == 13900008 && err.message == 'Bad file descriptor').assertTrue(); done(); }); @@ -248,13 +247,13 @@ describe('fileIO_fs_fsync', function () { }); /** - * @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_006 + * @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_0600 * @tc.name fileIO_test_fsync_async_006 * @tc.desc Test fsync() interface. await Promise. * Missing parameter. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_fsync_async_006', 0, async function (done) { @@ -270,19 +269,19 @@ describe('fileIO_fs_fsync', function () { }); /** - * @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_006 - * @tc.name fileIO_test_fsync_async_006 + * @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_0700 + * @tc.name fileIO_test_fsync_async_007 * @tc.desc Test fsync() interface. Callback. * Missing parameter. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_fsync_async_007', 0, async function (done) { try { - fileIO.fsync(() => { + fileIO.fsync((err) => { expect(false).assertTrue(); }); } catch (e) { diff --git a/storage/storagefileiov9jstest/src/main/js/test/members/listFile.test.js b/storage/storagefileiov9jstest/src/main/js/test/members/listFile.test.js index 4278940ebbb4163df4064f7edddf326279ab5057..a7093d793eec3a9d602a0be251768777137b6bdc 100644 --- a/storage/storagefileiov9jstest/src/main/js/test/members/listFile.test.js +++ b/storage/storagefileiov9jstest/src/main/js/test/members/listFile.test.js @@ -57,7 +57,7 @@ export default function fileIOListfile() { * Do not have prop filter.Filter files by quantity only. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_listfile_sync_001', 0, async function () { @@ -90,7 +90,7 @@ export default function fileIOListfile() { * Do not have prop listNum. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_listfile_sync_002', 0, async function () { @@ -129,7 +129,7 @@ export default function fileIOListfile() { * Do not have prop suffix. Not filter files by suffix. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_listfile_sync_003', 0, async function () { @@ -168,7 +168,7 @@ export default function fileIOListfile() { * Scanfile.Retain six files in the three-level directory. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_listfile_sync_004', 0, async function () { @@ -226,7 +226,7 @@ export default function fileIOListfile() { * Filter out files whose suffix is not '. txt' and does not meet other conditions.Two files are retained. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_listfile_sync_005', 0, async function () { @@ -268,7 +268,7 @@ export default function fileIOListfile() { * Invalid file suffix name format. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_listfile_sync_006', 0, async function () { @@ -308,7 +308,7 @@ export default function fileIOListfile() { * Filter out all files because the size of all files less than 12. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_listfile_sync_007', 0, async function () { @@ -348,7 +348,7 @@ export default function fileIOListfile() { * listNum is 0.Traverse all files. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_listfile_sync_008', 0, async function () { @@ -390,7 +390,7 @@ export default function fileIOListfile() { * Missing all arguments. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_listfile_sync_009', 0, async function () { @@ -411,7 +411,7 @@ export default function fileIOListfile() { * Invalid option args. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_listfile_sync_010', 0, async function () { @@ -463,7 +463,7 @@ export default function fileIOListfile() { fileIO.rmdirSync(dpath); }); } catch (e) { - console.info('fileIO_test_listfile_async_000 has failed for ' + e.message + ', code:' + e.code); + console.log('fileIO_test_listfile_async_000 has failed for ' + e.message + ', code:' + e.code); expect(false).assertTrue(); } }); @@ -475,7 +475,7 @@ export default function fileIOListfile() { * Only path, do not filter file. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_listfile_async_001', 0, async function (done) { @@ -494,7 +494,7 @@ export default function fileIOListfile() { fileIO.rmdirSync(dpath); done(); } catch (err) { - console.info('fileIO_test_listfile_async_001 has failed for ' + err.message + ', code:' + err.code); + console.log('fileIO_test_listfile_async_001 has failed for ' + err.message + ', code:' + err.code); expect(false).assertTrue(); } }); @@ -506,7 +506,7 @@ export default function fileIOListfile() { * Do not have prop filter.Filter files by quantity only. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_listfile_async_002', 0, async function () { @@ -544,7 +544,7 @@ export default function fileIOListfile() { * Do not have prop filter.Filter files by quantity only. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_listfile_async_003', 0, async function (done) { @@ -578,7 +578,7 @@ export default function fileIOListfile() { * Do not have prop listNum. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_listfile_async_004', 0, async function () { @@ -610,7 +610,7 @@ export default function fileIOListfile() { fileIO.rmdirSync(dpath); }); } catch (e) { - console.info('fileIO_test_listfile_async_004 has failed for ' + e.message + ', code:' + e.code); + console.log('fileIO_test_listfile_async_004 has failed for ' + e.message + ', code:' + e.code); expect(false).assertTrue(); } }); @@ -622,7 +622,7 @@ export default function fileIOListfile() { * Do not have prop listNum. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_listfile_async_005', 0, async function (done) { @@ -650,7 +650,7 @@ export default function fileIOListfile() { fileIO.rmdirSync(dpath); done(); } catch (err) { - console.info('fileIO_test_listfile_async_005 has failed for ' + err.message + ', code:' + err.code); + console.log('fileIO_test_listfile_async_005 has failed for ' + err.message + ', code:' + err.code); expect(false).assertTrue(); } }); @@ -662,7 +662,7 @@ export default function fileIOListfile() { * Do not have prop suffix. Not filter files by suffix. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_listfile_async_006', 0, async function () { @@ -706,7 +706,7 @@ export default function fileIOListfile() { * Do not have prop suffix. Not filter files by suffix. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_listfile_async_007', 0, async function (done) { @@ -746,7 +746,7 @@ export default function fileIOListfile() { * Scanfile.Retain six files in the three-level directory. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_listfile_async_008', 0, async function () { @@ -809,7 +809,7 @@ export default function fileIOListfile() { * Scanfile.Retain six files in the three-level directory. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_listfile_async_009', 0, async function (done) { @@ -868,7 +868,7 @@ export default function fileIOListfile() { * Filter out files whose suffix is not '. txt' and does not meet other conditions.Two files are retained. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_listfile_async_010', 0, async function () { @@ -915,7 +915,7 @@ export default function fileIOListfile() { * Filter out files whose suffix is not '. txt' and does not meet other conditions.Two files are retained. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_listfile_async_011', 0, async function (done) { @@ -958,7 +958,7 @@ export default function fileIOListfile() { * Invalid file suffix name format. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_listfile_async_012', 0, async function () { @@ -1001,7 +1001,7 @@ export default function fileIOListfile() { * Invalid file suffix name format. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_listfile_async_013', 0, async function (done) { @@ -1044,7 +1044,7 @@ export default function fileIOListfile() { * Filter out all files because the size of all files less than 12. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_listfile_async_014', 0, async function () { @@ -1089,7 +1089,7 @@ export default function fileIOListfile() { * Filter out all files because the size of all files less than 12. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_listfile_async_015', 0, async function (done) { @@ -1130,7 +1130,7 @@ export default function fileIOListfile() { * listNum is 0.Traverse all files. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_listfile_async_016', 0, async function () { @@ -1177,7 +1177,7 @@ export default function fileIOListfile() { * listNum is 0.Traverse all files. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_listfile_async_017', 0, async function (done) { @@ -1220,7 +1220,7 @@ export default function fileIOListfile() { * Missing all arguments. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_listfile_async_018', 0, async function (done) { @@ -1242,7 +1242,7 @@ export default function fileIOListfile() { * Invalid option args. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_listfile_async_019', 0, async function (done) { diff --git a/storage/storagefileiov9jstest/src/main/js/test/members/lstat.test.js b/storage/storagefileiov9jstest/src/main/js/test/members/lstat.test.js index c1e055596a2e0df1a1ab1d03ae82d73a664f42c0..57ecedf7dae617bf6d8f85751505a18ed7c7b7d8 100644 --- a/storage/storagefileiov9jstest/src/main/js/test/members/lstat.test.js +++ b/storage/storagefileiov9jstest/src/main/js/test/members/lstat.test.js @@ -14,7 +14,7 @@ */ import { - fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum, isBoolean, isBigInt, + fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum, isBigInt, describe, it, expect, } from '../Common'; @@ -52,7 +52,7 @@ describe('fileIO_fs_lstat', function () { * The path point to nothing, no such file. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_sync_001', 0, async function () { @@ -74,7 +74,7 @@ describe('fileIO_fs_lstat', function () { * Missing parameters. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_sync_002', 0, async function () { @@ -94,7 +94,7 @@ describe('fileIO_fs_lstat', function () { * Enter the path parameter to get stat.ino of the file. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_ino_000', 0, async function () { @@ -117,7 +117,7 @@ describe('fileIO_fs_lstat', function () { * Enter the path parameter to get stat.mode of the file. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_mode_000', 0, async function () { @@ -141,7 +141,7 @@ describe('fileIO_fs_lstat', function () { * Enter the path parameter to get stat.uid of the file. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_uid_000', 0, async function () { @@ -165,7 +165,7 @@ describe('fileIO_fs_lstat', function () { * Enter the path parameter to get stat.gid of the file. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_gid_000', 0, async function () { @@ -189,7 +189,7 @@ describe('fileIO_fs_lstat', function () { * Enter the path parameter to get stat.size of the file. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_size_000', 0, async function () { @@ -213,7 +213,7 @@ describe('fileIO_fs_lstat', function () { * Enter the path or parameter to get stat.atime of the file. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_atime_000', 0, async function () { @@ -237,7 +237,7 @@ describe('fileIO_fs_lstat', function () { * Enter the path parameter to get stat.mtime of the file. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_mtime_000', 0, async function () { @@ -261,7 +261,7 @@ describe('fileIO_fs_lstat', function () { * Enter the path parameter to get stat.ctime of the file. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_ctime_000', 0, async function () { @@ -285,7 +285,7 @@ describe('fileIO_fs_lstat', function () { * This interface shall not treat a normal file as a block special device. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_is_block_device_000', 0, async function () { @@ -309,7 +309,7 @@ describe('fileIO_fs_lstat', function () { * This interface does not require parameters. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_lstat_is_block_device_001', 0, async function () { @@ -321,7 +321,7 @@ describe('fileIO_fs_lstat', function () { expect(false).assertTrue(); } catch (e) { fileIO.unlinkSync(fpath); - console.info('fileIO_test_lstat_is_block_device_001 has failed for ' + e.message + ', code: ' + e.code); + console.log('fileIO_test_lstat_is_block_device_001 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); } }); @@ -333,7 +333,7 @@ describe('fileIO_fs_lstat', function () { * This interface shall not treat a normal file as a character special device. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_is_character_device_000', 0, async function () { @@ -357,7 +357,7 @@ describe('fileIO_fs_lstat', function () { * This interface does not require parameters. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_lstat_is_character_device_001', 0, async function () { @@ -381,7 +381,7 @@ describe('fileIO_fs_lstat', function () { * This interface shall not treat a normal file as a directory. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_is_directory_000', 0, async function () { @@ -405,7 +405,7 @@ describe('fileIO_fs_lstat', function () { * This interface shall treat a directory as a directory. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_is_directory_001', 0, async function () { @@ -429,7 +429,7 @@ describe('fileIO_fs_lstat', function () { * This interface does not require parameters. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_is_directory_002', 0, async function () { @@ -453,7 +453,7 @@ describe('fileIO_fs_lstat', function () { * This interface shall not treat a normal file as a FIFO. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_is_fifo_000', 0, async function () { @@ -477,7 +477,7 @@ describe('fileIO_fs_lstat', function () { * This interface does not require parameters. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_lstat_is_fifo_002', 0, async function () { @@ -501,7 +501,7 @@ describe('fileIO_fs_lstat', function () { * This interface shall treat a normal file as a normal file. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_is_file_000', 0, async function () { @@ -525,7 +525,7 @@ describe('fileIO_fs_lstat', function () { * This interface shall not treat a directory as a normal file. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_is_file_001', 0, async function () { @@ -549,7 +549,7 @@ describe('fileIO_fs_lstat', function () { * This interface does not require parameters. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_lstat_is_file_002', 0, async function () { @@ -573,7 +573,7 @@ describe('fileIO_fs_lstat', function () { * This interface shall not treat a file as a socket. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_is_socket_000', 0, async function () { @@ -597,7 +597,7 @@ describe('fileIO_fs_lstat', function () { * This interface does not require parameters. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_is_socket_001', 0, async function () { @@ -621,7 +621,7 @@ describe('fileIO_fs_lstat', function () { * This interface shall not treat a normal file as a symbolic link. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_is_symbolic_link_000', 0, async function () { @@ -645,7 +645,7 @@ describe('fileIO_fs_lstat', function () { * This interface does not require parameters. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_is_symbolic_link_001', 0, async function () { @@ -698,7 +698,7 @@ describe('fileIO_fs_lstat', function () { * Enter the path or parameter to get the file stat. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_async_001', 0, async function (done) { @@ -727,7 +727,7 @@ describe('fileIO_fs_lstat', function () { * Enter the path or parameter to get the file stat. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_async_002', 0, async function (done) { @@ -752,7 +752,7 @@ describe('fileIO_fs_lstat', function () { * The path point to nothing, no such file. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_async_003', 0, async function (done) { @@ -761,7 +761,7 @@ describe('fileIO_fs_lstat', function () { try { fileIO.lstat(fpath, (err) => { if (err) { - console.log('fileIO_lstat_async_003 error package: {' + err.message + ', code: ' + err.code + '}'); + console.log('fileIO_lstat_async_003 error: {message: ' + err.message + ', code: ' + err.code + '}'); expect(err.code == 13900002 && err.message == 'No such file or directory').assertTrue(); done(); } @@ -779,7 +779,7 @@ describe('fileIO_fs_lstat', function () { * The path point to nothing, no such file. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_async_004', 0, async function (done) { @@ -802,7 +802,7 @@ describe('fileIO_fs_lstat', function () { * Enter the path parameter to get stat.ino of the file. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_async_ino_000', 0, async function (done) { @@ -827,7 +827,7 @@ describe('fileIO_fs_lstat', function () { * Enter the path parameter to get stat.ino of the file. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_async_ino_001', 0, async function (done) { @@ -857,7 +857,7 @@ describe('fileIO_fs_lstat', function () { * Enter the path or parameter to get stat.mode of the file. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_async_mode_000', 0, async function (done) { @@ -882,7 +882,7 @@ describe('fileIO_fs_lstat', function () { * Enter the path or parameter to get stat.mode of the file. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_async_mode_001', 0, async function (done) { @@ -912,7 +912,7 @@ describe('fileIO_fs_lstat', function () { * Enter the path parameter to get stat.uid of the file. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_async_uid_000', 0, async function (done) { @@ -937,7 +937,7 @@ describe('fileIO_fs_lstat', function () { * Enter the path parameter to get stat.uid of the file. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_async_uid_001', 0, async function (done) { @@ -967,7 +967,7 @@ describe('fileIO_fs_lstat', function () { * Enter the path parameter to get stat.gid of the file. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_async_gid_000', 0, async function (done) { @@ -992,7 +992,7 @@ describe('fileIO_fs_lstat', function () { * Enter the path parameter to get stat.gid of the file. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_async_gid_001', 0, async function (done) { @@ -1022,7 +1022,7 @@ describe('fileIO_fs_lstat', function () { * Enter the path parameter to get stat.size of the file. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_async_size_000', 0, async function (done) { @@ -1047,7 +1047,7 @@ describe('fileIO_fs_lstat', function () { * Enter the path parameter to get stat.size of the file. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_async_size_001', 0, async function (done) { @@ -1077,7 +1077,7 @@ describe('fileIO_fs_lstat', function () { * Enter the path parameter to get stat.atime of the file. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_async_atime_000', 0, async function (done) { @@ -1102,7 +1102,7 @@ describe('fileIO_fs_lstat', function () { * Enter the path or fd parameter to get stat.atime of the file. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_async_atime_001', 0, async function (done) { @@ -1132,7 +1132,7 @@ describe('fileIO_fs_lstat', function () { * Enter the path or fd parameter to get stat.mtime of the file. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_async_mtime_000', 0, async function (done) { @@ -1157,7 +1157,7 @@ describe('fileIO_fs_lstat', function () { * Enter the path or fd parameter to get stat.mtime of the file. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_async_mtime_001', 0, async function (done) { @@ -1187,7 +1187,7 @@ describe('fileIO_fs_lstat', function () { * Enter the path or fd parameter to get stat.ctime of the file. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_async_ctime_000', 0, async function (done) { @@ -1212,7 +1212,7 @@ describe('fileIO_fs_lstat', function () { * Enter the path or fd parameter to get stat.ctime of the file. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_async_ctime_001', 0, async function (done) { @@ -1242,7 +1242,7 @@ describe('fileIO_fs_lstat', function () { * This interface shall not treat a normal file as a block special device. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_async_is_block_device_000', 0, async function (done) { @@ -1267,7 +1267,7 @@ describe('fileIO_fs_lstat', function () { * This interface shall not treat a normal file as a block special device. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_async_is_block_device_001', 0, async function (done) { @@ -1297,7 +1297,7 @@ describe('fileIO_fs_lstat', function () { * This interface shall not treat a normal file as a character special device. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_async_is_character_device_000', 0, async function (done) { @@ -1322,7 +1322,7 @@ describe('fileIO_fs_lstat', function () { * This interface shall not treat a normal file as a character special device. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_async_is_character_device_001', 0, async function (done) { @@ -1352,7 +1352,7 @@ describe('fileIO_fs_lstat', function () { * This interface shall not treat a normal file as a directory. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_async_is_directory_000', 0, async function (done) { @@ -1377,7 +1377,7 @@ describe('fileIO_fs_lstat', function () { * This interface shall not treat a directory as a directory. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_async_is_directory_001', 0, async function (done) { @@ -1403,7 +1403,7 @@ describe('fileIO_fs_lstat', function () { * This interface shall not treat a directory as a directory. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_async_is_directory_002', 0, async function (done) { @@ -1433,7 +1433,7 @@ describe('fileIO_fs_lstat', function () { * This interface shall not treat a normal file as a FIFO. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_async_is_fifo_000', 0, async function (done) { @@ -1458,7 +1458,7 @@ describe('fileIO_fs_lstat', function () { * This interface shall not treat a normal file as a FIFO. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_async_is_fifo_001', 0, async function (done) { @@ -1488,7 +1488,7 @@ describe('fileIO_fs_lstat', function () { * This interface shall treat a normal file as a normal file. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_async_is_file_000', 0, async function (done) { @@ -1513,7 +1513,7 @@ describe('fileIO_fs_lstat', function () { * This interface shall treat a normal file as a normal file. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_async_is_file_001', 0, async function (done) { @@ -1543,7 +1543,7 @@ describe('fileIO_fs_lstat', function () { * This interface shall not treat a directory as a normal file. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_async_is_file_002', 0, async function (done) { @@ -1568,7 +1568,7 @@ describe('fileIO_fs_lstat', function () { * This interface shall not treat a file as a socket. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_async_is_socket_000', 0, async function (done) { @@ -1593,7 +1593,7 @@ describe('fileIO_fs_lstat', function () { * This interface shall not treat a file as a socket. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_async_is_socket_001', 0, async function (done) { @@ -1623,7 +1623,7 @@ describe('fileIO_fs_lstat', function () { * This interface shall not treat a normal file as a symbolic link. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_async_is_symbolic_link_000', 0, async function (done) { @@ -1648,7 +1648,7 @@ describe('fileIO_fs_lstat', function () { * This interface shall not treat a normal file as a symbolic link. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_lstat_async_is_symbolic_link_001', 0, async function (done) { @@ -1678,7 +1678,7 @@ describe('fileIO_fs_lstat', function () { * Modify the file, view the file status changes by path. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_append_file_sync_000', 0, async function () { @@ -1693,7 +1693,7 @@ describe('fileIO_fs_lstat', function () { expect(isIntNum(file.fd)).assertTrue(); expect(fileIO.writeSync(file.fd, FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); - fileIO.closeSync(file.fd); + fileIO.closeSync(file); stat = fileIO.lstatSync(fpath); expect(stat.size == FILE_CONTENT.length * 2).assertTrue(); diff --git a/storage/storagefileiov9jstest/src/main/js/test/members/mkdir.test.js b/storage/storagefileiov9jstest/src/main/js/test/members/mkdir.test.js index eee69563fb6faf62312ef9a3fafba1f6082e214f..3791177fca0738d237e210333e64dffe678e88f5 100644 --- a/storage/storagefileiov9jstest/src/main/js/test/members/mkdir.test.js +++ b/storage/storagefileiov9jstest/src/main/js/test/members/mkdir.test.js @@ -96,7 +96,7 @@ describe('fileIO_fs_mkdir', function () { * @tc.require */ it('fileIO_test_mkdir_sync_003', 0, async function () { - let fpath = await nextFileName('fileIO_test_open_sync_000'); + let fpath = await nextFileName('fileIO_test_mkdir_sync_003'); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { @@ -198,7 +198,7 @@ describe('fileIO_fs_mkdir', function () { try { fileIO.mkdir('/', (err) => { if(err) { - console.log('fileIO_test_mkdir_async_003 error package: {' + err.message + ', code: ' + err.code + '}'); + console.log('fileIO_test_mkdir_async_003 error: {message: ' + err.message + ', code: ' + err.code + '}'); expect(err.code == 13900015 && err.message == 'File exists').assertTrue(); done(); } diff --git a/storage/storagefileiov9jstest/src/main/js/test/members/moveFile.test.js b/storage/storagefileiov9jstest/src/main/js/test/members/moveFile.test.js index 27a3743a3fab3da9472df23e42dd64945c1fa0a0..c0f3af2725f5ef565bbd03ccb3731fdfa95a0620 100644 --- a/storage/storagefileiov9jstest/src/main/js/test/members/moveFile.test.js +++ b/storage/storagefileiov9jstest/src/main/js/test/members/moveFile.test.js @@ -21,7 +21,7 @@ export default function fileIOMoveFile() { describe('fileIO_fs_moveFile', function () { /** - * @tc.number SUB_DF_FILEIO_MOVEFILESYNC_0000 + * @tc.number SUB_DF_FILEIO_MOVEFILE_SYNC_0000 * @tc.name fileIO_test_moveFile_sync_000 * @tc.desc Test moveFileSync() interface. * Move a single file, shall work properly in normal case. @@ -51,13 +51,13 @@ export default function fileIOMoveFile() { }); /** - * @tc.number SUB_DF_FILEIO_MOVEFILESYNC_0100 + * @tc.number SUB_DF_FILEIO_MOVEFILE_SYNC_0100 * @tc.name fileIO_test_moveFile_sync_001 * @tc.desc Test moveFileSync() interface. * A file with the same name already exists under the destination path. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_moveFile_sync_001', 0, async function () { @@ -81,13 +81,13 @@ export default function fileIOMoveFile() { }); /** - * @tc.number SUB_DF_FILEIO_MOVEFILESYNC_0200 + * @tc.number SUB_DF_FILEIO_MOVEFILE_SYNC_0200 * @tc.name fileIO_test_moveFile_sync_002 * @tc.desc Test moveFileSync() interface. * The path point to nothing, no such file. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_moveFile_sync_002', 0, async function () { @@ -109,13 +109,13 @@ export default function fileIOMoveFile() { }); /** - * @tc.number SUB_DF_FILEIO_MOVEFILESYNC_0400 + * @tc.number SUB_DF_FILEIO_MOVEFILE_SYNC_0400 * @tc.name fileIO_test_moveFile_sync_004 * @tc.desc Test moveFileSync() interface. * The path point to a directory, not a file. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_moveFile_sync_004', 0, async function () { @@ -134,13 +134,13 @@ export default function fileIOMoveFile() { }); /** - * @tc.number SUB_DF_FILEIO_MOVEFILESYNC_0500 + * @tc.number SUB_DF_FILEIO_MOVEFILE_SYNC_0500 * @tc.name fileIO_test_moveFile_sync_005 * @tc.desc Test moveFileSync() interface. * Missing parameter. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_moveFile_sync_005', 0, async function () { @@ -158,13 +158,13 @@ export default function fileIOMoveFile() { }); /** - * @tc.number SUB_DF_FILEIO_MOVEFILESYNC_0600 + * @tc.number SUB_DF_FILEIO_MOVEFILE_SYNC_0600 * @tc.name fileIO_test_moveFile_sync_006 * @tc.desc Test moveFileSync() interface. * Entry parameters increase forced movement when mode = 0. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_moveFile_sync_006', 0, async function () { @@ -189,7 +189,7 @@ export default function fileIOMoveFile() { }); /** - * @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0000 + * @tc.number SUB_DF_FILEIO_MOVEFILE_ASYNC_0000 * @tc.name fileIO_test_moveFile_async_000 * @tc.desc Test moveFile() interface. Promise. * Move a single file, shall work properly in normal case. @@ -220,13 +220,13 @@ export default function fileIOMoveFile() { }); /** - * @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0100 + * @tc.number SUB_DF_FILEIO_MOVEFILE_ASYNC_0100 * @tc.name fileIO_test_moveFile_async_001 * @tc.desc Test moveFile() interface. Callback. * Move a single file, shall work properly in normal case. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_moveFile_async_001', 0, async function (done) { @@ -256,13 +256,13 @@ export default function fileIOMoveFile() { }); /** - * @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0200 + * @tc.number SUB_DF_FILEIO_MOVEFILE_ASYNC_0200 * @tc.name fileIO_test_moveFile_async_002 * @tc.desc Test moveFile() interface. Promise. * A file with the same name already exists under the destination path. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_moveFile_async_002', 0, async function (done) { @@ -287,13 +287,13 @@ export default function fileIOMoveFile() { }); /** - * @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0300 + * @tc.number SUB_DF_FILEIO_MOVEFILE_ASYNC_0300 * @tc.name fileIO_test_moveFile_async_003 * @tc.desc Test moveFile() interface. Callback. * A file with the same name already exists under the destination path. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_moveFile_async_003', 0, async function (done) { @@ -310,7 +310,7 @@ export default function fileIOMoveFile() { fileIO.moveFile(fpath, ffpath, 1, (err) => { if (err) { fileIO.rmdirSync(dpath); - console.log('fileIO_test_moveFile_async_003 error package: {' + err.message + ', code: ' + err.code + '}'); + console.log('fileIO_test_moveFile_async_003 error: {message: ' + err.message + ', code: ' + err.code + '}'); expect(err.code == 13900015 && err.message == 'File exists').assertTrue(); done(); } @@ -322,13 +322,13 @@ export default function fileIOMoveFile() { }); /** - * @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0400 + * @tc.number SUB_DF_FILEIO_MOVEFILE_ASYNC_0400 * @tc.name fileIO_test_moveFile_async_004 * @tc.desc Test moveFile() interface. Promise. * The path point to nothing, no such file. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_moveFile_async_004', 0, async function (done) { @@ -351,13 +351,13 @@ export default function fileIOMoveFile() { }); /** - * @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0500 + * @tc.number SUB_DF_FILEIO_MOVEFILE_ASYNC_0500 * @tc.name fileIO_test_moveFile_async_005 * @tc.desc Test moveFile() interface. Callback. * The path point to nothing, no such file. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_moveFile_async_005', 0, async function (done) { @@ -372,7 +372,7 @@ export default function fileIOMoveFile() { fileIO.moveFile(fpath, ffpath, (err) => { if (err) { fileIO.rmdirSync(dpath); - console.log('fileIO_test_moveFile_async_005 error package: {' + err.message + ', code: ' + err.code + '}'); + console.log('fileIO_test_moveFile_async_005 error: {message: ' + err.message + ', code: ' + err.code + '}'); expect(err.code == 13900002 && err.message == 'No such file or directory').assertTrue(); done(); } @@ -384,13 +384,13 @@ export default function fileIOMoveFile() { }); /** - * @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0600 + * @tc.number SUB_DF_FILEIO_MOVEFILE_ASYNC_0600 * @tc.name fileIO_test_moveFile_async_006 * @tc.desc Test moveFile() interface. Promise. * The path point to a directory, not a file. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_moveFile_async_006', 0, async function (done) { @@ -410,13 +410,13 @@ export default function fileIOMoveFile() { }); /** - * @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0700 + * @tc.number SUB_DF_FILEIO_MOVEFILE_ASYNC_0700 * @tc.name fileIO_test_moveFile_async_007 * @tc.desc Test moveFile() interface. Callback. * The path point to a directory, not a file. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_moveFile_async_007', 0, async function (done) { @@ -440,13 +440,13 @@ export default function fileIOMoveFile() { }); /** - * @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0800 + * @tc.number SUB_DF_FILEIO_MOVEFILE_ASYNC_0800 * @tc.name fileIO_test_moveFile_async_008 * @tc.desc Test moveFile() interface. Promise. * Missing parameter. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_moveFile_async_008', 0, async function (done) { @@ -465,13 +465,13 @@ export default function fileIOMoveFile() { }); /** - * @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0900 + * @tc.number SUB_DF_FILEIO_MOVEFILE_ASYNC_0900 * @tc.name fileIO_test_moveFile_async_009 * @tc.desc Test moveFile() interface. Promise. * Entry parameters increase forced movement when mode = 0. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_moveFile_async_009', 0, async function (done) { @@ -497,13 +497,13 @@ export default function fileIOMoveFile() { }); /** - * @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_1000 + * @tc.number SUB_DF_FILEIO_MOVEFILE_ASYNC_1000 * @tc.name fileIO_test_moveFile_async_010 * @tc.desc Test moveFile() interface. Callback. * Entry parameters increase forced movement when mode = 0. * @tc.size MEDIUM * @tc.type Function - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_moveFile_async_010', 0, async function (done) { diff --git a/storage/storagefileiov9jstest/src/main/js/test/members/open.test.js b/storage/storagefileiov9jstest/src/main/js/test/members/open.test.js index e6c3e59af33829eef568d84867c7870e218fe513..9f7d752e03b627ddf8aa4d428ca333082035934f 100644 --- a/storage/storagefileiov9jstest/src/main/js/test/members/open.test.js +++ b/storage/storagefileiov9jstest/src/main/js/test/members/open.test.js @@ -14,8 +14,7 @@ */ import { - fileio, fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum, - describe, it, expect, + fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum, describe, it, expect, } from '../Common'; export default function fileIOOpen() { @@ -40,8 +39,8 @@ export default function fileIOOpen() { 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); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_open_sync_000 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -55,7 +54,7 @@ export default function fileIOOpen() { * Open the file in write-only mode, verifying the file is writable. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_sync_001', 0, async function () { @@ -65,10 +64,10 @@ export default function fileIOOpen() { try { let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); expect(isIntNum(file.fd)).assertTrue(); - let num = fileIO.writeSync(file.fd, FILE_CONTENT); - expect(num == FILE_CONTENT.length).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + let bytesWritten = fileIO.writeSync(file.fd, FILE_CONTENT); + expect(bytesWritten == FILE_CONTENT.length).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_open_sync_001 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -82,7 +81,7 @@ export default function fileIOOpen() { * Open the file in read-write mode, verifying the file is readable and writable. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_sync_002', 0, async function () { @@ -95,10 +94,10 @@ export default function fileIOOpen() { 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); + let bytesWritten = fileIO.writeSync(file.fd, new ArrayBuffer(length)); + expect(bytesWritten == length).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_open_sync_002 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -111,7 +110,7 @@ export default function fileIOOpen() { * @tc.desc Test openSync() interfaces. Missing parameters. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_sync_003', 0, function () { @@ -131,7 +130,7 @@ export default function fileIOOpen() { * If the path point to the file which does not exist, the file can be created. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_sync_004', 0, async function () { @@ -140,8 +139,8 @@ export default function fileIOOpen() { 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); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_open_sync_004 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -155,7 +154,7 @@ export default function fileIOOpen() { * If the file exists and the file is opened for read-write, trim its length to zero. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_sync_005', 0, async function () { @@ -165,10 +164,10 @@ export default function fileIOOpen() { 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); + let readLen = fileIO.readSync(file.fd, new ArrayBuffer(4096)); + expect(readLen == 0).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_open_sync_005 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -182,7 +181,7 @@ export default function fileIOOpen() { * Open as append, subsequent writes will append to the end of the file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_sync_006', 0, async function () { @@ -193,12 +192,12 @@ export default function fileIOOpen() { 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); + let bytesWritten = fileIO.writeSync(file.fd, new ArrayBuffer(length)); + expect(bytesWritten == length).assertTrue(); + let readLen = fileIO.readSync(file.fd, new ArrayBuffer(4096), { offset: 0 }); + expect(readLen == length + FILE_CONTENT.length).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_open_sync_006 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -212,7 +211,7 @@ export default function fileIOOpen() { * If the file is a special file, the opening and subsequent IOs perform non-blocking operations. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_sync_007', 0, async function () { @@ -222,8 +221,8 @@ export default function fileIOOpen() { 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); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_open_sync_007 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -237,17 +236,17 @@ export default function fileIOOpen() { * The path points to a directory. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_sync_008', 0, async function () { let dpath = await nextFileName('fileIO_test_open_sync_008'); - fileio.mkdirSync(dpath); + fileIO.mkdirSync(dpath); try { let file = fileIO.openSync(dpath, fileIO.OpenMode.DIR); expect(isIntNum(file.fd)).assertTrue(); - fileio.rmdirSync(dpath); + fileIO.rmdirSync(dpath); } catch (e) { console.log('fileIO_test_open_sync_008 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -261,7 +260,7 @@ export default function fileIOOpen() { * The path does not a directory, throw error. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_sync_009', 0, async function () { @@ -272,7 +271,7 @@ export default function fileIOOpen() { fileIO.openSync(fpath, fileIO.OpenMode.DIR); expect(false).assertTrue(); } catch (e) { - fileio.unlinkSync(fpath); + fileIO.unlinkSync(fpath); console.log('fileIO_test_open_sync_009 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900018 && e.message == 'Not a directory').assertTrue(); } @@ -285,7 +284,7 @@ export default function fileIOOpen() { * The path does not point to a symbolic link. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_sync_010', 0, async function () { @@ -295,8 +294,8 @@ export default function fileIOOpen() { 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); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_open_sync_010 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -310,7 +309,7 @@ export default function fileIOOpen() { * The path points to a symbolic link, throw error. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_sync_011', 0, async function () { @@ -319,12 +318,12 @@ export default function fileIOOpen() { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - fileio.symlinkSync(fpath, ffpath); + fileIO.symlinkSync(fpath, ffpath); fileIO.openSync(ffpath, fileIO.OpenMode.NOFOLLOW | fileIO.OpenMode.READ_WRITE); expect(false).assertTrue(); } catch (e) { - fileio.unlinkSync(fpath); - fileio.unlinkSync(ffpath); + fileIO.unlinkSync(fpath); + fileIO.unlinkSync(ffpath); 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(); } @@ -337,7 +336,7 @@ export default function fileIOOpen() { * Open the file in the way of synchronous IO. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_sync_012', 0, async function () { @@ -347,8 +346,8 @@ export default function fileIOOpen() { 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); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_open_sync_012 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -361,7 +360,7 @@ export default function fileIOOpen() { * @tc.desc Test openSync() interfaces. Invalid path. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_sync_013', 0, async function (done) { @@ -394,10 +393,10 @@ export default function fileIOOpen() { let file = await fileIO.open(fpath, fileIO.OpenMode.READ_ONLY); expect(isIntNum(file.fd)).assertTrue(); fileIO.read(file.fd, new ArrayBuffer(4096)) - .then((res) => { - expect(res == FILE_CONTENT.length).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + .then((readLen) => { + expect(readLen == FILE_CONTENT.length).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); }); } catch (e) { @@ -413,7 +412,7 @@ export default function fileIOOpen() { * Open the file in read-only mode, verifying the file is readable. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_async_001', 0, async function (done) { @@ -428,10 +427,10 @@ export default function fileIOOpen() { } expect(isIntNum(file.fd)).assertTrue(); fileIO.read(file.fd, new ArrayBuffer(4096)) - .then((res) => { - expect(res == FILE_CONTENT.length).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + .then((readLen) => { + expect(readLen == FILE_CONTENT.length).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); }); }); @@ -448,7 +447,7 @@ export default function fileIOOpen() { * Open the file in write-only mode, verifying the file is writable. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_async_002', 0, async function (done) { @@ -460,10 +459,10 @@ export default function fileIOOpen() { let file = await fileIO.open(fpath, fileIO.OpenMode.WRITE_ONLY); expect(isIntNum(file.fd)).assertTrue(); fileIO.write(file.fd, new ArrayBuffer(length)) - .then((num) => { - expect(num == length).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + .then((bytesWritten) => { + expect(bytesWritten == length).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); }); } catch (e) { @@ -479,7 +478,7 @@ export default function fileIOOpen() { * Open the file in write-only mode, verifying the file is writable. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_async_003', 0, async function (done) { @@ -495,10 +494,10 @@ export default function fileIOOpen() { } expect(isIntNum(file.fd)).assertTrue(); fileIO.write(file.fd, new ArrayBuffer(length)) - .then((num) => { - expect(num == length).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + .then((bytesWritten) => { + expect(bytesWritten == length).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); }); }); done(); @@ -515,7 +514,7 @@ export default function fileIOOpen() { * The path point to nothing, no such file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_async_004', 0, async function (done) { @@ -538,7 +537,7 @@ export default function fileIOOpen() { * The path point to nothing, no such file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_async_005', 0, async function (done) { @@ -547,7 +546,7 @@ export default function fileIOOpen() { try { fileIO.open(fpath, fileIO.OpenMode.READ_WRITE, (err) => { if(err) { - console.log('fileIO_test_open_async_005 error package: {' + err.message + ', code: ' + err.code + '}'); + console.log('fileIO_test_open_async_005 error: {message: ' + err.message + ', code: ' + err.code + '}'); expect(err.code == 13900002 && err.message == 'No such file or directory').assertTrue(); done(); } @@ -565,7 +564,7 @@ export default function fileIOOpen() { * The path point to nothing, no such file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_async_006', 0, async function () { @@ -575,8 +574,8 @@ export default function fileIOOpen() { fileIO.open(fpath, fileIO.OpenMode.READ_WRITE).then(() => { expect(false).assertTrue(); }).catch((err) => { - fileio.unlinkSync(fpath); - console.log('fileIO_test_open_async_006 error package: {' + err.message + ', code: ' + err.code + '}'); + fileIO.unlinkSync(fpath); + console.log('fileIO_test_open_async_006 error: {message: ' + err.message + ', code: ' + err.code + '}'); expect(err.code == 13900002 && err.message == 'No such file or directory').assertTrue(); }); } catch (e) { @@ -592,7 +591,7 @@ export default function fileIOOpen() { * Invalid path. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_async_007', 0, async function (done) { @@ -614,13 +613,13 @@ export default function fileIOOpen() { * Invalid path. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_async_008', 0, async function (done) { try { - fileIO.open(-1, fileIO.OpenMode.READ_WRITE, () => { + fileIO.open(-1, fileIO.OpenMode.READ_WRITE, (err) => { expect(false).assertTrue(); }); } catch (e) { @@ -637,7 +636,7 @@ export default function fileIOOpen() { * If the path point to the file which does not exist, the file can be created. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_async_009', 0, async function (done) { @@ -646,8 +645,8 @@ export default function fileIOOpen() { 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); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); } catch (e) { console.log('fileIO_test_open_async_009 has failed for ' + e.message + ', code: ' + e.code); @@ -662,7 +661,7 @@ export default function fileIOOpen() { * If the path point to the file which does not exist, the file can be created. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_async_010', 0, async function (done) { @@ -675,8 +674,8 @@ export default function fileIOOpen() { expect(false).assertTrue(); } expect(isIntNum(file.fd)).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); }); } catch (e) { @@ -692,7 +691,7 @@ export default function fileIOOpen() { * If the file exists and the file is opened for read-write, trim its length to zero. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_async_011', 0, async function (done) { @@ -703,10 +702,10 @@ export default function fileIOOpen() { let file = await fileIO.open(fpath, fileIO.OpenMode.TRUNC | fileIO.OpenMode.READ_WRITE); expect(isIntNum(file.fd)).assertTrue(); fileIO.read(file.fd, new ArrayBuffer(4096)) - .then((number) => { - expect(number == 0).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + .then((readLen) => { + expect(readLen == 0).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); }); done(); } catch (e) { @@ -722,7 +721,7 @@ export default function fileIOOpen() { * If the file exists and the file is opened for read-write, trim its length to zero. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_async_012', 0, async function (done) { @@ -737,10 +736,10 @@ export default function fileIOOpen() { } expect(isIntNum(file.fd)).assertTrue(); fileIO.read(file.fd, new ArrayBuffer(4096)) - .then((number) => { - expect(number == 0).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + .then((readLen) => { + expect(readLen == 0).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); }); done(); }); @@ -757,7 +756,7 @@ export default function fileIOOpen() { * Open as append, subsequent writes will append to the end of the file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_async_013', 0, async function (done) { @@ -770,10 +769,10 @@ export default function fileIOOpen() { expect(isIntNum(file.fd)).assertTrue(); fileIO.writeSync(file.fd, new ArrayBuffer(length)); fileIO.read(file.fd, new ArrayBuffer(4096), { offset: 0 }) - .then((number) => { - expect(number == length + FILE_CONTENT.length).assertTrue(); - fileIO.closeSync(file.fd); - fileio.unlinkSync(fpath); + .then((readLen) => { + expect(readLen == length + FILE_CONTENT.length).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); }); done(); } catch (e) { @@ -789,7 +788,7 @@ export default function fileIOOpen() { * Open as append, subsequent writes will append to the end of the file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_async_014', 0, async function (done) { @@ -806,10 +805,10 @@ export default function fileIOOpen() { expect(isIntNum(file.fd)).assertTrue(); fileIO.writeSync(file.fd, new ArrayBuffer(length)); fileIO.read(file.fd, new ArrayBuffer(4096), { offset: 0 }) - .then((number) => { - expect(number == length + FILE_CONTENT.length).assertTrue(); - fileIO.closeSync(file.fd); - fileio.unlinkSync(fpath); + .then((readLen) => { + expect(readLen == length + FILE_CONTENT.length).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); }); done(); }); @@ -826,7 +825,7 @@ export default function fileIOOpen() { * If the file is a special file, the opening and subsequent IOs perform non-blocking operations. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_async_015', 0, async function (done) { @@ -836,8 +835,8 @@ export default function fileIOOpen() { 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); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); } catch (e) { console.log('fileIO_test_open_async_015 has failed for ' + e.message + ', code: ' + e.code); @@ -852,7 +851,7 @@ export default function fileIOOpen() { * If the file is a special file, the opening and subsequent IOs perform non-blocking operations. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_async_016', 0, async function (done) { @@ -866,8 +865,8 @@ export default function fileIOOpen() { expect(false).assertTrue(); } expect(isIntNum(file.fd)).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); }); } catch (e) { @@ -883,17 +882,17 @@ export default function fileIOOpen() { * The path points to a directory. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_async_017', 0, async function (done) { let dpath = await nextFileName('fileIO_test_open_async_017'); - fileio.mkdirSync(dpath); + fileIO.mkdirSync(dpath); try { let file = await fileIO.open(dpath, fileIO.OpenMode.DIR); expect(isIntNum(file.fd)).assertTrue(); - fileio.rmdirSync(dpath); + fileIO.rmdirSync(dpath); done(); } catch (e) { console.log('fileIO_test_open_async_017 has failed for ' + e.message + ', code: ' + e.code); @@ -908,12 +907,12 @@ export default function fileIOOpen() { * The path points to a directory. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_async_018', 0, async function (done) { let dpath = await nextFileName('fileIO_test_open_async_018'); - fileio.mkdirSync(dpath); + fileIO.mkdirSync(dpath); try { fileIO.open(dpath, fileIO.OpenMode.DIR, (err, file) => { @@ -922,7 +921,7 @@ export default function fileIOOpen() { expect(false).assertTrue(); } expect(isIntNum(file.fd)).assertTrue(); - fileio.rmdirSync(dpath); + fileIO.rmdirSync(dpath); done(); }); } catch (e) { @@ -938,7 +937,7 @@ export default function fileIOOpen() { * The path does not point to a directory, throw error. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_async_019', 0, async function (done) { @@ -949,7 +948,7 @@ export default function fileIOOpen() { await fileIO.open(fpath, fileIO.OpenMode.DIR); expect(false).assertTrue(); } catch (e) { - fileio.unlinkSync(fpath); + fileIO.unlinkSync(fpath); console.log('fileIO_test_open_async_019 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900018 && e.message == 'Not a directory').assertTrue(); done(); @@ -963,7 +962,7 @@ export default function fileIOOpen() { * The path does not point to a directory, throw error. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_async_020', 0, async function (done) { @@ -973,8 +972,8 @@ export default function fileIOOpen() { try { fileIO.open(fpath, fileIO.OpenMode.DIR, (err) => { if(err) { - fileio.unlinkSync(fpath); - console.log('fileIO_test_open_async_020 error package: {' + err.message + ', code: ' + err.code + '}'); + fileIO.unlinkSync(fpath); + console.log('fileIO_test_open_async_020 error: {message: ' + err.message + ', code: ' + err.code + '}'); expect(err.code == 13900018 && err.message == 'Not a directory').assertTrue(); done(); } @@ -992,7 +991,7 @@ export default function fileIOOpen() { * The path does not point to a directory, throw error. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_async_021', 0, async function (done) { @@ -1003,8 +1002,8 @@ export default function fileIOOpen() { fileIO.open(fpath, fileIO.OpenMode.DIR).then(() => { expect(false).assertTrue(); }).catch((err) => { - fileio.unlinkSync(fpath); - console.log('fileIO_test_open_async_021 error package: {' + err.message + ', code: ' + err.code + '}'); + fileIO.unlinkSync(fpath); + console.log('fileIO_test_open_async_021 error: {message: ' + err.message + ', code: ' + err.code + '}'); expect(err.code == 13900018 && err.message == 'Not a directory').assertTrue(); done(); }); @@ -1021,7 +1020,7 @@ export default function fileIOOpen() { * The path does not point to a symbolic link. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_async_022', 0, async function (done) { @@ -1031,8 +1030,8 @@ export default function fileIOOpen() { 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); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); } catch (e) { console.log('fileIO_test_open_async_022 has failed for ' + e.message + ', code: ' + e.code); @@ -1047,7 +1046,7 @@ export default function fileIOOpen() { * The path does not point to a symbolic link. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_async_023', 0, async function (done) { @@ -1061,8 +1060,8 @@ export default function fileIOOpen() { expect(false).assertTrue(); } expect(isIntNum(file.fd)).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); }); } catch (e) { @@ -1078,7 +1077,7 @@ export default function fileIOOpen() { * The path point to a symbolic link, throw error. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_async_024', 0, async function (done) { @@ -1087,12 +1086,12 @@ export default function fileIOOpen() { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - fileio.symlinkSync(fpath, ffpath); + fileIO.symlinkSync(fpath, ffpath); await fileIO.open(ffpath, fileIO.OpenMode.NOFOLLOW | fileIO.OpenMode.READ_WRITE); expect(false).assertTrue(); } catch (e) { - fileio.unlinkSync(fpath); - fileio.unlinkSync(ffpath); + fileIO.unlinkSync(fpath); + fileIO.unlinkSync(ffpath); console.log('fileIO_test_open_async_024 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900033 && e.message == 'Too many symbolic links encountered').assertTrue(); done(); @@ -1106,7 +1105,7 @@ export default function fileIOOpen() { * The path point to a symbolic link, throw error. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_async_025', 0, async function (done) { @@ -1115,14 +1114,14 @@ export default function fileIOOpen() { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - fileio.symlinkSync(fpath, ffpath); + fileIO.symlinkSync(fpath, ffpath); fileIO.open(ffpath, fileIO.OpenMode.NOFOLLOW | fileIO.OpenMode.READ_WRITE, (err) => { if(err) { - console.log('fileIO_test_open_async_025 error package: {' + err.message + ', code: ' + err.code + '}'); + console.log('fileIO_test_open_async_025 error: {message: ' + err.message + ', code: ' + err.code + '}'); expect(err.code == 13900033 && err.message == 'Too many symbolic links encountered').assertTrue(); } - fileio.unlinkSync(fpath); - fileio.unlinkSync(ffpath); + fileIO.unlinkSync(fpath); + fileIO.unlinkSync(ffpath); done(); }); } catch (e) { @@ -1138,7 +1137,7 @@ export default function fileIOOpen() { * The path point to a symbolic link, throw error. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_async_026', 0, async function (done) { @@ -1147,14 +1146,14 @@ export default function fileIOOpen() { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - fileio.symlinkSync(fpath, ffpath); + fileIO.symlinkSync(fpath, ffpath); fileIO.open(ffpath, fileIO.OpenMode.NOFOLLOW | fileIO.OpenMode.READ_WRITE).then(() => { expect(false).assertTrue(); }).catch((err) => { - console.log('fileIO_test_open_async_026 error package: {' + err.message + ', code: ' + err.code + '}'); + console.log('fileIO_test_open_async_026 error: {message: ' + err.message + ', code: ' + err.code + '}'); expect(err.code == 13900033 && err.message == 'Too many symbolic links encountered').assertTrue(); - fileio.unlinkSync(fpath); - fileio.unlinkSync(ffpath); + fileIO.unlinkSync(fpath); + fileIO.unlinkSync(ffpath); done(); }); } catch (e) { @@ -1170,7 +1169,7 @@ export default function fileIOOpen() { * Open the file in the way of synchronous IO. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_async_027', 0, async function (done) { @@ -1180,8 +1179,8 @@ export default function fileIOOpen() { try { let file = await fileIO.open(fpath, fileIO.OpenMode.SYNC | fileIO.OpenMode.READ_WRITE); expect(isIntNum(file.fd)).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); } catch (e) { console.log('fileIO_test_open_async_027 has failed for ' + e.message + ', code: ' + e.code); @@ -1196,7 +1195,7 @@ export default function fileIOOpen() { * Open the file in the way of synchronous IO. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_open_async_028', 0, async function (done) { @@ -1210,8 +1209,8 @@ export default function fileIOOpen() { expect(false).assertTrue(); } expect(isIntNum(file.fd)).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); }); } catch (e) { diff --git a/storage/storagefileiov9jstest/src/main/js/test/members/read.test.js b/storage/storagefileiov9jstest/src/main/js/test/members/read.test.js index 6bebb857304193706dd099a1d4cad0be3ec85de9..378915fd45b21cc35dafff14596626011a20366c 100644 --- a/storage/storagefileiov9jstest/src/main/js/test/members/read.test.js +++ b/storage/storagefileiov9jstest/src/main/js/test/members/read.test.js @@ -14,8 +14,7 @@ */ import { - fileio, fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum, - describe, it, expect, util + fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum, describe, it, expect, util } from '../Common'; export default function fileIORead() { @@ -38,11 +37,10 @@ export default function fileIORead() { try { let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY); expect(isIntNum(file.fd)).assertTrue(); - expect( - fileIO.readSync(file.fd, new ArrayBuffer(4096)) - == FILE_CONTENT.length).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + let readLen = fileIO.readSync(file.fd, new ArrayBuffer(4096)); + expect(readLen == FILE_CONTENT.length).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_read_sync_000 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -56,7 +54,7 @@ export default function fileIORead() { * Open the file in read-only mode, reading the file with length = 1. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_read_sync_001', 0, async function () { @@ -66,13 +64,12 @@ export default function fileIORead() { try { let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY); expect(isIntNum(file.fd)).assertTrue(); - expect( - fileIO.readSync(file.fd, new ArrayBuffer(4096), { - length: 1, - }) - == 1).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + let readLen = fileIO.readSync(file.fd, new ArrayBuffer(4096), { + length: 1, + }); + expect(readLen == 1).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_read_sync_001 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -86,7 +83,7 @@ export default function fileIORead() { * Open the file in read-only mode, reading the file with length < 0(Read normal). * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_read_sync_002', 0, async function () { @@ -100,8 +97,8 @@ export default function fileIORead() { length: -1, }); expect(readLen == FILE_CONTENT.length).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_read_sync_002 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -115,7 +112,7 @@ export default function fileIORead() { * Open the file in read-only mode, reading the file with length > the content of file(Read normal). * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_read_sync_003', 0, async function () { @@ -125,12 +122,12 @@ export default function fileIORead() { try { let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY); expect(isIntNum(file.fd)).assertTrue(); - expect(fileIO.readSync(file.fd, new ArrayBuffer(4096), { - length: FILE_CONTENT.length + 1, - }) - == FILE_CONTENT.length).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + let readLen = fileIO.readSync(file.fd, new ArrayBuffer(4096), { + length: FILE_CONTENT.length + 1, + }); + expect(readLen == FILE_CONTENT.length).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_read_sync_003 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -144,7 +141,7 @@ export default function fileIORead() { * Read the file with invalid length > size of ArrayBuffer. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_read_sync_004', 0, async function () { @@ -159,8 +156,8 @@ export default function fileIORead() { }); expect(false).assertTrue(); } catch (e) { - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); console.log('fileIO_test_read_sync_004 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); } @@ -173,7 +170,7 @@ export default function fileIORead() { * Open the file in read-only mode, reading the file with offset(position) = 1. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_read_sync_005', 0, async function () { @@ -183,13 +180,12 @@ export default function fileIORead() { try { let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY); expect(isIntNum(file.fd)).assertTrue(); - expect( - fileIO.readSync(file.fd, new ArrayBuffer(4096), { - offset: 1, - }) - == FILE_CONTENT.length - 1).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + let readLen = fileIO.readSync(file.fd, new ArrayBuffer(4096), { + offset: 1, + }); + expect(readLen == FILE_CONTENT.length - 1).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_read_sync_005 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -203,7 +199,7 @@ export default function fileIORead() { * Read the file with invalid offset = -1. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_read_sync_006', 0, async function () { @@ -218,8 +214,8 @@ export default function fileIORead() { }); expect(false).assertTrue(); } catch (e) { - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); console.log('fileIO_test_read_sync_006 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); } @@ -232,7 +228,7 @@ export default function fileIORead() { * Open the file in read-only mode, reading the file with offset(position) > the content of file(Read normal). * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_read_sync_007', 0, async function () { @@ -242,13 +238,12 @@ export default function fileIORead() { try { let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY); expect(isIntNum(file.fd)).assertTrue(); - expect( - fileIO.readSync(file.fd, new ArrayBuffer(4096), { - offset: FILE_CONTENT.length + 1, - }) - == 0).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + let readLen = fileIO.readSync(file.fd, new ArrayBuffer(4096), { + offset: FILE_CONTENT.length + 1, + }); + expect(readLen == 0).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_read_sync_007 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -262,7 +257,7 @@ export default function fileIORead() { * Open the file in read-only mode, reading the file with offset(position) = 1, length = 10. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_read_sync_008', 0, async function () { @@ -272,14 +267,13 @@ export default function fileIORead() { try { let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY); expect(isIntNum(file.fd)).assertTrue(); - expect( - fileIO.readSync(file.fd, new ArrayBuffer(4096), { - offset: 1, - length: FILE_CONTENT.length - 1, - }) - == FILE_CONTENT.length - 1).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + let readLen = fileIO.readSync(file.fd, new ArrayBuffer(4096), { + offset: 1, + length: FILE_CONTENT.length - 1, + }); + expect(readLen == FILE_CONTENT.length - 1).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_read_sync_008 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -293,7 +287,7 @@ export default function fileIORead() { * Read the file with invalid fd. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_read_sync_009', 0, async function () { @@ -314,7 +308,7 @@ export default function fileIORead() { * Verify that the Chinese, English, and symbols can be read correctly. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_read_sync_010', 0, async function () { @@ -330,8 +324,8 @@ export default function fileIORead() { let textDecoder = new util.TextDecoder("utf-8", { ignoreBOM: true }); let resultPut = textDecoder.decode(new Uint8Array(buf), { stream: true }); expect(resultPut == CONTENT).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_read_sync_010 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -357,8 +351,8 @@ export default function fileIORead() { 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); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); } catch (e) { console.log('fileIO_test_read_async_000 has failed for ' + e.message + ', code: ' + e.code); @@ -373,7 +367,7 @@ export default function fileIORead() { * Open the file in read-only mode, verifying the normal read function. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_read_async_001', 0, async function (done) { @@ -389,8 +383,8 @@ export default function fileIORead() { expect(false).assertTrue(); } expect(readlen == FILE_CONTENT.length).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); }); } catch (e) { @@ -406,7 +400,7 @@ export default function fileIORead() { * Open the file in write-only mode, verifying it is not readable. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_read_async_002', 0, async function (done) { @@ -419,8 +413,8 @@ export default function fileIORead() { await fileIO.read(file.fd, new ArrayBuffer(4096)); expect(false).assertTrue(); } catch (e) { - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); console.log('fileIO_test_read_async_002 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900008 && e.message == 'Bad file descriptor').assertTrue(); done(); @@ -434,7 +428,7 @@ export default function fileIORead() { * Open the file in write-only mode, verifying it is not readable. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_read_async_003', 0, async function (done) { @@ -447,9 +441,9 @@ export default function fileIORead() { expect(isIntNum(file.fd)).assertTrue(); fileIO.read(file.fd, new ArrayBuffer(4096), (err) => { if(err) { - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); - console.log('fileIO_test_read_async_003 error package: {' + err.message + ', code: ' + err.code + '}'); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + console.log('fileIO_test_read_async_003 error: {message: ' + err.message + ', code: ' + err.code + '}'); expect(err.code == 13900008 && err.message == 'Bad file descriptor').assertTrue(); done(); } @@ -467,7 +461,7 @@ export default function fileIORead() { * Open the file in read-only mode, reading the file with offset(position) = 1. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_read_async_004', 0, async function (done) { @@ -481,8 +475,8 @@ export default function fileIORead() { offset: 1, }); expect(readlen == FILE_CONTENT.length - 1).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); } catch (e) { console.log('fileIO_test_read_async_004 has failed for ' + e.message + ', code: ' + e.code); @@ -497,7 +491,7 @@ export default function fileIORead() { * Open the file in read-only mode, reading the file with offset(position) = 1. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_read_async_005', 0, async function (done) { @@ -508,16 +502,16 @@ export default function fileIORead() { let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY); expect(isIntNum(file.fd)).assertTrue(); fileIO.read(file.fd, new ArrayBuffer(4096), { - offset: 1, - }, (err, readLen) => { - if(err) { - console.log('fileIO_test_read_async_005 err package' + JSON.stringify(err)); - expect(false).assertTrue(); - } - expect(readLen == FILE_CONTENT.length - 1).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); - done(); + offset: 1, + }, (err, readLen) => { + if(err) { + console.log('fileIO_test_read_async_005 err package' + JSON.stringify(err)); + expect(false).assertTrue(); + } + expect(readLen == FILE_CONTENT.length - 1).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + done(); }); } catch (e) { console.log('fileIO_test_read_async_005 has failed for ' + e.message + ', code: ' + e.code); @@ -532,7 +526,7 @@ export default function fileIORead() { * Open the file in read-only mode, reading the file with length = 1. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_read_async_006', 0, async function (done) { @@ -546,8 +540,8 @@ export default function fileIORead() { length: 3, }); expect(readLen == 3).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); } catch (e) { console.log('fileIO_test_read_async_006 has failed for ' + e.message + ', code: ' + e.code); @@ -562,7 +556,7 @@ export default function fileIORead() { * Open the file in read-only mode, reading the file with length = 1. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_read_async_007', 0, async function (done) { @@ -573,16 +567,16 @@ export default function fileIORead() { let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY); expect(isIntNum(file.fd)).assertTrue(); fileIO.read(file.fd, new ArrayBuffer(4096), { - length: 3, - }, (err, readLen) => { - if(err) { - console.log('fileIO_test_read_async_007 err package' + JSON.stringify(err)); - expect(false).assertTrue(); - } - expect(readLen == 3).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); - done(); + length: 3, + }, (err, readLen) => { + if(err) { + console.log('fileIO_test_read_async_007 err package' + JSON.stringify(err)); + expect(false).assertTrue(); + } + expect(readLen == 3).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + done(); }); } catch (e) { console.log('fileIO_test_read_async_007 has failed for ' + e.message + ', code: ' + e.code); @@ -597,7 +591,7 @@ export default function fileIORead() { * Open the file in read-only mode, reading the file with offset > the content of file(Read normal). * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_read_async_008', 0, async function (done) { @@ -607,12 +601,12 @@ export default function fileIORead() { 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), { + let readLen = await fileIO.read(file.fd, new ArrayBuffer(4096), { offset: FILE_CONTENT.length + 1, }); - expect(len == 0).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + expect(readLen == 0).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); } catch (e) { console.log('fileIO_test_read_async_008 has failed for ' + e.message + ', code: ' + e.code); @@ -627,7 +621,7 @@ export default function fileIORead() { * Open the file in read-only mode, reading the file with offset > the content of file(Read normal). * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_read_async_009', 0, async function (done) { @@ -638,16 +632,16 @@ export default function fileIORead() { let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY); expect(isIntNum(file.fd)).assertTrue(); fileIO.read(file.fd, new ArrayBuffer(4096), { - offset: FILE_CONTENT.length + 1, - }, (err, len) => { - if(err) { - console.log('fileIO_test_read_async_009 err package' + JSON.stringify(err)); - expect(false).assertTrue(); - } - expect(len == 0).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); - done(); + offset: FILE_CONTENT.length + 1, + }, (err, readLen) => { + if(err) { + console.log('fileIO_test_read_async_009 err package' + JSON.stringify(err)); + expect(false).assertTrue(); + } + expect(readLen == 0).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + done(); }); } catch (e) { console.log('fileIO_test_read_async_009 has failed for ' + e.message + ', code: ' + e.code); @@ -656,13 +650,13 @@ export default function fileIORead() { }); /** - * @tc.number SUB_DF_FILEIO_READ_ASYNC_0100 + * @tc.number SUB_DF_FILEIO_READ_ASYNC_1000 * @tc.name fileIO_test_read_async_010 * @tc.desc Test read() interfaces. * Open the file in read-only mode, reading the file with offset(position) = 1, length = 11. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_read_async_010', 0, async function (done) { @@ -677,8 +671,8 @@ export default function fileIORead() { length: FILE_CONTENT.length, }); expect(readLen == FILE_CONTENT.length - 1).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); } catch (e) { console.log('fileIO_test_read_async_010 has failed for ' + e.message + ', code: ' + e.code); @@ -693,7 +687,7 @@ export default function fileIORead() { * Open the file in read-only mode, reading the file with offset(position) = 1, length = 11. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_read_async_011', 0, async function (done) { @@ -712,8 +706,8 @@ export default function fileIORead() { expect(false).assertTrue(); } expect(readLen == FILE_CONTENT.length - 1).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); }); } catch (e) { @@ -723,13 +717,13 @@ export default function fileIORead() { }); /** - * @tc.number SUB_DF_FILEIO_READ_ASYNC_0120 + * @tc.number SUB_DF_FILEIO_READ_ASYNC_1200 * @tc.name fileIO_test_read_async_012 * @tc.desc Test read() interfaces. Promise. * Read with invalid fd parameters. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_read_async_012', 0, async function (done) { @@ -750,14 +744,14 @@ export default function fileIORead() { * Read with invalid fd parameters. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_read_async_013', 0, async function (done) { try { fileIO.read(-1, new ArrayBuffer(4096), (err) => { if(err) { - console.log('fileIO_test_read_async_013 error package: {' + err.message + ', code: ' + err.code + '}'); + console.log('fileIO_test_read_async_013 error: {message: ' + err.message + ', code: ' + err.code + '}'); expect(err.code == 13900008 && err.message == 'Bad file descriptor').assertTrue(); done(); } @@ -775,7 +769,7 @@ export default function fileIORead() { * Read with invalid offset < 0. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_read_async_014', 0, async function (done) { @@ -787,13 +781,13 @@ export default function fileIORead() { try { expect(isIntNum(file.fd)).assertTrue(); fileIO.read(file.fd, new ArrayBuffer(4096), { - offset: invalidOffset - }, () => { - expect(false).assertTrue(); + offset: invalidOffset, + }, (err) => { + expect(false).assertTrue(); }); } catch (e) { - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); console.log('fileIO_test_read_async_014 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); done(); @@ -807,7 +801,7 @@ export default function fileIORead() { * Read with invalid length > size of ArrayBuffer(4096). * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_read_async_015', 0, async function (done) { @@ -819,13 +813,13 @@ export default function fileIORead() { try { expect(isIntNum(file.fd)).assertTrue(); fileIO.read(file.fd, new ArrayBuffer(4096), { - length: invalidLength - }, () => { - expect(false).assertTrue(); + length: invalidLength, + }, (err) => { + expect(false).assertTrue(); }); } catch (e) { - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); console.log('fileIO_test_read_async_015 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); done(); @@ -839,7 +833,7 @@ export default function fileIORead() { * Open the file in read-only mode, reading the file with empty option. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_read_async_016', 0, async function (done) { @@ -851,8 +845,8 @@ export default function fileIORead() { 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); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); } catch (e) { console.log('fileIO_test_read_async_016 has failed for ' + e.message + ', code: ' + e.code); @@ -861,13 +855,13 @@ export default function fileIORead() { }); /** - * @tc.number SUB_DF_FILEIO_READ_ASYNC_0170 + * @tc.number SUB_DF_FILEIO_READ_ASYNC_1700 * @tc.name fileIO_test_read_async_017 * @tc.desc Test read() interfaces. Callback. * Open the file in read-only mode, reading the file with empty option. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_read_async_017', 0, async function (done) { @@ -878,16 +872,16 @@ export default function fileIORead() { let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY); expect(isIntNum(file.fd)).assertTrue(); fileIO.read(file.fd, new ArrayBuffer(4096), { - }, (err, readLen) => { - if(err) { - console.log('fileIO_test_read_async_017 err package ' + JSON.stringify(err)); - expect(false).assertTrue(); - } - expect(readLen == FILE_CONTENT.length).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); - done(); - }); + }, (err, readLen) => { + if(err) { + console.log('fileIO_test_read_async_017 err package ' + JSON.stringify(err)); + expect(false).assertTrue(); + } + expect(readLen == FILE_CONTENT.length).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + done(); + }); } catch (e) { console.log('fileIO_test_read_async_017 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -895,13 +889,13 @@ export default function fileIORead() { }); /** - * @tc.number SUB_DF_FILEIO_READ_ASYNC_0180 + * @tc.number SUB_DF_FILEIO_READ_ASYNC_1800 * @tc.name fileIO_test_read_async_018 * @tc.desc Test read() interfaces. * Open the file in read-only mode, reading the file with length = -1(Read normal). * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_read_async_018', 0, async function () { @@ -913,10 +907,10 @@ export default function fileIORead() { expect(isIntNum(file.fd)).assertTrue(); let readLen = await fileIO.read(file.fd, new ArrayBuffer(4096), { length: -1, - }) + }); expect(readLen == FILE_CONTENT.length).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_read_async_018 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -924,13 +918,13 @@ export default function fileIORead() { }); /** - * @tc.number SUB_DF_FILEIO_READ_ASYNC_0190 + * @tc.number SUB_DF_FILEIO_READ_ASYNC_1900 * @tc.name fileIO_test_read_async_019 * @tc.desc Test read() interfaces. * Verify that the Chinese, English, and symbols can be read correctly. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_read_async_019', 0, async function (done) { @@ -946,8 +940,8 @@ export default function fileIORead() { let textDecoder = new util.TextDecoder("utf-8", { ignoreBOM: true }); let resultPut = textDecoder.decodeWithStream(new Uint8Array(buf), { stream: true }); expect(resultPut == CONTENT).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); } catch (e) { console.log('fileIO_test_read_async_019 has failed for ' + e.message + ', code: ' + e.code); diff --git a/storage/storagefileiov9jstest/src/main/js/test/members/rmdir.test.js b/storage/storagefileiov9jstest/src/main/js/test/members/rmdir.test.js index 828f73baa03af69e2710051e4e8434ff75f15fad..e06a3ab1e76dfdbc650172602415a45763dd9567 100644 --- a/storage/storagefileiov9jstest/src/main/js/test/members/rmdir.test.js +++ b/storage/storagefileiov9jstest/src/main/js/test/members/rmdir.test.js @@ -14,14 +14,14 @@ */ import { - fileIO, FILE_CONTENT, prepareFile, nextFileName, describe, it, expect, + fileIO, FILE_CONTENT, prepareFile, nextFileName, describe, it, expect, } from '../Common'; export default function fileIORmdir() { describe('fileIO_fs_rmdir', function () { /** - * @tc.number SUB_STORAGE_FileIO_RMDIR_SYNC_0000 + * @tc.number SUB_STORAGE_FILEIO_RMDIR_SYNC_0000 * @tc.name fileIO_test_rmdir_sync_000 * @tc.desc Test rmdirSync() interface. * Recursively delete all files and subfolders in a directory. @@ -56,7 +56,7 @@ describe('fileIO_fs_rmdir', function () { }); /** - * @tc.number SUB_STORAGE_FileIO_RMDIR_SYNC_0100 + * @tc.number SUB_STORAGE_FILEIO_RMDIR_SYNC_0100 * @tc.name fileIO_test_rmdir_sync_001 * @tc.desc Test rmdirSync() interface. * Invalid path. @@ -78,7 +78,7 @@ describe('fileIO_fs_rmdir', function () { }); /** - * @tc.number SUB_STORAGE_FileIO_RMDIR_SYNC_0200 + * @tc.number SUB_STORAGE_FILEIO_RMDIR_SYNC_0200 * @tc.name fileIO_test_rmdir_sync_002 * @tc.desc Test rmdirSync() interface. * Missing parameters. @@ -99,7 +99,7 @@ describe('fileIO_fs_rmdir', function () { }); /** - * @tc.number SUB_STORAGE_FileIO_RMDIR_SYNC_0300 + * @tc.number SUB_STORAGE_FILEIO_RMDIR_SYNC_0300 * @tc.name fileIO_test_rmdir_sync_003 * @tc.desc Test rmdirSync() interface. * Invalid type of parameter. @@ -108,19 +108,19 @@ describe('fileIO_fs_rmdir', function () { * @tc.level Level 3 * @tc.require */ - it('fileIO_test_rmdirsync_003', 0, function () { + it('fileIO_test_rmdir_sync_003', 0, function () { try { fileIO.rmdirSync(12); expect(false).assertTrue(); } catch (e) { - console.log('fileIO_test_rmdirsync_003 has failed for ' + e.message + ', code: ' + e.code); + console.log('fileIO_test_rmdir_sync_003 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); } }); /** - * @tc.number SUB_STORAGE_FileIO_RMDIR_SYNC_0400 + * @tc.number SUB_STORAGE_FILEIO_RMDIR_SYNC_0400 * @tc.name fileIO_test_rmdir_sync_004 * @tc.desc Test rmdirSync() interface. * The path contains ../, normal call. @@ -144,7 +144,7 @@ describe('fileIO_fs_rmdir', function () { }); /** - * @tc.number SUB_STORAGE_FileIO_RMDIR_ASYNC_0000 + * @tc.number SUB_STORAGE_FILEIO_RMDIR_ASYNC_0000 * @tc.name fileIO_test_rmdir_async_000 * @tc.desc Test rmdir() interface. Promise. * Recursively delete all files and subfolders in a directory. @@ -180,7 +180,7 @@ describe('fileIO_fs_rmdir', function () { }); /** - * @tc.number SUB_STORAGE_FileIO_RMDIR_ASYNC_0100 + * @tc.number SUB_STORAGE_FILEIO_RMDIR_ASYNC_0100 * @tc.name fileIO_test_rmdir_async_001 * @tc.desc Test rmdir() interface. Callback. * Recursively delete all files and subfolders in a directory. @@ -221,7 +221,7 @@ describe('fileIO_fs_rmdir', function () { }); /** - * @tc.number SUB_STORAGE_FileIO_RMDIR_ASYNC_0200 + * @tc.number SUB_STORAGE_FILEIO_RMDIR_ASYNC_0200 * @tc.name fileIO_test_rmdir_async_002 * @tc.desc Test rmdir() interface. Promise. * Invalid path. @@ -244,7 +244,7 @@ describe('fileIO_fs_rmdir', function () { }); /** - * @tc.number SUB_STORAGE_FileIO_RMDIR_ASYNC_0300 + * @tc.number SUB_STORAGE_FILEIO_RMDIR_ASYNC_0300 * @tc.name fileIO_test_rmdir_async_003 * @tc.desc Test rmdir() interface. Callback. * Invalid path. @@ -259,7 +259,7 @@ describe('fileIO_fs_rmdir', function () { try { fileIO.rmdir(dpath, (err) => { if (err) { - console.log('fileIO_test_rmdir_async_003 error package: {' + err.message + ', code: ' + err.code + '}'); + console.log('fileIO_test_rmdir_async_003 error: {message: ' + err.message + ', code: ' + err.code + '}'); expect(err.code == 13900002 && err.message == 'No such file or directory').assertTrue(); done(); } @@ -271,7 +271,7 @@ describe('fileIO_fs_rmdir', function () { }); /** - * @tc.number SUB_STORAGE_FileIO_RMDIR_ASYNC_0400 + * @tc.number SUB_STORAGE_FILEIO_RMDIR_ASYNC_0400 * @tc.name fileIO_test_rmdir_async_004 * @tc.desc Test rmdir() interface. Callback. * Parameter mismatch. @@ -286,7 +286,7 @@ describe('fileIO_fs_rmdir', function () { try { fileIO.mkdirSync(dpath); expect(fileIO.accessSync(dpath)).assertTrue(); - fileIO.rmdir(dpath, '', () => { + fileIO.rmdir(dpath, '', (err) => { expect(false).assertTrue(); }); } catch (e) { @@ -298,7 +298,7 @@ describe('fileIO_fs_rmdir', function () { }); /** - * @tc.number SUB_DF_FILEIO_MKDIR_ASYNC_0500 + * @tc.number SUB_STORAGE_FILEIO_RMDIR_ASYNC_0500 * @tc.name fileIO_test_rmdir_async_005 * @tc.desc Test rmdir() interfaces. Promise. * Missing parameter. @@ -320,7 +320,7 @@ describe('fileIO_fs_rmdir', function () { }); /** - * @tc.number SUB_STORAGE_FileIO_RMDIR_ASYNC_0600 + * @tc.number SUB_STORAGE_FILEIO_RMDIR_ASYNC_0600 * @tc.name fileIO_test_rmdir_async_006 * @tc.desc Test rmdirSync() interface. Promise. * The path contains ../, normal call. diff --git a/storage/storagefileiov9jstest/src/main/js/test/members/stat.test.js b/storage/storagefileiov9jstest/src/main/js/test/members/stat.test.js index c0291448c945d2fe6a44e53c99b0e6115640dc0a..d6f55460f323a1a40c391882dd25ece539e55f55 100644 --- a/storage/storagefileiov9jstest/src/main/js/test/members/stat.test.js +++ b/storage/storagefileiov9jstest/src/main/js/test/members/stat.test.js @@ -14,7 +14,7 @@ */ import { - fileio, fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum, isBigInt, + fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum, isBigInt, describe, it, expect, } from '../Common'; @@ -42,8 +42,8 @@ describe('fileIO_fs_stat', function () { let file = fileIO.openSync(fpath); let stat2 = fileIO.statSync(file.fd); expect(stat2 !== null).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_stat_sync_000 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -57,7 +57,7 @@ describe('fileIO_fs_stat', function () { * The path point to nothing, no such file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_sync_001', 0, async function () { @@ -78,7 +78,7 @@ describe('fileIO_fs_stat', function () { * @tc.desc Test statSync() interfaces. Missing parameters. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_sync_002', 0, async function () { @@ -99,7 +99,7 @@ describe('fileIO_fs_stat', function () { * Enter the path or fd parameter to get stat.ino of the file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_sync_ino_000', 0, async function () { @@ -113,10 +113,10 @@ describe('fileIO_fs_stat', function () { let file = fileIO.openSync(fpath); let stat2 = fileIO.statSync(file.fd); expect(isBigInt(stat2.ino)).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { - console.info('fileIO_stat_sync_ino_000 has failed for ' + e.message + ', code: ' + e.code); + console.log('fileIO_stat_sync_ino_000 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); } }); @@ -128,7 +128,7 @@ describe('fileIO_fs_stat', function () { * Enter the path or fd parameter to get stat.mode of the file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_sync_mode_000', 0, async function () { @@ -142,10 +142,10 @@ describe('fileIO_fs_stat', function () { let file = fileIO.openSync(fpath); let stat2 = fileIO.statSync(file.fd); expect(isIntNum(stat2.mode)).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { - console.info('fileIO_stat_sync_mode_000 has failed for ' + e.message + ', code: ' + e.code); + console.log('fileIO_stat_sync_mode_000 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); } }); @@ -157,7 +157,7 @@ describe('fileIO_fs_stat', function () { * Enter the path or fd parameter to get stat.uid of the file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_sync_uid_000', 0, async function () { @@ -171,8 +171,8 @@ describe('fileIO_fs_stat', function () { let file = fileIO.openSync(fpath); let stat2 = fileIO.statSync(file.fd); expect(isIntNum(stat2.uid)).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_stat_sync_uid_000 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -186,7 +186,7 @@ describe('fileIO_fs_stat', function () { * Enter the path or fd parameter to get stat.gid of the file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_sync_gid_000', 0, async function () { @@ -200,8 +200,8 @@ describe('fileIO_fs_stat', function () { let file = fileIO.openSync(fpath); let stat2 = fileIO.statSync(file.fd); expect(isIntNum(stat2.gid)).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_stat_sync_gid_000 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -215,7 +215,7 @@ describe('fileIO_fs_stat', function () { * Enter the path or fd parameter to get stat.size of the file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_sync_size_000', 0, async function () { @@ -229,8 +229,8 @@ describe('fileIO_fs_stat', function () { let file = fileIO.openSync(fpath); let stat2 = fileIO.statSync(file.fd); expect(isIntNum(stat2.size)).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_stat_sync_size_000 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -244,7 +244,7 @@ describe('fileIO_fs_stat', function () { * Enter the path or fd parameter to get stat.atime of the file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_sync_atime_000', 0, async function () { @@ -258,8 +258,8 @@ describe('fileIO_fs_stat', function () { let file = fileIO.openSync(fpath); let stat2 = fileIO.statSync(file.fd); expect(isIntNum(stat2.atime)).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_stat_sync_atime_000 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -273,7 +273,7 @@ describe('fileIO_fs_stat', function () { * Enter the path or fd parameter to get stat.mtime of the file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_sync_mtime_000', 0, async function () { @@ -287,8 +287,8 @@ describe('fileIO_fs_stat', function () { let file = fileIO.openSync(fpath); let stat2 = fileIO.statSync(file.fd); expect(isIntNum(stat2.mtime)).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_stat_sync_mtime_000 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -302,7 +302,7 @@ describe('fileIO_fs_stat', function () { * Enter the path or fd parameter to get stat.ctime of the file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_sync_ctime_000', 0, async function () { @@ -316,8 +316,8 @@ describe('fileIO_fs_stat', function () { let file = fileIO.openSync(fpath); let stat2 = fileIO.statSync(file.fd); expect(isIntNum(stat2.ctime)).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_stat_sync_ctime_000 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -331,7 +331,7 @@ describe('fileIO_fs_stat', function () { * This interface shall not treat a normal file as a block special device. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_sync_is_block_device_000', 0, async function () { @@ -345,8 +345,8 @@ describe('fileIO_fs_stat', function () { let file = fileIO.openSync(fpath); let stat2 = fileIO.statSync(file.fd); expect(stat2.isBlockDevice() === false).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + 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(); @@ -360,7 +360,7 @@ describe('fileIO_fs_stat', function () { * This interface does not require parameters. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_sync_is_block_device_001', 0, async function () { @@ -371,8 +371,8 @@ describe('fileIO_fs_stat', function () { fileIO.statSync(fpath).isBlockDevice(-1); expect(false).assertTrue(); } catch (e) { - fileio.unlinkSync(fpath); - console.info('fileIO_stat_sync_is_block_device_001 has failed for ' + e.message + ', code: ' + e.code); + fileIO.unlinkSync(fpath); + console.log('fileIO_stat_sync_is_block_device_001 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); } }); @@ -384,7 +384,7 @@ describe('fileIO_fs_stat', function () { * This interface does not require parameters. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_sync_is_block_device_002', 0, async function () { @@ -396,9 +396,9 @@ describe('fileIO_fs_stat', function () { fileIO.statSync(file.fd).isBlockDevice(-1); expect(false).assertTrue(); } catch (e) { - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); - console.info('fileIO_stat_sync_is_block_device_002 has failed for ' + e.message + ', code: ' + e.code); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + console.log('fileIO_stat_sync_is_block_device_002 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); } @@ -411,7 +411,7 @@ describe('fileIO_fs_stat', function () { * This interface shall not treat a normal file as a character special device. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_sync_is_character_device_000', 0, async function () { @@ -425,8 +425,8 @@ describe('fileIO_fs_stat', function () { let file = fileIO.openSync(fpath); let stat2 = fileIO.statSync(file.fd); expect(stat2.isCharacterDevice() === false).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + 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(); @@ -440,7 +440,7 @@ describe('fileIO_fs_stat', function () { * This interface does not require parameters. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_sync_is_character_device_001', 0, async function () { @@ -451,7 +451,7 @@ describe('fileIO_fs_stat', function () { fileIO.statSync(fpath).isCharacterDevice(-1); expect(false).assertTrue(); } catch (e) { - fileio.unlinkSync(fpath); + fileIO.unlinkSync(fpath); console.log('fileIO_stat_sync_is_character_device_001 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); } @@ -464,7 +464,7 @@ describe('fileIO_fs_stat', function () { * This interface does not require parameters. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_sync_is_character_device_002', 0, async function () { @@ -476,8 +476,8 @@ describe('fileIO_fs_stat', function () { fileIO.statSync(file.fd).isCharacterDevice(-1); expect(false).assertTrue(); } catch (e) { - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); console.log('fileIO_stat_sync_is_character_device_002 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); } @@ -490,7 +490,7 @@ describe('fileIO_fs_stat', function () { * This interface shall not treat a normal file as a directory. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_sync_is_directory_000', 0, async function () { @@ -504,8 +504,8 @@ describe('fileIO_fs_stat', function () { let file = fileIO.openSync(fpath); let stat2 = fileIO.statSync(file.fd); expect(stat2.isDirectory() === false).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_stat_sync_is_directory_000 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -519,22 +519,22 @@ describe('fileIO_fs_stat', function () { * This interface shall treat a directory as a directory. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_sync_is_directory_001', 0, async function () { let dpath = await nextFileName('fileIO_stat_sync_is_directory_001'); try { - fileio.mkdirSync(dpath); + fileIO.mkdirSync(dpath); let stat = fileIO.statSync(dpath); expect(stat.isDirectory() === true).assertTrue(); let file = fileIO.openSync(dpath, fileIO.OpenMode.DIR); let stat2 = fileIO.statSync(file.fd); expect(stat2.isDirectory() === true).assertTrue(); - fileio.closeSync(file.fd); - fileio.rmdirSync(dpath); + fileIO.closeSync(file); + fileIO.rmdirSync(dpath); } catch (e) { console.log('fileIO_stat_sync_is_directory_001 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -548,18 +548,18 @@ describe('fileIO_fs_stat', function () { * This interface does not require parameters. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_sync_is_directory_002', 0, async function () { let dpath = await nextFileName('fileIO_stat_sync_is_directory_002') + 'd'; try { - fileio.mkdirSync(dpath); + fileIO.mkdirSync(dpath); fileIO.statSync(dpath).isDirectory(-1); expect(false).assertTrue(); } catch (e) { - fileio.rmdirSync(dpath); + fileIO.rmdirSync(dpath); console.log('fileIO_stat_sync_is_directory_002 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); } @@ -572,20 +572,20 @@ describe('fileIO_fs_stat', function () { * This interface does not require parameters. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_sync_is_directory_003', 0, async function () { let dpath = await nextFileName('fileIO_stat_sync_is_directory_003') + 'd'; - fileio.mkdirSync(dpath); + fileIO.mkdirSync(dpath); let file = fileIO.openSync(dpath, fileIO.OpenMode.DIR); try { fileIO.statSync(file.fd).isDirectory(-1); expect(false).assertTrue(); } catch (e) { - fileio.closeSync(file.fd); - fileio.rmdirSync(dpath); + fileIO.closeSync(file); + fileIO.rmdirSync(dpath); console.log('fileIO_stat_sync_is_directory_003 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); } @@ -598,7 +598,7 @@ describe('fileIO_fs_stat', function () { * This interface shall not treat a normal file as a FIFO. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_sync_is_fifo_000', 0, async function () { @@ -612,8 +612,8 @@ describe('fileIO_fs_stat', function () { let file = fileIO.openSync(fpath); let stat2 = fileIO.statSync(file.fd); expect(stat2.isFIFO() === false).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_stat_sync_is_fifo_000 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -627,7 +627,7 @@ describe('fileIO_fs_stat', function () { * This interface does not require parameters. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_sync_is_fifo_001', 0, async function () { @@ -638,7 +638,7 @@ describe('fileIO_fs_stat', function () { fileIO.statSync(fpath).isFile(-1); expect(false).assertTrue(); } catch (e) { - fileio.unlinkSync(fpath); + fileIO.unlinkSync(fpath); console.log('fileIO_stat_sync_is_fifo_001 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); } @@ -651,7 +651,7 @@ describe('fileIO_fs_stat', function () { * This interface does not require parameters. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_sync_is_fifo_002', 0, async function () { @@ -663,8 +663,8 @@ describe('fileIO_fs_stat', function () { fileIO.statSync(file.fd).isFile(-1); expect(false).assertTrue(); } catch (e) { - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); console.log('fileIO_stat_sync_is_fifo_002 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); } @@ -676,7 +676,7 @@ describe('fileIO_fs_stat', function () { * This interface shall treat a normal file as a normal file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_sync_is_file_000', 0, async function () { @@ -690,8 +690,8 @@ describe('fileIO_fs_stat', function () { let file = fileIO.openSync(fpath); let stat2 = fileIO.statSync(file.fd); expect(stat2.isFile() === true).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_stat_sync_is_file_000 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -705,22 +705,22 @@ describe('fileIO_fs_stat', function () { * This interface shall not treat a directory as a normal file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_sync_is_file_001', 0, async function () { let dpath = await nextFileName('fileIO_stat_sync_is_file_001'); try { - fileio.mkdirSync(dpath); + fileIO.mkdirSync(dpath); let stat = fileIO.statSync(dpath); expect(stat.isFile() === false).assertTrue(); let file = fileIO.openSync(dpath, fileIO.OpenMode.DIR); let stat2 = fileIO.statSync(file.fd); expect(stat2.isFile() === false).assertTrue(); - fileio.closeSync(file.fd); - fileio.rmdirSync(dpath); + fileIO.closeSync(file); + fileIO.rmdirSync(dpath); } catch (e) { console.log('fileIO_stat_sync_is_file_001 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -734,18 +734,18 @@ describe('fileIO_fs_stat', function () { * This interface does not require parameters. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @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); + fileIO.mkdirSync(dpath); fileIO.statSync(dpath).isFile(-1); expect(false).assertTrue(); } catch (e) { - fileio.rmdirSync(dpath); + fileIO.rmdirSync(dpath); console.log('fileIO_stat_sync_is_file_002 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); } @@ -758,20 +758,20 @@ describe('fileIO_fs_stat', function () { * This interface does not require parameters. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_sync_is_file_003', 0, async function () { let dpath = await nextFileName('fileIO_stat_sync_is_file_003'); - fileio.mkdirSync(dpath); + fileIO.mkdirSync(dpath); let file = fileIO.openSync(dpath, fileIO.OpenMode.DIR); try { fileIO.statSync(file.fd).isFile(-1); expect(false).assertTrue(); } catch (e) { - fileio.closeSync(file.fd); - fileio.rmdirSync(dpath); + fileIO.closeSync(file); + fileIO.rmdirSync(dpath); console.log('fileIO_stat_sync_is_file_003 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); } @@ -784,7 +784,7 @@ describe('fileIO_fs_stat', function () { * This interface shall not treat a file as a socket. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_sync_is_socket_000', 0, async function () { @@ -798,8 +798,8 @@ describe('fileIO_fs_stat', function () { let file = fileIO.openSync(fpath); let stat2 = fileIO.statSync(file.fd); expect(stat2.isSocket() === false).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_stat_sync_is_socket_000 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -813,7 +813,7 @@ describe('fileIO_fs_stat', function () { * This interface does not require parameters. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_sync_is_socket_001', 0, async function () { @@ -824,7 +824,7 @@ describe('fileIO_fs_stat', function () { fileIO.statSync(fpath).isSocket(-1); expect(false).assertTrue(); } catch (e) { - fileio.unlinkSync(fpath); + fileIO.unlinkSync(fpath); console.log('fileIO_stat_sync_is_socket_001 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); } @@ -837,7 +837,7 @@ describe('fileIO_fs_stat', function () { * This interface does not require parameters. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_sync_is_socket_002', 0, async function () { @@ -849,8 +849,8 @@ describe('fileIO_fs_stat', function () { fileIO.statSync(file.fd).isSocket(-1); expect(false).assertTrue(); } catch (e) { - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); console.log('fileIO_stat_sync_is_socket_002 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); } @@ -862,7 +862,7 @@ describe('fileIO_fs_stat', function () { * This interface shall not treat a normal file as a symbolic link. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_sync_is_symbolic_link_000', 0, async function () { @@ -876,8 +876,8 @@ describe('fileIO_fs_stat', function () { let file = fileIO.openSync(fpath); let stat2 = fileIO.statSync(file.fd); expect(stat2.isSymbolicLink() === false).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + 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(); @@ -891,7 +891,7 @@ describe('fileIO_fs_stat', function () { * This interface does not require parameters. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_sync_is_symbolic_link_001', 0, async function () { @@ -902,7 +902,7 @@ describe('fileIO_fs_stat', function () { fileIO.statSync(fpath).isSymbolicLink(-1); expect(false).assertTrue(); } catch (e) { - fileio.unlinkSync(fpath); + fileIO.unlinkSync(fpath); console.log('fileIO_stat_sync_is_symbolic_link_001 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); } @@ -915,7 +915,7 @@ describe('fileIO_fs_stat', function () { * This interface does not require parameters. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_sync_is_symbolic_link_002', 0, async function () { @@ -927,8 +927,8 @@ describe('fileIO_fs_stat', function () { fileIO.statSync(file.fd).isSymbolicLink(-1); expect(false).assertTrue(); } catch (e) { - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); console.log('fileIO_stat_sync_is_symbolic_link_001 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); } @@ -959,12 +959,12 @@ describe('fileIO_fs_stat', function () { let file = fileIO.openSync(fpath); fileIO.stat(file.fd).then((stat2) => { expect(stat2 !== null).assertTrue(); - fileio.closeSync(file.fd); + fileIO.closeSync(file); }).catch((err) => { console.log('fileIO_stat_async_000 error package2: ' + JSON.stringify(err)); expect(false).assertTrue(); }); - fileio.unlinkSync(fpath); + fileIO.unlinkSync(fpath); done(); } catch (e) { console.log('fileIO_stat_async_000 has failed for ' + e.message + ', code: ' + e.code); @@ -993,8 +993,8 @@ describe('fileIO_fs_stat', function () { let file = fileIO.openSync(fpath); let stat2 = await fileIO.stat(file.fd); expect(stat2 !== null).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); } catch (e) { console.log('fileIO_stat_async_001 has failed for ' + e.message + ', code: ' + e.code); @@ -1009,7 +1009,7 @@ describe('fileIO_fs_stat', function () { * Enter the path or fd parameter to get the file stat. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_async_002', 0, async function (done) { @@ -1032,8 +1032,8 @@ describe('fileIO_fs_stat', function () { expect(false).assertTrue(); } expect(stat2 !== null).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); }); } catch (e) { @@ -1049,7 +1049,7 @@ describe('fileIO_fs_stat', function () { * The path point to nothing, no such file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_async_003', 0, async function (done) { @@ -1072,7 +1072,7 @@ describe('fileIO_fs_stat', function () { * The path point to nothing, no such file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_async_004', 0, async function (done) { @@ -1081,7 +1081,7 @@ describe('fileIO_fs_stat', function () { try { fileIO.stat(fpath, (err) => { if (err) { - console.log('fileIO_stat_async_004 error package: {' + err.message + ', code: ' + err.code + '}'); + console.log('fileIO_stat_async_004 error: {message: ' + err.message + ', code: ' + err.code + '}'); expect(err.code == 13900002 && err.message == 'No such file or directory').assertTrue(); done(); } @@ -1099,7 +1099,7 @@ describe('fileIO_fs_stat', function () { * Invalid path or fd parameter. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_async_005', 0, async function (done) { @@ -1120,13 +1120,13 @@ describe('fileIO_fs_stat', function () { * Invalid path or fd parameter. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_async_006', 0, async function (done) { try { - fileIO.stat(-1, () => { + fileIO.stat(-1, (err) => { expect(false).assertTrue(); }); } catch (e) { @@ -1143,7 +1143,7 @@ describe('fileIO_fs_stat', function () { * Enter the path or fd parameter to get stat.ino of the file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_async_ino_000', 0, async function (done) { @@ -1157,8 +1157,8 @@ describe('fileIO_fs_stat', function () { let file = fileIO.openSync(fpath); let stat2 = await fileIO.stat(file.fd); expect(isBigInt(stat2.ino)).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); } catch (e) { console.log('fileIO_stat_async_ino_000 has failed for ' + e.message + ', code: ' + e.code); @@ -1173,7 +1173,7 @@ describe('fileIO_fs_stat', function () { * Enter the path or fd parameter to get stat.atime of the file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_async_ino_001', 0, async function (done) { @@ -1196,8 +1196,8 @@ describe('fileIO_fs_stat', function () { expect(false).assertTrue(); } expect(isBigInt(stat2.ino)).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); }); } catch (e) { @@ -1213,7 +1213,7 @@ describe('fileIO_fs_stat', function () { * Enter the path or fd parameter to get stat.mode of the file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_async_mode_000', 0, async function (done) { @@ -1227,8 +1227,8 @@ describe('fileIO_fs_stat', function () { let file = fileIO.openSync(fpath); let stat2 = await fileIO.stat(file.fd); expect(isIntNum(stat2.mode)).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); } catch (e) { console.log('fileIO_stat_async_mode_000 has failed for ' + e.message + ', code: ' + e.code); @@ -1243,7 +1243,7 @@ describe('fileIO_fs_stat', function () { * Enter the path or fd parameter to get stat.mode of the file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_async_mode_001', 0, async function (done) { @@ -1266,8 +1266,8 @@ describe('fileIO_fs_stat', function () { expect(false).assertTrue(); } expect(isIntNum(stat2.mode)).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); }); } catch (e) { @@ -1283,7 +1283,7 @@ describe('fileIO_fs_stat', function () { * Enter the path or fd parameter to get stat.uid of the file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_async_uid_000', 0, async function (done) { @@ -1297,8 +1297,8 @@ describe('fileIO_fs_stat', function () { let file = fileIO.openSync(fpath); let stat2 = await fileIO.stat(file.fd); expect(isIntNum(stat2.uid)).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); } catch (e) { console.log('fileIO_stat_async_uid_000 has failed for ' + e.message + ', code: ' + e.code); @@ -1313,7 +1313,7 @@ describe('fileIO_fs_stat', function () { * Enter the path or fd parameter to get stat.uid of the file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_async_uid_001', 0, async function (done) { @@ -1336,8 +1336,8 @@ describe('fileIO_fs_stat', function () { expect(false).assertTrue(); } expect(isIntNum(stat2.uid)).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); }); } catch (e) { @@ -1354,7 +1354,7 @@ describe('fileIO_fs_stat', function () { * Enter the path or fd parameter to get stat.gid of the file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_async_gid_000', 0, async function (done) { @@ -1368,8 +1368,8 @@ describe('fileIO_fs_stat', function () { let file = fileIO.openSync(fpath); let stat2 = await fileIO.stat(file.fd); expect(isIntNum(stat2.gid)).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); } catch (e) { console.log('fileIO_stat_async_gid_000 has failed for ' + e.message + ', code: ' + e.code); @@ -1384,7 +1384,7 @@ describe('fileIO_fs_stat', function () { * Enter the path or fd parameter to get stat.gid of the file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_async_gid_001', 0, async function (done) { @@ -1407,8 +1407,8 @@ describe('fileIO_fs_stat', function () { expect(false).assertTrue(); } expect(isIntNum(stat2.gid)).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); }); } catch (e) { @@ -1424,7 +1424,7 @@ describe('fileIO_fs_stat', function () { * Enter the path or fd parameter to get stat.size of the file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_async_size_000', 0, async function (done) { @@ -1438,8 +1438,8 @@ describe('fileIO_fs_stat', function () { let file = fileIO.openSync(fpath); let stat2 = await fileIO.stat(file.fd); expect(isIntNum(stat2.size)).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); } catch (e) { console.log('fileIO_stat_async_size_000 has failed for ' + e.message + ', code: ' + e.code); @@ -1454,7 +1454,7 @@ describe('fileIO_fs_stat', function () { * Enter the path or fd parameter to get stat.size of the file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_async_size_001', 0, async function (done) { @@ -1477,8 +1477,8 @@ describe('fileIO_fs_stat', function () { expect(false).assertTrue(); } expect(isIntNum(stat2.size)).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); }); } catch (e) { @@ -1494,7 +1494,7 @@ describe('fileIO_fs_stat', function () { * Enter the path or fd parameter to get stat.atime of the file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_async_atime_000', 0, async function (done) { @@ -1508,8 +1508,8 @@ describe('fileIO_fs_stat', function () { let file = fileIO.openSync(fpath); let stat2 = await fileIO.stat(file.fd); expect(isIntNum(stat2.atime)).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); } catch (e) { console.log('fileIO_stat_async_atime_000 has failed for ' + e.message + ', code: ' + e.code); @@ -1524,7 +1524,7 @@ describe('fileIO_fs_stat', function () { * Enter the path or fd parameter to get stat.atime of the file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_async_atime_001', 0, async function (done) { @@ -1547,8 +1547,8 @@ describe('fileIO_fs_stat', function () { expect(false).assertTrue(); } expect(isIntNum(stat2.atime)).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); }); } catch (e) { @@ -1564,7 +1564,7 @@ describe('fileIO_fs_stat', function () { * Enter the path or fd parameter to get stat.mtime of the file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_async_mtime_000', 0, async function (done) { @@ -1578,8 +1578,8 @@ describe('fileIO_fs_stat', function () { let file = fileIO.openSync(fpath); let stat2 = await fileIO.stat(file.fd); expect(isIntNum(stat2.mtime)).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); } catch (e) { console.log('fileIO_stat_async_mtime_000 has failed for ' + e.message + ', code: ' + e.code); @@ -1594,7 +1594,7 @@ describe('fileIO_fs_stat', function () { * Enter the path or fd parameter to get stat.mtime of the file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_async_mtime_001', 0, async function (done) { @@ -1617,8 +1617,8 @@ describe('fileIO_fs_stat', function () { expect(false).assertTrue(); } expect(isIntNum(stat2.mtime)).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); }); } catch (e) { @@ -1634,7 +1634,7 @@ describe('fileIO_fs_stat', function () { * Enter the path or fd parameter to get stat.ctime of the file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_async_ctime_000', 0, async function (done) { @@ -1648,8 +1648,8 @@ describe('fileIO_fs_stat', function () { let file = fileIO.openSync(fpath); let stat2 = await fileIO.stat(file.fd); expect(isIntNum(stat2.ctime)).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); } catch (e) { console.log('fileIO_stat_async_ctime_000 has failed for ' + e.message + ', code: ' + e.code); @@ -1664,7 +1664,7 @@ describe('fileIO_fs_stat', function () { * Enter the path or fd parameter to get stat.ctime of the file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_async_ctime_001', 0, async function (done) { @@ -1687,8 +1687,8 @@ describe('fileIO_fs_stat', function () { expect(false).assertTrue(); } expect(isIntNum(stat2.ctime)).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); }); } catch (e) { @@ -1704,7 +1704,7 @@ describe('fileIO_fs_stat', function () { * This interface shall not treat a normal file as a block special device. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_async_is_block_device_000', 0, async function (done) { @@ -1718,8 +1718,8 @@ describe('fileIO_fs_stat', function () { let file = fileIO.openSync(fpath); let stat2 = await fileIO.stat(file.fd); expect(stat2.isBlockDevice() === false).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); } catch (e) { console.log('fileIO_stat_async_is_block_device_000 has failed for ' + e.message + ', code: ' + e.code); @@ -1734,7 +1734,7 @@ describe('fileIO_fs_stat', function () { * This interface shall not treat a normal file as a block special device. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_async_is_block_device_001', 0, async function (done) { @@ -1757,8 +1757,8 @@ describe('fileIO_fs_stat', function () { expect(false).assertTrue(); } expect(stat2.isBlockDevice() === false).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); }); } catch (e) { @@ -1774,7 +1774,7 @@ describe('fileIO_fs_stat', function () { * This interface shall not treat a normal file as a character special device. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_async_is_character_device_000', 0, async function (done) { @@ -1788,8 +1788,8 @@ describe('fileIO_fs_stat', function () { let file = fileIO.openSync(fpath); let stat2 = await fileIO.stat(file.fd); expect(stat2.isCharacterDevice() === false).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); } catch (e) { console.log('fileIO_stat_async_is_character_device_000 has failed for ' + e.message + ', code: ' + e.code); @@ -1804,7 +1804,7 @@ describe('fileIO_fs_stat', function () { * This interface shall not treat a normal file as a character special device. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_async_is_character_device_001', 0, async function (done) { @@ -1827,8 +1827,8 @@ describe('fileIO_fs_stat', function () { expect(false).assertTrue(); } expect(stat2.isCharacterDevice() === false).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); }); } catch (e) { @@ -1844,7 +1844,7 @@ describe('fileIO_fs_stat', function () { * This interface shall not treat a normal file as a directory. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_async_is_directory_000', 0, async function (done) { @@ -1858,8 +1858,8 @@ describe('fileIO_fs_stat', function () { let file = fileIO.openSync(fpath); let stat2 = await fileIO.stat(file.fd); expect(stat2.isDirectory() === false).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); } catch (e) { console.log('fileIO_stat_async_is_directory_000 has failed for ' + e.message + ', code: ' + e.code); @@ -1874,22 +1874,22 @@ describe('fileIO_fs_stat', function () { * This interface shall not treat a directory as a directory. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_async_is_directory_001', 0, async function (done) { let dpath = await nextFileName('fileIO_stat_async_is_directory_001') + 'd'; try { - fileio.mkdirSync(dpath); + fileIO.mkdirSync(dpath); let stat = await fileIO.stat(dpath); expect(stat.isDirectory() === true).assertTrue(); let file = fileIO.openSync(dpath, fileIO.OpenMode.DIR); let stat2 = await fileIO.stat(file.fd); expect(stat2.isDirectory() === true).assertTrue(); - fileio.closeSync(file.fd); - fileio.rmdirSync(dpath); + fileIO.closeSync(file); + fileIO.rmdirSync(dpath); done(); } catch (e) { console.log('fileIO_stat_async_is_directory_001 has failed for ' + e.message + ', code: ' + e.code); @@ -1904,14 +1904,14 @@ describe('fileIO_fs_stat', function () { * This interface shall not treat a directory as a directory. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @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); + fileIO.mkdirSync(dpath); fileIO.stat(dpath, (err, stat) => { if(err) { console.log('fileIO_stat_async_is_directory_002 error package1: ' + JSON.stringify(err)); @@ -1927,8 +1927,8 @@ describe('fileIO_fs_stat', function () { expect(false).assertTrue(); } expect(stat2.isDirectory() === true).assertTrue(); - fileio.closeSync(file.fd); - fileio.rmdirSync(dpath); + fileIO.closeSync(file); + fileIO.rmdirSync(dpath); done(); }); } catch (e) { @@ -1944,7 +1944,7 @@ describe('fileIO_fs_stat', function () { * This interface shall not treat a normal file as a FIFO. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_async_is_fifo_000', 0, async function (done) { @@ -1958,8 +1958,8 @@ describe('fileIO_fs_stat', function () { let file = fileIO.openSync(fpath); let stat2 = await fileIO.stat(file.fd); expect(stat2.isFIFO() === false).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); } catch (e) { console.log('fileIO_stat_async_is_fifo_000 has failed for ' + e.message + ', code: ' + e.code); @@ -1974,7 +1974,7 @@ describe('fileIO_fs_stat', function () { * This interface shall not treat a normal file as a FIFO. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_async_is_fifo_001', 0, async function (done) { @@ -1997,8 +1997,8 @@ describe('fileIO_fs_stat', function () { expect(false).assertTrue(); } expect(stat2.isFIFO() === false).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); }); } catch (e) { @@ -2014,7 +2014,7 @@ describe('fileIO_fs_stat', function () { * This interface shall treat a normal file as a normal file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_async_is_file_000', 0, async function (done) { @@ -2028,8 +2028,8 @@ describe('fileIO_fs_stat', function () { let file = fileIO.openSync(fpath); let stat2 = await fileIO.stat(file.fd); expect(stat2.isFile() === true).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); } catch (e) { console.log('fileIO_stat_async_is_file_000 has failed for ' + e.message + ', code: ' + e.code); @@ -2044,7 +2044,7 @@ describe('fileIO_fs_stat', function () { * This interface shall treat a normal file as a normal file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_async_is_file_001', 0, async function (done) { @@ -2067,8 +2067,8 @@ describe('fileIO_fs_stat', function () { expect(false).assertTrue(); } expect(stat2.isFile() === true).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); }); } catch (e) { @@ -2084,22 +2084,22 @@ describe('fileIO_fs_stat', function () { * This interface shall not treat a directory as a normal file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @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); + fileIO.mkdirSync(dpath); let stat = await fileIO.stat(dpath); expect(stat.isFile() === false).assertTrue(); let file = fileIO.openSync(dpath, fileIO.OpenMode.DIR); let stat2 = await fileIO.stat(file.fd); expect(stat2.isFile() === false).assertTrue(); - fileio.closeSync(file.fd); - fileio.rmdirSync(dpath); + fileIO.closeSync(file); + fileIO.rmdirSync(dpath); done(); } catch (e) { console.log('fileIO_stat_async_is_file_002 has failed for ' + e.message + ', code: ' + e.code); @@ -2114,7 +2114,7 @@ describe('fileIO_fs_stat', function () { * This interface shall not treat a file as a socket. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_async_is_socket_000', 0, async function (done) { @@ -2128,7 +2128,7 @@ describe('fileIO_fs_stat', function () { let file = fileIO.openSync(fpath); let stat2 = await fileIO.stat(file.fd); expect(stat2.isSocket() === false).assertTrue(); - fileio.closeSync(file.fd); + fileIO.closeSync(file); done(); } catch (e) { console.log('fileIO_stat_async_is_socket_000 has failed for ' + e.message + ', code: ' + e.code); @@ -2143,7 +2143,7 @@ describe('fileIO_fs_stat', function () { * This interface shall not treat a file as a socket. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_async_is_socket_001', 0, async function (done) { @@ -2166,8 +2166,8 @@ describe('fileIO_fs_stat', function () { expect(false).assertTrue(); } expect(stat2.isSocket() === false).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); }); } catch (e) { @@ -2183,7 +2183,7 @@ describe('fileIO_fs_stat', function () { * This interface shall not treat a normal file as a symbolic link. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_async_is_symbolic_link_000', 0, async function (done) { @@ -2197,8 +2197,8 @@ describe('fileIO_fs_stat', function () { let file = fileIO.openSync(fpath); let stat2 = await fileIO.stat(file.fd); expect(stat2.isSymbolicLink() === false).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); } catch (e) { console.log('fileIO_stat_async_is_symbolic_link_000 has failed for ' + e.message + ', code: ' + e.code); @@ -2213,7 +2213,7 @@ describe('fileIO_fs_stat', function () { * This interface shall not treat a normal file as a symbolic link. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_stat_async_is_symbolic_link_001', 0, async function (done) { @@ -2236,8 +2236,8 @@ describe('fileIO_fs_stat', function () { expect(false).assertTrue(); } expect(stat2.isSymbolicLink() === false).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); }); } catch (e) { @@ -2253,7 +2253,7 @@ describe('fileIO_fs_stat', function () { * Modify the file, view the file status changes by path. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_append_file_sync_000', 0, async function (done) { @@ -2267,11 +2267,11 @@ describe('fileIO_fs_stat', function () { 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); + fileIO.closeSync(file); stat = fileIO.statSync(fpath); expect(stat.size == FILE_CONTENT.length * 2).assertTrue(); - fileio.unlinkSync(fpath); + fileIO.unlinkSync(fpath); done(); } catch (e) { console.log('fileIO_test_append_file_sync_000 has failed for ' + e.message + ', code: ' + e.code); @@ -2286,7 +2286,7 @@ describe('fileIO_fs_stat', function () { * Modify the file, view the file status changes by fd. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_append_file_sync_001', 0, async function (done) { @@ -2299,13 +2299,13 @@ describe('fileIO_fs_stat', function () { 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); + fileIO.closeSync(file); 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); + fileIO.closeSync(file2.fd); + fileIO.unlinkSync(fpath); done(); } catch (e) { console.log('fileIO_test_append_file_sync_001 has failed for ' + e.message + ', code: ' + e.code); diff --git a/storage/storagefileiov9jstest/src/main/js/test/members/symlink.test.js b/storage/storagefileiov9jstest/src/main/js/test/members/symlink.test.js index 91b7d43f4606cf9fb7cbfb0e04712bdd6b0bb270..0e94637db91afd2949df45265a53be4dca6cffcd 100644 --- a/storage/storagefileiov9jstest/src/main/js/test/members/symlink.test.js +++ b/storage/storagefileiov9jstest/src/main/js/test/members/symlink.test.js @@ -52,7 +52,7 @@ describe('fileIO_fs_symlink', function () { * Missing parameter. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_symlink_sync_001', 0, async function () { @@ -84,10 +84,10 @@ describe('fileIO_fs_symlink', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - fileIO.symlink(fpath, fpath + 'link3').then(() => { - expect(fileIO.accessSync(fpath + 'link3')).assertTrue(); + fileIO.symlink(fpath, fpath + 'link1').then(() => { + expect(fileIO.accessSync(fpath + 'link1')).assertTrue(); fileIO.unlinkSync(fpath); - fileIO.unlinkSync(fpath + 'link3'); + fileIO.unlinkSync(fpath + 'link1'); }).catch((err) => { console.log('fileIO_test_symlink_async_000 error package: ' + JSON.stringify(err)); expect(false).assertTrue(); @@ -106,7 +106,7 @@ describe('fileIO_fs_symlink', function () { * Create a symbolic link to verify normal function. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_symlink_async_001', 0, async function (done) { @@ -114,10 +114,10 @@ describe('fileIO_fs_symlink', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - await fileIO.symlink(fpath, fpath + 'link4'); - expect(fileIO.accessSync(fpath + 'link4')).assertTrue(); + await fileIO.symlink(fpath, fpath + 'link2'); + expect(fileIO.accessSync(fpath + 'link2')).assertTrue(); fileIO.unlinkSync(fpath); - fileIO.unlinkSync(fpath + 'link4'); + fileIO.unlinkSync(fpath + 'link2'); done(); } catch (e) { console.log('fileIO_test_symlink_async_001 has failed for ' + e.message + ', code: ' + e.code); @@ -132,7 +132,7 @@ describe('fileIO_fs_symlink', function () { * Create a symbolic link to verify normal function. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_symlink_async_002', 0, async function (done) { @@ -140,14 +140,14 @@ describe('fileIO_fs_symlink', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - fileIO.symlink(fpath, fpath + 'link5', (err) => { + fileIO.symlink(fpath, fpath + 'link3', (err) => { if (err) { console.log('fileIO_test_symlink_async_002 error package: ' + JSON.stringify(err)); expect(false).assertTrue(); } - expect(fileIO.accessSync(fpath + 'link5')).assertTrue(); + expect(fileIO.accessSync(fpath + 'link3')).assertTrue(); fileIO.unlinkSync(fpath); - fileIO.unlinkSync(fpath + 'link5'); + fileIO.unlinkSync(fpath + 'link3'); done(); }); } catch (e) { @@ -163,7 +163,7 @@ describe('fileIO_fs_symlink', function () { * Missing parameter. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_symlink_async_003', 0, async function (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 index 39d2b2bc7c11054614ddd3cba8e9e0ff90309ac5..654f1dd4f0e19370674d949692ce15685f20fa01 100644 --- a/storage/storagefileiov9jstest/src/main/js/test/members/truncate.test.js +++ b/storage/storagefileiov9jstest/src/main/js/test/members/truncate.test.js @@ -14,8 +14,7 @@ */ import { - fileio, fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum, - describe, it, expect, + fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum, describe, it, expect, } from '../Common'; export default function fileIOTruncate() { @@ -40,13 +39,13 @@ import { 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); + let readLen = fileIO.readSync(file.fd, new ArrayBuffer(4096)); + expect(readLen == truncateLen).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); } catch (e) { - console.info('fileIO_truncate_async_000 has failed for ' + e.message + ', code: ' + e.code); + console.log('fileIO_truncate_async_000 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); } }); @@ -58,7 +57,7 @@ import { * Truncate the file with fd and truncateLen = 5. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_truncate_async_001', 0, async function (done) { @@ -74,12 +73,12 @@ import { console.log('fileIO_truncate_async_001 error package: ' + JSON.stringify(err)); expect(false).assertTrue(); } - let len = fileIO.readSync(file.fd, new ArrayBuffer(4096)); - expect(len == truncateLen).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + let readLen = fileIO.readSync(file.fd, new ArrayBuffer(4096)); + expect(readLen == truncateLen).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); - }) + }); } catch (e) { console.log('fileIO_truncate_async_001 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -93,7 +92,7 @@ import { * Truncate the file with path and truncateLen = 2. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_truncate_async_002', 0, async function (done) { @@ -105,10 +104,10 @@ import { fileIO.truncate(fpath, truncateLen).then(() => { 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); + let readLen = fileIO.readSync(file.fd, new ArrayBuffer(4096)); + expect(readLen == truncateLen).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); }).catch((err) => { console.log('fileIO_truncate_async_002 error package: ' + JSON.stringify(err)); @@ -127,7 +126,7 @@ import { * Truncate the file with fd and truncateLen = 2. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_truncate_async_003', 0, async function (done) { @@ -139,15 +138,15 @@ import { try { expect(isIntNum(file.fd)).assertTrue(); fileIO.truncate(file.fd, truncateLen).then(() => { - let len = fileIO.readSync(file.fd, new ArrayBuffer(4096)); - expect(len == truncateLen).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + let readLen = fileIO.readSync(file.fd, new ArrayBuffer(4096)); + expect(readLen == truncateLen).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); }).catch((err) => { console.log('fileIO_truncate_async_003 error package: ' + JSON.stringify(err)); expect(false).assertTrue(); - }) + }); } catch(e) { console.log('fileIO_truncate_async_003 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -158,10 +157,10 @@ import { * @tc.number SUB_DF_FILEIO_TRUNCATE_ASYNC_0400 * @tc.name fileIO_truncate_async_004 * @tc.desc Test the truncate() interface. Callback. - * Truncate the file with path and truncateLen = 2. + * The path point to nothing, no such file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_truncate_async_004', 0, async function (done) { @@ -171,7 +170,7 @@ import { try { fileIO.truncate(fpath, truncateLen, (err) => { if (err) { - console.log('fileIO_truncate_async_004 error package: {' + err.message + ', code: ' + err.code + '}'); + console.log('fileIO_truncate_async_004 error: {message: ' + err.message + ', code: ' + err.code + '}'); expect(err.code == 13900002 && err.message == 'No such file or directory').assertTrue(); done(); } @@ -186,10 +185,10 @@ import { * @tc.number SUB_DF_FILEIO_TRUNCATE_ASYNC_0500 * @tc.name fileIO_truncate_async_005 * @tc.desc Test the truncate() interface. Promise. - * Truncate the file with path and truncateLen = 2. + * The path point to nothing, no such file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_truncate_async_005', 0, async function (done) { @@ -206,6 +205,74 @@ import { } }); + /** + * @tc.number SUB_DF_FILEIO_TRUNCATE_ASYNC_0600 + * @tc.name fileIO_truncate_async_006 + * @tc.desc Test the truncate() interface. Callback. + * Truncate the file with fd and truncateLen = 0. + * @tc.size MEDIUM + * @tc.type Functoin + * @tc.level Level 3 + * @tc.require + */ + it('fileIO_truncate_async_006', 0, async function (done) { + let fpath = await nextFileName('fileIO_truncate_async_006'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); + + try { + expect(isIntNum(file.fd)).assertTrue(); + fileIO.truncate(file.fd, (err) => { + if(err) { + console.log('fileIO_truncate_async_006 error package: ' + JSON.stringify(err)); + expect(false).assertTrue(); + } + let readLen = fileIO.readSync(file.fd, new ArrayBuffer(4096)); + expect(readLen == 0).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + done(); + }); + } catch (e) { + console.log('fileIO_truncate_async_006 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_TRUNCATE_ASYNC_0700 + * @tc.name fileIO_truncate_async_007 + * @tc.desc Test the truncate() interface. Callback. + * Truncate the file with fd and truncateLen = 0. + * @tc.size MEDIUM + * @tc.type Functoin + * @tc.level Level 3 + * @tc.require + */ + it('fileIO_truncate_async_007', 0, async function (done) { + let fpath = await nextFileName('fileIO_truncate_async_007'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + fileIO.truncate(fpath, (err) => { + if(err) { + console.log('fileIO_truncate_async_007 error package: ' + JSON.stringify(err)); + expect(false).assertTrue(); + } + 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 == 0).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + done(); + }); + } catch (e) { + console.log('fileIO_truncate_async_008 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + /** * @tc.number SUB_DF_FILEIO_TRUNCATE_SYNC_0000 * @tc.name fileIO_test_truncate_sync_000 @@ -213,7 +280,7 @@ import { * Truncate the file with path. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_truncate_sync_000', 0, async function () { @@ -223,7 +290,7 @@ import { try { fileIO.truncateSync(fpath); expect(fileIO.statSync(fpath).size == 0).assertTrue(); - fileio.unlinkSync(fpath); + fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_truncate_sync_000 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -237,7 +304,7 @@ import { * Truncate the file with fd and truncateLen = 5. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_truncate_sync_001', 0, async function () { @@ -249,10 +316,10 @@ import { try { 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); + let readLen = fileIO.readSync(file.fd, new ArrayBuffer(4096)); + expect(readLen == truncateLen).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_truncate_sync_001 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -266,7 +333,7 @@ import { * The path point to nothing, no such file. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_truncate_sync_002', 0, async function () { @@ -287,7 +354,7 @@ import { * @tc.desc Test the truncateSync() interface. Invalid parameter. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_truncate_sync_003', 0, async function () { @@ -308,7 +375,7 @@ import { * @tc.desc Test truncateSync() interfaces. Missing parameters. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_truncate_sync_004', 0, function () { diff --git a/storage/storagefileiov9jstest/src/main/js/test/members/unlink.test.js b/storage/storagefileiov9jstest/src/main/js/test/members/unlink.test.js index b0113c88f8792d6608ac131dc23007db39186117..5fb4d2d5d40a45980f3441a6db82f3efaaee80cc 100644 --- a/storage/storagefileiov9jstest/src/main/js/test/members/unlink.test.js +++ b/storage/storagefileiov9jstest/src/main/js/test/members/unlink.test.js @@ -14,8 +14,7 @@ */ import { - fileIO, FILE_CONTENT, prepareFile, nextFileName, - describe, it, expect, + fileIO, FILE_CONTENT, prepareFile, nextFileName, describe, it, expect, } from '../Common'; export default function fileIOUnlink() { @@ -88,7 +87,7 @@ describe('fileIO_fs_unlink', function () { }); /** - * @tc.number SUB_DF_FileIO_UNLINKASYNC_0000 + * @tc.number SUB_DF_FileIO_UNLINK_ASYNC_0000 * @tc.name fileIO_test_unlink_async_000 * @tc.desc Test unlinkAsync() interfaces. Promise. * Delete the file by path, verify the normal function. @@ -113,7 +112,7 @@ describe('fileIO_fs_unlink', function () { }); /** - * @tc.number SUB_DF_FileIO_UNLINKASYNC_0100 + * @tc.number SUB_DF_FileIO_UNLINK_ASYNC_0100 * @tc.name fileIO_test_unlink_async_001 * @tc.desc Test unlinkAsync() interfaces. Callback. * Delete the file by path, verify the normal function. @@ -143,7 +142,7 @@ describe('fileIO_fs_unlink', function () { }); /** - * @tc.number SUB_DF_FileIO_UNLINKASYNC_0200 + * @tc.number SUB_DF_FileIO_UNLINK_ASYNC_0200 * @tc.name fileIO_test_unlink_async_002 * @tc.desc Test unlink() interfaces. Callback. * The path point to nothing, no such file. @@ -158,7 +157,7 @@ describe('fileIO_fs_unlink', function () { try { fileIO.unlink(fpath, (err) => { if (err) { - console.log('fileIO_test_unlink_async_002 error package: {' + err.message + ', code: ' + err.code + '}'); + console.log('fileIO_test_unlink_async_002 error: {message: ' + err.message + ', code: ' + err.code + '}'); expect(err.code == 13900002 && err.message == 'No such file or directory').assertTrue(); done(); } @@ -170,7 +169,7 @@ describe('fileIO_fs_unlink', function () { }); /** - * @tc.number SUB_DF_FileIO_UNLINKASYNC_0300 + * @tc.number SUB_DF_FileIO_UNLINK_ASYNC_0300 * @tc.name fileIO_test_unlink_async_003 * @tc.desc Test unlink() interfaces. Promise. * The path point to nothing, no such file. @@ -193,7 +192,7 @@ describe('fileIO_fs_unlink', function () { }); /** - * @tc.number SUB_DF_FileIO_UNLINKASYNC_0400 + * @tc.number SUB_DF_FileIO_UNLINK_ASYNC_0400 * @tc.name fileIO_test_unlink_async_004 * @tc.desc Test unlink() interfaces. Promise. * Missing parameter. diff --git a/storage/storagefileiov9jstest/src/main/js/test/members/write.test.js b/storage/storagefileiov9jstest/src/main/js/test/members/write.test.js index 883c67852aeba1a3f068e1f7bc029ee5b2be262b..c2b36e1e56a240f996f8d615cbc9af54672132ca 100644 --- a/storage/storagefileiov9jstest/src/main/js/test/members/write.test.js +++ b/storage/storagefileiov9jstest/src/main/js/test/members/write.test.js @@ -14,8 +14,7 @@ */ import { - fileio, fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum, - describe, it, expect, + fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum, describe, it, expect, } from '../Common'; export default function fileIOWrite() { @@ -38,11 +37,10 @@ export default function fileIOWrite() { 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); + let bytesWritten = fileIO.writeSync(file.fd, FILE_CONTENT); + expect(bytesWritten == FILE_CONTENT.length).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_write_sync_000 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -56,7 +54,7 @@ export default function fileIOWrite() { * Open the file in write-only mode, writing a string with encoding = 'utf-8'. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_write_sync_001', 0, async function () { @@ -66,13 +64,12 @@ export default function fileIOWrite() { 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); + let bytesWritten = fileIO.writeSync(file.fd, FILE_CONTENT, { + encoding: 'utf-8', + }) + expect(bytesWritten == FILE_CONTENT.length).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_write_sync_001 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -86,7 +83,7 @@ export default function fileIOWrite() { * Open the file in write-only mode, writing a string from offset(position) = 1. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_write_sync_002', 0, async function () { @@ -96,13 +93,12 @@ export default function fileIOWrite() { try { let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); expect(isIntNum(file.fd)).assertTrue(); - expect( - fileIO.writeSync(file.fd, FILE_CONTENT, { - offset: 1, - }) - == FILE_CONTENT.length).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + let bytesWritten = fileIO.writeSync(file.fd, FILE_CONTENT, { + offset: 1, + }); + expect(bytesWritten == FILE_CONTENT.length).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_write_sync_002 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -116,7 +112,7 @@ export default function fileIOWrite() { * Open the file in write-only mode, writing a string of length = 1. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_write_sync_003', 0, async function () { @@ -126,13 +122,12 @@ export default function fileIOWrite() { 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); + let bytesWritten = fileIO.writeSync(file.fd, FILE_CONTENT, { + length: 1, + }); + expect(bytesWritten == 1).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_write_sync_003 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -146,25 +141,24 @@ export default function fileIOWrite() { * Open the file in write-only mode, writing a string of length = 1 and offset(position) = 1. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ - it('fileio_test_write_sync_004', 0, async function () { - let fpath = await nextFileName('fileio_test_write_sync_004'); + it('fileIO_test_write_sync_004', 0, async function () { + let fpath = await nextFileName('fileIO_test_write_sync_004'); 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, { - offset: 1, - length: 1, - }) - == 1).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); - } catch (e) { - console.log('fileio_test_write_sync_004 has failed for ' + e.message + ', code: ' + e.code); + let bytesWritten = fileIO.writeSync(file.fd, FILE_CONTENT, { + offset: 1, + length: 1, + }); + expect(bytesWritten == 1).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + } catch (e) { + console.log('fileIO_test_write_sync_004 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); } }); @@ -176,7 +170,7 @@ export default function fileIOWrite() { * Open the file in write-only mode, writing a string of length = 1, offset(position) = 1, encoding = 'utf-8'. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_write_sync_005', 0, async function () { @@ -185,18 +179,17 @@ export default function fileIOWrite() { try { let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); expect(isIntNum(file.fd)).assertTrue(); - expect( - fileIO.writeSync(file.fd, FILE_CONTENT, { - offset: 1, - length: 5, - encoding: 'utf-8', - }) - == 5).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + let bytesWritten = fileIO.writeSync(file.fd, FILE_CONTENT, { + offset: 1, + length: 5, + encoding: 'utf-8', + }); + expect(bytesWritten == 5).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_write_sync_005 has failed for ' + e.message + ', code: ' + e.code); - expect(null).assertFail(); + expect(false).assertTrue(); } }); @@ -207,23 +200,23 @@ export default function fileIOWrite() { * Write with invalid 'length' option. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @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(); let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); - + const invalidLength = 9999; + try { expect(isIntNum(file.fd)).assertTrue(); - const invalidLength = 9999; 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_006 has failed for ' + e.message + ', code: ' + e.code); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + console.log('fileIO_test_write_sync_006 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); } }); @@ -235,7 +228,7 @@ export default function fileIOWrite() { * Write with invalid fd parameters. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_write_sync_007', 0, function () { @@ -256,7 +249,7 @@ export default function fileIOWrite() { * Open the file in write-only mode, writing an ArrayBuffer(4096). * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_write_sync_008', 0, async function () { @@ -266,10 +259,10 @@ export default function fileIOWrite() { 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); + let bytesWritten = fileIO.writeSync(file.fd, new ArrayBuffer(4096)); + expect(bytesWritten == 4096).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); } catch (e) { console.log('fileIO_test_write_sync_008 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -283,23 +276,23 @@ export default function fileIOWrite() { * Write with invalid 'length' option. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_write_sync_009', 0, async function () { let fpath = await nextFileName('fileIO_test_write_sync_009'); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); - + const invalidLength = 4097; + try { expect(isIntNum(file.fd)).assertTrue(); - const invalidLength = 4097; fileIO.writeSync(file.fd, new ArrayBuffer(4096), { length: invalidLength }) expect(false).assertTrue(); } catch (e) { - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); - console.info('fileIO_test_write_sync_009 has failed for ' + e.message + ', code: ' + e.code); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + console.log('fileIO_test_write_sync_009 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); } }); @@ -311,23 +304,23 @@ export default function fileIOWrite() { * Write with invalid 'offset' option. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_write_sync_010', 0, async function () { let fpath = await nextFileName('fileIO_test_write_sync_010'); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); - + const invalidOffset = -1; + try { expect(isIntNum(file.fd)).assertTrue(); - const invalidOffset = -1; fileIO.writeSync(file.fd, FILE_CONTENT, { offset: invalidOffset }); expect(false).assertTrue(); } catch (e) { - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); - console.info('fileIO_test_write_sync_010 has failed for ' + e.message + ', code: ' + e.code); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + console.log('fileIO_test_write_sync_010 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); } }); @@ -349,10 +342,10 @@ export default function fileIOWrite() { try { let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); expect(isIntNum(file.fd)).assertTrue(); - let writeLen = await fileIO.write(file.fd, FILE_CONTENT); - expect(writeLen == FILE_CONTENT.length).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + let bytesWritten = await fileIO.write(file.fd, FILE_CONTENT); + expect(bytesWritten == FILE_CONTENT.length).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); } catch (e) { console.log('fileIO_test_write_async_000 has failed for ' + e.message + ', code: ' + e.code); @@ -367,7 +360,7 @@ export default function fileIOWrite() { * Open the file in write-only mode, verifying the normal write function. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_write_async_001', 0, async function (done) { @@ -377,10 +370,10 @@ export default function fileIOWrite() { try { let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); expect(isIntNum(file.fd)).assertTrue(); - let writeLen = await fileIO.write(file.fd, FILE_CONTENT); - expect(writeLen == FILE_CONTENT.length).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + let bytesWritten = await fileIO.write(file.fd, FILE_CONTENT); + expect(bytesWritten == FILE_CONTENT.length).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); } catch (e) { console.log('fileIO_test_write_async_001 has failed for ' + e.message + ', code: ' + e.code); @@ -395,7 +388,7 @@ export default function fileIOWrite() { * Open the file in read-only mode, verifying that it is not writable. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_write_async_002', 0, async function (done) { @@ -408,8 +401,8 @@ export default function fileIOWrite() { await fileIO.write(file.fd, FILE_CONTENT); expect(false).assertTrue(); } catch (e) { - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); console.log('fileIO_test_write_async_002 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900008 && e.message == 'Bad file descriptor').assertTrue(); done(); @@ -423,7 +416,7 @@ export default function fileIOWrite() { * Open the file in read-only mode, verifying that it is not writable. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_write_async_003', 0, async function (done) { @@ -435,9 +428,9 @@ export default function fileIOWrite() { expect(isIntNum(file.fd)).assertTrue(); fileIO.write(file.fd, FILE_CONTENT, (err) => { if(err) { - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); - console.log('fileIO_test_write_async_003 error package: {' + err.message + ', code: ' + err.code + '}'); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + console.log('fileIO_test_write_async_003 error: {message: ' + err.message + ', code: ' + err.code + '}'); expect(err.code == 13900008 && err.message == 'Bad file descriptor').assertTrue(); done(); } @@ -455,7 +448,7 @@ export default function fileIOWrite() { * Open the file in write-only mode, writing a string of length = 3. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_write_async_004', 0, async function (done) { @@ -469,8 +462,8 @@ export default function fileIOWrite() { length: 3, }); expect(bytesWritten == 3).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); } catch (e) { console.log('fileIO_test_write_async_004 has failed for ' + e.message + ', code: ' + e.code); @@ -485,7 +478,7 @@ export default function fileIOWrite() { * Open the file in write-only mode, writing a string of length = 3. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_write_async_005', 0, async function (done) { @@ -495,14 +488,16 @@ export default function fileIOWrite() { try { let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); expect(isIntNum(file.fd)).assertTrue(); - fileIO.write(file.fd, FILE_CONTENT, { length: 3 }, (err, bytesWritten) => { + fileIO.write(file.fd, FILE_CONTENT, { + length: 3, + }, (err, bytesWritten) => { if(err) { console.log('fileIO_test_write_async_005 err package: ' + JSON.stringify(err)); expect(false).assertTrue(); } expect(bytesWritten == 3).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); }); } catch (e) { @@ -518,7 +513,7 @@ export default function fileIOWrite() { * Open the file in write-only mode, writing a string from offset(position) = 5. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_write_async_006', 0, async function (done) { @@ -528,12 +523,12 @@ export default function fileIOWrite() { try { let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); expect(isIntNum(file.fd)).assertTrue(); - let writeNum = await fileIO.write(file.fd, FILE_CONTENT, { + let bytesWritten = await fileIO.write(file.fd, FILE_CONTENT, { offset: 5, }); - expect(writeNum == FILE_CONTENT.length).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + expect(bytesWritten == FILE_CONTENT.length).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); } catch (e) { console.log('fileIO_test_write_async_006 has failed for ' + e.message + ', code: ' + e.code); @@ -548,7 +543,7 @@ export default function fileIOWrite() { * Open the file in write-only mode, writing a string from offset(position) = 5. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_write_async_007', 0, async function (done) { @@ -559,17 +554,17 @@ export default function fileIOWrite() { let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); expect(isIntNum(file.fd)).assertTrue(); fileIO.write(file.fd, FILE_CONTENT, { - offset: 5 - }, (err, bytesWritten) => { - if(err) { - console.log('fileIO_test_write_async_007 err package: ' + JSON.stringify(err)); - expect(false).assertTrue(); - } - expect(bytesWritten == FILE_CONTENT.length).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); - done(); - }); + offset: 5, + }, (err, bytesWritten) => { + if(err) { + console.log('fileIO_test_write_async_007 err package: ' + JSON.stringify(err)); + expect(false).assertTrue(); + } + expect(bytesWritten == FILE_CONTENT.length).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + done(); + }); } catch (e) { console.log('fileIO_test_write_async_007 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -583,7 +578,7 @@ export default function fileIOWrite() { * Open the file in write-only mode, writing a string of with length = 3 and offset = 5. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_write_async_008', 0, async function (done) { @@ -593,13 +588,13 @@ export default function fileIOWrite() { try { let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); expect(isIntNum(file.fd)).assertTrue(); - let writeNum = await fileIO.write(file.fd, FILE_CONTENT, { + let bytesWritten = await fileIO.write(file.fd, FILE_CONTENT, { length: 3, offset: 5, }); - expect(writeNum == 3).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + expect(bytesWritten == 3).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); } catch (e) { console.log('fileIO_test_write_async_008 has failed for ' + e.message + ', code: ' + e.code); @@ -614,7 +609,7 @@ export default function fileIOWrite() { * Open the file in write-only mode, writing a string of with length = 3 and offset = 5. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_write_async_009', 0, async function (done) { @@ -625,18 +620,18 @@ export default function fileIOWrite() { let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); expect(isIntNum(file.fd)).assertTrue(); fileIO.write(file.fd, FILE_CONTENT, { - length: 3, - offset: 5, - }, (err, writeNum) => { - if(err) { - console.log('fileIO_test_write_async_009 err package: ' + JSON.stringify(err)); - expect(false).assertTrue(); - } - expect(writeNum == 3).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); - done(); - }); + length: 3, + offset: 5, + }, (err, bytesWritten) => { + if(err) { + console.log('fileIO_test_write_async_009 err package: ' + JSON.stringify(err)); + expect(false).assertTrue(); + } + expect(bytesWritten == 3).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + done(); + }); } catch (e) { console.log('fileIO_test_write_async_009 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -650,7 +645,7 @@ export default function fileIOWrite() { * Open the file in write-only mode, writing a string of with length = 3, offset = 5 and encoding = 'utf-8'. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_write_async_010', 0, async function (done) { @@ -660,14 +655,14 @@ export default function fileIOWrite() { try { let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); expect(isIntNum(file.fd)).assertTrue(); - let writeNum = await fileIO.write(file.fd, FILE_CONTENT, { + let bytesWritten = 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); + expect(bytesWritten == 4).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); } catch (e) { console.log('fileIO_test_write_async_010 has failed for ' + e.message + ', code: ' + e.code); @@ -682,7 +677,7 @@ export default function fileIOWrite() { * Open the file in write-only mode, writing a string of with length = 3, offset = 5 and encoding = 'utf-8'. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_write_async_011', 0, async function (done) { @@ -693,20 +688,19 @@ export default function fileIOWrite() { let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); expect(isIntNum(file.fd)).assertTrue(); fileIO.write(file.fd, FILE_CONTENT, { - length: 5, - offset: 5, - encoding: 'utf-8', - }, (err, bytesWritten) => { - if(err) { - console.log('fileIO_test_write_async_011 err package: ' + JSON.stringify(err)); - expect(false).assertTrue(); - } - expect(bytesWritten == 5).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); - done(); + length: 5, + offset: 5, + encoding: 'utf-8', + }, (err, bytesWritten) => { + if(err) { + console.log('fileIO_test_write_async_011 err package: ' + JSON.stringify(err)); + expect(false).assertTrue(); } - ); + expect(bytesWritten == 5).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + done(); + }); } catch (e) { console.log('fileIO_test_write_async_011 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -720,7 +714,7 @@ export default function fileIOWrite() { * Open the file in write-only mode, writing an ArrayBuffer(4096). * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_write_async_012', 0, async function (done) { @@ -732,8 +726,8 @@ export default function fileIOWrite() { expect(isIntNum(file.fd)).assertTrue(); let bytesWritten = await fileIO.write(file.fd, new ArrayBuffer(4096)); expect(bytesWritten == 4096).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); } catch (e) { console.log('fileIO_test_write_async_012 has failed for ' + e.message + ', code: ' + e.code); @@ -748,7 +742,7 @@ export default function fileIOWrite() { * Open the file in write-only mode, writing an ArrayBuffer(4096). * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_write_async_013', 0, async function (done) { @@ -764,8 +758,8 @@ export default function fileIOWrite() { expect(false).assertTrue(); } expect(bytesWritten == 4096).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); }); } catch (e) { @@ -781,7 +775,7 @@ export default function fileIOWrite() { * Open the file in write-only mode, writing a string with empty option parameters. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_write_async_014', 0, async function (done) { @@ -793,8 +787,8 @@ export default function fileIOWrite() { expect(isIntNum(file.fd)).assertTrue(); let bytesWritten = await fileIO.write(file.fd, FILE_CONTENT, {}); expect(bytesWritten == FILE_CONTENT.length).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); done(); } catch (e) { console.log('fileIO_test_write_async_014 has failed for ' + e.message + ', code: ' + e.code); @@ -809,7 +803,7 @@ export default function fileIOWrite() { * Open the file in write-only mode, writing a string with empty option parameters. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_write_async_015', 0, async function (done) { @@ -820,16 +814,16 @@ export default function fileIOWrite() { let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); expect(isIntNum(file.fd)).assertTrue(); fileIO.write(file.fd, new ArrayBuffer(4096), { - }, (err, bytesWritten) => { - if(err) { - console.log('fileIO_test_write_async_015 err package ' + JSON.stringify(err)); - expect(false).assertTrue(); - } - expect(bytesWritten == 4096).assertTrue(); - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); - done(); - }); + }, (err, bytesWritten) => { + if(err) { + console.log('fileIO_test_write_async_015 err package ' + JSON.stringify(err)); + expect(false).assertTrue(); + } + expect(bytesWritten == 4096).assertTrue(); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + done(); + }); } catch (e) { console.log('fileIO_test_write_async_015 has failed for ' + e.message + ', code: ' + e.code); expect(false).assertTrue(); @@ -843,7 +837,7 @@ export default function fileIOWrite() { * Write with invalid fd parameters. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_write_async_016', 0, async function (done) { @@ -854,7 +848,7 @@ export default function fileIOWrite() { await fileIO.write(-1, FILE_CONTENT); expect(false).assertTrue(); } catch (e) { - fileio.unlinkSync(fpath); + fileIO.unlinkSync(fpath); console.log('fileIO_test_write_async_016 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900008 && e.message == 'Bad file descriptor').assertTrue(); done(); @@ -868,7 +862,7 @@ export default function fileIOWrite() { * Write with invalid fd parameters. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_write_async_017', 0, async function (done) { @@ -878,8 +872,8 @@ export default function fileIOWrite() { try { fileIO.write(-1, FILE_CONTENT, (err) => { if(err) { - fileio.unlinkSync(fpath); - console.log('fileIO_test_open_async_020 error package: {' + err.message + ', code: ' + err.code + '}'); + fileIO.unlinkSync(fpath); + console.log('fileIO_test_open_async_020 error: {message: ' + err.message + ', code: ' + err.code + '}'); expect(err.code == 13900008 && err.message == 'Bad file descriptor').assertTrue(); done(); } @@ -896,26 +890,26 @@ export default function fileIOWrite() { * Write with invalid length parameters. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_write_async_018', 0, async function (done) { let fpath = await nextFileName('fileIO_test_write_async_018'); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); - + const invalidLength = 9999; + try { expect(isIntNum(file.fd)).assertTrue(); - const invalidLength = 9999; fileIO.write(file.fd, FILE_CONTENT, { - length: invalidLength, - }, () => { - expect(false).assertTrue(); - }) + length: invalidLength, + }, (err) => { + expect(false).assertTrue(); + }); } catch (e) { - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); - console.info('fileIO_test_write_async_018 has failed for ' + e.message + ', code: ' + e.code); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + console.log('fileIO_test_write_async_018 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); done(); } @@ -928,26 +922,26 @@ export default function fileIOWrite() { * Write with invalid length parameters. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_write_async_019', 0, async function (done) { let fpath = await nextFileName('fileIO_test_write_async_019'); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); - + const invalidLength = 4097; + try { expect(isIntNum(file.fd)).assertTrue(); - const invalidLength = 4097; fileIO.write(file.fd, new ArrayBuffer(4096), { length: invalidLength, - }, () => { - expect(false).assertTrue(); - }) + }, (err) => { + expect(false).assertTrue(); + }); } catch (e) { - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); - console.info('fileIO_test_write_async_019 has failed for ' + e.message + ', code: ' + e.code); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + console.log('fileIO_test_write_async_019 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); done(); } @@ -960,26 +954,26 @@ export default function fileIOWrite() { * Write with invalid length parameters. * @tc.size MEDIUM * @tc.type Functoin - * @tc.level Level 0 + * @tc.level Level 3 * @tc.require */ it('fileIO_test_write_async_020', 0, async function (done) { let fpath = await nextFileName('fileIO_test_write_async_020'); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); - + const invalidOffset = -1; + try { expect(isIntNum(file.fd)).assertTrue(); - const invalidOffset = -1; fileIO.write(file.fd, FILE_CONTENT, { - offset: invalidOffset, - }, () => { - expect(false).assertTrue(); - }) + offset: invalidOffset, + }, (err) => { + expect(false).assertTrue(); + }); } catch (e) { - fileio.closeSync(file.fd); - fileio.unlinkSync(fpath); - console.info('fileIO_test_write_async_020 has failed for ' + e.message + ', code: ' + e.code); + fileIO.closeSync(file); + fileIO.unlinkSync(fpath); + console.log('fileIO_test_write_async_020 has failed for ' + e.message + ', code: ' + e.code); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); done(); }