未验证 提交 c2937281 编写于 作者: O openharmony_ci 提交者: Gitee

!7394 【回合monthly】Add XTS for lstat, symlink hash, readText, access mkdtemp,...

!7394 【回合monthly】Add XTS for lstat, symlink hash, readText, access mkdtemp, rename, copyFile interfaces of mod_fs
Merge pull request !7394 from zhuhongtao666/cherry-pick-1675386955
/* /*
* 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'); * Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
* limitations under the License. * limitations under the License.
*/ */
import fileio from '@ohos.fileio';
import fileIO from '@ohos.file.fs'; import fileIO from '@ohos.file.fs';
import util from '@ohos.util'; import util from '@ohos.util';
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.featureAbility';
...@@ -30,8 +29,8 @@ export function prepareFile(fpath, content) { ...@@ -30,8 +29,8 @@ export function prepareFile(fpath, content) {
let file = fileIO.openSync(fpath, fileIO.OpenMode.CREATE | fileIO.OpenMode.READ_WRITE) let file = fileIO.openSync(fpath, fileIO.OpenMode.CREATE | fileIO.OpenMode.READ_WRITE)
fileIO.truncateSync(file.fd) fileIO.truncateSync(file.fd)
fileIO.writeSync(file.fd, content) fileIO.writeSync(file.fd, content)
fileio.fsyncSync(file.fd) fileIO.fsyncSync(file.fd)
fileio.closeSync(file.fd) fileIO.closeSync(file)
return true return true
} }
catch (e) { catch (e) {
...@@ -40,46 +39,6 @@ export function prepareFile(fpath, content) { ...@@ -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) { export async function nextFileName(testName) {
let context = featureAbility.getContext(); let context = featureAbility.getContext();
let data = await context.getCacheDir(); let data = await context.getCacheDir();
...@@ -105,15 +64,6 @@ export function randomString(num) { ...@@ -105,15 +64,6 @@ export function randomString(num) {
return pwd; 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) { function isIntNum(val) {
return typeof val === 'number' && val % 1 === 0; return typeof val === 'number' && val % 1 === 0;
} }
...@@ -126,22 +76,11 @@ function isString(str) { ...@@ -126,22 +76,11 @@ function isString(str) {
return (typeof str == 'string') && str.constructor == String; 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 { export {
fileio,
fileIO, fileIO,
isIntNum, isIntNum,
isBigInt, isBigInt,
isString, isString,
isBoolean,
isInclude,
describe, describe,
it, it,
expect, expect,
......
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum, describe, it, expect,
} from '../Common';
export default function fileIOAccess() {
describe('fileIO_fs_access', function () {
/**
* @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.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_access_sync_000', 0, async function () {
let fpath = await nextFileName('fileIO_test_access_sync_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
expect(fileIO.accessSync(fpath)).assertTrue();
let file = fileIO.openSync(fpath);
expect(isIntNum(file.fd)).assertTrue();
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_access_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @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.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_access_sync_001', 0, async function () {
let fpath = await nextFileName('fileIO_test_access_sync_001');
try {
let ret = fileIO.accessSync(fpath);
expect(ret === false).assertTrue();
} catch (e) {
console.log('fileIO_test_access_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @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.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_access_sync_002', 0, async function () {
try {
expect(fileIO.accessSync(-1)).assertTrue();
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_access_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @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.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_access_async_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_access_async_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ret = await fileIO.access(fpath);
expect(ret === true).assertTrue();
let file = fileIO.openSync(fpath);
expect(isIntNum(file.fd)).assertTrue();
let readlen = fileIO.readSync(file.fd, new ArrayBuffer(4096));
expect(readlen == FILE_CONTENT.length).assertTrue();
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_test_access_async_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @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.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_access_async_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_access_async_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.access(fpath, (err, ret) => {
if (err) {
console.log('fileIO_test_access_async_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(ret === true).assertTrue();
let file = fileIO.openSync(fpath);
expect(isIntNum(file.fd)).assertTrue();
let readlen = fileIO.readSync(file.fd, new ArrayBuffer(4096));
expect(readlen == FILE_CONTENT.length).assertTrue();
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
});
done();
} catch (e) {
console.log('fileIO_test_access_async_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @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.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_access_async_002', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_access_async_002');
try {
let ret = await fileIO.access(fpath);
expect(ret === false).assertTrue();
done();
} catch (e) {
console.log('fileIO_test_access_async_002 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @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.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_access_async_003', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_access_async_002');
try {
fileIO.access(fpath, (err, ret) => {
if (err) {
console.log('fileIO_test_access_async_003 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(ret === false).assertTrue();
done();
});
} catch (e) {
console.log('fileIO_test_access_async_003 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_ACCESS_ASYNC_0400
* @tc.name fileIO_test_access_async_004
* @tc.desc Test access() interface. Promise.
* Invalid path parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_access_async_004', 0, async function (done) {
try {
await fileIO.access(-1);
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_access_async_004 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_ACCESS_ASYNC_0500
* @tc.name fileIO_test_access_async_005
* @tc.desc Test access() interface. Callback.
* Invalid path parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_access_async_005', 0, async function (done) {
try {
fileIO.access(-1, (err) => {
expect(false).assertTrue();
});
} catch (e) {
console.log('fileIO_test_access_async_005 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
}
});
});
}
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
fileIO, FILE_CONTENT, prepareFile, nextFileName, describe, it, expect, randomString
} from '../Common';
export default function fileIOCopyfile() {
describe('fileIO_fs_copyfile', function () {
/**
* @tc.number SUB_DF_FILEIO_COPY_FILE_SYNC_0000
* @tc.name fileIO_copy_file_sync_000
* @tc.desc Test copyFileSync() interfaces.
* Test file copied successfully by path.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileIO_copy_file_sync_000', 0, async function () {
let fpath = await nextFileName('fileIO_copy_file_sync_000');
let fpathTarget = fpath + 'tgt';
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.copyFileSync(fpath, fpathTarget);
let stat1 = fileIO.statSync(fpath);
let stat2 = fileIO.statSync(fpathTarget);
expect(stat1.size == stat2.size).assertTrue();
fileIO.unlinkSync(fpath);
fileIO.unlinkSync(fpathTarget);
} catch (e) {
console.log('fileIO_copy_file_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPY_FILE_SYNC_0100
* @tc.name fileIO_copy_file_sync_001
* @tc.desc Test copyFileSync() interfaces.
* Test file copied successfully by file descriptor.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_copy_file_sync_001', 0, async function () {
let fpath = await nextFileName('fileIO_copy_file_sync_001');
let fpathTarget = fpath + 'tgt';
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
fileIO.copyFileSync(file.fd, fpathTarget);
let stat1 = fileIO.statSync(fpath);
let stat2 = fileIO.statSync(fpathTarget);
expect(stat1.size == stat2.size).assertTrue();
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
fileIO.unlinkSync(fpathTarget);
} catch (e) {
console.log('fileIO_copy_file_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPY_FILE_SYNC_0200
* @tc.name fileIO_copy_file_sync_002
* @tc.desc Test copyFileSync() interfaces.
* The path point to nothing, no such file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_copy_file_sync_002', 0, async function () {
let fpath = await nextFileName('fileIO_copy_file_sync_002');
let fpathTarget = fpath + 'tgt';
try {
fileIO.copyFileSync(fpath, fpathTarget);
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_copy_file_sync_002 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900002 && e.message == 'No such file or directory').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPY_FILE_SYNC_0300
* @tc.name fileIO_copy_file_sync_003
* @tc.desc Test copyFileSync() interfaces.
* Missing parameters.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_copy_file_sync_003', 0, function () {
try {
fileIO.copyFileSync();
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_copy_file_sync_003 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPY_FILE_SYNC_0400
* @tc.name fileIO_copy_file_sync_004
* @tc.desc Test copyFileSync() interfaces.
* Invalid type of mode.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_copy_file_sync_004', 0, async function () {
let fpath = await nextFileName('fileIO_copy_file_sync_004');
let fpathTarget = fpath + 'tgt';
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.copyFileSync(fpath, fpathTarget, '0');
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_copy_file_sync_004 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPY_FILE_SYNC_0500
* @tc.name fileIO_copy_file_sync_005
* @tc.desc Test copyFileSync() interfaces.
* Test file copied successfully by file descriptor.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_copy_file_sync_005', 0, async function () {
let fpath = await nextFileName('fileIO_copy_file_sync_005');
let fpathTarget = fpath + 'tgt';
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let fileTgt = fileIO.openSync(fpathTarget, fileIO.OpenMode.CREATE | fileIO.OpenMode.READ_WRITE);
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
fileIO.copyFileSync(file.fd, fileTgt.fd);
let stat1 = fileIO.statSync(fpath);
let stat2 = fileIO.statSync(fpathTarget);
expect(stat1.size == stat2.size).assertTrue();
fileIO.closeSync(file);
fileIO.closeSync(fileTgt);
fileIO.unlinkSync(fpath);
fileIO.unlinkSync(fpathTarget);
} catch (e) {
console.log('fileIO_copy_file_sync_005 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPY_FILE_SYNC_0600
* @tc.name fileIO_copy_file_sync_006
* @tc.desc Test copyFileSync() interfaces.
* Test file copied successfully by file descriptor and path.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_copy_file_sync_006', 0, async function () {
let fpath = await nextFileName('fileIO_copy_file_sync_006');
let fpathTarget = fpath + 'tgt';
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let fileTgt = fileIO.openSync(fpathTarget, fileIO.OpenMode.CREATE | fileIO.OpenMode.READ_WRITE);
try {
fileIO.copyFileSync(fpath, fileTgt.fd);
let stat1 = fileIO.statSync(fpath);
let stat2 = fileIO.statSync(fpathTarget);
expect(stat1.size == stat2.size).assertTrue();
fileIO.closeSync(fileTgt);
fileIO.unlinkSync(fpath);
fileIO.unlinkSync(fpathTarget);
} catch (e) {
console.log('fileIO_copy_file_sync_006 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPY_FILE_SYNC_0700
* @tc.name fileIO_copy_file_sync_007
* @tc.desc Test copyFileSync() interfaces.
* Don't support mode = 1.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_copy_file_sync_007', 0, async function (done) {
let fpath = await nextFileName('fileIO_copy_file_sync_007');
let fpathTarget = fpath + 'tgt';
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.copyFileSync(fpath, fpathTarget, 1);
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_copy_file_sync_007 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPY_FILE_SYNC_0800
* @tc.name fileIO_copy_file_sync_008
* @tc.desc Test copyFileSync() interfaces.
* The length of file name is too long.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_copy_file_sync_008', 0, async function () {
let fpath = await nextFileName('fileIO_copy_file_sync_008');
let fpathTarget = fpath + randomString(250);
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.copyFileSync(fpath, fpathTarget);
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_copy_file_sync_008 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900030 && e.message == 'File name too long').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPY_FILE_ASYNC_0000
* @tc.name fileIO_copy_file_async_000
* @tc.desc Test copyFile() interfaces. Promise.
* Test file copied successfully by path.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_copy_file_async_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_copy_file_async_000');
let fpathTarget = fpath + 'tgt';
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
await fileIO.copyFile(fpath, fpathTarget);
let stat1 = fileIO.statSync(fpath);
let stat2 = fileIO.statSync(fpathTarget);
expect(stat1.size == stat2.size).assertTrue();
fileIO.unlinkSync(fpath);
fileIO.unlinkSync(fpathTarget);
done();
} catch (e) {
console.log('fileIO_copy_file_async_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPY_FILE_ASYNC_0100
* @tc.name fileIO_copy_file_async_001
* @tc.desc Test copyFile() interfaces. Callback.
* Test file copied successfully by path.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_copy_file_async_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_copy_file_async_001');
let fpathTarget = fpath + 'tgt';
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.copyFile(fpath, fpathTarget, (err) => {
if (err) {
console.log('fileIO_copy_file_async_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
let stat1 = fileIO.statSync(fpath);
let stat2 = fileIO.statSync(fpathTarget);
expect(stat1.size == stat2.size).assertTrue();
fileIO.unlinkSync(fpath);
fileIO.unlinkSync(fpathTarget);
done();
});
} catch (e) {
console.log('fileIO_copy_file_async_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPY_FILE_ASYNC_0200
* @tc.name fileIO_copy_file_async_002
* @tc.desc Test copyFile() interfaces. Promise.
* Test file copied successfully by file descriptor.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_copy_file_async_002', 0, async function (done) {
let fpath = await nextFileName('fileIO_copy_file_async_002');
let fpathTarget = fpath + 'tgt';
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.CREATE | fileIO.OpenMode.READ_WRITE);
await fileIO.copyFile(file.fd, fpathTarget);
let stat1 = fileIO.statSync(fpath);
let stat2 = fileIO.statSync(fpathTarget);
expect(stat1.size == stat2.size).assertTrue();
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
fileIO.unlinkSync(fpathTarget);
done();
} catch (e) {
console.log('fileIO_copy_file_async_002 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPY_FILE_ASYNC_0300
* @tc.name fileIO_copy_file_async_003
* @tc.desc Test copyFile() interfaces. Promise.
* The path point to nothing, no such file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_copy_file_async_003', 0, async function (done) {
let fpath = await nextFileName('fileIO_copy_file_async_003');
let fpathTarget = fpath + 'tgt';
try {
await fileIO.copyFile(fpath, fpathTarget);
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_copy_file_async_003 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900002 && e.message == 'No such file or directory').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPY_FILE_ASYNC_0400
* @tc.name fileIO_copy_file_async_004
* @tc.desc Test copyFile() interfaces. Callback.
* The path point to nothing, no such file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_copy_file_async_004', 0, async function (done) {
let fpath = await nextFileName('fileIO_copy_file_async_004');
let fpathTarget = fpath + 'tgt';
try {
fileIO.copyFile(fpath, fpathTarget, (err) => {
if (err) {
console.log('fileIO_copy_file_async_005 error: {message: ' + err.message + ', code: ' + err.code + '}');
expect(err.code == 13900002 && err.message == 'No such file or directory').assertTrue();
done();
}
});
} catch (e) {
console.log('fileIO_copy_file_async_004 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPY_FILE_ASYNC_0500
* @tc.name fileIO_copy_file_async_005
* @tc.desc Test copyFile() interfaces. Promise.then().catch()
* The path point to nothing, no such file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_copy_file_async_005', 0, async function (done) {
let fpath = await nextFileName('fileIO_copy_file_async_005');
let fpathTarget = fpath + 'tgt';
try {
fileIO.copyFile(fpath, fpathTarget).then(() => {
expect(false).assertTrue();
}).catch((err) => {
console.log('fileIO_copy_file_async_005 error: {message: ' + err.message + ', code: ' + err.code + '}');
expect(err.code == 13900002 && err.message == 'No such file or directory').assertTrue();
done();
});
} catch (e) {
console.log('fileIO_copy_file_async_005 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPY_FILE_ASYNC_0600
* @tc.name fileIO_copy_file_async_006
* @tc.desc Test copyFile() interfaces. Promise.
* Missing Parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_copy_file_async_006', 0, async function (done) {
let fpath = await nextFileName('fileIO_copy_file_async_006');
try {
await fileIO.copyFile(fpath);
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_copy_file_async_006 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPY_FILE_ASYNC_0700
* @tc.name fileIO_copy_file_async_007
* @tc.desc Test copyFile() interfaces. Callback.
* Missing Parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_copy_file_async_007', 0, async function (done) {
let fpath = await nextFileName('fileIO_copy_file_async_007');
try {
fileIO.copyFile(fpath, (err) => {
expect(false).assertTrue();
});
} catch (e) {
console.log('fileIO_copy_file_async_007 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPY_FILE_ASYNC_0800
* @tc.name fileIO_copy_file_async_008
* @tc.desc Test copyFile() interfaces. Promise.
* Test file copied successfully by path when mode = 0.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_copy_file_async_008', 0, async function (done) {
let fpath = await nextFileName('fileIO_copy_file_async_008');
let fpathTarget = fpath + 'tgt';
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
await fileIO.copyFile(fpath, fpathTarget, 0);
let stat1 = fileIO.statSync(fpath);
let stat2 = fileIO.statSync(fpathTarget);
expect(stat1.size == stat2.size).assertTrue();
fileIO.unlinkSync(fpath);
fileIO.unlinkSync(fpathTarget);
done();
} catch (e) {
console.log('fileIO_copy_file_async_008 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPY_FILE_ASYNC_0900
* @tc.name fileIO_copy_file_async_009
* @tc.desc Test copyFile() interfaces. Callback.
* Test file copied successfully by path when mode = 0.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_copy_file_async_009', 0, async function (done) {
let fpath = await nextFileName('fileIO_copy_file_async_009');
let fpathTarget = fpath + 'tgt';
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.copyFile(fpath, fpathTarget, 0, (err) => {
if (err) {
console.log('fileIO_copy_file_async_007 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
let stat1 = fileIO.statSync(fpath);
let stat2 = fileIO.statSync(fpathTarget);
expect(stat1.size == stat2.size).assertTrue();
fileIO.unlinkSync(fpath);
fileIO.unlinkSync(fpathTarget);
done();
});
} catch (e) {
console.log('fileIO_copy_file_async_007 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPY_FILE_ASYNC_1000
* @tc.name fileIO_copy_file_async_010
* @tc.desc Test copyFile() interfaces. Callback.
* Don't support mode = 1.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_copy_file_async_010', 0, async function (done) {
let fpath = await nextFileName('fileIO_copy_file_async_010');
let fpathTarget = fpath + 'tgt';
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.copyFile(fpath, fpathTarget, 1, (err) => {
expect(false).assertTrue();
});
} catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_copy_file_async_010 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPY_FILE_ASYNC_1100
* @tc.name fileIO_copy_file_async_011
* @tc.desc Test copyFile() interfaces. Promise.
* Invalid type of mode.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_copy_file_async_011', 0, async function (done) {
let fpath = await nextFileName('fileIO_copy_file_async_011');
let fpathTarget = fpath + 'tgt';
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
await fileIO.copyFile(fpath, fpathTarget, '0');
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_copy_file_async_011 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPY_FILE_ASYNC_1200
* @tc.name fileIO_copy_file_async_012
* @tc.desc Test copyFile() interfaces. Promise.
* Test file copied successfully by file descriptor.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_copy_file_async_012', 0, async function (done) {
let fpath = await nextFileName('fileIO_copy_file_async_012');
let fpathTarget = fpath + 'tgt';
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let fileTgt = fileIO.openSync(fpathTarget, fileIO.OpenMode.CREATE | fileIO.OpenMode.READ_WRITE);
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
await fileIO.copyFile(file.fd, fileTgt.fd);
let stat1 = fileIO.statSync(fpath);
let stat2 = fileIO.statSync(fpathTarget);
expect(stat1.size == stat2.size).assertTrue();
fileIO.closeSync(file);
fileIO.closeSync(fileTgt);
fileIO.unlinkSync(fpath);
fileIO.unlinkSync(fpathTarget);
done();
} catch (e) {
console.log('fileIO_copy_file_async_012 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPY_FILE_ASYNC_1300
* @tc.name fileIO_copy_file_async_013
* @tc.desc Test copyFile() interfaces. Callback.
* Test file copied successfully by file descriptor.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_copy_file_async_013', 0, async function (done) {
let fpath = await nextFileName('fileIO_copy_file_async_012');
let fpathTarget = fpath + 'tgt';
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let fileTgt = fileIO.openSync(fpathTarget, fileIO.OpenMode.CREATE | fileIO.OpenMode.READ_WRITE);
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
fileIO.copyFile(file.fd, fileTgt.fd, (err) => {
if (err) {
console.log('fileIO_copy_file_async_013 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
let stat1 = fileIO.statSync(fpath);
let stat2 = fileIO.statSync(fpathTarget);
expect(stat1.size == stat2.size).assertTrue();
fileIO.closeSync(file);
fileIO.closeSync(fileTgt);
fileIO.unlinkSync(fpath);
fileIO.unlinkSync(fpathTarget);
done();
});
} catch (e) {
console.log('fileIO_copy_file_async_013 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPY_FILE_ASYNC_1400
* @tc.name fileIO_copy_file_async_014
* @tc.desc Test copyFile() interfaces. Promise.
* Test file copied successfully by file descriptor and path when mode = 0.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_copy_file_async_014', 0, async function (done) {
let fpath = await nextFileName('fileIO_copy_file_async_014');
let fpathTarget = fpath + 'tgt';
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(prepareFile(fpathTarget, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpathTarget, fileIO.OpenMode.READ_WRITE);
await fileIO.copyFile(fpath, file.fd, 0);
let stat1 = fileIO.statSync(fpath);
let stat2 = fileIO.statSync(fpathTarget);
expect(stat1.size == stat2.size).assertTrue();
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
fileIO.unlinkSync(fpathTarget);
done();
} catch (e) {
console.log('fileIO_copy_file_async_014 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPY_FILE_ASYNC_1500
* @tc.name fileIO_copy_file_async_015
* @tc.desc Test copyFile() interfaces. Callback.
* Test file copied successfully by file descriptor and path.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_copy_file_async_015', 0, async function (done) {
let fpath = await nextFileName('fileIO_copy_file_async_014');
let fpathTarget = fpath + 'tgt';
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let file = fileIO.openSync(fpathTarget, fileIO.OpenMode.CREATE | fileIO.OpenMode.READ_WRITE);
try {
fileIO.copyFile(fpath, file.fd, 0, (err) => {
if (err) {
console.log('fileIO_copy_file_async_013 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
let stat1 = fileIO.statSync(fpath);
let stat2 = fileIO.statSync(fpathTarget);
expect(stat1.size == stat2.size).assertTrue();
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
fileIO.unlinkSync(fpathTarget);
done();
});
} catch (e) {
console.log('fileIO_copy_file_async_015 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPY_FILE_ASYNC_1600
* @tc.name fileIO_copy_file_async_016
* @tc.desc Test copyFile() interfaces. Promise
* The length of file name is too long.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_copy_file_async_016', 0, async function (done) {
let fpath = await nextFileName('fileIO_copy_file_async_016');
let fpathTarget = fpath + randomString(250);
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
await fileIO.copyFile(fpath, fpathTarget);
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_copy_file_async_016 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900030 && e.message == 'File name too long').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPY_FILE_ASYNC_1700
* @tc.name fileIO_copy_file_async_017
* @tc.desc Test copyFile() interfaces. Callback
* The length of file name is too long.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_copy_file_async_017', 0, async function (done) {
let fpath = await nextFileName('fileIO_copy_file_async_017');
let fpathTarget = fpath + randomString(250);
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.copyFile(fpath, fpathTarget, (err) => {
if (err) {
fileIO.unlinkSync(fpath);
console.log('fileIO_copy_file_async_017 error: {message: ' + err.message + ', code: ' + err.code);
expect(err.code == 13900030 && err.message == 'File name too long').assertTrue();
done();
}
});
} catch (e) {
console.log('fileIO_copy_file_async_017 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
});
}
...@@ -14,8 +14,7 @@ ...@@ -14,8 +14,7 @@
*/ */
import { import {
fileio, fileIO, FILE_CONTENT, prepareFile, nextFileName, fileIO, FILE_CONTENT, prepareFile, nextFileName, describe, it, expect,
describe, it, expect,
} from '../Common'; } from '../Common';
export default function fileIOFdatasync() { export default function fileIOFdatasync() {
...@@ -38,8 +37,8 @@ export default function fileIOFdatasync() { ...@@ -38,8 +37,8 @@ export default function fileIOFdatasync() {
try { try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
fileIO.fdatasyncSync(file.fd); fileIO.fdatasyncSync(file.fd);
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_fdatasync_sync_000 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_fdatasync_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -47,12 +46,12 @@ export default function fileIOFdatasync() { ...@@ -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.name fileIO_test_fdatasync_sync_001
* @tc.desc Test fdatasyncSync() interfaces. Invalid fd parameter. * @tc.desc Test fdatasyncSync() interfaces. Invalid fd parameter.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_fdatasync_sync_001', 0, async function () { it('fileIO_test_fdatasync_sync_001', 0, async function () {
...@@ -67,12 +66,12 @@ export default function fileIOFdatasync() { ...@@ -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.name fileIO_test_fdatasync_sync_002
* @tc.desc Test fdatasyncSync() interfaces. Missing parameter. * @tc.desc Test fdatasyncSync() interfaces. Missing parameter.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_fdatasync_sync_002', 0, async function () { it('fileIO_test_fdatasync_sync_002', 0, async function () {
...@@ -107,8 +106,8 @@ export default function fileIOFdatasync() { ...@@ -107,8 +106,8 @@ export default function fileIOFdatasync() {
console.log('fileIO_test_fdatasync_async_000 error package: ' + JSON.stringify(err)); console.log('fileIO_test_fdatasync_async_000 error package: ' + JSON.stringify(err));
expect(false).assertTrue(); expect(false).assertTrue();
} }
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
} catch (e) { } catch (e) {
...@@ -118,13 +117,13 @@ export default function fileIOFdatasync() { ...@@ -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.name fileIO_test_fdatasync_async_001
* @tc.desc Test fdatasync() interfaces. Promise.then().catch(). * @tc.desc Test fdatasync() interfaces. Promise.then().catch().
* Open the file in read-write mode, and synchronize the file content data. * Open the file in read-write mode, and synchronize the file content data.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_fdatasync_async_001', 0, async function (done) { it('fileIO_test_fdatasync_async_001', 0, async function (done) {
...@@ -133,9 +132,9 @@ export default function fileIOFdatasync() { ...@@ -133,9 +132,9 @@ export default function fileIOFdatasync() {
try { try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
fileio.fdatasync(file.fd).then(() => { fileIO.fdatasync(file.fd).then(() => {
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}).catch((err) => { }).catch((err) => {
console.log('fileIO_test_fdatasync_async_001 error package: ' + JSON.stringify(err)); console.log('fileIO_test_fdatasync_async_001 error package: ' + JSON.stringify(err));
...@@ -148,13 +147,13 @@ export default function fileIOFdatasync() { ...@@ -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.name fileIO_test_fdatasync_async_002
* @tc.desc Test fdatasync() interfaces. await Promise. * @tc.desc Test fdatasync() interfaces. await Promise.
* Open the file in read-write mode, and synchronize the file content data. * Open the file in read-write mode, and synchronize the file content data.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_fdatasync_async_002', 0, async function (done) { it('fileIO_test_fdatasync_async_002', 0, async function (done) {
...@@ -163,9 +162,9 @@ export default function fileIOFdatasync() { ...@@ -163,9 +162,9 @@ export default function fileIOFdatasync() {
try { try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
await fileio.fdatasync(file.fd); await fileIO.fdatasync(file.fd);
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_test_fdatasync_async_002 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_fdatasync_async_002 has failed for ' + e.message + ', code: ' + e.code);
...@@ -174,13 +173,13 @@ export default function fileIOFdatasync() { ...@@ -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.name fileIO_test_fdatasync_async_003
* @tc.desc Test fdatasync() interfaces. await Promise. * @tc.desc Test fdatasync() interfaces. await Promise.
* Invalid fd parameter. * Invalid fd parameter.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_fdatasync_async_003', 0, async function (done) { it('fileIO_test_fdatasync_async_003', 0, async function (done) {
...@@ -196,13 +195,13 @@ export default function fileIOFdatasync() { ...@@ -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.name fileIO_test_fdatasync_async_004
* @tc.desc Test fdatasync() interfaces. Callback. * @tc.desc Test fdatasync() interfaces. Callback.
* Invalid fd parameter. * Invalid fd parameter.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_fdatasync_async_004', 0, async function (done) { it('fileIO_test_fdatasync_async_004', 0, async function (done) {
...@@ -210,7 +209,7 @@ export default function fileIOFdatasync() { ...@@ -210,7 +209,7 @@ export default function fileIOFdatasync() {
try { try {
fileIO.fdatasync(-1, (err) => { fileIO.fdatasync(-1, (err) => {
if (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(); expect(err.code == 13900008 && err.message == 'Bad file descriptor').assertTrue();
done(); done();
} }
...@@ -222,13 +221,13 @@ export default function fileIOFdatasync() { ...@@ -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.name fileIO_test_fdatasync_async_005
* @tc.desc Test fdatasync() interfaces. Promise.then().catch() * @tc.desc Test fdatasync() interfaces. Promise.then().catch()
* Invalid fd parameter. * Invalid fd parameter.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_fdatasync_async_005', 0, async function (done) { it('fileIO_test_fdatasync_async_005', 0, async function (done) {
...@@ -237,7 +236,7 @@ export default function fileIOFdatasync() { ...@@ -237,7 +236,7 @@ export default function fileIOFdatasync() {
fileIO.fdatasync(-1).then(() => { fileIO.fdatasync(-1).then(() => {
expect(false).assertTrue(); expect(false).assertTrue();
}).catch((err) => { }).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(); expect(err.code == 13900008 && err.message == 'Bad file descriptor').assertTrue();
done(); done();
}); });
...@@ -248,13 +247,13 @@ export default function fileIOFdatasync() { ...@@ -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.name fileIO_test_fdatasync_async_006
* @tc.desc Test fdatasync() interfaces. Promise. * @tc.desc Test fdatasync() interfaces. Promise.
* Missing parameter. * Missing parameter.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_fdatasync_async_006', 0, async function (done) { it('fileIO_test_fdatasync_async_006', 0, async function (done) {
...@@ -270,19 +269,19 @@ export default function fileIOFdatasync() { ...@@ -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.name fileIO_test_fdatasync_async_007
* @tc.desc Test fdatasync() interfaces. Callback. * @tc.desc Test fdatasync() interfaces. Callback.
* Missing parameter. * Missing parameter.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_fdatasync_async_007', 0, async function (done) { it('fileIO_test_fdatasync_async_007', 0, async function (done) {
try { try {
fileIO.fdatasync(() => { fileIO.fdatasync((err) => {
expect(false).assertTrue(); expect(false).assertTrue();
}); });
} catch (e) { } catch (e) {
......
...@@ -14,8 +14,7 @@ ...@@ -14,8 +14,7 @@
*/ */
import { import {
fileio, fileIO, FILE_CONTENT, prepareFile, nextFileName, fileIO, FILE_CONTENT, prepareFile, nextFileName, describe, it, expect,
describe, it, expect,
} from '../Common'; } from '../Common';
export default function fileIOFsync() { export default function fileIOFsync() {
...@@ -38,8 +37,8 @@ describe('fileIO_fs_fsync', function () { ...@@ -38,8 +37,8 @@ describe('fileIO_fs_fsync', function () {
try { try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
fileIO.fsyncSync(file.fd); fileIO.fsyncSync(file.fd);
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_fsync_sync_000 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_fsync_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -47,12 +46,12 @@ describe('fileIO_fs_fsync', function () { ...@@ -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.name fileIO_test_fsync_sync_001
* @tc.desc Test fsyncSync() interface. Invalid fd parameter. * @tc.desc Test fsyncSync() interface. Invalid fd parameter.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_fsync_sync_001', 0, function () { it('fileIO_test_fsync_sync_001', 0, function () {
...@@ -67,12 +66,12 @@ describe('fileIO_fs_fsync', 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.name fileIO_test_fsync_sync_002
* @tc.desc Test fsyncSync() interface. Missing parameter. * @tc.desc Test fsyncSync() interface. Missing parameter.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_fsync_sync_002', 0, function () { it('fileIO_test_fsync_sync_002', 0, function () {
...@@ -103,8 +102,8 @@ describe('fileIO_fs_fsync', function () { ...@@ -103,8 +102,8 @@ describe('fileIO_fs_fsync', function () {
try { try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
await fileIO.fsync(file.fd); await fileIO.fsync(file.fd);
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_test_fsync_async_000 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_fsync_async_000 has failed for ' + e.message + ', code: ' + e.code);
...@@ -113,13 +112,13 @@ describe('fileIO_fs_fsync', function () { ...@@ -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.name fileIO_test_fsync_async_001
* @tc.desc Test fsync() interface. Promise.then().catch() * @tc.desc Test fsync() interface. Promise.then().catch()
* Open the file in read-write mode, and synchronize the file content data. * Open the file in read-write mode, and synchronize the file content data.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_fsync_async_001', 0, async function (done) { it('fileIO_test_fsync_async_001', 0, async function (done) {
...@@ -129,8 +128,8 @@ describe('fileIO_fs_fsync', function () { ...@@ -129,8 +128,8 @@ describe('fileIO_fs_fsync', function () {
try { try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
fileIO.fsync(file.fd).then(() => { fileIO.fsync(file.fd).then(() => {
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}).catch((err) => { }).catch((err) => {
console.log('fileIO_test_fsync_async_001 error package: ' + JSON.stringify(err)); console.log('fileIO_test_fsync_async_001 error package: ' + JSON.stringify(err));
...@@ -143,13 +142,13 @@ describe('fileIO_fs_fsync', function () { ...@@ -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.name fileIO_test_fsync_async_002
* @tc.desc Test fsync() interface. Callback. * @tc.desc Test fsync() interface. Callback.
* Open the file in read-write mode, and synchronize the file content data. * Open the file in read-write mode, and synchronize the file content data.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_fsync_async_002', 0, async function (done) { it('fileIO_test_fsync_async_002', 0, async function (done) {
...@@ -163,8 +162,8 @@ describe('fileIO_fs_fsync', function () { ...@@ -163,8 +162,8 @@ describe('fileIO_fs_fsync', function () {
console.log('fileIO_test_fsync_async_002 error package: ' + JSON.stringify(err)); console.log('fileIO_test_fsync_async_002 error package: ' + JSON.stringify(err));
expect(false).assertTrue(); expect(false).assertTrue();
} }
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
}); });
done(); done();
} catch (e) { } catch (e) {
...@@ -174,13 +173,13 @@ describe('fileIO_fs_fsync', function () { ...@@ -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.name fileIO_test_fsync_async_003
* @tc.desc Test fsync() interface. await Promise. * @tc.desc Test fsync() interface. await Promise.
* Invalid fd parameter. * Invalid fd parameter.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_fsync_async_003', 0, async function (done) { it('fileIO_test_fsync_async_003', 0, async function (done) {
...@@ -196,13 +195,13 @@ describe('fileIO_fs_fsync', function () { ...@@ -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.name fileIO_test_fsync_async_004
* @tc.desc Test fsync() interface. Callback. * @tc.desc Test fsync() interface. Callback.
* Invalid fd parameter. * Invalid fd parameter.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_fsync_async_004', 0, async function (done) { it('fileIO_test_fsync_async_004', 0, async function (done) {
...@@ -210,7 +209,7 @@ describe('fileIO_fs_fsync', function () { ...@@ -210,7 +209,7 @@ describe('fileIO_fs_fsync', function () {
try { try {
fileIO.fsync(-1, (err) => { fileIO.fsync(-1, (err) => {
if (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(); expect(err.code == 13900008 && err.message == 'Bad file descriptor').assertTrue();
done(); done();
} }
...@@ -222,13 +221,13 @@ describe('fileIO_fs_fsync', function () { ...@@ -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.name fileIO_test_fsync_async_005
* @tc.desc Test fsync() interface. Promise.then().catch() * @tc.desc Test fsync() interface. Promise.then().catch()
* Missing parameter. * Missing parameter.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_fsync_async_005', 0, async function (done) { it('fileIO_test_fsync_async_005', 0, async function (done) {
...@@ -237,7 +236,7 @@ describe('fileIO_fs_fsync', function () { ...@@ -237,7 +236,7 @@ describe('fileIO_fs_fsync', function () {
fileIO.fsync(-1).then(() => { fileIO.fsync(-1).then(() => {
expect(false).assertTrue(); expect(false).assertTrue();
}).catch((err) => { }).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(); expect(err.code == 13900008 && err.message == 'Bad file descriptor').assertTrue();
done(); done();
}); });
...@@ -248,13 +247,13 @@ describe('fileIO_fs_fsync', function () { ...@@ -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.name fileIO_test_fsync_async_006
* @tc.desc Test fsync() interface. await Promise. * @tc.desc Test fsync() interface. await Promise.
* Missing parameter. * Missing parameter.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_fsync_async_006', 0, async function (done) { it('fileIO_test_fsync_async_006', 0, async function (done) {
...@@ -270,19 +269,19 @@ describe('fileIO_fs_fsync', function () { ...@@ -270,19 +269,19 @@ describe('fileIO_fs_fsync', function () {
}); });
/** /**
* @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_006 * @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_0700
* @tc.name fileIO_test_fsync_async_006 * @tc.name fileIO_test_fsync_async_007
* @tc.desc Test fsync() interface. Callback. * @tc.desc Test fsync() interface. Callback.
* Missing parameter. * Missing parameter.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_fsync_async_007', 0, async function (done) { it('fileIO_test_fsync_async_007', 0, async function (done) {
try { try {
fileIO.fsync(() => { fileIO.fsync((err) => {
expect(false).assertTrue(); expect(false).assertTrue();
}); });
} catch (e) { } catch (e) {
......
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import fileHash from '@ohos.file.hash';
import {
fileIO, FILE_CONTENT, prepareFile, nextFileName, describe, it, expect,
} from '../Common';
export default function fileIOHash() {
describe('fileIO_fs_hash', function () {
/**
* @tc.number SUB_DF_FILEIO_HASH_ASYNC_0000
* @tc.name fileIO_test_hash_async_000
* @tc.desc Test hash() interface. Promise.
* Encrypt files using the MD5 hashing algorithm
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_hash_async_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_hash_async_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let str = await fileHash.hash(fpath,'md5');
console.log('fileIO_test_hash_async_000 hash value is ' + str);
expect(str == '5EB63BBBE01EEED093CB22BB8F5ACDC3').assertTrue();
fileIO.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_test_hash_async_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_HASH_ASYNC_0100
* @tc.name fileIO_test_hash_async_001
* @tc.desc Test hash() interface. Callback.
* Encrypt files using the MD5 hashing algorithm.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_hash_async_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_hash_async_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileHash.hash(fpath, 'md5', (err, str) => {
if (err) {
console.log('fileIO_test_hash_async_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
console.log('fileIO_test_hash_async_001 hash value is ' + str);
expect(str == '5EB63BBBE01EEED093CB22BB8F5ACDC3').assertTrue();
fileIO.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_test_hash_async_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_HASH_ASYNC_0200
* @tc.name fileIO_test_hash_async_002
* @tc.desc Test hash() interface. Promise.
* Encrypt files using the sha1 hashing algorithm.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_hash_async_002', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_hash_async_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let str = await fileHash.hash(fpath, 'sha1');
console.log('fileIO_test_hash_async_000 hash value is ' + str);
expect(str == '2AAE6C35C94FCFB415DBE95F408B9CE91EE846ED').assertTrue();
fileIO.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_test_hash_async_002 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_HASH_ASYNC_0300
* @tc.name fileIO_test_hash_async_003
* @tc.desc Test hash() interface. Callback.
* Encrypt files using the sha1 hashing algorithm.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_hash_async_003', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_hash_async_003');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileHash.hash(fpath, 'sha1', (err, str) => {
if (err) {
console.log('fileIO_test_hash_async_003 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
console.log('fileIO_test_hash_async_003 hash value is ' + str);
expect(str == '2AAE6C35C94FCFB415DBE95F408B9CE91EE846ED').assertTrue();
fileIO.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_test_hash_async_003 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_HASH_ASYNC_0400
* @tc.name fileIO_test_hash_async_004
* @tc.desc Test hash() interface. Promise.
* Encrypt files using the sha256 hashing algorithm.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_hash_async_004', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_hash_async_004');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let str = await fileHash.hash(fpath, 'sha256');
console.log('fileIO_test_hash_async_001 hash value is ' + str);
expect(str == 'B94D27B9934D3E08A52E52D7DA7DABFAC484EFE37A5380EE9088F7ACE2EFCDE9').assertTrue();
fileIO.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_test_hash_async_004 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_HASH_ASYNC_0500
* @tc.name fileIO_test_hash_async_005
* @tc.desc Test hash() interface. Callback.
* Encrypt files using the sha256 hashing algorithm.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_hash_async_005', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_hash_async_005');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileHash.hash(fpath, 'sha256', (err, str) => {
if (err) {
console.log('fileIO_test_hash_async_005 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
console.log('fileIO_test_hash_async_005 hash value is ' + str);
expect(str == 'B94D27B9934D3E08A52E52D7DA7DABFAC484EFE37A5380EE9088F7ACE2EFCDE9').assertTrue();
fileIO.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_test_hash_async_005 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_HASH_ASYNC_0600
* @tc.name fileIO_test_hash_async_006
* @tc.desc Test hash() interface. Promise.
* Invalid mode.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_hash_async_006', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_hash_async_006');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
await fileHash.hash(fpath, '256');
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_test_hash_async_006 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_HASH_ASYNC_0700
* @tc.name fileIO_test_hash_async_007
* @tc.desc Test hash() interface. Promise.
* Missing parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_hash_async_007', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_hash_async_007');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileHash.hash(fpath, (err) => {
expect(false).assertTrue();
});
} catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_test_hash_async_007 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
}
});
})
}
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum, isBigInt,
describe, it, expect,
} from '../Common';
export default function fileIOLstat() {
describe('fileIO_fs_lstat', function () {
/**
* @tc.number SUB_DF_FILEIO_LSTAT_SYNC_0000
* @tc.name fileIO_lstat_sync_000
* @tc.desc Test lstatSync() interface.
* Enter the path parameter to get the file stat.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileIO_lstat_sync_000', 0, async function () {
let fpath = await nextFileName('fileIO_lstat_sync_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.lstatSync(fpath);
expect(stat !== null).assertTrue();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_lstat_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_SYNC_0100
* @tc.name fileIO_lstat_sync_001
* @tc.desc Test lstatSync() interface.
* The path point to nothing, no such file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_sync_001', 0, async function () {
let fpath = await nextFileName('fileIO_lstat_sync_001');
try {
fileIO.lstatSync(fpath);
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_lstat_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900002 && e.message == 'No such file or directory').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_SYNC_0200
* @tc.name fileIO_lstat_sync_002
* @tc.desc Test lstatSync() interface.
* Missing parameters.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_sync_002', 0, async function () {
try {
fileIO.lstatSync();
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_lstat_sync_002 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_INO_0000
* @tc.name fileIO_lstat_ino_000
* @tc.desc Test the ino member of class Stat.
* Enter the path parameter to get stat.ino of the file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_ino_000', 0, async function () {
let fpath = await nextFileName('fileIO_lstat_ino_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.lstatSync(fpath);
expect(isBigInt(stat.ino)).assertTrue();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_lstat_ino_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_MODE_0000
* @tc.name fileIO_lstat_mode_000
* @tc.desc Test the mode member of class Stat.
* Enter the path parameter to get stat.mode of the file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_mode_000', 0, async function () {
let fpath = await nextFileName('fileIO_lstat_mode_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.lstatSync(fpath);
expect(isIntNum(stat.mode)).assertTrue();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_lstat_mode_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_UID_0000
* @tc.name fileIO_lstat_uid_000
* @tc.desc Test the uid member of class Stat.
* Enter the path parameter to get stat.uid of the file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_uid_000', 0, async function () {
let fpath = await nextFileName('fileIO_lstat_uid_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.lstatSync(fpath);
expect(isIntNum(stat.uid)).assertTrue();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_lstat_uid_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_GID_0000
* @tc.name fileIO_lstat_gid_000
* @tc.desc Test the gid member of class Stat.
* Enter the path parameter to get stat.gid of the file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_gid_000', 0, async function () {
let fpath = await nextFileName('fileIO_lstat_gid_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.lstatSync(fpath);
expect(isIntNum(stat.gid)).assertTrue();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_lstat_gid_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_SIZE_0000
* @tc.name fileIO_lstat_size_000
* @tc.desc Test the size member of class Stat.
* Enter the path parameter to get stat.size of the file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_size_000', 0, async function () {
let fpath = await nextFileName('fileIO_lstat_size_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.lstatSync(fpath);
expect(isIntNum(stat.size)).assertTrue();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_lstat_size_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_ATIME_0000
* @tc.name fileIO_lstat_atime_000
* @tc.desc Test the atime member of class Stat.
* Enter the path or parameter to get stat.atime of the file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_atime_000', 0, async function () {
let fpath = await nextFileName('fileIO_lstat_atime_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.lstatSync(fpath);
expect(isIntNum(stat.atime)).assertTrue();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_lstat_atime_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_MTIME_0000
* @tc.name fileIO_lstat_mtime_000
* @tc.desc Test the mtime member of class Stat.
* Enter the path parameter to get stat.mtime of the file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_mtime_000', 0, async function () {
let fpath = await nextFileName('fileIO_lstat_mtime_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.lstatSync(fpath);
expect(isIntNum(stat.mtime)).assertTrue();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_lstat_mtime_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_CTIME_0000
* @tc.name fileIO_lstat_ctime_000
* @tc.desc Test the ctime member of class Stat.
* Enter the path parameter to get stat.ctime of the file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_ctime_000', 0, async function () {
let fpath = await nextFileName('fileIO_lstat_ctime_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.lstatSync(fpath);
expect(isIntNum(stat.ctime)).assertTrue();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_lstat_ctime_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_IS_BLOCK_DEVICE_0000
* @tc.name fileIO_lstat_is_block_device_000
* @tc.desc Test Lstat.isBlockDevice() interface.
* This interface shall not treat a normal file as a block special device.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_is_block_device_000', 0, async function () {
let fpath = await nextFileName('fileIO_lstat_is_block_device_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.lstatSync(fpath);
expect(stat.isBlockDevice() === false).assertTrue();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_lstat_is_block_device_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_IS_BLOCK_DEVICE_0100
* @tc.name fileIO_test_lstat_is_block_device_001
* @tc.desc Test Lstat.isBlockDevice() interface.
* This interface does not require parameters.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_lstat_is_block_device_001', 0, async function () {
let fpath = await nextFileName('fileIO_test_lstat_is_block_device_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.lstatSync(fpath).isBlockDevice(-1);
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
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();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_IS_CHARACTER_DEVICE_0000
* @tc.name fileIO_lstat_is_character_device_000
* @tc.desc Test Lstat.isCharacterDevice() interface.
* This interface shall not treat a normal file as a character special device.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_is_character_device_000', 0, async function () {
let fpath = await nextFileName('fileIO_lstat_is_character_device_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.lstatSync(fpath);
expect(stat.isCharacterDevice() === false).assertTrue();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_lstat_is_character_device_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_IS_CHARACTER_DEVICE_0100
* @tc.name fileIO_lstat_is_character_device_001
* @tc.desc Test Lstat.isCharacterDevice() interface.
* This interface does not require parameters.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_lstat_is_character_device_001', 0, async function () {
let fpath = await nextFileName('fileIO_test_lstat_is_character_device_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.lstatSync(fpath).isCharacterDevice(-1);
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_test_lstat_is_character_device_001 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_IS_DIRECTORY_0000
* @tc.name fileIO_lstat_is_directory_000
* @tc.desc Test Lstat.isDirectory() interface.
* This interface shall not treat a normal file as a directory.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_is_directory_000', 0, async function () {
let fpath = await nextFileName('fileIO_lstat_is_directory_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.lstatSync(fpath);
expect(stat.isDirectory() === false).assertTrue();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_lstat_is_directory_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_IS_DIRECTORY_0100
* @tc.name fileIO_lstat_is_directory_001
* @tc.desc Test Lstat.isDirectory() interface.
* This interface shall treat a directory as a directory.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_is_directory_001', 0, async function () {
let dpath = await nextFileName('fileIO_lstat_is_directory_001') + 'd';
try {
fileIO.mkdirSync(dpath);
let stat = fileIO.lstatSync(dpath);
expect(stat.isDirectory() === true).assertTrue();
fileIO.rmdirSync(dpath);
} catch (e) {
console.log('fileIO_lstat_is_directory_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_IS_DIRECTORY_0200
* @tc.name fileIO_lstat_is_directory_002
* @tc.desc Test Lstat.isDirectory() interface.
* This interface does not require parameters.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_is_directory_002', 0, async function () {
let dpath = await nextFileName('fileIO_lstat_is_directory_002') + 'd';
try {
fileIO.mkdirSync(dpath);
fileIO.lstatSync(dpath).isDirectory(-1);
expect(false).assertTrue();
} catch (e) {
fileIO.rmdirSync(dpath);
console.log('fileIO_lstat_is_directory_002 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_IS_FIFO_0000
* @tc.name fileIO_lstat_is_fifo_000
* @tc.desc Test Lstat.isFIFO() interface.
* This interface shall not treat a normal file as a FIFO.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_is_fifo_000', 0, async function () {
let fpath = await nextFileName('fileIO_lstat_is_fifo_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.lstatSync(fpath);
expect(stat.isFIFO() === false).assertTrue();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_lstat_is_fifo_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_IS_FIFO_0100
* @tc.name fileIO_lstat_is_fifo_001
* @tc.desc Test Lstat.isFIFO() interface.
* This interface does not require parameters.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_lstat_is_fifo_002', 0, async function () {
let fpath = await nextFileName('fileIO_test_lstat_is_fifo_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.lstatSync(fpath).isFIFO(-1);
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_test_lstat_is_fifo_002 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_IS_FILE_0000
* @tc.name fileIO_lstat_is_file_000
* @tc.desc Test Lstat.isFile() interface.
* This interface shall treat a normal file as a normal file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_is_file_000', 0, async function () {
let fpath = await nextFileName('fileIO_lstat_is_file_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.lstatSync(fpath);
expect(stat.isFile() === true).assertTrue();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_lstat_is_file_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_IS_FILE_0100
* @tc.name fileIO_lstat_is_file_001
* @tc.desc Test Lstat.isFile() interface.
* This interface shall not treat a directory as a normal file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_is_file_001', 0, async function () {
let dpath = await nextFileName('fileIO_lstat_is_file_001');
try {
fileIO.mkdirSync(dpath);
let stat = fileIO.lstatSync(dpath);
expect(stat.isFile() === false).assertTrue();
fileIO.rmdirSync(dpath);
} catch (e) {
console.log('fileIO_lstat_is_file_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_IS_FILE_0200
* @tc.name fileIO_test_lstat_is_file_002
* @tc.desc Test Lstat.isFile() interface.
* This interface does not require parameters.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_lstat_is_file_002', 0, async function () {
let dpath = await nextFileName('fileIO_test_lstat_is_file_002');
try {
fileIO.mkdirSync(dpath);
fileIO.lstatSync(dpath).isFile(-1);
expect(false).assertTrue();
} catch (e) {
fileIO.rmdirSync(dpath);
console.log('fileIO_test_lstat_is_file_002 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_IS_SOCKET_0000
* @tc.name fileIO_lstat_is_socket_000
* @tc.desc Test Lstat.isSocket() interface.
* This interface shall not treat a file as a socket.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_is_socket_000', 0, async function () {
let fpath = await nextFileName('fileIO_lstat_is_socket_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.lstatSync(fpath);
expect(stat.isSocket() === false).assertTrue();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_lstat_is_socket_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_IS_SOCKET_0100
* @tc.name fileIO_lstat_is_socket_001
* @tc.desc Test Lstat.isSocket() interface.
* This interface does not require parameters.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_is_socket_001', 0, async function () {
let fpath = await nextFileName('fileIO_lstat_is_socket_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.lstatSync(fpath).isSocket(-1);
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_lstat_is_socket_001 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_IS_SYMBOLIC_LINK_0000
* @tc.name fileIO_lstat_is_symbolic_link_000
* @tc.desc Test Lstat.isSymbolicLink() interface.
* This interface shall not treat a normal file as a symbolic link.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_is_symbolic_link_000', 0, async function () {
let fpath = await nextFileName('fileIO_lstat_is_symbolic_link_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.lstatSync(fpath);
expect(stat.isSymbolicLink() === false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_lstat_is_symbolic_link_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_IS_SYMBOLIC_LINK_0100
* @tc.name fileIO_lstat_is_symbolic_link_001
* @tc.desc Test Lstat.isSymbolicLink() interface.
* This interface does not require parameters.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_is_symbolic_link_001', 0, async function () {
let fpath = await nextFileName('fileIO_lstat_is_symbolic_link_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.lstatSync(fpath).isSymbolicLink(-1);
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_lstat_is_symbolic_link_001 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_0000
* @tc.name fileIO_lstat_async_000
* @tc.desc Test lstat() interface. Promise.then().catch()
* Enter the path parameter to get the file stat.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileIO_lstat_async_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_lstat_async_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.lstat(fpath).then((stat) => {
expect(stat !== null).assertTrue();
fileIO.unlinkSync(fpath);
done();
}).catch((err) => {
console.log('fileIO_lstat_async_000 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
});
} catch (e) {
console.log('fileIO_lstat_async_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_0100
* @tc.name fileIO_lstat_async_001
* @tc.desc Test lstat() interface. Callback.
* Enter the path or parameter to get the file stat.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_async_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_lstat_async_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.lstat(fpath, (err) => {
if(err) {
console.log('fileIO_lstat_async_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
fileIO.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_lstat_async_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_0200
* @tc.name fileIO_lstat_async_002
* @tc.desc Test lstat() interface. Promise.
* Enter the path or parameter to get the file stat.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_async_002', 0, async function (done) {
let fpath = await nextFileName('fileIO_lstat_async_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.lstat(fpath);
expect(stat !== null).assertTrue();
fileIO.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_lstat_async_002 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_0300
* @tc.name fileIO_lstat_async_003
* @tc.desc Test lstat() interface.
* The path point to nothing, no such file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_async_003', 0, async function (done) {
let fpath = await nextFileName('fileIO_lstat_async_003');
try {
fileIO.lstat(fpath, (err) => {
if (err) {
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();
}
});
} catch (e) {
console.log('fileIO_lstat_async_003 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_0400
* @tc.name fileIO_lstat_async_004
* @tc.desc Test lstat() interface. Promise.
* The path point to nothing, no such file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_async_004', 0, async function (done) {
let fpath = await nextFileName('fileIO_lstat_async_004');
try {
await fileIO.lstat(fpath);
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_lstat_async_004 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900002 && e.message == 'No such file or directory').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_INO_0000
* @tc.name fileIO_lstat_async_ino_000
* @tc.desc Test the ino member of class Stat. Promise.
* Enter the path parameter to get stat.ino of the file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_async_ino_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_lstat_async_ino_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.lstat(fpath);
expect(isBigInt(stat.ino)).assertTrue();
fileIO.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_lstat_async_ino_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_INO_0100
* @tc.name fileIO_lstat_async_ino_001
* @tc.desc Test the ino member of class Stat. Callback.
* Enter the path parameter to get stat.ino of the file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_async_ino_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_lstat_async_ino_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.lstat(fpath, (err, stat) => {
if(err) {
console.log('fileIO_lstat_async_ino_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(isBigInt(stat.ino)).assertTrue();
fileIO.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_lstat_async_ino_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_MODE_0000
* @tc.name fileIO_lstat_async_mode_000
* @tc.desc Test the mode member of class Stat. Promise.
* Enter the path or parameter to get stat.mode of the file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_async_mode_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_lstat_async_mode_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.lstat(fpath);
expect(isIntNum(stat.mode)).assertTrue();
fileIO.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_lstat_async_mode_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_MODE_0100
* @tc.name fileIO_lstat_async_mode_001
* @tc.desc Test the mode member of class Stat. Callback.
* Enter the path or parameter to get stat.mode of the file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_async_mode_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_lstat_async_mode_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.lstat(fpath, (err, stat) => {
if(err) {
console.log('fileIO_lstat_async_mode_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(isIntNum(stat.mode)).assertTrue();
fileIO.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_lstat_async_mode_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_UID_0000
* @tc.name fileIO_lstat_async_uid_000
* @tc.desc Test the uid member of class Stat. Promise.
* Enter the path parameter to get stat.uid of the file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_async_uid_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_lstat_async_uid_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.lstat(fpath);
expect(isIntNum(stat.uid)).assertTrue();
fileIO.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_lstat_async_uid_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_UID_0100
* @tc.name fileIO_lstat_async_uid_001
* @tc.desc Test the uid member of class Stat. Callback.
* Enter the path parameter to get stat.uid of the file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_async_uid_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_lstat_async_uid_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.lstat(fpath, (err, stat) => {
if(err) {
console.log('fileIO_lstat_async_uid_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(isIntNum(stat.uid)).assertTrue();
fileIO.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_lstat_async_uid_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_GID_0000
* @tc.name fileIO_lstat_async_gid_000
* @tc.desc Test the gid member of class Stat. Promise.
* Enter the path parameter to get stat.gid of the file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_async_gid_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_lstat_async_gid_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.lstat(fpath);
expect(isIntNum(stat.gid)).assertTrue();
fileIO.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_lstat_async_gid_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_GID_0100
* @tc.name fileIO_lstat_async_gid_001
* @tc.desc Test the gid member of class Stat. Callback.
* Enter the path parameter to get stat.gid of the file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_async_gid_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_lstat_async_gid_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.lstat(fpath, (err, stat) => {
if (err) {
console.log('fileIO_lstat_async_gid_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(isIntNum(stat.gid)).assertTrue();
fileIO.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_lstat_async_gid_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_SIZE_0000
* @tc.name fileIO_lstat_async_size_000
* @tc.desc Test the size member of class Stat. Promise.
* Enter the path parameter to get stat.size of the file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_async_size_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_lstat_async_size_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.lstat(fpath);
expect(isIntNum(stat.size)).assertTrue();
fileIO.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_lstat_async_size_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_SIZE_0100
* @tc.name fileIO_lstat_async_size_001
* @tc.desc Test the size member of class Stat. Callback.
* Enter the path parameter to get stat.size of the file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_async_size_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_lstat_async_size_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.lstat(fpath, (err, stat) => {
if (err) {
console.log('fileIO_lstat_async_size_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(isIntNum(stat.size)).assertTrue();
fileIO.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_lstat_async_size_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_ATIME_0000
* @tc.name fileIO_lstat_async_atime_000
* @tc.desc Test the atime member of class Stat. Promise.
* Enter the path parameter to get stat.atime of the file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_async_atime_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_lstat_async_atime_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.lstat(fpath);
expect(isIntNum(stat.atime)).assertTrue();
fileIO.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_lstat_async_atime_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_ATIME_0100
* @tc.name fileIO_lstat_async_atime_001
* @tc.desc Test the atime member of class Stat. Callback.
* Enter the path or fd parameter to get stat.atime of the file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_async_atime_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_lstat_async_atime_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.lstat(fpath, (err, stat) => {
if (err) {
console.log('fileIO_lstat_async_atime_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(isIntNum(stat.atime)).assertTrue();
fileIO.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_lstat_async_atime_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_MTIME_0000
* @tc.name fileIO_lstat_async_mtime_000
* @tc.desc Test the mtime member of class Stat. Promise.
* Enter the path or fd parameter to get stat.mtime of the file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_async_mtime_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_lstat_async_mtime_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.lstat(fpath);
expect(isIntNum(stat.mtime)).assertTrue();
fileIO.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_lstat_async_mtime_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_MTIME_0100
* @tc.name fileIO_lstat_async_mtime_001
* @tc.desc Test the mtime member of class Stat. Callback.
* Enter the path or fd parameter to get stat.mtime of the file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_async_mtime_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_lstat_async_mtime_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.lstat(fpath, (err, stat) => {
if (err) {
console.log('fileIO_lstat_async_mtime_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(isIntNum(stat.mtime)).assertTrue();
fileIO.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_lstat_async_mtime_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_CTIME_0000
* @tc.name fileIO_lstat_async_ctime_000
* @tc.desc Test the ctime member of class Stat. Promise.
* Enter the path or fd parameter to get stat.ctime of the file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_async_ctime_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_lstat_async_ctime_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.lstat(fpath);
expect(isIntNum(stat.ctime)).assertTrue();
fileIO.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_lstat_async_ctime_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_CTIME_0100
* @tc.name fileIO_lstat_async_ctime_001
* @tc.desc Test the ctime member of class Stat. Callback.
* Enter the path or fd parameter to get stat.ctime of the file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_async_ctime_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_lstat_async_ctime_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.lstat(fpath, (err, stat) => {
if (err) {
console.log('fileIO_lstat_async_ctime_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(isIntNum(stat.ctime)).assertTrue();
fileIO.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_lstat_async_ctime_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_IS_BLOCK_DEVICE_0000
* @tc.name fileIO_lstat_async_is_block_device_000
* @tc.desc Test the isBlockDevice() method of class Stat. Promise.
* This interface shall not treat a normal file as a block special device.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_async_is_block_device_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_lstat_async_is_block_device_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.lstat(fpath);
expect(stat.isBlockDevice() === false).assertTrue();
fileIO.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_lstat_async_is_block_device_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_IS_BLOCK_DEVICE_0010
* @tc.name fileIO_lstat_async_is_block_device_001
* @tc.desc Test the isBlockDevice() method of class Stat. Callback.
* This interface shall not treat a normal file as a block special device.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_async_is_block_device_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_lstat_async_is_block_device_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.lstat(fpath, (err, stat) => {
if (err) {
console.log('fileIO_lstat_async_is_block_device_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(stat.isBlockDevice() === false).assertTrue();
fileIO.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_lstat_async_is_block_device_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_IS_CHARACTER_DEVICE_0000
* @tc.name fileIO_lstat_async_is_character_device_000
* @tc.desc Test the isCharacterDevice() method of class Stat. Promise.
* This interface shall not treat a normal file as a character special device.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_async_is_character_device_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_lstat_async_is_character_device_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.lstat(fpath);
expect(stat.isCharacterDevice() === false).assertTrue();
fileIO.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_lstat_async_is_character_device_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_IS_CHARACTER_DEVICE_0010
* @tc.name fileIO_lstat_async_is_character_device_001
* @tc.desc Test the isCharacterDevice() method of class Stat. Callback.
* This interface shall not treat a normal file as a character special device.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_async_is_character_device_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_lstat_async_is_character_device_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.lstat(fpath, (err, stat) => {
if (err) {
console.log('fileIO_lstat_async_is_character_device_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(stat.isCharacterDevice() === false).assertTrue();
fileIO.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_lstat_async_is_character_device_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_IS_DIRECTORY_0000
* @tc.name fileIO_lstat_async_is_directory_000
* @tc.desc Test the isDirectory() method of class Stat. Promise.
* This interface shall not treat a normal file as a directory.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_async_is_directory_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_lstat_async_is_directory_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.lstat(fpath);
expect(stat.isDirectory() === false).assertTrue();
fileIO.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_lstat_async_is_directory_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_IS_DIRECTORY_0010
* @tc.name fileIO_lstat_async_is_directory_001
* @tc.desc Test the isDirectory() method of class Stat. Promise.
* This interface shall not treat a directory as a directory.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_async_is_directory_001', 0, async function (done) {
let dpath = await nextFileName('fileIO_lstat_async_is_directory_001') + 'd';
try {
fileIO.mkdirSync(dpath);
let stat = await fileIO.lstat(dpath);
expect(stat.isDirectory() === true).assertTrue();
fileIO.rmdirSync(dpath);
done();
} catch (e) {
console.log('fileIO_lstat_async_is_directory_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_IS_DIRECTORY_0020
* @tc.name fileIO_lstat_async_is_directory_002
* @tc.desc Test the isDirectory() method of class Stat. Callback.
* This interface shall not treat a directory as a directory.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_async_is_directory_002', 0, async function (done) {
let dpath = await nextFileName('fileIO_lstat_async_is_directory_002') + 'd';
try {
fileIO.mkdirSync(dpath);
fileIO.lstat(dpath, (err, stat) => {
if (err) {
console.log('fileIO_lstat_async_is_directory_002 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(stat.isDirectory() === true).assertTrue();
fileIO.rmdirSync(dpath);
done();
});
} catch (e) {
console.log('fileIO_lstat_async_is_directory_002 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_IS_FIFO_0000
* @tc.name fileIO_lstat_async_is_fifo_000
* @tc.desc Test the isFIFO() method of class Stat. Promise.
* This interface shall not treat a normal file as a FIFO.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_async_is_fifo_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_lstat_async_is_fifo_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.lstat(fpath);
expect(stat.isFIFO() === false).assertTrue();
fileIO.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_lstat_async_is_fifo_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_IS_FIFO_0010
* @tc.name fileIO_lstat_async_is_fifo_001
* @tc.desc Test the isFIFO() method of class Stat. Callback.
* This interface shall not treat a normal file as a FIFO.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_async_is_fifo_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_lstat_async_is_fifo_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.lstat(fpath, (err, stat) => {
if (err) {
console.log('fileIO_lstat_async_is_character_device_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(stat.isFIFO() === false).assertTrue();
fileIO.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_lstat_async_is_fifo_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_IS_FILE_0000
* @tc.name fileIO_lstat_async_is_file_000
* @tc.desc Test the isFile() method of class Stat. Promise.
* This interface shall treat a normal file as a normal file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_async_is_file_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_lstat_async_is_file_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.lstat(fpath);
expect(stat.isFile() === true).assertTrue();
fileIO.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_lstat_async_is_file_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_IS_FILE_0010
* @tc.name fileIO_lstat_async_is_file_001
* @tc.desc Test the isFile() method of class Stat. Callback.
* This interface shall treat a normal file as a normal file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_async_is_file_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_lstat_async_is_file_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.lstat(fpath, (err, stat) => {
if (err) {
console.log('fileIO_lstat_async_is_file_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(stat.isFile() === true).assertTrue();
fileIO.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_lstat_async_is_file_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_IS_FILE_0020
* @tc.name fileIO_lstat_async_is_file_002
* @tc.desc Test the isFile() method of class Stat. Promise.
* This interface shall not treat a directory as a normal file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_async_is_file_002', 0, async function (done) {
let dpath = await nextFileName('fileIO_lstat_async_is_file_002');
try {
fileIO.mkdirSync(dpath);
let stat = await fileIO.lstat(dpath);
expect(stat.isFile() === false).assertTrue();
fileIO.rmdirSync(dpath);
done();
} catch (e) {
console.log('fileIO_lstat_async_is_file_002 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_IS_SOCKET_0000
* @tc.name fileIO_lstat_async_is_socket_000
* @tc.desc Test the isSocket() method of class Stat. Promise.
* This interface shall not treat a file as a socket.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_async_is_socket_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_lstat_async_is_socket_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.lstat(fpath);
expect(stat.isSocket() === false).assertTrue();
fileIO.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_lstat_async_is_socket_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_IS_SOCKET_0010
* @tc.name fileIO_lstat_async_is_socket_001
* @tc.desc Test the isSocket() method of class Stat. Callback.
* This interface shall not treat a file as a socket.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_async_is_socket_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_lstat_async_is_socket_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.lstat(fpath, (err, stat) => {
if (err) {
console.log('fileIO_lstat_async_is_socket_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(stat.isSocket() === false).assertTrue();
fileIO.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_lstat_async_is_socket_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_IS_SYMBOLIC_LINK_0000
* @tc.name fileIO_lstat_async_is_symbolic_link_000
* @tc.desc Test the isSymbolicLink() method of class Stat. Promise.
* This interface shall not treat a normal file as a symbolic link.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_async_is_symbolic_link_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_lstat_async_is_symbolic_link_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.lstat(fpath);
expect(stat.isSymbolicLink() === false).assertTrue();
fileIO.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_lstat_async_is_symbolic_link_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_IS_SYMBOLIC_LINK_0100
* @tc.name fileIO_lstat_async_is_symbolic_link_001
* @tc.desc Test the isSymbolicLink() method of class Stat. Callback.
* This interface shall not treat a normal file as a symbolic link.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_lstat_async_is_symbolic_link_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_lstat_async_is_symbolic_link_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.lstat(fpath, (err, stat) => {
if (err) {
console.log('fileIO_lstat_async_is_symbolic_link_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(stat.isSymbolicLink() === false).assertTrue();
fileIO.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_lstat_async_is_symbolic_link_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_APPEND_FILE_SYNC_0010
* @tc.name fileIO_test_append_file_sync_000
* @tc.desc Test lstat.lstatSync() interface.
* Modify the file, view the file status changes by path.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_append_file_sync_000', 0, async function () {
let fpath = await nextFileName('fileIO_test_append_file_sync_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.lstatSync(fpath);
expect(isIntNum(stat.size)).assertTrue();
let file = fileIO.openSync(fpath, fileIO.OpenMode.APPEND | fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file.fd)).assertTrue();
expect(fileIO.writeSync(file.fd, FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
fileIO.closeSync(file);
stat = fileIO.lstatSync(fpath);
expect(stat.size == FILE_CONTENT.length * 2).assertTrue();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_append_file_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
})
}
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { fileIO, nextFileName, describe, it, expect } from '../Common';
export default function fileIOMkdtemp() {
describe('fileIO_fs_mkdtemp', function () {
/**
* @tc.number SUB_DF_FILEIO_MKDTEMP_SYNC_0000
* @tc.name fileIO_test_mkdtemp_sync_000
* @tc.desc Test mkdtempSync() interface.
* Create a temporary directory, verify the normal function.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_mkdtemp_sync_000', 0, async function () {
let dpath = await nextFileName('fileIO_test_mkdtemp_sync_000');
try {
dpath = dpath + 'XXXXXX';
let res = fileIO.mkdtempSync(dpath);
expect(fileIO.accessSync(res)).assertTrue();
fileIO.rmdirSync(res);
} catch (e) {
console.log('fileIO_test_mkdtemp_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_MKDTEMP_SYNC_0100
* @tc.name fileIO_test_mkdtemp_sync_001
* @tc.desc Test mkdtempSync() interface.
* The directory should end in XXXXXX.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_mkdtemp_sync_001', 0, async function () {
let dpath = await nextFileName('fileIO_test_mkdtemp_sync_000');
try {
fileIO.mkdtempSync(dpath);
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_mkdtemp_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_MKDTEMP_SYNC_0200
* @tc.name fileIO_test_mkdtemp_sync_002
* @tc.desc Test mkdtempSync() interface.
* Missing parameters.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_mkdtemp_sync_002', 0, async function () {
try {
fileIO.mkdtempSync();
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_mkdtemp_sync_002 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_MKDTEMP_ASYNC_0000
* @tc.name fileIO_test_mkdtemp_async_000
* @tc.desc Test mkdtemp() interface. Promise.
* Create a temporary directory, verify the normal function.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_mkdtemp_async_000', 0, async function (done) {
let dpath = await nextFileName('fileIO_test_mkdtemp_async_000');
try {
dpath = dpath + 'XXXXXX';
let res = await fileIO.mkdtemp(dpath);
expect(fileIO.accessSync(res)).assertTrue();
fileIO.rmdirSync(res);
done();
} catch (e) {
console.log('fileIO_test_mkdtemp_async_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_MKDTEMP_ASYNC_0100
* @tc.name fileIO_test_mkdtemp_async_001
* @tc.desc Test mkdtemp() interface. Callback.
* Create a temporary directory, verify the normal function.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_mkdtemp_async_001', 0, async function (done) {
let dpath = await nextFileName('fileIO_test_mkdtemp_async_001');
try {
dpath = dpath + 'XXXXXX';
fileIO.mkdtemp(dpath, (err, res) => {
if (err) {
console.log('fileIO_test_mkdtemp_async_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(fileIO.accessSync(res)).assertTrue();
fileIO.rmdirSync(res);
done();
});
} catch (e) {
console.log('fileIO_test_mkdtemp_async_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_MKDTEMP_ASYNC_0200
* @tc.name fileIO_test_mkdtemp_async_002
* @tc.desc Test mkdtemp() interface. Promise.
* The directory should end in XXXXXX.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_mkdtemp_async_002', 0, async function (done) {
let dpath = await nextFileName('fileIO_test_mkdtemp_async_002');
try {
await fileIO.mkdtemp(dpath);
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_mkdtemp_async_002 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_MKDTEMP_ASYNC_0300
* @tc.name fileIO_test_mkdtemp_async_003
* @tc.desc Test mkdtemp() interface. Callback.
* The directory should end in XXXXXX.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_mkdtemp_async_003', 0, async function (done) {
let dpath = await nextFileName('fileIO_test_mkdtemp_async_003');
try {
fileIO.mkdtemp(dpath, (err) => {
if (err) {
console.log('fileIO_test_mkdtemp_async_003 error package: ' + JSON.stringify(err));
expect(err.code == 13900020 && err.message == 'Invalid argument').assertTrue();
done();
}
});
} catch (e) {
console.log('fileIO_test_mkdtemp_async_003 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_MKDTEMP_ASYNC_0400
* @tc.name fileIO_test_mkdtemp_async_004
* @tc.desc Test mkdtemp() interface. Promise.
* Missing parameters.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_mkdtemp_async_004', 0, async function (done) {
try {
await fileIO.mkdtemp();
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_mkdtemp_async_004 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
}
});
});
}
...@@ -14,8 +14,7 @@ ...@@ -14,8 +14,7 @@
*/ */
import { import {
fileio, fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum, fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum, describe, it, expect,
describe, it, expect,
} from '../Common'; } from '../Common';
export default function fileIOOpen() { export default function fileIOOpen() {
...@@ -40,8 +39,8 @@ export default function fileIOOpen() { ...@@ -40,8 +39,8 @@ export default function fileIOOpen() {
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
let readlen = fileIO.readSync(file.fd, new ArrayBuffer(4096)); let readlen = fileIO.readSync(file.fd, new ArrayBuffer(4096));
expect(readlen == FILE_CONTENT.length).assertTrue(); expect(readlen == FILE_CONTENT.length).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_open_sync_000 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_open_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -55,7 +54,7 @@ export default function fileIOOpen() { ...@@ -55,7 +54,7 @@ export default function fileIOOpen() {
* Open the file in write-only mode, verifying the file is writable. * Open the file in write-only mode, verifying the file is writable.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_sync_001', 0, async function () { it('fileIO_test_open_sync_001', 0, async function () {
...@@ -65,10 +64,10 @@ export default function fileIOOpen() { ...@@ -65,10 +64,10 @@ export default function fileIOOpen() {
try { try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
let num = fileIO.writeSync(file.fd, FILE_CONTENT); let bytesWritten = fileIO.writeSync(file.fd, FILE_CONTENT);
expect(num == FILE_CONTENT.length).assertTrue(); expect(bytesWritten == FILE_CONTENT.length).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_open_sync_001 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_open_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -82,7 +81,7 @@ export default function fileIOOpen() { ...@@ -82,7 +81,7 @@ export default function fileIOOpen() {
* Open the file in read-write mode, verifying the file is readable and writable. * Open the file in read-write mode, verifying the file is readable and writable.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_sync_002', 0, async function () { it('fileIO_test_open_sync_002', 0, async function () {
...@@ -95,10 +94,10 @@ export default function fileIOOpen() { ...@@ -95,10 +94,10 @@ export default function fileIOOpen() {
let readlen = fileIO.readSync(file.fd, new ArrayBuffer(4096)); let readlen = fileIO.readSync(file.fd, new ArrayBuffer(4096));
expect(readlen == FILE_CONTENT.length).assertTrue(); expect(readlen == FILE_CONTENT.length).assertTrue();
let length = 20; let length = 20;
let num = fileIO.writeSync(file.fd, new ArrayBuffer(length)); let bytesWritten = fileIO.writeSync(file.fd, new ArrayBuffer(length));
expect(num == length).assertTrue(); expect(bytesWritten == length).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_open_sync_002 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_open_sync_002 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -111,7 +110,7 @@ export default function fileIOOpen() { ...@@ -111,7 +110,7 @@ export default function fileIOOpen() {
* @tc.desc Test openSync() interfaces. Missing parameters. * @tc.desc Test openSync() interfaces. Missing parameters.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_sync_003', 0, function () { it('fileIO_test_open_sync_003', 0, function () {
...@@ -131,7 +130,7 @@ export default function fileIOOpen() { ...@@ -131,7 +130,7 @@ export default function fileIOOpen() {
* If the path point to the file which does not exist, the file can be created. * If the path point to the file which does not exist, the file can be created.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_sync_004', 0, async function () { it('fileIO_test_open_sync_004', 0, async function () {
...@@ -140,8 +139,8 @@ export default function fileIOOpen() { ...@@ -140,8 +139,8 @@ export default function fileIOOpen() {
try { try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.CREATE | fileIO.OpenMode.READ_WRITE); let file = fileIO.openSync(fpath, fileIO.OpenMode.CREATE | fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_open_sync_004 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_open_sync_004 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -155,7 +154,7 @@ export default function fileIOOpen() { ...@@ -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. * If the file exists and the file is opened for read-write, trim its length to zero.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_sync_005', 0, async function () { it('fileIO_test_open_sync_005', 0, async function () {
...@@ -165,10 +164,10 @@ export default function fileIOOpen() { ...@@ -165,10 +164,10 @@ export default function fileIOOpen() {
try { try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.TRUNC | fileIO.OpenMode.READ_WRITE); let file = fileIO.openSync(fpath, fileIO.OpenMode.TRUNC | fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
let number = fileIO.readSync(file.fd, new ArrayBuffer(4096)); let readLen = fileIO.readSync(file.fd, new ArrayBuffer(4096));
expect(number == 0).assertTrue(); expect(readLen == 0).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_open_sync_005 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_open_sync_005 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -182,7 +181,7 @@ export default function fileIOOpen() { ...@@ -182,7 +181,7 @@ export default function fileIOOpen() {
* Open as append, subsequent writes will append to the end of the file. * Open as append, subsequent writes will append to the end of the file.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_sync_006', 0, async function () { it('fileIO_test_open_sync_006', 0, async function () {
...@@ -193,12 +192,12 @@ export default function fileIOOpen() { ...@@ -193,12 +192,12 @@ export default function fileIOOpen() {
let file = fileIO.openSync(fpath, fileIO.OpenMode.APPEND | fileIO.OpenMode.READ_WRITE); let file = fileIO.openSync(fpath, fileIO.OpenMode.APPEND | fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
let length = 100; let length = 100;
let num = fileIO.writeSync(file.fd, new ArrayBuffer(length)); let bytesWritten = fileIO.writeSync(file.fd, new ArrayBuffer(length));
expect(num == length).assertTrue(); expect(bytesWritten == length).assertTrue();
let number = fileIO.readSync(file.fd, new ArrayBuffer(4096), { offset: 0 }); let readLen = fileIO.readSync(file.fd, new ArrayBuffer(4096), { offset: 0 });
expect(number == length + FILE_CONTENT.length).assertTrue(); expect(readLen == length + FILE_CONTENT.length).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_open_sync_006 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_open_sync_006 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -212,7 +211,7 @@ export default function fileIOOpen() { ...@@ -212,7 +211,7 @@ export default function fileIOOpen() {
* If the file is a special file, the opening and subsequent IOs perform non-blocking operations. * If the file is a special file, the opening and subsequent IOs perform non-blocking operations.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_sync_007', 0, async function () { it('fileIO_test_open_sync_007', 0, async function () {
...@@ -222,8 +221,8 @@ export default function fileIOOpen() { ...@@ -222,8 +221,8 @@ export default function fileIOOpen() {
try { try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.NONBLOCK | fileIO.OpenMode.READ_WRITE); let file = fileIO.openSync(fpath, fileIO.OpenMode.NONBLOCK | fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_open_sync_007 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_open_sync_007 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -237,17 +236,17 @@ export default function fileIOOpen() { ...@@ -237,17 +236,17 @@ export default function fileIOOpen() {
* The path points to a directory. * The path points to a directory.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_sync_008', 0, async function () { it('fileIO_test_open_sync_008', 0, async function () {
let dpath = await nextFileName('fileIO_test_open_sync_008'); let dpath = await nextFileName('fileIO_test_open_sync_008');
fileio.mkdirSync(dpath); fileIO.mkdirSync(dpath);
try { try {
let file = fileIO.openSync(dpath, fileIO.OpenMode.DIR); let file = fileIO.openSync(dpath, fileIO.OpenMode.DIR);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileio.rmdirSync(dpath); fileIO.rmdirSync(dpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_open_sync_008 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_open_sync_008 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -261,7 +260,7 @@ export default function fileIOOpen() { ...@@ -261,7 +260,7 @@ export default function fileIOOpen() {
* The path does not a directory, throw error. * The path does not a directory, throw error.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_sync_009', 0, async function () { it('fileIO_test_open_sync_009', 0, async function () {
...@@ -272,7 +271,7 @@ export default function fileIOOpen() { ...@@ -272,7 +271,7 @@ export default function fileIOOpen() {
fileIO.openSync(fpath, fileIO.OpenMode.DIR); fileIO.openSync(fpath, fileIO.OpenMode.DIR);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_test_open_sync_009 has failed for ' + e.message + ', code: ' + e.code); 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(); expect(e.code == 13900018 && e.message == 'Not a directory').assertTrue();
} }
...@@ -285,7 +284,7 @@ export default function fileIOOpen() { ...@@ -285,7 +284,7 @@ export default function fileIOOpen() {
* The path does not point to a symbolic link. * The path does not point to a symbolic link.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_sync_010', 0, async function () { it('fileIO_test_open_sync_010', 0, async function () {
...@@ -295,8 +294,8 @@ export default function fileIOOpen() { ...@@ -295,8 +294,8 @@ export default function fileIOOpen() {
try { try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.NOFOLLOW | fileIO.OpenMode.READ_WRITE); let file = fileIO.openSync(fpath, fileIO.OpenMode.NOFOLLOW | fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_open_sync_010 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_open_sync_010 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -310,7 +309,7 @@ export default function fileIOOpen() { ...@@ -310,7 +309,7 @@ export default function fileIOOpen() {
* The path points to a symbolic link, throw error. * The path points to a symbolic link, throw error.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_sync_011', 0, async function () { it('fileIO_test_open_sync_011', 0, async function () {
...@@ -319,12 +318,12 @@ export default function fileIOOpen() { ...@@ -319,12 +318,12 @@ export default function fileIOOpen() {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
fileio.symlinkSync(fpath, ffpath); fileIO.symlinkSync(fpath, ffpath);
fileIO.openSync(ffpath, fileIO.OpenMode.NOFOLLOW | fileIO.OpenMode.READ_WRITE); fileIO.openSync(ffpath, fileIO.OpenMode.NOFOLLOW | fileIO.OpenMode.READ_WRITE);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
fileio.unlinkSync(ffpath); fileIO.unlinkSync(ffpath);
console.log('fileIO_test_open_sync_011 has failed for ' + e.message + ', code: ' + e.code); 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(); expect(e.code == 13900033 && e.message == 'Too many symbolic links encountered').assertTrue();
} }
...@@ -337,7 +336,7 @@ export default function fileIOOpen() { ...@@ -337,7 +336,7 @@ export default function fileIOOpen() {
* Open the file in the way of synchronous IO. * Open the file in the way of synchronous IO.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_sync_012', 0, async function () { it('fileIO_test_open_sync_012', 0, async function () {
...@@ -347,8 +346,8 @@ export default function fileIOOpen() { ...@@ -347,8 +346,8 @@ export default function fileIOOpen() {
try { try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.SYNC | fileIO.OpenMode.READ_WRITE); let file = fileIO.openSync(fpath, fileIO.OpenMode.SYNC | fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_open_sync_012 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_open_sync_012 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -361,7 +360,7 @@ export default function fileIOOpen() { ...@@ -361,7 +360,7 @@ export default function fileIOOpen() {
* @tc.desc Test openSync() interfaces. Invalid path. * @tc.desc Test openSync() interfaces. Invalid path.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_sync_013', 0, async function (done) { it('fileIO_test_open_sync_013', 0, async function (done) {
...@@ -394,10 +393,10 @@ export default function fileIOOpen() { ...@@ -394,10 +393,10 @@ export default function fileIOOpen() {
let file = await fileIO.open(fpath, fileIO.OpenMode.READ_ONLY); let file = await fileIO.open(fpath, fileIO.OpenMode.READ_ONLY);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileIO.read(file.fd, new ArrayBuffer(4096)) fileIO.read(file.fd, new ArrayBuffer(4096))
.then((res) => { .then((readLen) => {
expect(res == FILE_CONTENT.length).assertTrue(); expect(readLen == FILE_CONTENT.length).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
} catch (e) { } catch (e) {
...@@ -413,7 +412,7 @@ export default function fileIOOpen() { ...@@ -413,7 +412,7 @@ export default function fileIOOpen() {
* Open the file in read-only mode, verifying the file is readable. * Open the file in read-only mode, verifying the file is readable.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_async_001', 0, async function (done) { it('fileIO_test_open_async_001', 0, async function (done) {
...@@ -428,10 +427,10 @@ export default function fileIOOpen() { ...@@ -428,10 +427,10 @@ export default function fileIOOpen() {
} }
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileIO.read(file.fd, new ArrayBuffer(4096)) fileIO.read(file.fd, new ArrayBuffer(4096))
.then((res) => { .then((readLen) => {
expect(res == FILE_CONTENT.length).assertTrue(); expect(readLen == FILE_CONTENT.length).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
}); });
...@@ -448,7 +447,7 @@ export default function fileIOOpen() { ...@@ -448,7 +447,7 @@ export default function fileIOOpen() {
* Open the file in write-only mode, verifying the file is writable. * Open the file in write-only mode, verifying the file is writable.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_async_002', 0, async function (done) { it('fileIO_test_open_async_002', 0, async function (done) {
...@@ -460,10 +459,10 @@ export default function fileIOOpen() { ...@@ -460,10 +459,10 @@ export default function fileIOOpen() {
let file = await fileIO.open(fpath, fileIO.OpenMode.WRITE_ONLY); let file = await fileIO.open(fpath, fileIO.OpenMode.WRITE_ONLY);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileIO.write(file.fd, new ArrayBuffer(length)) fileIO.write(file.fd, new ArrayBuffer(length))
.then((num) => { .then((bytesWritten) => {
expect(num == length).assertTrue(); expect(bytesWritten == length).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
} catch (e) { } catch (e) {
...@@ -479,7 +478,7 @@ export default function fileIOOpen() { ...@@ -479,7 +478,7 @@ export default function fileIOOpen() {
* Open the file in write-only mode, verifying the file is writable. * Open the file in write-only mode, verifying the file is writable.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_async_003', 0, async function (done) { it('fileIO_test_open_async_003', 0, async function (done) {
...@@ -495,10 +494,10 @@ export default function fileIOOpen() { ...@@ -495,10 +494,10 @@ export default function fileIOOpen() {
} }
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileIO.write(file.fd, new ArrayBuffer(length)) fileIO.write(file.fd, new ArrayBuffer(length))
.then((num) => { .then((bytesWritten) => {
expect(num == length).assertTrue(); expect(bytesWritten == length).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
}); });
}); });
done(); done();
...@@ -515,7 +514,7 @@ export default function fileIOOpen() { ...@@ -515,7 +514,7 @@ export default function fileIOOpen() {
* The path point to nothing, no such file. * The path point to nothing, no such file.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_async_004', 0, async function (done) { it('fileIO_test_open_async_004', 0, async function (done) {
...@@ -538,7 +537,7 @@ export default function fileIOOpen() { ...@@ -538,7 +537,7 @@ export default function fileIOOpen() {
* The path point to nothing, no such file. * The path point to nothing, no such file.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_async_005', 0, async function (done) { it('fileIO_test_open_async_005', 0, async function (done) {
...@@ -547,7 +546,7 @@ export default function fileIOOpen() { ...@@ -547,7 +546,7 @@ export default function fileIOOpen() {
try { try {
fileIO.open(fpath, fileIO.OpenMode.READ_WRITE, (err) => { fileIO.open(fpath, fileIO.OpenMode.READ_WRITE, (err) => {
if(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(); expect(err.code == 13900002 && err.message == 'No such file or directory').assertTrue();
done(); done();
} }
...@@ -565,7 +564,7 @@ export default function fileIOOpen() { ...@@ -565,7 +564,7 @@ export default function fileIOOpen() {
* The path point to nothing, no such file. * The path point to nothing, no such file.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_async_006', 0, async function () { it('fileIO_test_open_async_006', 0, async function () {
...@@ -575,8 +574,8 @@ export default function fileIOOpen() { ...@@ -575,8 +574,8 @@ export default function fileIOOpen() {
fileIO.open(fpath, fileIO.OpenMode.READ_WRITE).then(() => { fileIO.open(fpath, fileIO.OpenMode.READ_WRITE).then(() => {
expect(false).assertTrue(); expect(false).assertTrue();
}).catch((err) => { }).catch((err) => {
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_test_open_async_006 error package: {' + err.message + ', code: ' + err.code + '}'); 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(); expect(err.code == 13900002 && err.message == 'No such file or directory').assertTrue();
}); });
} catch (e) { } catch (e) {
...@@ -592,7 +591,7 @@ export default function fileIOOpen() { ...@@ -592,7 +591,7 @@ export default function fileIOOpen() {
* Invalid path. * Invalid path.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_async_007', 0, async function (done) { it('fileIO_test_open_async_007', 0, async function (done) {
...@@ -614,13 +613,13 @@ export default function fileIOOpen() { ...@@ -614,13 +613,13 @@ export default function fileIOOpen() {
* Invalid path. * Invalid path.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_async_008', 0, async function (done) { it('fileIO_test_open_async_008', 0, async function (done) {
try { try {
fileIO.open(-1, fileIO.OpenMode.READ_WRITE, () => { fileIO.open(-1, fileIO.OpenMode.READ_WRITE, (err) => {
expect(false).assertTrue(); expect(false).assertTrue();
}); });
} catch (e) { } catch (e) {
...@@ -637,7 +636,7 @@ export default function fileIOOpen() { ...@@ -637,7 +636,7 @@ export default function fileIOOpen() {
* If the path point to the file which does not exist, the file can be created. * If the path point to the file which does not exist, the file can be created.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_async_009', 0, async function (done) { it('fileIO_test_open_async_009', 0, async function (done) {
...@@ -646,8 +645,8 @@ export default function fileIOOpen() { ...@@ -646,8 +645,8 @@ export default function fileIOOpen() {
try { try {
let file = await fileIO.open(fpath, fileIO.OpenMode.CREATE | fileIO.OpenMode.READ_WRITE); let file = await fileIO.open(fpath, fileIO.OpenMode.CREATE | fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_test_open_async_009 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_open_async_009 has failed for ' + e.message + ', code: ' + e.code);
...@@ -662,7 +661,7 @@ export default function fileIOOpen() { ...@@ -662,7 +661,7 @@ export default function fileIOOpen() {
* If the path point to the file which does not exist, the file can be created. * If the path point to the file which does not exist, the file can be created.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_async_010', 0, async function (done) { it('fileIO_test_open_async_010', 0, async function (done) {
...@@ -675,8 +674,8 @@ export default function fileIOOpen() { ...@@ -675,8 +674,8 @@ export default function fileIOOpen() {
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
} catch (e) { } catch (e) {
...@@ -692,7 +691,7 @@ export default function fileIOOpen() { ...@@ -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. * If the file exists and the file is opened for read-write, trim its length to zero.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_async_011', 0, async function (done) { it('fileIO_test_open_async_011', 0, async function (done) {
...@@ -703,10 +702,10 @@ export default function fileIOOpen() { ...@@ -703,10 +702,10 @@ export default function fileIOOpen() {
let file = await fileIO.open(fpath, fileIO.OpenMode.TRUNC | fileIO.OpenMode.READ_WRITE); let file = await fileIO.open(fpath, fileIO.OpenMode.TRUNC | fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileIO.read(file.fd, new ArrayBuffer(4096)) fileIO.read(file.fd, new ArrayBuffer(4096))
.then((number) => { .then((readLen) => {
expect(number == 0).assertTrue(); expect(readLen == 0).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
}); });
done(); done();
} catch (e) { } catch (e) {
...@@ -722,7 +721,7 @@ export default function fileIOOpen() { ...@@ -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. * If the file exists and the file is opened for read-write, trim its length to zero.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_async_012', 0, async function (done) { it('fileIO_test_open_async_012', 0, async function (done) {
...@@ -737,10 +736,10 @@ export default function fileIOOpen() { ...@@ -737,10 +736,10 @@ export default function fileIOOpen() {
} }
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileIO.read(file.fd, new ArrayBuffer(4096)) fileIO.read(file.fd, new ArrayBuffer(4096))
.then((number) => { .then((readLen) => {
expect(number == 0).assertTrue(); expect(readLen == 0).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
}); });
done(); done();
}); });
...@@ -757,7 +756,7 @@ export default function fileIOOpen() { ...@@ -757,7 +756,7 @@ export default function fileIOOpen() {
* Open as append, subsequent writes will append to the end of the file. * Open as append, subsequent writes will append to the end of the file.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_async_013', 0, async function (done) { it('fileIO_test_open_async_013', 0, async function (done) {
...@@ -770,10 +769,10 @@ export default function fileIOOpen() { ...@@ -770,10 +769,10 @@ export default function fileIOOpen() {
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileIO.writeSync(file.fd, new ArrayBuffer(length)); fileIO.writeSync(file.fd, new ArrayBuffer(length));
fileIO.read(file.fd, new ArrayBuffer(4096), { offset: 0 }) fileIO.read(file.fd, new ArrayBuffer(4096), { offset: 0 })
.then((number) => { .then((readLen) => {
expect(number == length + FILE_CONTENT.length).assertTrue(); expect(readLen == length + FILE_CONTENT.length).assertTrue();
fileIO.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
}); });
done(); done();
} catch (e) { } catch (e) {
...@@ -789,7 +788,7 @@ export default function fileIOOpen() { ...@@ -789,7 +788,7 @@ export default function fileIOOpen() {
* Open as append, subsequent writes will append to the end of the file. * Open as append, subsequent writes will append to the end of the file.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_async_014', 0, async function (done) { it('fileIO_test_open_async_014', 0, async function (done) {
...@@ -806,10 +805,10 @@ export default function fileIOOpen() { ...@@ -806,10 +805,10 @@ export default function fileIOOpen() {
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileIO.writeSync(file.fd, new ArrayBuffer(length)); fileIO.writeSync(file.fd, new ArrayBuffer(length));
fileIO.read(file.fd, new ArrayBuffer(4096), { offset: 0 }) fileIO.read(file.fd, new ArrayBuffer(4096), { offset: 0 })
.then((number) => { .then((readLen) => {
expect(number == length + FILE_CONTENT.length).assertTrue(); expect(readLen == length + FILE_CONTENT.length).assertTrue();
fileIO.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
}); });
done(); done();
}); });
...@@ -826,7 +825,7 @@ export default function fileIOOpen() { ...@@ -826,7 +825,7 @@ export default function fileIOOpen() {
* If the file is a special file, the opening and subsequent IOs perform non-blocking operations. * If the file is a special file, the opening and subsequent IOs perform non-blocking operations.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_async_015', 0, async function (done) { it('fileIO_test_open_async_015', 0, async function (done) {
...@@ -836,8 +835,8 @@ export default function fileIOOpen() { ...@@ -836,8 +835,8 @@ export default function fileIOOpen() {
try { try {
let file = await fileIO.open(fpath, fileIO.OpenMode.NONBLOCK | fileIO.OpenMode.READ_WRITE); let file = await fileIO.open(fpath, fileIO.OpenMode.NONBLOCK | fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_test_open_async_015 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_open_async_015 has failed for ' + e.message + ', code: ' + e.code);
...@@ -852,7 +851,7 @@ export default function fileIOOpen() { ...@@ -852,7 +851,7 @@ export default function fileIOOpen() {
* If the file is a special file, the opening and subsequent IOs perform non-blocking operations. * If the file is a special file, the opening and subsequent IOs perform non-blocking operations.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_async_016', 0, async function (done) { it('fileIO_test_open_async_016', 0, async function (done) {
...@@ -866,8 +865,8 @@ export default function fileIOOpen() { ...@@ -866,8 +865,8 @@ export default function fileIOOpen() {
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
} catch (e) { } catch (e) {
...@@ -883,17 +882,17 @@ export default function fileIOOpen() { ...@@ -883,17 +882,17 @@ export default function fileIOOpen() {
* The path points to a directory. * The path points to a directory.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_async_017', 0, async function (done) { it('fileIO_test_open_async_017', 0, async function (done) {
let dpath = await nextFileName('fileIO_test_open_async_017'); let dpath = await nextFileName('fileIO_test_open_async_017');
fileio.mkdirSync(dpath); fileIO.mkdirSync(dpath);
try { try {
let file = await fileIO.open(dpath, fileIO.OpenMode.DIR); let file = await fileIO.open(dpath, fileIO.OpenMode.DIR);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileio.rmdirSync(dpath); fileIO.rmdirSync(dpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_test_open_async_017 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_open_async_017 has failed for ' + e.message + ', code: ' + e.code);
...@@ -908,12 +907,12 @@ export default function fileIOOpen() { ...@@ -908,12 +907,12 @@ export default function fileIOOpen() {
* The path points to a directory. * The path points to a directory.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_async_018', 0, async function (done) { it('fileIO_test_open_async_018', 0, async function (done) {
let dpath = await nextFileName('fileIO_test_open_async_018'); let dpath = await nextFileName('fileIO_test_open_async_018');
fileio.mkdirSync(dpath); fileIO.mkdirSync(dpath);
try { try {
fileIO.open(dpath, fileIO.OpenMode.DIR, (err, file) => { fileIO.open(dpath, fileIO.OpenMode.DIR, (err, file) => {
...@@ -922,7 +921,7 @@ export default function fileIOOpen() { ...@@ -922,7 +921,7 @@ export default function fileIOOpen() {
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileio.rmdirSync(dpath); fileIO.rmdirSync(dpath);
done(); done();
}); });
} catch (e) { } catch (e) {
...@@ -938,7 +937,7 @@ export default function fileIOOpen() { ...@@ -938,7 +937,7 @@ export default function fileIOOpen() {
* The path does not point to a directory, throw error. * The path does not point to a directory, throw error.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_async_019', 0, async function (done) { it('fileIO_test_open_async_019', 0, async function (done) {
...@@ -949,7 +948,7 @@ export default function fileIOOpen() { ...@@ -949,7 +948,7 @@ export default function fileIOOpen() {
await fileIO.open(fpath, fileIO.OpenMode.DIR); await fileIO.open(fpath, fileIO.OpenMode.DIR);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_test_open_async_019 has failed for ' + e.message + ', code: ' + e.code); 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(); expect(e.code == 13900018 && e.message == 'Not a directory').assertTrue();
done(); done();
...@@ -963,7 +962,7 @@ export default function fileIOOpen() { ...@@ -963,7 +962,7 @@ export default function fileIOOpen() {
* The path does not point to a directory, throw error. * The path does not point to a directory, throw error.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_async_020', 0, async function (done) { it('fileIO_test_open_async_020', 0, async function (done) {
...@@ -973,8 +972,8 @@ export default function fileIOOpen() { ...@@ -973,8 +972,8 @@ export default function fileIOOpen() {
try { try {
fileIO.open(fpath, fileIO.OpenMode.DIR, (err) => { fileIO.open(fpath, fileIO.OpenMode.DIR, (err) => {
if(err) { if(err) {
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_test_open_async_020 error package: {' + err.message + ', code: ' + err.code + '}'); console.log('fileIO_test_open_async_020 error: {message: ' + err.message + ', code: ' + err.code + '}');
expect(err.code == 13900018 && err.message == 'Not a directory').assertTrue(); expect(err.code == 13900018 && err.message == 'Not a directory').assertTrue();
done(); done();
} }
...@@ -992,7 +991,7 @@ export default function fileIOOpen() { ...@@ -992,7 +991,7 @@ export default function fileIOOpen() {
* The path does not point to a directory, throw error. * The path does not point to a directory, throw error.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_async_021', 0, async function (done) { it('fileIO_test_open_async_021', 0, async function (done) {
...@@ -1003,8 +1002,8 @@ export default function fileIOOpen() { ...@@ -1003,8 +1002,8 @@ export default function fileIOOpen() {
fileIO.open(fpath, fileIO.OpenMode.DIR).then(() => { fileIO.open(fpath, fileIO.OpenMode.DIR).then(() => {
expect(false).assertTrue(); expect(false).assertTrue();
}).catch((err) => { }).catch((err) => {
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_test_open_async_021 error package: {' + err.message + ', code: ' + err.code + '}'); console.log('fileIO_test_open_async_021 error: {message: ' + err.message + ', code: ' + err.code + '}');
expect(err.code == 13900018 && err.message == 'Not a directory').assertTrue(); expect(err.code == 13900018 && err.message == 'Not a directory').assertTrue();
done(); done();
}); });
...@@ -1021,7 +1020,7 @@ export default function fileIOOpen() { ...@@ -1021,7 +1020,7 @@ export default function fileIOOpen() {
* The path does not point to a symbolic link. * The path does not point to a symbolic link.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_async_022', 0, async function (done) { it('fileIO_test_open_async_022', 0, async function (done) {
...@@ -1031,8 +1030,8 @@ export default function fileIOOpen() { ...@@ -1031,8 +1030,8 @@ export default function fileIOOpen() {
try { try {
let file = await fileIO.open(fpath, fileIO.OpenMode.NOFOLLOW | fileIO.OpenMode.READ_WRITE); let file = await fileIO.open(fpath, fileIO.OpenMode.NOFOLLOW | fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_test_open_async_022 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_open_async_022 has failed for ' + e.message + ', code: ' + e.code);
...@@ -1047,7 +1046,7 @@ export default function fileIOOpen() { ...@@ -1047,7 +1046,7 @@ export default function fileIOOpen() {
* The path does not point to a symbolic link. * The path does not point to a symbolic link.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_async_023', 0, async function (done) { it('fileIO_test_open_async_023', 0, async function (done) {
...@@ -1061,8 +1060,8 @@ export default function fileIOOpen() { ...@@ -1061,8 +1060,8 @@ export default function fileIOOpen() {
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
} catch (e) { } catch (e) {
...@@ -1078,7 +1077,7 @@ export default function fileIOOpen() { ...@@ -1078,7 +1077,7 @@ export default function fileIOOpen() {
* The path point to a symbolic link, throw error. * The path point to a symbolic link, throw error.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_async_024', 0, async function (done) { it('fileIO_test_open_async_024', 0, async function (done) {
...@@ -1087,12 +1086,12 @@ export default function fileIOOpen() { ...@@ -1087,12 +1086,12 @@ export default function fileIOOpen() {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
fileio.symlinkSync(fpath, ffpath); fileIO.symlinkSync(fpath, ffpath);
await fileIO.open(ffpath, fileIO.OpenMode.NOFOLLOW | fileIO.OpenMode.READ_WRITE); await fileIO.open(ffpath, fileIO.OpenMode.NOFOLLOW | fileIO.OpenMode.READ_WRITE);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
fileio.unlinkSync(ffpath); fileIO.unlinkSync(ffpath);
console.log('fileIO_test_open_async_024 has failed for ' + e.message + ', code: ' + e.code); 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(); expect(e.code == 13900033 && e.message == 'Too many symbolic links encountered').assertTrue();
done(); done();
...@@ -1106,7 +1105,7 @@ export default function fileIOOpen() { ...@@ -1106,7 +1105,7 @@ export default function fileIOOpen() {
* The path point to a symbolic link, throw error. * The path point to a symbolic link, throw error.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_async_025', 0, async function (done) { it('fileIO_test_open_async_025', 0, async function (done) {
...@@ -1115,14 +1114,14 @@ export default function fileIOOpen() { ...@@ -1115,14 +1114,14 @@ export default function fileIOOpen() {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
fileio.symlinkSync(fpath, ffpath); fileIO.symlinkSync(fpath, ffpath);
fileIO.open(ffpath, fileIO.OpenMode.NOFOLLOW | fileIO.OpenMode.READ_WRITE, (err) => { fileIO.open(ffpath, fileIO.OpenMode.NOFOLLOW | fileIO.OpenMode.READ_WRITE, (err) => {
if(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(); expect(err.code == 13900033 && err.message == 'Too many symbolic links encountered').assertTrue();
} }
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
fileio.unlinkSync(ffpath); fileIO.unlinkSync(ffpath);
done(); done();
}); });
} catch (e) { } catch (e) {
...@@ -1138,7 +1137,7 @@ export default function fileIOOpen() { ...@@ -1138,7 +1137,7 @@ export default function fileIOOpen() {
* The path point to a symbolic link, throw error. * The path point to a symbolic link, throw error.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_async_026', 0, async function (done) { it('fileIO_test_open_async_026', 0, async function (done) {
...@@ -1147,14 +1146,14 @@ export default function fileIOOpen() { ...@@ -1147,14 +1146,14 @@ export default function fileIOOpen() {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
fileio.symlinkSync(fpath, ffpath); fileIO.symlinkSync(fpath, ffpath);
fileIO.open(ffpath, fileIO.OpenMode.NOFOLLOW | fileIO.OpenMode.READ_WRITE).then(() => { fileIO.open(ffpath, fileIO.OpenMode.NOFOLLOW | fileIO.OpenMode.READ_WRITE).then(() => {
expect(false).assertTrue(); expect(false).assertTrue();
}).catch((err) => { }).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(); expect(err.code == 13900033 && err.message == 'Too many symbolic links encountered').assertTrue();
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
fileio.unlinkSync(ffpath); fileIO.unlinkSync(ffpath);
done(); done();
}); });
} catch (e) { } catch (e) {
...@@ -1170,7 +1169,7 @@ export default function fileIOOpen() { ...@@ -1170,7 +1169,7 @@ export default function fileIOOpen() {
* Open the file in the way of synchronous IO. * Open the file in the way of synchronous IO.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_async_027', 0, async function (done) { it('fileIO_test_open_async_027', 0, async function (done) {
...@@ -1180,8 +1179,8 @@ export default function fileIOOpen() { ...@@ -1180,8 +1179,8 @@ export default function fileIOOpen() {
try { try {
let file = await fileIO.open(fpath, fileIO.OpenMode.SYNC | fileIO.OpenMode.READ_WRITE); let file = await fileIO.open(fpath, fileIO.OpenMode.SYNC | fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_test_open_async_027 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_open_async_027 has failed for ' + e.message + ', code: ' + e.code);
...@@ -1196,7 +1195,7 @@ export default function fileIOOpen() { ...@@ -1196,7 +1195,7 @@ export default function fileIOOpen() {
* Open the file in the way of synchronous IO. * Open the file in the way of synchronous IO.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_open_async_028', 0, async function (done) { it('fileIO_test_open_async_028', 0, async function (done) {
...@@ -1210,8 +1209,8 @@ export default function fileIOOpen() { ...@@ -1210,8 +1209,8 @@ export default function fileIOOpen() {
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
} catch (e) { } catch (e) {
......
...@@ -14,8 +14,7 @@ ...@@ -14,8 +14,7 @@
*/ */
import { import {
fileio, fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum, fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum, describe, it, expect, util
describe, it, expect, util
} from '../Common'; } from '../Common';
export default function fileIORead() { export default function fileIORead() {
...@@ -38,11 +37,10 @@ export default function fileIORead() { ...@@ -38,11 +37,10 @@ export default function fileIORead() {
try { try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY); let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
expect( let readLen = fileIO.readSync(file.fd, new ArrayBuffer(4096));
fileIO.readSync(file.fd, new ArrayBuffer(4096)) expect(readLen == FILE_CONTENT.length).assertTrue();
== FILE_CONTENT.length).assertTrue(); fileIO.closeSync(file);
fileio.closeSync(file.fd); fileIO.unlinkSync(fpath);
fileio.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_read_sync_000 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_read_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -56,7 +54,7 @@ export default function fileIORead() { ...@@ -56,7 +54,7 @@ export default function fileIORead() {
* Open the file in read-only mode, reading the file with length = 1. * Open the file in read-only mode, reading the file with length = 1.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_read_sync_001', 0, async function () { it('fileIO_test_read_sync_001', 0, async function () {
...@@ -66,13 +64,12 @@ export default function fileIORead() { ...@@ -66,13 +64,12 @@ export default function fileIORead() {
try { try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY); let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
expect( let readLen = fileIO.readSync(file.fd, new ArrayBuffer(4096), {
fileIO.readSync(file.fd, new ArrayBuffer(4096), { length: 1,
length: 1, });
}) expect(readLen == 1).assertTrue();
== 1).assertTrue(); fileIO.closeSync(file);
fileio.closeSync(file.fd); fileIO.unlinkSync(fpath);
fileio.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_read_sync_001 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_read_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -86,7 +83,7 @@ export default function fileIORead() { ...@@ -86,7 +83,7 @@ export default function fileIORead() {
* Open the file in read-only mode, reading the file with length < 0(Read normal). * Open the file in read-only mode, reading the file with length < 0(Read normal).
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_read_sync_002', 0, async function () { it('fileIO_test_read_sync_002', 0, async function () {
...@@ -100,8 +97,8 @@ export default function fileIORead() { ...@@ -100,8 +97,8 @@ export default function fileIORead() {
length: -1, length: -1,
}); });
expect(readLen == FILE_CONTENT.length).assertTrue(); expect(readLen == FILE_CONTENT.length).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_read_sync_002 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_read_sync_002 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -115,7 +112,7 @@ export default function fileIORead() { ...@@ -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). * Open the file in read-only mode, reading the file with length > the content of file(Read normal).
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_read_sync_003', 0, async function () { it('fileIO_test_read_sync_003', 0, async function () {
...@@ -125,12 +122,12 @@ export default function fileIORead() { ...@@ -125,12 +122,12 @@ export default function fileIORead() {
try { try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY); let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
expect(fileIO.readSync(file.fd, new ArrayBuffer(4096), { let readLen = fileIO.readSync(file.fd, new ArrayBuffer(4096), {
length: FILE_CONTENT.length + 1, length: FILE_CONTENT.length + 1,
}) });
== FILE_CONTENT.length).assertTrue(); expect(readLen == FILE_CONTENT.length).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_read_sync_003 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_read_sync_003 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -144,7 +141,7 @@ export default function fileIORead() { ...@@ -144,7 +141,7 @@ export default function fileIORead() {
* Read the file with invalid length > size of ArrayBuffer. * Read the file with invalid length > size of ArrayBuffer.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_read_sync_004', 0, async function () { it('fileIO_test_read_sync_004', 0, async function () {
...@@ -159,8 +156,8 @@ export default function fileIORead() { ...@@ -159,8 +156,8 @@ export default function fileIORead() {
}); });
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_test_read_sync_004 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_read_sync_004 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
} }
...@@ -173,7 +170,7 @@ export default function fileIORead() { ...@@ -173,7 +170,7 @@ export default function fileIORead() {
* Open the file in read-only mode, reading the file with offset(position) = 1. * Open the file in read-only mode, reading the file with offset(position) = 1.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_read_sync_005', 0, async function () { it('fileIO_test_read_sync_005', 0, async function () {
...@@ -183,13 +180,12 @@ export default function fileIORead() { ...@@ -183,13 +180,12 @@ export default function fileIORead() {
try { try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY); let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
expect( let readLen = fileIO.readSync(file.fd, new ArrayBuffer(4096), {
fileIO.readSync(file.fd, new ArrayBuffer(4096), { offset: 1,
offset: 1, });
}) expect(readLen == FILE_CONTENT.length - 1).assertTrue();
== FILE_CONTENT.length - 1).assertTrue(); fileIO.closeSync(file);
fileio.closeSync(file.fd); fileIO.unlinkSync(fpath);
fileio.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_read_sync_005 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_read_sync_005 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -203,7 +199,7 @@ export default function fileIORead() { ...@@ -203,7 +199,7 @@ export default function fileIORead() {
* Read the file with invalid offset = -1. * Read the file with invalid offset = -1.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_read_sync_006', 0, async function () { it('fileIO_test_read_sync_006', 0, async function () {
...@@ -218,8 +214,8 @@ export default function fileIORead() { ...@@ -218,8 +214,8 @@ export default function fileIORead() {
}); });
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_test_read_sync_006 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_read_sync_006 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
} }
...@@ -232,7 +228,7 @@ export default function fileIORead() { ...@@ -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). * Open the file in read-only mode, reading the file with offset(position) > the content of file(Read normal).
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_read_sync_007', 0, async function () { it('fileIO_test_read_sync_007', 0, async function () {
...@@ -242,13 +238,12 @@ export default function fileIORead() { ...@@ -242,13 +238,12 @@ export default function fileIORead() {
try { try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY); let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
expect( let readLen = fileIO.readSync(file.fd, new ArrayBuffer(4096), {
fileIO.readSync(file.fd, new ArrayBuffer(4096), { offset: FILE_CONTENT.length + 1,
offset: FILE_CONTENT.length + 1, });
}) expect(readLen == 0).assertTrue();
== 0).assertTrue(); fileIO.closeSync(file);
fileio.closeSync(file.fd); fileIO.unlinkSync(fpath);
fileio.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_read_sync_007 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_read_sync_007 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -262,7 +257,7 @@ export default function fileIORead() { ...@@ -262,7 +257,7 @@ export default function fileIORead() {
* Open the file in read-only mode, reading the file with offset(position) = 1, length = 10. * Open the file in read-only mode, reading the file with offset(position) = 1, length = 10.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_read_sync_008', 0, async function () { it('fileIO_test_read_sync_008', 0, async function () {
...@@ -272,14 +267,13 @@ export default function fileIORead() { ...@@ -272,14 +267,13 @@ export default function fileIORead() {
try { try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY); let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
expect( let readLen = fileIO.readSync(file.fd, new ArrayBuffer(4096), {
fileIO.readSync(file.fd, new ArrayBuffer(4096), { offset: 1,
offset: 1, length: FILE_CONTENT.length - 1,
length: FILE_CONTENT.length - 1, });
}) expect(readLen == FILE_CONTENT.length - 1).assertTrue();
== FILE_CONTENT.length - 1).assertTrue(); fileIO.closeSync(file);
fileio.closeSync(file.fd); fileIO.unlinkSync(fpath);
fileio.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_read_sync_008 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_read_sync_008 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -293,7 +287,7 @@ export default function fileIORead() { ...@@ -293,7 +287,7 @@ export default function fileIORead() {
* Read the file with invalid fd. * Read the file with invalid fd.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_read_sync_009', 0, async function () { it('fileIO_test_read_sync_009', 0, async function () {
...@@ -314,7 +308,7 @@ export default function fileIORead() { ...@@ -314,7 +308,7 @@ export default function fileIORead() {
* Verify that the Chinese, English, and symbols can be read correctly. * Verify that the Chinese, English, and symbols can be read correctly.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_read_sync_010', 0, async function () { it('fileIO_test_read_sync_010', 0, async function () {
...@@ -330,8 +324,8 @@ export default function fileIORead() { ...@@ -330,8 +324,8 @@ export default function fileIORead() {
let textDecoder = new util.TextDecoder("utf-8", { ignoreBOM: true }); let textDecoder = new util.TextDecoder("utf-8", { ignoreBOM: true });
let resultPut = textDecoder.decode(new Uint8Array(buf), { stream: true }); let resultPut = textDecoder.decode(new Uint8Array(buf), { stream: true });
expect(resultPut == CONTENT).assertTrue(); expect(resultPut == CONTENT).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_read_sync_010 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_read_sync_010 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -357,8 +351,8 @@ export default function fileIORead() { ...@@ -357,8 +351,8 @@ export default function fileIORead() {
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
let readLen = await fileIO.read(file.fd, new ArrayBuffer(4096)); let readLen = await fileIO.read(file.fd, new ArrayBuffer(4096));
expect(readLen == FILE_CONTENT.length).assertTrue(); expect(readLen == FILE_CONTENT.length).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_test_read_async_000 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_read_async_000 has failed for ' + e.message + ', code: ' + e.code);
...@@ -373,7 +367,7 @@ export default function fileIORead() { ...@@ -373,7 +367,7 @@ export default function fileIORead() {
* Open the file in read-only mode, verifying the normal read function. * Open the file in read-only mode, verifying the normal read function.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_read_async_001', 0, async function (done) { it('fileIO_test_read_async_001', 0, async function (done) {
...@@ -389,8 +383,8 @@ export default function fileIORead() { ...@@ -389,8 +383,8 @@ export default function fileIORead() {
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(readlen == FILE_CONTENT.length).assertTrue(); expect(readlen == FILE_CONTENT.length).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
} catch (e) { } catch (e) {
...@@ -406,7 +400,7 @@ export default function fileIORead() { ...@@ -406,7 +400,7 @@ export default function fileIORead() {
* Open the file in write-only mode, verifying it is not readable. * Open the file in write-only mode, verifying it is not readable.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_read_async_002', 0, async function (done) { it('fileIO_test_read_async_002', 0, async function (done) {
...@@ -419,8 +413,8 @@ export default function fileIORead() { ...@@ -419,8 +413,8 @@ export default function fileIORead() {
await fileIO.read(file.fd, new ArrayBuffer(4096)); await fileIO.read(file.fd, new ArrayBuffer(4096));
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_test_read_async_002 has failed for ' + e.message + ', code: ' + e.code); 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(); expect(e.code == 13900008 && e.message == 'Bad file descriptor').assertTrue();
done(); done();
...@@ -434,7 +428,7 @@ export default function fileIORead() { ...@@ -434,7 +428,7 @@ export default function fileIORead() {
* Open the file in write-only mode, verifying it is not readable. * Open the file in write-only mode, verifying it is not readable.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_read_async_003', 0, async function (done) { it('fileIO_test_read_async_003', 0, async function (done) {
...@@ -447,9 +441,9 @@ export default function fileIORead() { ...@@ -447,9 +441,9 @@ export default function fileIORead() {
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileIO.read(file.fd, new ArrayBuffer(4096), (err) => { fileIO.read(file.fd, new ArrayBuffer(4096), (err) => {
if(err) { if(err) {
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_test_read_async_003 error package: {' + err.message + ', code: ' + err.code + '}'); console.log('fileIO_test_read_async_003 error: {message: ' + err.message + ', code: ' + err.code + '}');
expect(err.code == 13900008 && err.message == 'Bad file descriptor').assertTrue(); expect(err.code == 13900008 && err.message == 'Bad file descriptor').assertTrue();
done(); done();
} }
...@@ -467,7 +461,7 @@ export default function fileIORead() { ...@@ -467,7 +461,7 @@ export default function fileIORead() {
* Open the file in read-only mode, reading the file with offset(position) = 1. * Open the file in read-only mode, reading the file with offset(position) = 1.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_read_async_004', 0, async function (done) { it('fileIO_test_read_async_004', 0, async function (done) {
...@@ -481,8 +475,8 @@ export default function fileIORead() { ...@@ -481,8 +475,8 @@ export default function fileIORead() {
offset: 1, offset: 1,
}); });
expect(readlen == FILE_CONTENT.length - 1).assertTrue(); expect(readlen == FILE_CONTENT.length - 1).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_test_read_async_004 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_read_async_004 has failed for ' + e.message + ', code: ' + e.code);
...@@ -497,7 +491,7 @@ export default function fileIORead() { ...@@ -497,7 +491,7 @@ export default function fileIORead() {
* Open the file in read-only mode, reading the file with offset(position) = 1. * Open the file in read-only mode, reading the file with offset(position) = 1.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_read_async_005', 0, async function (done) { it('fileIO_test_read_async_005', 0, async function (done) {
...@@ -508,16 +502,16 @@ export default function fileIORead() { ...@@ -508,16 +502,16 @@ export default function fileIORead() {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY); let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileIO.read(file.fd, new ArrayBuffer(4096), { fileIO.read(file.fd, new ArrayBuffer(4096), {
offset: 1, offset: 1,
}, (err, readLen) => { }, (err, readLen) => {
if(err) { if(err) {
console.log('fileIO_test_read_async_005 err package' + JSON.stringify(err)); console.log('fileIO_test_read_async_005 err package' + JSON.stringify(err));
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(readLen == FILE_CONTENT.length - 1).assertTrue(); expect(readLen == FILE_CONTENT.length - 1).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
} catch (e) { } catch (e) {
console.log('fileIO_test_read_async_005 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_read_async_005 has failed for ' + e.message + ', code: ' + e.code);
...@@ -532,7 +526,7 @@ export default function fileIORead() { ...@@ -532,7 +526,7 @@ export default function fileIORead() {
* Open the file in read-only mode, reading the file with length = 1. * Open the file in read-only mode, reading the file with length = 1.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_read_async_006', 0, async function (done) { it('fileIO_test_read_async_006', 0, async function (done) {
...@@ -546,8 +540,8 @@ export default function fileIORead() { ...@@ -546,8 +540,8 @@ export default function fileIORead() {
length: 3, length: 3,
}); });
expect(readLen == 3).assertTrue(); expect(readLen == 3).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_test_read_async_006 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_read_async_006 has failed for ' + e.message + ', code: ' + e.code);
...@@ -562,7 +556,7 @@ export default function fileIORead() { ...@@ -562,7 +556,7 @@ export default function fileIORead() {
* Open the file in read-only mode, reading the file with length = 1. * Open the file in read-only mode, reading the file with length = 1.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_read_async_007', 0, async function (done) { it('fileIO_test_read_async_007', 0, async function (done) {
...@@ -573,16 +567,16 @@ export default function fileIORead() { ...@@ -573,16 +567,16 @@ export default function fileIORead() {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY); let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileIO.read(file.fd, new ArrayBuffer(4096), { fileIO.read(file.fd, new ArrayBuffer(4096), {
length: 3, length: 3,
}, (err, readLen) => { }, (err, readLen) => {
if(err) { if(err) {
console.log('fileIO_test_read_async_007 err package' + JSON.stringify(err)); console.log('fileIO_test_read_async_007 err package' + JSON.stringify(err));
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(readLen == 3).assertTrue(); expect(readLen == 3).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
} catch (e) { } catch (e) {
console.log('fileIO_test_read_async_007 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_read_async_007 has failed for ' + e.message + ', code: ' + e.code);
...@@ -597,7 +591,7 @@ export default function fileIORead() { ...@@ -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). * Open the file in read-only mode, reading the file with offset > the content of file(Read normal).
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_read_async_008', 0, async function (done) { it('fileIO_test_read_async_008', 0, async function (done) {
...@@ -607,12 +601,12 @@ export default function fileIORead() { ...@@ -607,12 +601,12 @@ export default function fileIORead() {
try { try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY); let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY);
expect(isIntNum(file.fd)).assertTrue(); 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, offset: FILE_CONTENT.length + 1,
}); });
expect(len == 0).assertTrue(); expect(readLen == 0).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_test_read_async_008 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_read_async_008 has failed for ' + e.message + ', code: ' + e.code);
...@@ -627,7 +621,7 @@ export default function fileIORead() { ...@@ -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). * Open the file in read-only mode, reading the file with offset > the content of file(Read normal).
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_read_async_009', 0, async function (done) { it('fileIO_test_read_async_009', 0, async function (done) {
...@@ -638,16 +632,16 @@ export default function fileIORead() { ...@@ -638,16 +632,16 @@ export default function fileIORead() {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY); let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileIO.read(file.fd, new ArrayBuffer(4096), { fileIO.read(file.fd, new ArrayBuffer(4096), {
offset: FILE_CONTENT.length + 1, offset: FILE_CONTENT.length + 1,
}, (err, len) => { }, (err, readLen) => {
if(err) { if(err) {
console.log('fileIO_test_read_async_009 err package' + JSON.stringify(err)); console.log('fileIO_test_read_async_009 err package' + JSON.stringify(err));
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(len == 0).assertTrue(); expect(readLen == 0).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
} catch (e) { } catch (e) {
console.log('fileIO_test_read_async_009 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_read_async_009 has failed for ' + e.message + ', code: ' + e.code);
...@@ -656,13 +650,13 @@ export default function fileIORead() { ...@@ -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.name fileIO_test_read_async_010
* @tc.desc Test read() interfaces. * @tc.desc Test read() interfaces.
* Open the file in read-only mode, reading the file with offset(position) = 1, length = 11. * Open the file in read-only mode, reading the file with offset(position) = 1, length = 11.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_read_async_010', 0, async function (done) { it('fileIO_test_read_async_010', 0, async function (done) {
...@@ -677,8 +671,8 @@ export default function fileIORead() { ...@@ -677,8 +671,8 @@ export default function fileIORead() {
length: FILE_CONTENT.length, length: FILE_CONTENT.length,
}); });
expect(readLen == FILE_CONTENT.length - 1).assertTrue(); expect(readLen == FILE_CONTENT.length - 1).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_test_read_async_010 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_read_async_010 has failed for ' + e.message + ', code: ' + e.code);
...@@ -693,7 +687,7 @@ export default function fileIORead() { ...@@ -693,7 +687,7 @@ export default function fileIORead() {
* Open the file in read-only mode, reading the file with offset(position) = 1, length = 11. * Open the file in read-only mode, reading the file with offset(position) = 1, length = 11.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_read_async_011', 0, async function (done) { it('fileIO_test_read_async_011', 0, async function (done) {
...@@ -712,8 +706,8 @@ export default function fileIORead() { ...@@ -712,8 +706,8 @@ export default function fileIORead() {
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(readLen == FILE_CONTENT.length - 1).assertTrue(); expect(readLen == FILE_CONTENT.length - 1).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
} catch (e) { } catch (e) {
...@@ -723,13 +717,13 @@ export default function fileIORead() { ...@@ -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.name fileIO_test_read_async_012
* @tc.desc Test read() interfaces. Promise. * @tc.desc Test read() interfaces. Promise.
* Read with invalid fd parameters. * Read with invalid fd parameters.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_read_async_012', 0, async function (done) { it('fileIO_test_read_async_012', 0, async function (done) {
...@@ -750,14 +744,14 @@ export default function fileIORead() { ...@@ -750,14 +744,14 @@ export default function fileIORead() {
* Read with invalid fd parameters. * Read with invalid fd parameters.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_read_async_013', 0, async function (done) { it('fileIO_test_read_async_013', 0, async function (done) {
try { try {
fileIO.read(-1, new ArrayBuffer(4096), (err) => { fileIO.read(-1, new ArrayBuffer(4096), (err) => {
if(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(); expect(err.code == 13900008 && err.message == 'Bad file descriptor').assertTrue();
done(); done();
} }
...@@ -775,7 +769,7 @@ export default function fileIORead() { ...@@ -775,7 +769,7 @@ export default function fileIORead() {
* Read with invalid offset < 0. * Read with invalid offset < 0.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_read_async_014', 0, async function (done) { it('fileIO_test_read_async_014', 0, async function (done) {
...@@ -787,13 +781,13 @@ export default function fileIORead() { ...@@ -787,13 +781,13 @@ export default function fileIORead() {
try { try {
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileIO.read(file.fd, new ArrayBuffer(4096), { fileIO.read(file.fd, new ArrayBuffer(4096), {
offset: invalidOffset offset: invalidOffset,
}, () => { }, (err) => {
expect(false).assertTrue(); expect(false).assertTrue();
}); });
} catch (e) { } catch (e) {
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_test_read_async_014 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_read_async_014 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done(); done();
...@@ -807,7 +801,7 @@ export default function fileIORead() { ...@@ -807,7 +801,7 @@ export default function fileIORead() {
* Read with invalid length > size of ArrayBuffer(4096). * Read with invalid length > size of ArrayBuffer(4096).
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_read_async_015', 0, async function (done) { it('fileIO_test_read_async_015', 0, async function (done) {
...@@ -819,13 +813,13 @@ export default function fileIORead() { ...@@ -819,13 +813,13 @@ export default function fileIORead() {
try { try {
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileIO.read(file.fd, new ArrayBuffer(4096), { fileIO.read(file.fd, new ArrayBuffer(4096), {
length: invalidLength length: invalidLength,
}, () => { }, (err) => {
expect(false).assertTrue(); expect(false).assertTrue();
}); });
} catch (e) { } catch (e) {
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_test_read_async_015 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_read_async_015 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done(); done();
...@@ -839,7 +833,7 @@ export default function fileIORead() { ...@@ -839,7 +833,7 @@ export default function fileIORead() {
* Open the file in read-only mode, reading the file with empty option. * Open the file in read-only mode, reading the file with empty option.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_read_async_016', 0, async function (done) { it('fileIO_test_read_async_016', 0, async function (done) {
...@@ -851,8 +845,8 @@ export default function fileIORead() { ...@@ -851,8 +845,8 @@ export default function fileIORead() {
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
let readLen = await fileIO.read(file.fd, new ArrayBuffer(4096), {}); let readLen = await fileIO.read(file.fd, new ArrayBuffer(4096), {});
expect(readLen == FILE_CONTENT.length).assertTrue(); expect(readLen == FILE_CONTENT.length).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_test_read_async_016 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_read_async_016 has failed for ' + e.message + ', code: ' + e.code);
...@@ -861,13 +855,13 @@ export default function fileIORead() { ...@@ -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.name fileIO_test_read_async_017
* @tc.desc Test read() interfaces. Callback. * @tc.desc Test read() interfaces. Callback.
* Open the file in read-only mode, reading the file with empty option. * Open the file in read-only mode, reading the file with empty option.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_read_async_017', 0, async function (done) { it('fileIO_test_read_async_017', 0, async function (done) {
...@@ -878,16 +872,16 @@ export default function fileIORead() { ...@@ -878,16 +872,16 @@ export default function fileIORead() {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY); let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileIO.read(file.fd, new ArrayBuffer(4096), { fileIO.read(file.fd, new ArrayBuffer(4096), {
}, (err, readLen) => { }, (err, readLen) => {
if(err) { if(err) {
console.log('fileIO_test_read_async_017 err package ' + JSON.stringify(err)); console.log('fileIO_test_read_async_017 err package ' + JSON.stringify(err));
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(readLen == FILE_CONTENT.length).assertTrue(); expect(readLen == FILE_CONTENT.length).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
} catch (e) { } catch (e) {
console.log('fileIO_test_read_async_017 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_read_async_017 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -895,13 +889,13 @@ export default function fileIORead() { ...@@ -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.name fileIO_test_read_async_018
* @tc.desc Test read() interfaces. * @tc.desc Test read() interfaces.
* Open the file in read-only mode, reading the file with length = -1(Read normal). * Open the file in read-only mode, reading the file with length = -1(Read normal).
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_read_async_018', 0, async function () { it('fileIO_test_read_async_018', 0, async function () {
...@@ -913,10 +907,10 @@ export default function fileIORead() { ...@@ -913,10 +907,10 @@ export default function fileIORead() {
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
let readLen = await fileIO.read(file.fd, new ArrayBuffer(4096), { let readLen = await fileIO.read(file.fd, new ArrayBuffer(4096), {
length: -1, length: -1,
}) });
expect(readLen == FILE_CONTENT.length).assertTrue(); expect(readLen == FILE_CONTENT.length).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_read_async_018 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_read_async_018 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -924,13 +918,13 @@ export default function fileIORead() { ...@@ -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.name fileIO_test_read_async_019
* @tc.desc Test read() interfaces. * @tc.desc Test read() interfaces.
* Verify that the Chinese, English, and symbols can be read correctly. * Verify that the Chinese, English, and symbols can be read correctly.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_read_async_019', 0, async function (done) { it('fileIO_test_read_async_019', 0, async function (done) {
...@@ -946,8 +940,8 @@ export default function fileIORead() { ...@@ -946,8 +940,8 @@ export default function fileIORead() {
let textDecoder = new util.TextDecoder("utf-8", { ignoreBOM: true }); let textDecoder = new util.TextDecoder("utf-8", { ignoreBOM: true });
let resultPut = textDecoder.decodeWithStream(new Uint8Array(buf), { stream: true }); let resultPut = textDecoder.decodeWithStream(new Uint8Array(buf), { stream: true });
expect(resultPut == CONTENT).assertTrue(); expect(resultPut == CONTENT).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_test_read_async_019 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_read_async_019 has failed for ' + e.message + ', code: ' + e.code);
......
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
fileIO, FILE_CONTENT, prepareFile, nextFileName, describe, it, expect,
} from '../Common';
export default function fileIOReadtext() {
describe('fileIO_fs_readtext', function () {
/**
* @tc.number SUB_DF_FILEIO_READ_TEXT_SYNC_0000
* @tc.name fileIO_test_readtext_sync_000
* @tc.desc Test readtextSync() interfaces.
* Read file content by path, verify normal function.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_readtext_sync_000', 0, async function () {
let fpath = await nextFileName('fileIO_test_readtext_sync_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let str = fileIO.readTextSync(fpath);
expect(str == FILE_CONTENT).assertTrue();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_readtext_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_READ_TEXT_SYNC_0100
* @tc.name fileIO_test_readtext_sync_001
* @tc.desc Test readtextSync() interfaces.
* str.substring(startIndex, [endIndex - 1]): Extracts and returns a string by index.
* Read file content by path when offset = 1.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_readtext_sync_001', 0, async function () {
let fpath = await nextFileName('fileIO_test_readtext_sync_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let str = fileIO.readTextSync(fpath, { offset: 1 });
expect(str == FILE_CONTENT.substring(1, FILE_CONTENT.length + 1)).assertTrue();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_readtext_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_READ_TEXT_SYNC_0200
* @tc.name fileIO_test_readtext_sync_002
* @tc.desc Test readtextSync() interfaces.
* Read file content by path when offset = 2, length = 4.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_readtext_sync_002', 0, async function () {
let fpath = await nextFileName('fileIO_test_readtext_sync_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let str = fileIO.readTextSync(fpath, {
offset: 2,
length: 4
});
expect(str == FILE_CONTENT.substring(2, 6)).assertTrue();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_readtext_sync_002 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_READ_TEXT_SYNC_0300
* @tc.name fileIO_test_readtext_sync_003
* @tc.desc Test readtextSync() interfaces.
* Read file content by path when offset = 1, length = 11, encoding = 'utf-8'.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_readtext_sync_003', 0, async function () {
let fpath = await nextFileName('fileIO_test_readtext_sync_003');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let str = fileIO.readTextSync(fpath, {
offset: 1,
length: FILE_CONTENT.length,
encoding: 'utf-8'
});
expect(str == FILE_CONTENT.substring(1, FILE_CONTENT.length + 1)).assertTrue();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_readtext_sync_002 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_READ_TEXT_SYNC_0400
* @tc.name fileIO_test_readtext_sync_004
* @tc.desc Test readtextSync() interfaces.
* Missing parameter.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_readtext_sync_004', 0, async function () {
try {
fileIO.readTextSync();
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_readtext_sync_003 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_READ_TEXT_SYNC_0500
* @tc.name fileIO_test_readtext_sync_005
* @tc.desc Test readtextSync() interfaces.
* The path point to nothing, no such file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_readtext_sync_005', 0, async function () {
let fpath = await nextFileName('fileIO_test_readtext_sync_005');
try {
fileIO.readTextSync(fpath);
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_readtext_sync_005 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900002 && e.message == 'No such file or directory').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_READ_TEXT_SYNC_0600
* @tc.name fileIO_test_readtext_sync_006
* @tc.desc Test readtextSync() interfaces.
* Read file content with invalid offset < 0.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_readtext_sync_006', 0, async function () {
let fpath = await nextFileName('fileIO_test_readtext_sync_006');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
const invalidOffset = -1;
fileIO.readTextSync(fpath, { offset: invalidOffset });
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_test_readtext_sync_006 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_READ_TEXT_SYNC_0700
* @tc.name fileIO_test_readtext_sync_007
* @tc.desc Test readtextSync() interfaces.
* Read file content with invalid offset = 9999.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_readtext_sync_007', 0, async function () {
let fpath = await nextFileName('fileIO_test_readtext_sync_007');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
const invalidOffset = 9999;
fileIO.readTextSync(fpath, { offset: invalidOffset });
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_test_readtext_sync_007 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_READ_TEXT_SYNC_0800
* @tc.name fileIO_test_readtext_sync_008
* @tc.desc Test readtextSync() interfaces.
* Read file content with invalid length < 0.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_readtext_sync_008', 0, async function () {
let fpath = await nextFileName('fileIO_test_readtext_sync_008');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
const invalidLength = -1;
fileIO.readTextSync(fpath, { length: invalidLength });
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_test_readtext_sync_008 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_READ_TEXT_ASYNC_0000
* @tc.name fileIO_test_readtext_async_000
* @tc.desc Test readtext() interfaces. Promise.
* Read file content by path, verify normal function.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_readtext_async_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_readtext_async_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let str = await fileIO.readText(fpath);
expect(str == FILE_CONTENT).assertTrue();
fileIO.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_test_readtext_async_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_READ_TEXT_ASYNC_0100
* @tc.name fileIO_test_readtext_async_001
* @tc.desc Test readtext() interfaces. Callback.
* Read file content by path, verify normal function.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_readtext_async_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_readtext_async_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.readText(fpath, (err, str) => {
if (err) {
console.log('fileIO_test_readtext_async_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(str == FILE_CONTENT).assertTrue();
fileIO.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_test_readtext_async_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_READ_TEXT_ASYNC_0200
* @tc.name fileIO_test_readtext_async_002
* @tc.desc Test readtext() interfaces. Promise.
* Read file content by path when offset = 1.
* str.substr(startIndex, [length]): Extracts and returns a string by index and length of str.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_readtext_async_002', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_readtext_async_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let str = await fileIO.readText(fpath, { offset: 1 });
expect(str == FILE_CONTENT.substr(1, FILE_CONTENT.length - 1)).assertTrue();
fileIO.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_test_readtext_async_002 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_READ_TEXT_ASYNC_0300
* @tc.name fileIO_test_readtext_async_003
* @tc.desc Test readtext() interfaces. Callback.
* Read file content by path when offset = 1.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_readtext_async_003', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_readtext_async_003');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.readText(fpath, { offset: 1 }, (err, str) => {
if (err) {
console.log('fileIO_test_readtext_async_003 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(str == FILE_CONTENT.substr(1, FILE_CONTENT.length - 1)).assertTrue();
fileIO.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_test_readtext_async_003 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_READ_TEXT_ASYNC_0400
* @tc.name fileIO_test_readtext_async_004
* @tc.desc Test readtext() interfaces. Promise.
* Read file content by path when offset = 1, length = 2.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_readtext_async_004', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_readtext_async_004');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let str = await fileIO.readText(fpath, {
offset: 1,
length: 2
});
expect(str == FILE_CONTENT.substr(1, 2)).assertTrue();
fileIO.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_test_readtext_async_004 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_READ_TEXT_ASYNC_0500
* @tc.name fileIO_test_readtext_async_005
* @tc.desc Test readtext() interfaces. Callback.
* Read file content by path when offset = 1, length = 2.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_readtext_async_005', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_readtext_async_005');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.readText(fpath, {
offset: 1,
length: 2
}, (err, str) => {
if (err) {
console.log('fileIO_test_readtext_async_005 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(str == FILE_CONTENT.substr(1, 2)).assertTrue();
fileIO.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_test_readtext_async_005 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_READ_TEXT_ASYNC_0600
* @tc.name fileIO_test_readtext_async_006
* @tc.desc Test readtext() interfaces. Promise.
* Read file content by path when offset = 1, length = 11, encoding = 'utf-8'.
* str.slice(startIndex, [endIndex - 1]): Extracts and returns a string by index.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_readtext_async_006', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_readtext_async_006');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let str = await fileIO.readText(fpath, {
offset: 1,
length: FILE_CONTENT.length,
encoding: 'utf-8'
});
expect(str == FILE_CONTENT.slice(1, FILE_CONTENT.length + 1)).assertTrue();
fileIO.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_test_readtext_async_006 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_READ_TEXT_ASYNC_0700
* @tc.name fileIO_test_readtext_async_007
* @tc.desc Test readtext() interfaces. Promise.then().catch()
* Read file content by path when offset = 1, length = 11, encoding = 'utf-8'.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_readtext_async_007', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_readtext_async_007');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.readText(fpath, {
offset: 1,
length: FILE_CONTENT.length,
encoding: 'utf-8'
}).then((str) => {
expect(str == FILE_CONTENT.slice(1, FILE_CONTENT.length + 1)).assertTrue();
fileIO.unlinkSync(fpath);
done();
}).catch((err) => {
console.log('fileIO_test_readtext_async_007 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
});
} catch (e) {
console.log('fileIO_test_readtext_async_007 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_READ_TEXT_ASYNC_0800
* @tc.name fileIO_test_readtext_async_008
* @tc.desc Test readtext() interfaces. Callback.
* Read file content by path when offset = 1, length = 11, encoding = 'utf-8'.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_readtext_async_008', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_readtext_async_008');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.readText(fpath, {
offset: 1,
length: FILE_CONTENT.length,
encoding: 'utf-8'
}, (err, str) => {
if (err) {
console.log('fileIO_test_readtext_async_008 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(str == FILE_CONTENT.slice(1, FILE_CONTENT.length + 1)).assertTrue();
fileIO.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_test_readtext_async_008 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_READ_TEXT_ASYNC_0900
* @tc.name fileIO_test_readtext_async_009
* @tc.desc Test readtext() interfaces. Promise.
* Read file content by path when option parameter is empty.
* str.slice(startIndex, [endIndex - 1]): Extracts and returns a string by index.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_readtext_async_009', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_readtext_async_009');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let str = await fileIO.readText(fpath, {});
expect(str == FILE_CONTENT).assertTrue();
fileIO.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_test_readtext_async_009 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_READ_TEXT_ASYNC_1000
* @tc.name fileIO_test_readtext_async_010
* @tc.desc Test readtext() interfaces. Callback.
* Read file content by path when option parameter is empty.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_readtext_async_010', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_readtext_async_010');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.readText(fpath, {}, (err, str) => {
if (err) {
console.log('fileIO_test_readtext_async_010 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(str == FILE_CONTENT).assertTrue();
fileIO.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_test_readtext_async_010 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_READ_TEXT_ASYNC_1100
* @tc.name fileIO_test_readtext_async_011
* @tc.desc Test readtext() interfaces. Promise.
* The path point to nothing, no such file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_readtext_async_011', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_readtext_async_011');
try {
await fileIO.readText(fpath);
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_readtext_async_011 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900002 && e.message == 'No such file or directory').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_READ_TEXT_ASYNC_1200
* @tc.name fileIO_test_readtext_async_012
* @tc.desc Test readtext() interfaces. Callback.
* The path point to nothing, no such file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_readtext_async_012', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_readtext_async_012');
try {
fileIO.readText(fpath, (err) => {
if (err) {
console.log('fileIO_test_readtext_async_012 error: {message:' + err.message + ', code: ' + err.code + '}');
expect(err.code == 13900002 && err.message == 'No such file or directory').assertTrue();
done();
}
});
} catch (e) {
console.log('fileIO_test_readtext_async_012 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_READ_TEXT_ASYNC_1300
* @tc.name fileIO_test_readtext_async_013
* @tc.desc Test readtext() interfaces.
* Read file content with invalid offset < 0.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_readtext_async_013', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_readtext_async_013');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
const invalidOffset = -1;
await fileIO.readText(fpath, { offset: invalidOffset });
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_test_readtext_async_013 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_READ_TEXT_ASYNC_1400
* @tc.name fileIO_test_readtext_async_014
* @tc.desc Test readtext() interfaces.
* Read file content with invalid offset = 9999.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_readtext_async_014', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_readtext_async_014');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
const invalidOffset = 9999;
await fileIO.readText(fpath, { offset: invalidOffset });
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_test_readtext_async_014 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_READ_TEXT_ASYNC_1500
* @tc.name fileIO_test_readtext_async_015
* @tc.desc Test readtext() interfaces.
* Read file content with invalid length < 0.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_readtext_async_015', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_readtext_async_015');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
const invalidLength = -1;
await fileIO.readText(fpath, { length: invalidLength });
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_test_readtext_async_015 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
}
});
});
}
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
fileIO, FILE_CONTENT, prepareFile, nextFileName, describe, it, expect, randomString
} from '../Common';
export default function fileIORename() {
describe('fileIO_fs_rename', function () {
/**
* @tc.number SUB_DF_FILEIO_RENAME_SYNC_0000
* @tc.name fileIO_test_rename_sync_000
* @tc.desc Test renameSync() interfaces.
* Rename the file by path, verify the normal function.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_rename_sync_000', 0, async function () {
let fpath = await nextFileName('fileIO_test_rename_sync_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let newf = fpath + 'test';
fileIO.renameSync(fpath, newf);
expect(fileIO.accessSync(newf)).assertTrue();
fileIO.unlinkSync(newf);
} catch (e) {
console.log('fileIO_test_rename_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_RENAME_SYNC_0100
* @tc.name fileIO_test_rename_sync_001
* @tc.desc Test renameSync() interfaces.
* The path point to nothing, no such file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_rename_sync_001', 0, async function () {
let fpath = await nextFileName('fileIO_test_rename_sync_001');
try {
fileIO.renameSync(fpath, fpath + 'test');
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_rename_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900002 && e.message == 'No such file or directory').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_RENAME_SYNC_0200
* @tc.name fileIO_test_rename_sync_002
* @tc.desc Test renameSync() interfaces.
* Missing parameter.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_rename_sync_002', 0, async function () {
let fpath = await nextFileName('fileIO_test_rename_sync_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.renameSync(fpath);
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_test_rename_sync_002 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_RENAME_SYNC_0300
* @tc.name fileIO_test_rename_sync_003
* @tc.desc Test renameSync() interfaces.
* Illegal second parameter.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_rename_sync_003', 0, async function () {
let fpath = await nextFileName('fileIO_test_rename_sync_003');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.renameSync(fpath, null);
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_test_rename_sync_003 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_RENAME_SYNC_0400
* @tc.name fileIO_test_rename_sync_004
* @tc.desc Test renameSync() interfaces.
* Illegal second parameter.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_rename_sync_004', 0, async function () {
let fpath = await nextFileName('fileIO_test_rename_sync_004');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.renameSync(fpath, undefined);
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_test_rename_sync_004 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_RENAME_SYNC_0500
* @tc.name fileIO_test_rename_sync_005
* @tc.desc Test renameSync() interfaces.
* Modify file names across directory.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_rename_sync_005', 0, async function () {
let dpath = await nextFileName('fileIO_test_rename_sync_005');
let fpath = dpath + '/file_000';
fileIO.mkdirSync(dpath);
fileIO.mkdirSync(dpath + '/dir_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let newf = dpath + '/dir_000/newFileName';
fileIO.renameSync(fpath, newf);
fileIO.rmdirSync(dpath);
} catch (e) {
console.log('fileIO_test_rename_sync_005 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_RENAME_SYNC_0600
* @tc.name fileIO_test_rename_sync_006
* @tc.desc Test renameSync() interfaces.
* The length of file name is too long.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_rename_sync_006', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_rename_sync_006');
let fpathTarget = fpath + randomString(250);
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
await fileIO.rename(fpath, fpathTarget);
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_rename_sync_006 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900030 && e.message == 'File name too long').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_RENAME_ASYNC_0000
* @tc.name fileIO_test_rename_async_000
* @tc.desc Test rename() interfaces. Promise.
* Rename the file by path, verify the normal function.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_rename_async_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_rename_async_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let newf = fpath + '123';
try {
await fileIO.rename(fpath, newf);
expect(fileIO.accessSync(newf)).assertTrue();
fileIO.unlinkSync(newf);
done();
} catch (e) {
console.log('fileIO_test_rename_async_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_RENAME_ASYNC_0100
* @tc.name fileIO_test_rename_async_001
* @tc.desc Test rename() interfaces. Callback.
* Rename the file by path, verify the normal function.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_rename_async_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_rename_async_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let newf = fpath + 'aaa';
try {
fileIO.rename(fpath, newf, (err) => {
if (err) {
console.log('fileIO_test_rename_async_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(fileIO.accessSync(newf)).assertTrue();
fileIO.unlinkSync(newf);
done();
})
} catch (e) {
console.log('fileIO_test_rename_async_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_RENAME_ASYNC_0200
* @tc.name fileIO_test_rename_async_002
* @tc.desc Test rename() interfaces. Promise.
* The path point to nothing, no such file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_rename_async_002', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_rename_async_002');
try {
await fileIO.rename(fpath, fpath + 'bbb');
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_rename_async_002 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900002 && e.message == 'No such file or directory').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_RENAME_ASYNC_0300
* @tc.name fileIO_test_rename_async_003
* @tc.desc Test rename() interfaces. Callback.
* The path point to nothing, no such file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_rename_async_003', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_rename_async_003');
try {
fileIO.rename(fpath, fpath + 'bbb', (err) => {
if (err) {
console.log('fileIO_test_rename_async_003 error: {message: ' + err.message + ', code: ' + err.code + '}');
expect(err.code == 13900002 && err.message == 'No such file or directory').assertTrue();
done();
}
});
} catch (e) {
console.log('fileIO_test_rename_async_003 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_RENAME_ASYNC_0400
* @tc.name fileIO_test_rename_async_004
* @tc.desc Test rename() interfaces. Promise.
* Missing parameter.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_rename_async_004', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_rename_async_004');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
await fileIO.rename(fpath);
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_test_rename_async_004 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_RENAME_ASYNC_0500
* @tc.name fileIO_test_rename_async_005
* @tc.desc Test rename() interfaces. Promise.
* Illegal second parameter.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_rename_async_005', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_rename_async_005');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
await fileIO.rename(fpath, null);
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_test_rename_async_005 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_RENAME_ASYNC_0600
* @tc.name fileIO_test_rename_async_006
* @tc.desc Test rename() interfaces. Promise.
* Illegal second parameter.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_rename_async_006', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_rename_async_006');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
await fileIO.rename(fpath, undefined);
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_test_rename_async_006 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_RENAME_ASYNC_0700
* @tc.name fileIO_test_rename_async_007
* @tc.desc Test rename() interfaces. Promise.
* Modify file names across directory.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_rename_async_007', 0, async function (done) {
let dpath = await nextFileName('fileIO_test_rename_async_007');
let fpath = dpath + '/file_001';
fileIO.mkdirSync(dpath);
fileIO.mkdirSync(dpath + '/dir_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let newf = dpath + '/dir_001/newFileName';
await fileIO.rename(fpath, newf);
fileIO.rmdirSync(dpath);
done();
} catch (e) {
console.log('fileIO_test_rename_async_007 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_RENAME_ASYNC_0800
* @tc.name fileIO_test_rename_async_008
* @tc.desc Test rename() interfaces. Callback.
* Modify file names across directory.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_rename_async_008', 0, async function (done) {
let dpath = await nextFileName('fileIO_test_rename_async_008');
let fpath = dpath + '/file_002';
fileIO.mkdirSync(dpath);
fileIO.mkdirSync(dpath + '/dir_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let newf = dpath + '/dir_002/newFileName';
fileIO.rename(fpath, newf, (err) => {
if (err) {
console.log('fileIO_test_rename_async_008 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
fileIO.rmdirSync(dpath);
});
done();
} catch (e) {
console.log('fileIO_test_rename_async_008 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_RENAME_ASYNC_0900
* @tc.name fileIO_test_rename_async_009
* @tc.desc Test rename() interfaces. Promise
* The length of file name is too long.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_rename_async_009', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_rename_async_009');
let fpathTarget = fpath + randomString(250);
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
await fileIO.rename(fpath, fpathTarget);
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_rename_async_009 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900030 && e.message == 'File name too long').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_RENAME_ASYNC_1000
* @tc.name fileIO_test_rename_async_010
* @tc.desc Test rename() interfaces. Callback
* The length of file name is too long.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_rename_async_010', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_rename_async_010');
let fpathTarget = fpath + randomString(250);
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.rename(fpath, fpathTarget, (err) => {
if (err) {
fileIO.unlinkSync(fpath);
console.log('fileIO_test_rename_async_010 error: {message: ' + err.message + ', code: ' + err.code + '}');
expect(err.code == 13900030 && err.message == 'File name too long').assertTrue();
done();
}
});
} catch (e) {
console.log('fileIO_test_rename_async_010 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
});
}
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
*/ */
import { import {
fileio, fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum, isBigInt, fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum, isBigInt,
describe, it, expect, describe, it, expect,
} from '../Common'; } from '../Common';
...@@ -42,8 +42,8 @@ describe('fileIO_fs_stat', function () { ...@@ -42,8 +42,8 @@ describe('fileIO_fs_stat', function () {
let file = fileIO.openSync(fpath); let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd); let stat2 = fileIO.statSync(file.fd);
expect(stat2 !== null).assertTrue(); expect(stat2 !== null).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_stat_sync_000 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_stat_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -57,7 +57,7 @@ describe('fileIO_fs_stat', function () { ...@@ -57,7 +57,7 @@ describe('fileIO_fs_stat', function () {
* The path point to nothing, no such file. * The path point to nothing, no such file.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_sync_001', 0, async function () { it('fileIO_stat_sync_001', 0, async function () {
...@@ -78,7 +78,7 @@ describe('fileIO_fs_stat', function () { ...@@ -78,7 +78,7 @@ describe('fileIO_fs_stat', function () {
* @tc.desc Test statSync() interfaces. Missing parameters. * @tc.desc Test statSync() interfaces. Missing parameters.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_sync_002', 0, async function () { it('fileIO_stat_sync_002', 0, async function () {
...@@ -99,7 +99,7 @@ describe('fileIO_fs_stat', function () { ...@@ -99,7 +99,7 @@ describe('fileIO_fs_stat', function () {
* Enter the path or fd parameter to get stat.ino of the file. * Enter the path or fd parameter to get stat.ino of the file.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_sync_ino_000', 0, async function () { it('fileIO_stat_sync_ino_000', 0, async function () {
...@@ -113,10 +113,10 @@ describe('fileIO_fs_stat', function () { ...@@ -113,10 +113,10 @@ describe('fileIO_fs_stat', function () {
let file = fileIO.openSync(fpath); let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd); let stat2 = fileIO.statSync(file.fd);
expect(isBigInt(stat2.ino)).assertTrue(); expect(isBigInt(stat2.ino)).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } 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(); expect(false).assertTrue();
} }
}); });
...@@ -128,7 +128,7 @@ describe('fileIO_fs_stat', function () { ...@@ -128,7 +128,7 @@ describe('fileIO_fs_stat', function () {
* Enter the path or fd parameter to get stat.mode of the file. * Enter the path or fd parameter to get stat.mode of the file.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_sync_mode_000', 0, async function () { it('fileIO_stat_sync_mode_000', 0, async function () {
...@@ -142,10 +142,10 @@ describe('fileIO_fs_stat', function () { ...@@ -142,10 +142,10 @@ describe('fileIO_fs_stat', function () {
let file = fileIO.openSync(fpath); let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd); let stat2 = fileIO.statSync(file.fd);
expect(isIntNum(stat2.mode)).assertTrue(); expect(isIntNum(stat2.mode)).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } 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(); expect(false).assertTrue();
} }
}); });
...@@ -157,7 +157,7 @@ describe('fileIO_fs_stat', function () { ...@@ -157,7 +157,7 @@ describe('fileIO_fs_stat', function () {
* Enter the path or fd parameter to get stat.uid of the file. * Enter the path or fd parameter to get stat.uid of the file.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_sync_uid_000', 0, async function () { it('fileIO_stat_sync_uid_000', 0, async function () {
...@@ -171,8 +171,8 @@ describe('fileIO_fs_stat', function () { ...@@ -171,8 +171,8 @@ describe('fileIO_fs_stat', function () {
let file = fileIO.openSync(fpath); let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd); let stat2 = fileIO.statSync(file.fd);
expect(isIntNum(stat2.uid)).assertTrue(); expect(isIntNum(stat2.uid)).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_stat_sync_uid_000 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_stat_sync_uid_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -186,7 +186,7 @@ describe('fileIO_fs_stat', function () { ...@@ -186,7 +186,7 @@ describe('fileIO_fs_stat', function () {
* Enter the path or fd parameter to get stat.gid of the file. * Enter the path or fd parameter to get stat.gid of the file.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_sync_gid_000', 0, async function () { it('fileIO_stat_sync_gid_000', 0, async function () {
...@@ -200,8 +200,8 @@ describe('fileIO_fs_stat', function () { ...@@ -200,8 +200,8 @@ describe('fileIO_fs_stat', function () {
let file = fileIO.openSync(fpath); let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd); let stat2 = fileIO.statSync(file.fd);
expect(isIntNum(stat2.gid)).assertTrue(); expect(isIntNum(stat2.gid)).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_stat_sync_gid_000 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_stat_sync_gid_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -215,7 +215,7 @@ describe('fileIO_fs_stat', function () { ...@@ -215,7 +215,7 @@ describe('fileIO_fs_stat', function () {
* Enter the path or fd parameter to get stat.size of the file. * Enter the path or fd parameter to get stat.size of the file.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_sync_size_000', 0, async function () { it('fileIO_stat_sync_size_000', 0, async function () {
...@@ -229,8 +229,8 @@ describe('fileIO_fs_stat', function () { ...@@ -229,8 +229,8 @@ describe('fileIO_fs_stat', function () {
let file = fileIO.openSync(fpath); let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd); let stat2 = fileIO.statSync(file.fd);
expect(isIntNum(stat2.size)).assertTrue(); expect(isIntNum(stat2.size)).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_stat_sync_size_000 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_stat_sync_size_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -244,7 +244,7 @@ describe('fileIO_fs_stat', function () { ...@@ -244,7 +244,7 @@ describe('fileIO_fs_stat', function () {
* Enter the path or fd parameter to get stat.atime of the file. * Enter the path or fd parameter to get stat.atime of the file.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_sync_atime_000', 0, async function () { it('fileIO_stat_sync_atime_000', 0, async function () {
...@@ -258,8 +258,8 @@ describe('fileIO_fs_stat', function () { ...@@ -258,8 +258,8 @@ describe('fileIO_fs_stat', function () {
let file = fileIO.openSync(fpath); let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd); let stat2 = fileIO.statSync(file.fd);
expect(isIntNum(stat2.atime)).assertTrue(); expect(isIntNum(stat2.atime)).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_stat_sync_atime_000 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_stat_sync_atime_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -273,7 +273,7 @@ describe('fileIO_fs_stat', function () { ...@@ -273,7 +273,7 @@ describe('fileIO_fs_stat', function () {
* Enter the path or fd parameter to get stat.mtime of the file. * Enter the path or fd parameter to get stat.mtime of the file.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_sync_mtime_000', 0, async function () { it('fileIO_stat_sync_mtime_000', 0, async function () {
...@@ -287,8 +287,8 @@ describe('fileIO_fs_stat', function () { ...@@ -287,8 +287,8 @@ describe('fileIO_fs_stat', function () {
let file = fileIO.openSync(fpath); let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd); let stat2 = fileIO.statSync(file.fd);
expect(isIntNum(stat2.mtime)).assertTrue(); expect(isIntNum(stat2.mtime)).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_stat_sync_mtime_000 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_stat_sync_mtime_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -302,7 +302,7 @@ describe('fileIO_fs_stat', function () { ...@@ -302,7 +302,7 @@ describe('fileIO_fs_stat', function () {
* Enter the path or fd parameter to get stat.ctime of the file. * Enter the path or fd parameter to get stat.ctime of the file.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_sync_ctime_000', 0, async function () { it('fileIO_stat_sync_ctime_000', 0, async function () {
...@@ -316,8 +316,8 @@ describe('fileIO_fs_stat', function () { ...@@ -316,8 +316,8 @@ describe('fileIO_fs_stat', function () {
let file = fileIO.openSync(fpath); let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd); let stat2 = fileIO.statSync(file.fd);
expect(isIntNum(stat2.ctime)).assertTrue(); expect(isIntNum(stat2.ctime)).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_stat_sync_ctime_000 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_stat_sync_ctime_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -331,7 +331,7 @@ describe('fileIO_fs_stat', function () { ...@@ -331,7 +331,7 @@ describe('fileIO_fs_stat', function () {
* This interface shall not treat a normal file as a block special device. * This interface shall not treat a normal file as a block special device.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_sync_is_block_device_000', 0, async function () { it('fileIO_stat_sync_is_block_device_000', 0, async function () {
...@@ -345,8 +345,8 @@ describe('fileIO_fs_stat', function () { ...@@ -345,8 +345,8 @@ describe('fileIO_fs_stat', function () {
let file = fileIO.openSync(fpath); let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd); let stat2 = fileIO.statSync(file.fd);
expect(stat2.isBlockDevice() === false).assertTrue(); expect(stat2.isBlockDevice() === false).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_stat_sync_is_block_device_000 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_stat_sync_is_block_device_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -360,7 +360,7 @@ describe('fileIO_fs_stat', function () { ...@@ -360,7 +360,7 @@ describe('fileIO_fs_stat', function () {
* This interface does not require parameters. * This interface does not require parameters.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_sync_is_block_device_001', 0, async function () { it('fileIO_stat_sync_is_block_device_001', 0, async function () {
...@@ -371,8 +371,8 @@ describe('fileIO_fs_stat', function () { ...@@ -371,8 +371,8 @@ describe('fileIO_fs_stat', function () {
fileIO.statSync(fpath).isBlockDevice(-1); fileIO.statSync(fpath).isBlockDevice(-1);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.info('fileIO_stat_sync_is_block_device_001 has failed for ' + e.message + ', code: ' + e.code); 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(); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
} }
}); });
...@@ -384,7 +384,7 @@ describe('fileIO_fs_stat', function () { ...@@ -384,7 +384,7 @@ describe('fileIO_fs_stat', function () {
* This interface does not require parameters. * This interface does not require parameters.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_sync_is_block_device_002', 0, async function () { it('fileIO_stat_sync_is_block_device_002', 0, async function () {
...@@ -396,9 +396,9 @@ describe('fileIO_fs_stat', function () { ...@@ -396,9 +396,9 @@ describe('fileIO_fs_stat', function () {
fileIO.statSync(file.fd).isBlockDevice(-1); fileIO.statSync(file.fd).isBlockDevice(-1);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.info('fileIO_stat_sync_is_block_device_002 has failed for ' + e.message + ', code: ' + e.code); 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(); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
} }
...@@ -411,7 +411,7 @@ describe('fileIO_fs_stat', function () { ...@@ -411,7 +411,7 @@ describe('fileIO_fs_stat', function () {
* This interface shall not treat a normal file as a character special device. * This interface shall not treat a normal file as a character special device.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_sync_is_character_device_000', 0, async function () { it('fileIO_stat_sync_is_character_device_000', 0, async function () {
...@@ -425,8 +425,8 @@ describe('fileIO_fs_stat', function () { ...@@ -425,8 +425,8 @@ describe('fileIO_fs_stat', function () {
let file = fileIO.openSync(fpath); let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd); let stat2 = fileIO.statSync(file.fd);
expect(stat2.isCharacterDevice() === false).assertTrue(); expect(stat2.isCharacterDevice() === false).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_stat_sync_is_character_device_000 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_stat_sync_is_character_device_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -440,7 +440,7 @@ describe('fileIO_fs_stat', function () { ...@@ -440,7 +440,7 @@ describe('fileIO_fs_stat', function () {
* This interface does not require parameters. * This interface does not require parameters.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_sync_is_character_device_001', 0, async function () { it('fileIO_stat_sync_is_character_device_001', 0, async function () {
...@@ -451,7 +451,7 @@ describe('fileIO_fs_stat', function () { ...@@ -451,7 +451,7 @@ describe('fileIO_fs_stat', function () {
fileIO.statSync(fpath).isCharacterDevice(-1); fileIO.statSync(fpath).isCharacterDevice(-1);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } 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); 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(); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
} }
...@@ -464,7 +464,7 @@ describe('fileIO_fs_stat', function () { ...@@ -464,7 +464,7 @@ describe('fileIO_fs_stat', function () {
* This interface does not require parameters. * This interface does not require parameters.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_sync_is_character_device_002', 0, async function () { it('fileIO_stat_sync_is_character_device_002', 0, async function () {
...@@ -476,8 +476,8 @@ describe('fileIO_fs_stat', function () { ...@@ -476,8 +476,8 @@ describe('fileIO_fs_stat', function () {
fileIO.statSync(file.fd).isCharacterDevice(-1); fileIO.statSync(file.fd).isCharacterDevice(-1);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_stat_sync_is_character_device_002 has failed for ' + e.message + ', code: ' + e.code); 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(); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
} }
...@@ -490,7 +490,7 @@ describe('fileIO_fs_stat', function () { ...@@ -490,7 +490,7 @@ describe('fileIO_fs_stat', function () {
* This interface shall not treat a normal file as a directory. * This interface shall not treat a normal file as a directory.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_sync_is_directory_000', 0, async function () { it('fileIO_stat_sync_is_directory_000', 0, async function () {
...@@ -504,8 +504,8 @@ describe('fileIO_fs_stat', function () { ...@@ -504,8 +504,8 @@ describe('fileIO_fs_stat', function () {
let file = fileIO.openSync(fpath); let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd); let stat2 = fileIO.statSync(file.fd);
expect(stat2.isDirectory() === false).assertTrue(); expect(stat2.isDirectory() === false).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_stat_sync_is_directory_000 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_stat_sync_is_directory_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -519,22 +519,22 @@ describe('fileIO_fs_stat', function () { ...@@ -519,22 +519,22 @@ describe('fileIO_fs_stat', function () {
* This interface shall treat a directory as a directory. * This interface shall treat a directory as a directory.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_sync_is_directory_001', 0, async function () { it('fileIO_stat_sync_is_directory_001', 0, async function () {
let dpath = await nextFileName('fileIO_stat_sync_is_directory_001'); let dpath = await nextFileName('fileIO_stat_sync_is_directory_001');
try { try {
fileio.mkdirSync(dpath); fileIO.mkdirSync(dpath);
let stat = fileIO.statSync(dpath); let stat = fileIO.statSync(dpath);
expect(stat.isDirectory() === true).assertTrue(); expect(stat.isDirectory() === true).assertTrue();
let file = fileIO.openSync(dpath, fileIO.OpenMode.DIR); let file = fileIO.openSync(dpath, fileIO.OpenMode.DIR);
let stat2 = fileIO.statSync(file.fd); let stat2 = fileIO.statSync(file.fd);
expect(stat2.isDirectory() === true).assertTrue(); expect(stat2.isDirectory() === true).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.rmdirSync(dpath); fileIO.rmdirSync(dpath);
} catch (e) { } catch (e) {
console.log('fileIO_stat_sync_is_directory_001 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_stat_sync_is_directory_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -548,18 +548,18 @@ describe('fileIO_fs_stat', function () { ...@@ -548,18 +548,18 @@ describe('fileIO_fs_stat', function () {
* This interface does not require parameters. * This interface does not require parameters.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_sync_is_directory_002', 0, async function () { it('fileIO_stat_sync_is_directory_002', 0, async function () {
let dpath = await nextFileName('fileIO_stat_sync_is_directory_002') + 'd'; let dpath = await nextFileName('fileIO_stat_sync_is_directory_002') + 'd';
try { try {
fileio.mkdirSync(dpath); fileIO.mkdirSync(dpath);
fileIO.statSync(dpath).isDirectory(-1); fileIO.statSync(dpath).isDirectory(-1);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
fileio.rmdirSync(dpath); fileIO.rmdirSync(dpath);
console.log('fileIO_stat_sync_is_directory_002 has failed for ' + e.message + ', code: ' + e.code); 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(); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
} }
...@@ -572,20 +572,20 @@ describe('fileIO_fs_stat', function () { ...@@ -572,20 +572,20 @@ describe('fileIO_fs_stat', function () {
* This interface does not require parameters. * This interface does not require parameters.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_sync_is_directory_003', 0, async function () { it('fileIO_stat_sync_is_directory_003', 0, async function () {
let dpath = await nextFileName('fileIO_stat_sync_is_directory_003') + 'd'; 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); let file = fileIO.openSync(dpath, fileIO.OpenMode.DIR);
try { try {
fileIO.statSync(file.fd).isDirectory(-1); fileIO.statSync(file.fd).isDirectory(-1);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.rmdirSync(dpath); fileIO.rmdirSync(dpath);
console.log('fileIO_stat_sync_is_directory_003 has failed for ' + e.message + ', code: ' + e.code); 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(); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
} }
...@@ -598,7 +598,7 @@ describe('fileIO_fs_stat', function () { ...@@ -598,7 +598,7 @@ describe('fileIO_fs_stat', function () {
* This interface shall not treat a normal file as a FIFO. * This interface shall not treat a normal file as a FIFO.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_sync_is_fifo_000', 0, async function () { it('fileIO_stat_sync_is_fifo_000', 0, async function () {
...@@ -612,8 +612,8 @@ describe('fileIO_fs_stat', function () { ...@@ -612,8 +612,8 @@ describe('fileIO_fs_stat', function () {
let file = fileIO.openSync(fpath); let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd); let stat2 = fileIO.statSync(file.fd);
expect(stat2.isFIFO() === false).assertTrue(); expect(stat2.isFIFO() === false).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_stat_sync_is_fifo_000 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_stat_sync_is_fifo_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -627,7 +627,7 @@ describe('fileIO_fs_stat', function () { ...@@ -627,7 +627,7 @@ describe('fileIO_fs_stat', function () {
* This interface does not require parameters. * This interface does not require parameters.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_sync_is_fifo_001', 0, async function () { it('fileIO_stat_sync_is_fifo_001', 0, async function () {
...@@ -638,7 +638,7 @@ describe('fileIO_fs_stat', function () { ...@@ -638,7 +638,7 @@ describe('fileIO_fs_stat', function () {
fileIO.statSync(fpath).isFile(-1); fileIO.statSync(fpath).isFile(-1);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_stat_sync_is_fifo_001 has failed for ' + e.message + ', code: ' + e.code); 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(); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
} }
...@@ -651,7 +651,7 @@ describe('fileIO_fs_stat', function () { ...@@ -651,7 +651,7 @@ describe('fileIO_fs_stat', function () {
* This interface does not require parameters. * This interface does not require parameters.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_sync_is_fifo_002', 0, async function () { it('fileIO_stat_sync_is_fifo_002', 0, async function () {
...@@ -663,8 +663,8 @@ describe('fileIO_fs_stat', function () { ...@@ -663,8 +663,8 @@ describe('fileIO_fs_stat', function () {
fileIO.statSync(file.fd).isFile(-1); fileIO.statSync(file.fd).isFile(-1);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_stat_sync_is_fifo_002 has failed for ' + e.message + ', code: ' + e.code); 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(); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
} }
...@@ -676,7 +676,7 @@ describe('fileIO_fs_stat', function () { ...@@ -676,7 +676,7 @@ describe('fileIO_fs_stat', function () {
* This interface shall treat a normal file as a normal file. * This interface shall treat a normal file as a normal file.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_sync_is_file_000', 0, async function () { it('fileIO_stat_sync_is_file_000', 0, async function () {
...@@ -690,8 +690,8 @@ describe('fileIO_fs_stat', function () { ...@@ -690,8 +690,8 @@ describe('fileIO_fs_stat', function () {
let file = fileIO.openSync(fpath); let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd); let stat2 = fileIO.statSync(file.fd);
expect(stat2.isFile() === true).assertTrue(); expect(stat2.isFile() === true).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_stat_sync_is_file_000 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_stat_sync_is_file_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -705,22 +705,22 @@ describe('fileIO_fs_stat', function () { ...@@ -705,22 +705,22 @@ describe('fileIO_fs_stat', function () {
* This interface shall not treat a directory as a normal file. * This interface shall not treat a directory as a normal file.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_sync_is_file_001', 0, async function () { it('fileIO_stat_sync_is_file_001', 0, async function () {
let dpath = await nextFileName('fileIO_stat_sync_is_file_001'); let dpath = await nextFileName('fileIO_stat_sync_is_file_001');
try { try {
fileio.mkdirSync(dpath); fileIO.mkdirSync(dpath);
let stat = fileIO.statSync(dpath); let stat = fileIO.statSync(dpath);
expect(stat.isFile() === false).assertTrue(); expect(stat.isFile() === false).assertTrue();
let file = fileIO.openSync(dpath, fileIO.OpenMode.DIR); let file = fileIO.openSync(dpath, fileIO.OpenMode.DIR);
let stat2 = fileIO.statSync(file.fd); let stat2 = fileIO.statSync(file.fd);
expect(stat2.isFile() === false).assertTrue(); expect(stat2.isFile() === false).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.rmdirSync(dpath); fileIO.rmdirSync(dpath);
} catch (e) { } catch (e) {
console.log('fileIO_stat_sync_is_file_001 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_stat_sync_is_file_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -734,18 +734,18 @@ describe('fileIO_fs_stat', function () { ...@@ -734,18 +734,18 @@ describe('fileIO_fs_stat', function () {
* This interface does not require parameters. * This interface does not require parameters.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_sync_is_file_002', 0, async function () { it('fileIO_stat_sync_is_file_002', 0, async function () {
let dpath = await nextFileName('fileIO_stat_sync_is_file_002'); let dpath = await nextFileName('fileIO_stat_sync_is_file_002');
try { try {
fileio.mkdirSync(dpath); fileIO.mkdirSync(dpath);
fileIO.statSync(dpath).isFile(-1); fileIO.statSync(dpath).isFile(-1);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
fileio.rmdirSync(dpath); fileIO.rmdirSync(dpath);
console.log('fileIO_stat_sync_is_file_002 has failed for ' + e.message + ', code: ' + e.code); 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(); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
} }
...@@ -758,20 +758,20 @@ describe('fileIO_fs_stat', function () { ...@@ -758,20 +758,20 @@ describe('fileIO_fs_stat', function () {
* This interface does not require parameters. * This interface does not require parameters.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_sync_is_file_003', 0, async function () { it('fileIO_stat_sync_is_file_003', 0, async function () {
let dpath = await nextFileName('fileIO_stat_sync_is_file_003'); let dpath = await nextFileName('fileIO_stat_sync_is_file_003');
fileio.mkdirSync(dpath); fileIO.mkdirSync(dpath);
let file = fileIO.openSync(dpath, fileIO.OpenMode.DIR); let file = fileIO.openSync(dpath, fileIO.OpenMode.DIR);
try { try {
fileIO.statSync(file.fd).isFile(-1); fileIO.statSync(file.fd).isFile(-1);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.rmdirSync(dpath); fileIO.rmdirSync(dpath);
console.log('fileIO_stat_sync_is_file_003 has failed for ' + e.message + ', code: ' + e.code); 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(); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
} }
...@@ -784,7 +784,7 @@ describe('fileIO_fs_stat', function () { ...@@ -784,7 +784,7 @@ describe('fileIO_fs_stat', function () {
* This interface shall not treat a file as a socket. * This interface shall not treat a file as a socket.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_sync_is_socket_000', 0, async function () { it('fileIO_stat_sync_is_socket_000', 0, async function () {
...@@ -798,8 +798,8 @@ describe('fileIO_fs_stat', function () { ...@@ -798,8 +798,8 @@ describe('fileIO_fs_stat', function () {
let file = fileIO.openSync(fpath); let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd); let stat2 = fileIO.statSync(file.fd);
expect(stat2.isSocket() === false).assertTrue(); expect(stat2.isSocket() === false).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_stat_sync_is_socket_000 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_stat_sync_is_socket_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -813,7 +813,7 @@ describe('fileIO_fs_stat', function () { ...@@ -813,7 +813,7 @@ describe('fileIO_fs_stat', function () {
* This interface does not require parameters. * This interface does not require parameters.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_sync_is_socket_001', 0, async function () { it('fileIO_stat_sync_is_socket_001', 0, async function () {
...@@ -824,7 +824,7 @@ describe('fileIO_fs_stat', function () { ...@@ -824,7 +824,7 @@ describe('fileIO_fs_stat', function () {
fileIO.statSync(fpath).isSocket(-1); fileIO.statSync(fpath).isSocket(-1);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_stat_sync_is_socket_001 has failed for ' + e.message + ', code: ' + e.code); 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(); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
} }
...@@ -837,7 +837,7 @@ describe('fileIO_fs_stat', function () { ...@@ -837,7 +837,7 @@ describe('fileIO_fs_stat', function () {
* This interface does not require parameters. * This interface does not require parameters.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_sync_is_socket_002', 0, async function () { it('fileIO_stat_sync_is_socket_002', 0, async function () {
...@@ -849,8 +849,8 @@ describe('fileIO_fs_stat', function () { ...@@ -849,8 +849,8 @@ describe('fileIO_fs_stat', function () {
fileIO.statSync(file.fd).isSocket(-1); fileIO.statSync(file.fd).isSocket(-1);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_stat_sync_is_socket_002 has failed for ' + e.message + ', code: ' + e.code); 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(); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
} }
...@@ -862,7 +862,7 @@ describe('fileIO_fs_stat', function () { ...@@ -862,7 +862,7 @@ describe('fileIO_fs_stat', function () {
* This interface shall not treat a normal file as a symbolic link. * This interface shall not treat a normal file as a symbolic link.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_sync_is_symbolic_link_000', 0, async function () { it('fileIO_stat_sync_is_symbolic_link_000', 0, async function () {
...@@ -876,8 +876,8 @@ describe('fileIO_fs_stat', function () { ...@@ -876,8 +876,8 @@ describe('fileIO_fs_stat', function () {
let file = fileIO.openSync(fpath); let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd); let stat2 = fileIO.statSync(file.fd);
expect(stat2.isSymbolicLink() === false).assertTrue(); expect(stat2.isSymbolicLink() === false).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_stat_sync_is_symbolic_link_000 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_stat_sync_is_symbolic_link_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -891,7 +891,7 @@ describe('fileIO_fs_stat', function () { ...@@ -891,7 +891,7 @@ describe('fileIO_fs_stat', function () {
* This interface does not require parameters. * This interface does not require parameters.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_sync_is_symbolic_link_001', 0, async function () { it('fileIO_stat_sync_is_symbolic_link_001', 0, async function () {
...@@ -902,7 +902,7 @@ describe('fileIO_fs_stat', function () { ...@@ -902,7 +902,7 @@ describe('fileIO_fs_stat', function () {
fileIO.statSync(fpath).isSymbolicLink(-1); fileIO.statSync(fpath).isSymbolicLink(-1);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } 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); 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(); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
} }
...@@ -915,7 +915,7 @@ describe('fileIO_fs_stat', function () { ...@@ -915,7 +915,7 @@ describe('fileIO_fs_stat', function () {
* This interface does not require parameters. * This interface does not require parameters.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_sync_is_symbolic_link_002', 0, async function () { it('fileIO_stat_sync_is_symbolic_link_002', 0, async function () {
...@@ -927,8 +927,8 @@ describe('fileIO_fs_stat', function () { ...@@ -927,8 +927,8 @@ describe('fileIO_fs_stat', function () {
fileIO.statSync(file.fd).isSymbolicLink(-1); fileIO.statSync(file.fd).isSymbolicLink(-1);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_stat_sync_is_symbolic_link_001 has failed for ' + e.message + ', code: ' + e.code); 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(); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
} }
...@@ -959,12 +959,12 @@ describe('fileIO_fs_stat', function () { ...@@ -959,12 +959,12 @@ describe('fileIO_fs_stat', function () {
let file = fileIO.openSync(fpath); let file = fileIO.openSync(fpath);
fileIO.stat(file.fd).then((stat2) => { fileIO.stat(file.fd).then((stat2) => {
expect(stat2 !== null).assertTrue(); expect(stat2 !== null).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
}).catch((err) => { }).catch((err) => {
console.log('fileIO_stat_async_000 error package2: ' + JSON.stringify(err)); console.log('fileIO_stat_async_000 error package2: ' + JSON.stringify(err));
expect(false).assertTrue(); expect(false).assertTrue();
}); });
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_stat_async_000 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_stat_async_000 has failed for ' + e.message + ', code: ' + e.code);
...@@ -993,8 +993,8 @@ describe('fileIO_fs_stat', function () { ...@@ -993,8 +993,8 @@ describe('fileIO_fs_stat', function () {
let file = fileIO.openSync(fpath); let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd); let stat2 = await fileIO.stat(file.fd);
expect(stat2 !== null).assertTrue(); expect(stat2 !== null).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_stat_async_001 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_stat_async_001 has failed for ' + e.message + ', code: ' + e.code);
...@@ -1009,7 +1009,7 @@ describe('fileIO_fs_stat', function () { ...@@ -1009,7 +1009,7 @@ describe('fileIO_fs_stat', function () {
* Enter the path or fd parameter to get the file stat. * Enter the path or fd parameter to get the file stat.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_async_002', 0, async function (done) { it('fileIO_stat_async_002', 0, async function (done) {
...@@ -1032,8 +1032,8 @@ describe('fileIO_fs_stat', function () { ...@@ -1032,8 +1032,8 @@ describe('fileIO_fs_stat', function () {
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(stat2 !== null).assertTrue(); expect(stat2 !== null).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
} catch (e) { } catch (e) {
...@@ -1049,7 +1049,7 @@ describe('fileIO_fs_stat', function () { ...@@ -1049,7 +1049,7 @@ describe('fileIO_fs_stat', function () {
* The path point to nothing, no such file. * The path point to nothing, no such file.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_async_003', 0, async function (done) { it('fileIO_stat_async_003', 0, async function (done) {
...@@ -1072,7 +1072,7 @@ describe('fileIO_fs_stat', function () { ...@@ -1072,7 +1072,7 @@ describe('fileIO_fs_stat', function () {
* The path point to nothing, no such file. * The path point to nothing, no such file.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_async_004', 0, async function (done) { it('fileIO_stat_async_004', 0, async function (done) {
...@@ -1081,7 +1081,7 @@ describe('fileIO_fs_stat', function () { ...@@ -1081,7 +1081,7 @@ describe('fileIO_fs_stat', function () {
try { try {
fileIO.stat(fpath, (err) => { fileIO.stat(fpath, (err) => {
if (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(); expect(err.code == 13900002 && err.message == 'No such file or directory').assertTrue();
done(); done();
} }
...@@ -1099,7 +1099,7 @@ describe('fileIO_fs_stat', function () { ...@@ -1099,7 +1099,7 @@ describe('fileIO_fs_stat', function () {
* Invalid path or fd parameter. * Invalid path or fd parameter.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_async_005', 0, async function (done) { it('fileIO_stat_async_005', 0, async function (done) {
...@@ -1120,13 +1120,13 @@ describe('fileIO_fs_stat', function () { ...@@ -1120,13 +1120,13 @@ describe('fileIO_fs_stat', function () {
* Invalid path or fd parameter. * Invalid path or fd parameter.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_async_006', 0, async function (done) { it('fileIO_stat_async_006', 0, async function (done) {
try { try {
fileIO.stat(-1, () => { fileIO.stat(-1, (err) => {
expect(false).assertTrue(); expect(false).assertTrue();
}); });
} catch (e) { } catch (e) {
...@@ -1143,7 +1143,7 @@ describe('fileIO_fs_stat', function () { ...@@ -1143,7 +1143,7 @@ describe('fileIO_fs_stat', function () {
* Enter the path or fd parameter to get stat.ino of the file. * Enter the path or fd parameter to get stat.ino of the file.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_async_ino_000', 0, async function (done) { it('fileIO_stat_async_ino_000', 0, async function (done) {
...@@ -1157,8 +1157,8 @@ describe('fileIO_fs_stat', function () { ...@@ -1157,8 +1157,8 @@ describe('fileIO_fs_stat', function () {
let file = fileIO.openSync(fpath); let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd); let stat2 = await fileIO.stat(file.fd);
expect(isBigInt(stat2.ino)).assertTrue(); expect(isBigInt(stat2.ino)).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_stat_async_ino_000 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_stat_async_ino_000 has failed for ' + e.message + ', code: ' + e.code);
...@@ -1173,7 +1173,7 @@ describe('fileIO_fs_stat', function () { ...@@ -1173,7 +1173,7 @@ describe('fileIO_fs_stat', function () {
* Enter the path or fd parameter to get stat.atime of the file. * Enter the path or fd parameter to get stat.atime of the file.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_async_ino_001', 0, async function (done) { it('fileIO_stat_async_ino_001', 0, async function (done) {
...@@ -1196,8 +1196,8 @@ describe('fileIO_fs_stat', function () { ...@@ -1196,8 +1196,8 @@ describe('fileIO_fs_stat', function () {
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(isBigInt(stat2.ino)).assertTrue(); expect(isBigInt(stat2.ino)).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
} catch (e) { } catch (e) {
...@@ -1213,7 +1213,7 @@ describe('fileIO_fs_stat', function () { ...@@ -1213,7 +1213,7 @@ describe('fileIO_fs_stat', function () {
* Enter the path or fd parameter to get stat.mode of the file. * Enter the path or fd parameter to get stat.mode of the file.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_async_mode_000', 0, async function (done) { it('fileIO_stat_async_mode_000', 0, async function (done) {
...@@ -1227,8 +1227,8 @@ describe('fileIO_fs_stat', function () { ...@@ -1227,8 +1227,8 @@ describe('fileIO_fs_stat', function () {
let file = fileIO.openSync(fpath); let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd); let stat2 = await fileIO.stat(file.fd);
expect(isIntNum(stat2.mode)).assertTrue(); expect(isIntNum(stat2.mode)).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_stat_async_mode_000 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_stat_async_mode_000 has failed for ' + e.message + ', code: ' + e.code);
...@@ -1243,7 +1243,7 @@ describe('fileIO_fs_stat', function () { ...@@ -1243,7 +1243,7 @@ describe('fileIO_fs_stat', function () {
* Enter the path or fd parameter to get stat.mode of the file. * Enter the path or fd parameter to get stat.mode of the file.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_async_mode_001', 0, async function (done) { it('fileIO_stat_async_mode_001', 0, async function (done) {
...@@ -1266,8 +1266,8 @@ describe('fileIO_fs_stat', function () { ...@@ -1266,8 +1266,8 @@ describe('fileIO_fs_stat', function () {
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(isIntNum(stat2.mode)).assertTrue(); expect(isIntNum(stat2.mode)).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
} catch (e) { } catch (e) {
...@@ -1283,7 +1283,7 @@ describe('fileIO_fs_stat', function () { ...@@ -1283,7 +1283,7 @@ describe('fileIO_fs_stat', function () {
* Enter the path or fd parameter to get stat.uid of the file. * Enter the path or fd parameter to get stat.uid of the file.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_async_uid_000', 0, async function (done) { it('fileIO_stat_async_uid_000', 0, async function (done) {
...@@ -1297,8 +1297,8 @@ describe('fileIO_fs_stat', function () { ...@@ -1297,8 +1297,8 @@ describe('fileIO_fs_stat', function () {
let file = fileIO.openSync(fpath); let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd); let stat2 = await fileIO.stat(file.fd);
expect(isIntNum(stat2.uid)).assertTrue(); expect(isIntNum(stat2.uid)).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_stat_async_uid_000 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_stat_async_uid_000 has failed for ' + e.message + ', code: ' + e.code);
...@@ -1313,7 +1313,7 @@ describe('fileIO_fs_stat', function () { ...@@ -1313,7 +1313,7 @@ describe('fileIO_fs_stat', function () {
* Enter the path or fd parameter to get stat.uid of the file. * Enter the path or fd parameter to get stat.uid of the file.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_async_uid_001', 0, async function (done) { it('fileIO_stat_async_uid_001', 0, async function (done) {
...@@ -1336,8 +1336,8 @@ describe('fileIO_fs_stat', function () { ...@@ -1336,8 +1336,8 @@ describe('fileIO_fs_stat', function () {
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(isIntNum(stat2.uid)).assertTrue(); expect(isIntNum(stat2.uid)).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
} catch (e) { } catch (e) {
...@@ -1354,7 +1354,7 @@ describe('fileIO_fs_stat', function () { ...@@ -1354,7 +1354,7 @@ describe('fileIO_fs_stat', function () {
* Enter the path or fd parameter to get stat.gid of the file. * Enter the path or fd parameter to get stat.gid of the file.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_async_gid_000', 0, async function (done) { it('fileIO_stat_async_gid_000', 0, async function (done) {
...@@ -1368,8 +1368,8 @@ describe('fileIO_fs_stat', function () { ...@@ -1368,8 +1368,8 @@ describe('fileIO_fs_stat', function () {
let file = fileIO.openSync(fpath); let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd); let stat2 = await fileIO.stat(file.fd);
expect(isIntNum(stat2.gid)).assertTrue(); expect(isIntNum(stat2.gid)).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_stat_async_gid_000 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_stat_async_gid_000 has failed for ' + e.message + ', code: ' + e.code);
...@@ -1384,7 +1384,7 @@ describe('fileIO_fs_stat', function () { ...@@ -1384,7 +1384,7 @@ describe('fileIO_fs_stat', function () {
* Enter the path or fd parameter to get stat.gid of the file. * Enter the path or fd parameter to get stat.gid of the file.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_async_gid_001', 0, async function (done) { it('fileIO_stat_async_gid_001', 0, async function (done) {
...@@ -1407,8 +1407,8 @@ describe('fileIO_fs_stat', function () { ...@@ -1407,8 +1407,8 @@ describe('fileIO_fs_stat', function () {
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(isIntNum(stat2.gid)).assertTrue(); expect(isIntNum(stat2.gid)).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
} catch (e) { } catch (e) {
...@@ -1424,7 +1424,7 @@ describe('fileIO_fs_stat', function () { ...@@ -1424,7 +1424,7 @@ describe('fileIO_fs_stat', function () {
* Enter the path or fd parameter to get stat.size of the file. * Enter the path or fd parameter to get stat.size of the file.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_async_size_000', 0, async function (done) { it('fileIO_stat_async_size_000', 0, async function (done) {
...@@ -1438,8 +1438,8 @@ describe('fileIO_fs_stat', function () { ...@@ -1438,8 +1438,8 @@ describe('fileIO_fs_stat', function () {
let file = fileIO.openSync(fpath); let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd); let stat2 = await fileIO.stat(file.fd);
expect(isIntNum(stat2.size)).assertTrue(); expect(isIntNum(stat2.size)).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_stat_async_size_000 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_stat_async_size_000 has failed for ' + e.message + ', code: ' + e.code);
...@@ -1454,7 +1454,7 @@ describe('fileIO_fs_stat', function () { ...@@ -1454,7 +1454,7 @@ describe('fileIO_fs_stat', function () {
* Enter the path or fd parameter to get stat.size of the file. * Enter the path or fd parameter to get stat.size of the file.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_async_size_001', 0, async function (done) { it('fileIO_stat_async_size_001', 0, async function (done) {
...@@ -1477,8 +1477,8 @@ describe('fileIO_fs_stat', function () { ...@@ -1477,8 +1477,8 @@ describe('fileIO_fs_stat', function () {
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(isIntNum(stat2.size)).assertTrue(); expect(isIntNum(stat2.size)).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
} catch (e) { } catch (e) {
...@@ -1494,7 +1494,7 @@ describe('fileIO_fs_stat', function () { ...@@ -1494,7 +1494,7 @@ describe('fileIO_fs_stat', function () {
* Enter the path or fd parameter to get stat.atime of the file. * Enter the path or fd parameter to get stat.atime of the file.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_async_atime_000', 0, async function (done) { it('fileIO_stat_async_atime_000', 0, async function (done) {
...@@ -1508,8 +1508,8 @@ describe('fileIO_fs_stat', function () { ...@@ -1508,8 +1508,8 @@ describe('fileIO_fs_stat', function () {
let file = fileIO.openSync(fpath); let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd); let stat2 = await fileIO.stat(file.fd);
expect(isIntNum(stat2.atime)).assertTrue(); expect(isIntNum(stat2.atime)).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_stat_async_atime_000 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_stat_async_atime_000 has failed for ' + e.message + ', code: ' + e.code);
...@@ -1524,7 +1524,7 @@ describe('fileIO_fs_stat', function () { ...@@ -1524,7 +1524,7 @@ describe('fileIO_fs_stat', function () {
* Enter the path or fd parameter to get stat.atime of the file. * Enter the path or fd parameter to get stat.atime of the file.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_async_atime_001', 0, async function (done) { it('fileIO_stat_async_atime_001', 0, async function (done) {
...@@ -1547,8 +1547,8 @@ describe('fileIO_fs_stat', function () { ...@@ -1547,8 +1547,8 @@ describe('fileIO_fs_stat', function () {
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(isIntNum(stat2.atime)).assertTrue(); expect(isIntNum(stat2.atime)).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
} catch (e) { } catch (e) {
...@@ -1564,7 +1564,7 @@ describe('fileIO_fs_stat', function () { ...@@ -1564,7 +1564,7 @@ describe('fileIO_fs_stat', function () {
* Enter the path or fd parameter to get stat.mtime of the file. * Enter the path or fd parameter to get stat.mtime of the file.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_async_mtime_000', 0, async function (done) { it('fileIO_stat_async_mtime_000', 0, async function (done) {
...@@ -1578,8 +1578,8 @@ describe('fileIO_fs_stat', function () { ...@@ -1578,8 +1578,8 @@ describe('fileIO_fs_stat', function () {
let file = fileIO.openSync(fpath); let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd); let stat2 = await fileIO.stat(file.fd);
expect(isIntNum(stat2.mtime)).assertTrue(); expect(isIntNum(stat2.mtime)).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_stat_async_mtime_000 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_stat_async_mtime_000 has failed for ' + e.message + ', code: ' + e.code);
...@@ -1594,7 +1594,7 @@ describe('fileIO_fs_stat', function () { ...@@ -1594,7 +1594,7 @@ describe('fileIO_fs_stat', function () {
* Enter the path or fd parameter to get stat.mtime of the file. * Enter the path or fd parameter to get stat.mtime of the file.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_async_mtime_001', 0, async function (done) { it('fileIO_stat_async_mtime_001', 0, async function (done) {
...@@ -1617,8 +1617,8 @@ describe('fileIO_fs_stat', function () { ...@@ -1617,8 +1617,8 @@ describe('fileIO_fs_stat', function () {
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(isIntNum(stat2.mtime)).assertTrue(); expect(isIntNum(stat2.mtime)).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
} catch (e) { } catch (e) {
...@@ -1634,7 +1634,7 @@ describe('fileIO_fs_stat', function () { ...@@ -1634,7 +1634,7 @@ describe('fileIO_fs_stat', function () {
* Enter the path or fd parameter to get stat.ctime of the file. * Enter the path or fd parameter to get stat.ctime of the file.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_async_ctime_000', 0, async function (done) { it('fileIO_stat_async_ctime_000', 0, async function (done) {
...@@ -1648,8 +1648,8 @@ describe('fileIO_fs_stat', function () { ...@@ -1648,8 +1648,8 @@ describe('fileIO_fs_stat', function () {
let file = fileIO.openSync(fpath); let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd); let stat2 = await fileIO.stat(file.fd);
expect(isIntNum(stat2.ctime)).assertTrue(); expect(isIntNum(stat2.ctime)).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_stat_async_ctime_000 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_stat_async_ctime_000 has failed for ' + e.message + ', code: ' + e.code);
...@@ -1664,7 +1664,7 @@ describe('fileIO_fs_stat', function () { ...@@ -1664,7 +1664,7 @@ describe('fileIO_fs_stat', function () {
* Enter the path or fd parameter to get stat.ctime of the file. * Enter the path or fd parameter to get stat.ctime of the file.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_async_ctime_001', 0, async function (done) { it('fileIO_stat_async_ctime_001', 0, async function (done) {
...@@ -1687,8 +1687,8 @@ describe('fileIO_fs_stat', function () { ...@@ -1687,8 +1687,8 @@ describe('fileIO_fs_stat', function () {
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(isIntNum(stat2.ctime)).assertTrue(); expect(isIntNum(stat2.ctime)).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
} catch (e) { } catch (e) {
...@@ -1704,7 +1704,7 @@ describe('fileIO_fs_stat', function () { ...@@ -1704,7 +1704,7 @@ describe('fileIO_fs_stat', function () {
* This interface shall not treat a normal file as a block special device. * This interface shall not treat a normal file as a block special device.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_async_is_block_device_000', 0, async function (done) { it('fileIO_stat_async_is_block_device_000', 0, async function (done) {
...@@ -1718,8 +1718,8 @@ describe('fileIO_fs_stat', function () { ...@@ -1718,8 +1718,8 @@ describe('fileIO_fs_stat', function () {
let file = fileIO.openSync(fpath); let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd); let stat2 = await fileIO.stat(file.fd);
expect(stat2.isBlockDevice() === false).assertTrue(); expect(stat2.isBlockDevice() === false).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_stat_async_is_block_device_000 has failed for ' + e.message + ', code: ' + e.code); 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 () { ...@@ -1734,7 +1734,7 @@ describe('fileIO_fs_stat', function () {
* This interface shall not treat a normal file as a block special device. * This interface shall not treat a normal file as a block special device.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_async_is_block_device_001', 0, async function (done) { it('fileIO_stat_async_is_block_device_001', 0, async function (done) {
...@@ -1757,8 +1757,8 @@ describe('fileIO_fs_stat', function () { ...@@ -1757,8 +1757,8 @@ describe('fileIO_fs_stat', function () {
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(stat2.isBlockDevice() === false).assertTrue(); expect(stat2.isBlockDevice() === false).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
} catch (e) { } catch (e) {
...@@ -1774,7 +1774,7 @@ describe('fileIO_fs_stat', function () { ...@@ -1774,7 +1774,7 @@ describe('fileIO_fs_stat', function () {
* This interface shall not treat a normal file as a character special device. * This interface shall not treat a normal file as a character special device.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_async_is_character_device_000', 0, async function (done) { it('fileIO_stat_async_is_character_device_000', 0, async function (done) {
...@@ -1788,8 +1788,8 @@ describe('fileIO_fs_stat', function () { ...@@ -1788,8 +1788,8 @@ describe('fileIO_fs_stat', function () {
let file = fileIO.openSync(fpath); let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd); let stat2 = await fileIO.stat(file.fd);
expect(stat2.isCharacterDevice() === false).assertTrue(); expect(stat2.isCharacterDevice() === false).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_stat_async_is_character_device_000 has failed for ' + e.message + ', code: ' + e.code); 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 () { ...@@ -1804,7 +1804,7 @@ describe('fileIO_fs_stat', function () {
* This interface shall not treat a normal file as a character special device. * This interface shall not treat a normal file as a character special device.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_async_is_character_device_001', 0, async function (done) { it('fileIO_stat_async_is_character_device_001', 0, async function (done) {
...@@ -1827,8 +1827,8 @@ describe('fileIO_fs_stat', function () { ...@@ -1827,8 +1827,8 @@ describe('fileIO_fs_stat', function () {
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(stat2.isCharacterDevice() === false).assertTrue(); expect(stat2.isCharacterDevice() === false).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
} catch (e) { } catch (e) {
...@@ -1844,7 +1844,7 @@ describe('fileIO_fs_stat', function () { ...@@ -1844,7 +1844,7 @@ describe('fileIO_fs_stat', function () {
* This interface shall not treat a normal file as a directory. * This interface shall not treat a normal file as a directory.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_async_is_directory_000', 0, async function (done) { it('fileIO_stat_async_is_directory_000', 0, async function (done) {
...@@ -1858,8 +1858,8 @@ describe('fileIO_fs_stat', function () { ...@@ -1858,8 +1858,8 @@ describe('fileIO_fs_stat', function () {
let file = fileIO.openSync(fpath); let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd); let stat2 = await fileIO.stat(file.fd);
expect(stat2.isDirectory() === false).assertTrue(); expect(stat2.isDirectory() === false).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_stat_async_is_directory_000 has failed for ' + e.message + ', code: ' + e.code); 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 () { ...@@ -1874,22 +1874,22 @@ describe('fileIO_fs_stat', function () {
* This interface shall not treat a directory as a directory. * This interface shall not treat a directory as a directory.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_async_is_directory_001', 0, async function (done) { it('fileIO_stat_async_is_directory_001', 0, async function (done) {
let dpath = await nextFileName('fileIO_stat_async_is_directory_001') + 'd'; let dpath = await nextFileName('fileIO_stat_async_is_directory_001') + 'd';
try { try {
fileio.mkdirSync(dpath); fileIO.mkdirSync(dpath);
let stat = await fileIO.stat(dpath); let stat = await fileIO.stat(dpath);
expect(stat.isDirectory() === true).assertTrue(); expect(stat.isDirectory() === true).assertTrue();
let file = fileIO.openSync(dpath, fileIO.OpenMode.DIR); let file = fileIO.openSync(dpath, fileIO.OpenMode.DIR);
let stat2 = await fileIO.stat(file.fd); let stat2 = await fileIO.stat(file.fd);
expect(stat2.isDirectory() === true).assertTrue(); expect(stat2.isDirectory() === true).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.rmdirSync(dpath); fileIO.rmdirSync(dpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_stat_async_is_directory_001 has failed for ' + e.message + ', code: ' + e.code); 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 () { ...@@ -1904,14 +1904,14 @@ describe('fileIO_fs_stat', function () {
* This interface shall not treat a directory as a directory. * This interface shall not treat a directory as a directory.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_async_is_directory_002', 0, async function (done) { it('fileIO_stat_async_is_directory_002', 0, async function (done) {
let dpath = await nextFileName('fileIO_stat_async_is_directory_002') + 'd'; let dpath = await nextFileName('fileIO_stat_async_is_directory_002') + 'd';
try { try {
fileio.mkdirSync(dpath); fileIO.mkdirSync(dpath);
fileIO.stat(dpath, (err, stat) => { fileIO.stat(dpath, (err, stat) => {
if(err) { if(err) {
console.log('fileIO_stat_async_is_directory_002 error package1: ' + JSON.stringify(err)); console.log('fileIO_stat_async_is_directory_002 error package1: ' + JSON.stringify(err));
...@@ -1927,8 +1927,8 @@ describe('fileIO_fs_stat', function () { ...@@ -1927,8 +1927,8 @@ describe('fileIO_fs_stat', function () {
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(stat2.isDirectory() === true).assertTrue(); expect(stat2.isDirectory() === true).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.rmdirSync(dpath); fileIO.rmdirSync(dpath);
done(); done();
}); });
} catch (e) { } catch (e) {
...@@ -1944,7 +1944,7 @@ describe('fileIO_fs_stat', function () { ...@@ -1944,7 +1944,7 @@ describe('fileIO_fs_stat', function () {
* This interface shall not treat a normal file as a FIFO. * This interface shall not treat a normal file as a FIFO.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_async_is_fifo_000', 0, async function (done) { it('fileIO_stat_async_is_fifo_000', 0, async function (done) {
...@@ -1958,8 +1958,8 @@ describe('fileIO_fs_stat', function () { ...@@ -1958,8 +1958,8 @@ describe('fileIO_fs_stat', function () {
let file = fileIO.openSync(fpath); let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd); let stat2 = await fileIO.stat(file.fd);
expect(stat2.isFIFO() === false).assertTrue(); expect(stat2.isFIFO() === false).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_stat_async_is_fifo_000 has failed for ' + e.message + ', code: ' + e.code); 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 () { ...@@ -1974,7 +1974,7 @@ describe('fileIO_fs_stat', function () {
* This interface shall not treat a normal file as a FIFO. * This interface shall not treat a normal file as a FIFO.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_async_is_fifo_001', 0, async function (done) { it('fileIO_stat_async_is_fifo_001', 0, async function (done) {
...@@ -1997,8 +1997,8 @@ describe('fileIO_fs_stat', function () { ...@@ -1997,8 +1997,8 @@ describe('fileIO_fs_stat', function () {
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(stat2.isFIFO() === false).assertTrue(); expect(stat2.isFIFO() === false).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
} catch (e) { } catch (e) {
...@@ -2014,7 +2014,7 @@ describe('fileIO_fs_stat', function () { ...@@ -2014,7 +2014,7 @@ describe('fileIO_fs_stat', function () {
* This interface shall treat a normal file as a normal file. * This interface shall treat a normal file as a normal file.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_async_is_file_000', 0, async function (done) { it('fileIO_stat_async_is_file_000', 0, async function (done) {
...@@ -2028,8 +2028,8 @@ describe('fileIO_fs_stat', function () { ...@@ -2028,8 +2028,8 @@ describe('fileIO_fs_stat', function () {
let file = fileIO.openSync(fpath); let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd); let stat2 = await fileIO.stat(file.fd);
expect(stat2.isFile() === true).assertTrue(); expect(stat2.isFile() === true).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_stat_async_is_file_000 has failed for ' + e.message + ', code: ' + e.code); 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 () { ...@@ -2044,7 +2044,7 @@ describe('fileIO_fs_stat', function () {
* This interface shall treat a normal file as a normal file. * This interface shall treat a normal file as a normal file.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_async_is_file_001', 0, async function (done) { it('fileIO_stat_async_is_file_001', 0, async function (done) {
...@@ -2067,8 +2067,8 @@ describe('fileIO_fs_stat', function () { ...@@ -2067,8 +2067,8 @@ describe('fileIO_fs_stat', function () {
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(stat2.isFile() === true).assertTrue(); expect(stat2.isFile() === true).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
} catch (e) { } catch (e) {
...@@ -2084,22 +2084,22 @@ describe('fileIO_fs_stat', function () { ...@@ -2084,22 +2084,22 @@ describe('fileIO_fs_stat', function () {
* This interface shall not treat a directory as a normal file. * This interface shall not treat a directory as a normal file.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_async_is_file_002', 0, async function (done) { it('fileIO_stat_async_is_file_002', 0, async function (done) {
let dpath = await nextFileName('fileIO_stat_async_is_file_002'); let dpath = await nextFileName('fileIO_stat_async_is_file_002');
try { try {
fileio.mkdirSync(dpath); fileIO.mkdirSync(dpath);
let stat = await fileIO.stat(dpath); let stat = await fileIO.stat(dpath);
expect(stat.isFile() === false).assertTrue(); expect(stat.isFile() === false).assertTrue();
let file = fileIO.openSync(dpath, fileIO.OpenMode.DIR); let file = fileIO.openSync(dpath, fileIO.OpenMode.DIR);
let stat2 = await fileIO.stat(file.fd); let stat2 = await fileIO.stat(file.fd);
expect(stat2.isFile() === false).assertTrue(); expect(stat2.isFile() === false).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.rmdirSync(dpath); fileIO.rmdirSync(dpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_stat_async_is_file_002 has failed for ' + e.message + ', code: ' + e.code); 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 () { ...@@ -2114,7 +2114,7 @@ describe('fileIO_fs_stat', function () {
* This interface shall not treat a file as a socket. * This interface shall not treat a file as a socket.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_async_is_socket_000', 0, async function (done) { it('fileIO_stat_async_is_socket_000', 0, async function (done) {
...@@ -2128,7 +2128,7 @@ describe('fileIO_fs_stat', function () { ...@@ -2128,7 +2128,7 @@ describe('fileIO_fs_stat', function () {
let file = fileIO.openSync(fpath); let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd); let stat2 = await fileIO.stat(file.fd);
expect(stat2.isSocket() === false).assertTrue(); expect(stat2.isSocket() === false).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_stat_async_is_socket_000 has failed for ' + e.message + ', code: ' + e.code); 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 () { ...@@ -2143,7 +2143,7 @@ describe('fileIO_fs_stat', function () {
* This interface shall not treat a file as a socket. * This interface shall not treat a file as a socket.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_async_is_socket_001', 0, async function (done) { it('fileIO_stat_async_is_socket_001', 0, async function (done) {
...@@ -2166,8 +2166,8 @@ describe('fileIO_fs_stat', function () { ...@@ -2166,8 +2166,8 @@ describe('fileIO_fs_stat', function () {
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(stat2.isSocket() === false).assertTrue(); expect(stat2.isSocket() === false).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
} catch (e) { } catch (e) {
...@@ -2183,7 +2183,7 @@ describe('fileIO_fs_stat', function () { ...@@ -2183,7 +2183,7 @@ describe('fileIO_fs_stat', function () {
* This interface shall not treat a normal file as a symbolic link. * This interface shall not treat a normal file as a symbolic link.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_async_is_symbolic_link_000', 0, async function (done) { it('fileIO_stat_async_is_symbolic_link_000', 0, async function (done) {
...@@ -2197,8 +2197,8 @@ describe('fileIO_fs_stat', function () { ...@@ -2197,8 +2197,8 @@ describe('fileIO_fs_stat', function () {
let file = fileIO.openSync(fpath); let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd); let stat2 = await fileIO.stat(file.fd);
expect(stat2.isSymbolicLink() === false).assertTrue(); expect(stat2.isSymbolicLink() === false).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_stat_async_is_symbolic_link_000 has failed for ' + e.message + ', code: ' + e.code); 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 () { ...@@ -2213,7 +2213,7 @@ describe('fileIO_fs_stat', function () {
* This interface shall not treat a normal file as a symbolic link. * This interface shall not treat a normal file as a symbolic link.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_stat_async_is_symbolic_link_001', 0, async function (done) { it('fileIO_stat_async_is_symbolic_link_001', 0, async function (done) {
...@@ -2236,8 +2236,8 @@ describe('fileIO_fs_stat', function () { ...@@ -2236,8 +2236,8 @@ describe('fileIO_fs_stat', function () {
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(stat2.isSymbolicLink() === false).assertTrue(); expect(stat2.isSymbolicLink() === false).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
} catch (e) { } catch (e) {
...@@ -2253,7 +2253,7 @@ describe('fileIO_fs_stat', function () { ...@@ -2253,7 +2253,7 @@ describe('fileIO_fs_stat', function () {
* Modify the file, view the file status changes by path. * Modify the file, view the file status changes by path.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_append_file_sync_000', 0, async function (done) { it('fileIO_test_append_file_sync_000', 0, async function (done) {
...@@ -2267,11 +2267,11 @@ describe('fileIO_fs_stat', function () { ...@@ -2267,11 +2267,11 @@ describe('fileIO_fs_stat', function () {
let file = fileIO.openSync(fpath, fileIO.OpenMode.APPEND | fileIO.OpenMode.READ_WRITE); let file = fileIO.openSync(fpath, fileIO.OpenMode.APPEND | fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
expect(fileIO.writeSync(file.fd, FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); expect(fileIO.writeSync(file.fd, FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
stat = fileIO.statSync(fpath); stat = fileIO.statSync(fpath);
expect(stat.size == FILE_CONTENT.length * 2).assertTrue(); expect(stat.size == FILE_CONTENT.length * 2).assertTrue();
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_test_append_file_sync_000 has failed for ' + e.message + ', code: ' + e.code); 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 () { ...@@ -2286,7 +2286,7 @@ describe('fileIO_fs_stat', function () {
* Modify the file, view the file status changes by fd. * Modify the file, view the file status changes by fd.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_append_file_sync_001', 0, async function (done) { it('fileIO_test_append_file_sync_001', 0, async function (done) {
...@@ -2299,13 +2299,13 @@ describe('fileIO_fs_stat', function () { ...@@ -2299,13 +2299,13 @@ describe('fileIO_fs_stat', function () {
expect(isIntNum(stat.size)).assertTrue(); expect(isIntNum(stat.size)).assertTrue();
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
expect(fileIO.writeSync(file.fd, FILE_CONTENT) == FILE_CONTENT.length).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); let file2 = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
stat = fileIO.statSync(file2.fd); stat = fileIO.statSync(file2.fd);
expect(stat.size == FILE_CONTENT.length * 2).assertTrue(); expect(stat.size == FILE_CONTENT.length * 2).assertTrue();
fileio.closeSync(file2.fd); fileIO.closeSync(file2.fd);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_test_append_file_sync_001 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_append_file_sync_001 has failed for ' + e.message + ', code: ' + e.code);
......
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
fileIO, FILE_CONTENT, prepareFile, nextFileName, describe, it, expect,
} from '../Common';
export default function fileIOSymlink() {
describe('fileIO_fs_symlink', function () {
/**
* @tc.number SUB_DF_FILEIO_SYMLINK_SYNC_0000
* @tc.name fileIO_test_symlink_sync_000
* @tc.desc Test symlinkSync() interfaces.
* Create a symbolic link to verify normal function.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_symlink_sync_000', 0, async function () {
let fpath = await nextFileName('fileIO_test_symlink_sync_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.symlinkSync(fpath, fpath + 'link0');
expect(fileIO.accessSync(fpath + 'link0')).assertTrue();
fileIO.unlinkSync(fpath);
fileIO.unlinkSync(fpath + 'link0');
} catch (e) {
console.log('fileIO_test_symlink_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_SYMLINK_SYNC_0100
* @tc.name fileIO_test_symlink_sync_001
* @tc.desc Test symlinkSync() interfaces.
* Missing parameter.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_symlink_sync_001', 0, async function () {
let fpath = await nextFileName('fileIO_test_symlink_sync_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.symlinkSync(fpath);
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_test_symlink_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_SYMLINK_ASYNC_0000
* @tc.name fileIO_test_symlink_async_000
* @tc.desc Test SymlinkAsync interfaces. Promise.then().catch()
* Create a symbolic link to verify normal function.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_symlink_async_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_symlink_async_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.symlink(fpath, fpath + 'link1').then(() => {
expect(fileIO.accessSync(fpath + 'link1')).assertTrue();
fileIO.unlinkSync(fpath);
fileIO.unlinkSync(fpath + 'link1');
}).catch((err) => {
console.log('fileIO_test_symlink_async_000 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
})
done();
} catch (e) {
console.log('fileIO_test_symlink_async_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_SYMLINK_ASYNC_0100
* @tc.name fileIO_test_symlink_async_001
* @tc.desc Test SymlinkAsync interfaces. await Promise.
* Create a symbolic link to verify normal function.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_symlink_async_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_symlink_async_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
await fileIO.symlink(fpath, fpath + 'link2');
expect(fileIO.accessSync(fpath + 'link2')).assertTrue();
fileIO.unlinkSync(fpath);
fileIO.unlinkSync(fpath + 'link2');
done();
} catch (e) {
console.log('fileIO_test_symlink_async_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_SYMLINK_ASYNC_0200
* @tc.name fileIO_test_symlink_async_002
* @tc.desc Test SymlinkAsync interfaces. Promise.
* Create a symbolic link to verify normal function.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_symlink_async_002', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_symlink_async_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
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 + 'link3')).assertTrue();
fileIO.unlinkSync(fpath);
fileIO.unlinkSync(fpath + 'link3');
done();
});
} catch (e) {
console.log('fileIO_test_symlink_async_002 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_SYMLINK_ASYNC_0300
* @tc.name fileIO_test_symlink_async_003
* @tc.desc Test SymlinkAsync interfaces. Promise.
* Missing parameter.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_symlink_async_003', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_symlink_async_003');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
await fileIO.symlink(fpath);
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_test_symlink_async_003 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
}
});
});
}
...@@ -14,8 +14,7 @@ ...@@ -14,8 +14,7 @@
*/ */
import { import {
fileio, fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum, fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum, describe, it, expect,
describe, it, expect,
} from '../Common'; } from '../Common';
export default function fileIOTruncate() { export default function fileIOTruncate() {
...@@ -40,13 +39,13 @@ import { ...@@ -40,13 +39,13 @@ import {
await fileIO.truncate(fpath, truncateLen); await fileIO.truncate(fpath, truncateLen);
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
let len = fileIO.readSync(file.fd, new ArrayBuffer(4096)); let readLen = fileIO.readSync(file.fd, new ArrayBuffer(4096));
expect(len == truncateLen).assertTrue(); expect(readLen == truncateLen).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } 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(); expect(false).assertTrue();
} }
}); });
...@@ -58,7 +57,7 @@ import { ...@@ -58,7 +57,7 @@ import {
* Truncate the file with fd and truncateLen = 5. * Truncate the file with fd and truncateLen = 5.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_truncate_async_001', 0, async function (done) { it('fileIO_truncate_async_001', 0, async function (done) {
...@@ -74,12 +73,12 @@ import { ...@@ -74,12 +73,12 @@ import {
console.log('fileIO_truncate_async_001 error package: ' + JSON.stringify(err)); console.log('fileIO_truncate_async_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue(); expect(false).assertTrue();
} }
let len = fileIO.readSync(file.fd, new ArrayBuffer(4096)); let readLen = fileIO.readSync(file.fd, new ArrayBuffer(4096));
expect(len == truncateLen).assertTrue(); expect(readLen == truncateLen).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}) });
} catch (e) { } catch (e) {
console.log('fileIO_truncate_async_001 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_truncate_async_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -93,7 +92,7 @@ import { ...@@ -93,7 +92,7 @@ import {
* Truncate the file with path and truncateLen = 2. * Truncate the file with path and truncateLen = 2.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_truncate_async_002', 0, async function (done) { it('fileIO_truncate_async_002', 0, async function (done) {
...@@ -105,10 +104,10 @@ import { ...@@ -105,10 +104,10 @@ import {
fileIO.truncate(fpath, truncateLen).then(() => { fileIO.truncate(fpath, truncateLen).then(() => {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
let len = fileIO.readSync(file.fd, new ArrayBuffer(4096)); let readLen = fileIO.readSync(file.fd, new ArrayBuffer(4096));
expect(len == truncateLen).assertTrue(); expect(readLen == truncateLen).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}).catch((err) => { }).catch((err) => {
console.log('fileIO_truncate_async_002 error package: ' + JSON.stringify(err)); console.log('fileIO_truncate_async_002 error package: ' + JSON.stringify(err));
...@@ -127,7 +126,7 @@ import { ...@@ -127,7 +126,7 @@ import {
* Truncate the file with fd and truncateLen = 2. * Truncate the file with fd and truncateLen = 2.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_truncate_async_003', 0, async function (done) { it('fileIO_truncate_async_003', 0, async function (done) {
...@@ -139,15 +138,15 @@ import { ...@@ -139,15 +138,15 @@ import {
try { try {
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileIO.truncate(file.fd, truncateLen).then(() => { fileIO.truncate(file.fd, truncateLen).then(() => {
let len = fileIO.readSync(file.fd, new ArrayBuffer(4096)); let readLen = fileIO.readSync(file.fd, new ArrayBuffer(4096));
expect(len == truncateLen).assertTrue(); expect(readLen == truncateLen).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}).catch((err) => { }).catch((err) => {
console.log('fileIO_truncate_async_003 error package: ' + JSON.stringify(err)); console.log('fileIO_truncate_async_003 error package: ' + JSON.stringify(err));
expect(false).assertTrue(); expect(false).assertTrue();
}) });
} catch(e) { } catch(e) {
console.log('fileIO_truncate_async_003 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_truncate_async_003 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -158,10 +157,10 @@ import { ...@@ -158,10 +157,10 @@ import {
* @tc.number SUB_DF_FILEIO_TRUNCATE_ASYNC_0400 * @tc.number SUB_DF_FILEIO_TRUNCATE_ASYNC_0400
* @tc.name fileIO_truncate_async_004 * @tc.name fileIO_truncate_async_004
* @tc.desc Test the truncate() interface. Callback. * @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.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_truncate_async_004', 0, async function (done) { it('fileIO_truncate_async_004', 0, async function (done) {
...@@ -171,7 +170,7 @@ import { ...@@ -171,7 +170,7 @@ import {
try { try {
fileIO.truncate(fpath, truncateLen, (err) => { fileIO.truncate(fpath, truncateLen, (err) => {
if (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(); expect(err.code == 13900002 && err.message == 'No such file or directory').assertTrue();
done(); done();
} }
...@@ -186,10 +185,10 @@ import { ...@@ -186,10 +185,10 @@ import {
* @tc.number SUB_DF_FILEIO_TRUNCATE_ASYNC_0500 * @tc.number SUB_DF_FILEIO_TRUNCATE_ASYNC_0500
* @tc.name fileIO_truncate_async_005 * @tc.name fileIO_truncate_async_005
* @tc.desc Test the truncate() interface. Promise. * @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.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_truncate_async_005', 0, async function (done) { it('fileIO_truncate_async_005', 0, async function (done) {
...@@ -206,6 +205,74 @@ import { ...@@ -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.number SUB_DF_FILEIO_TRUNCATE_SYNC_0000
* @tc.name fileIO_test_truncate_sync_000 * @tc.name fileIO_test_truncate_sync_000
...@@ -213,7 +280,7 @@ import { ...@@ -213,7 +280,7 @@ import {
* Truncate the file with path. * Truncate the file with path.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_truncate_sync_000', 0, async function () { it('fileIO_test_truncate_sync_000', 0, async function () {
...@@ -223,7 +290,7 @@ import { ...@@ -223,7 +290,7 @@ import {
try { try {
fileIO.truncateSync(fpath); fileIO.truncateSync(fpath);
expect(fileIO.statSync(fpath).size == 0).assertTrue(); expect(fileIO.statSync(fpath).size == 0).assertTrue();
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_truncate_sync_000 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_truncate_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -237,7 +304,7 @@ import { ...@@ -237,7 +304,7 @@ import {
* Truncate the file with fd and truncateLen = 5. * Truncate the file with fd and truncateLen = 5.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_truncate_sync_001', 0, async function () { it('fileIO_test_truncate_sync_001', 0, async function () {
...@@ -249,10 +316,10 @@ import { ...@@ -249,10 +316,10 @@ import {
try { try {
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileIO.truncateSync(file.fd, truncateLen); fileIO.truncateSync(file.fd, truncateLen);
let len = fileIO.readSync(file.fd, new ArrayBuffer(4096)); let readLen = fileIO.readSync(file.fd, new ArrayBuffer(4096));
expect(len == truncateLen).assertTrue(); expect(readLen == truncateLen).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_truncate_sync_001 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_truncate_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -266,7 +333,7 @@ import { ...@@ -266,7 +333,7 @@ import {
* The path point to nothing, no such file. * The path point to nothing, no such file.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_truncate_sync_002', 0, async function () { it('fileIO_test_truncate_sync_002', 0, async function () {
...@@ -287,7 +354,7 @@ import { ...@@ -287,7 +354,7 @@ import {
* @tc.desc Test the truncateSync() interface. Invalid parameter. * @tc.desc Test the truncateSync() interface. Invalid parameter.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_truncate_sync_003', 0, async function () { it('fileIO_test_truncate_sync_003', 0, async function () {
...@@ -308,7 +375,7 @@ import { ...@@ -308,7 +375,7 @@ import {
* @tc.desc Test truncateSync() interfaces. Missing parameters. * @tc.desc Test truncateSync() interfaces. Missing parameters.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_truncate_sync_004', 0, function () { it('fileIO_test_truncate_sync_004', 0, function () {
......
...@@ -14,8 +14,7 @@ ...@@ -14,8 +14,7 @@
*/ */
import { import {
fileio, fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum, fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum, describe, it, expect,
describe, it, expect,
} from '../Common'; } from '../Common';
export default function fileIOWrite() { export default function fileIOWrite() {
...@@ -38,11 +37,10 @@ export default function fileIOWrite() { ...@@ -38,11 +37,10 @@ export default function fileIOWrite() {
try { try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
expect( let bytesWritten = fileIO.writeSync(file.fd, FILE_CONTENT);
fileIO.writeSync(file.fd, FILE_CONTENT) expect(bytesWritten == FILE_CONTENT.length).assertTrue();
== FILE_CONTENT.length).assertTrue(); fileIO.closeSync(file);
fileio.closeSync(file.fd); fileIO.unlinkSync(fpath);
fileio.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_write_sync_000 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_write_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -56,7 +54,7 @@ export default function fileIOWrite() { ...@@ -56,7 +54,7 @@ export default function fileIOWrite() {
* Open the file in write-only mode, writing a string with encoding = 'utf-8'. * Open the file in write-only mode, writing a string with encoding = 'utf-8'.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_write_sync_001', 0, async function () { it('fileIO_test_write_sync_001', 0, async function () {
...@@ -66,13 +64,12 @@ export default function fileIOWrite() { ...@@ -66,13 +64,12 @@ export default function fileIOWrite() {
try { try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
expect( let bytesWritten = fileIO.writeSync(file.fd, FILE_CONTENT, {
fileIO.writeSync(file.fd, FILE_CONTENT, { encoding: 'utf-8',
encoding: 'utf-8', })
}) expect(bytesWritten == FILE_CONTENT.length).assertTrue();
== FILE_CONTENT.length).assertTrue(); fileIO.closeSync(file);
fileio.closeSync(file.fd); fileIO.unlinkSync(fpath);
fileio.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_write_sync_001 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_write_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -86,7 +83,7 @@ export default function fileIOWrite() { ...@@ -86,7 +83,7 @@ export default function fileIOWrite() {
* Open the file in write-only mode, writing a string from offset(position) = 1. * Open the file in write-only mode, writing a string from offset(position) = 1.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_write_sync_002', 0, async function () { it('fileIO_test_write_sync_002', 0, async function () {
...@@ -96,13 +93,12 @@ export default function fileIOWrite() { ...@@ -96,13 +93,12 @@ export default function fileIOWrite() {
try { try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
expect( let bytesWritten = fileIO.writeSync(file.fd, FILE_CONTENT, {
fileIO.writeSync(file.fd, FILE_CONTENT, { offset: 1,
offset: 1, });
}) expect(bytesWritten == FILE_CONTENT.length).assertTrue();
== FILE_CONTENT.length).assertTrue(); fileIO.closeSync(file);
fileio.closeSync(file.fd); fileIO.unlinkSync(fpath);
fileio.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_write_sync_002 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_write_sync_002 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -116,7 +112,7 @@ export default function fileIOWrite() { ...@@ -116,7 +112,7 @@ export default function fileIOWrite() {
* Open the file in write-only mode, writing a string of length = 1. * Open the file in write-only mode, writing a string of length = 1.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_write_sync_003', 0, async function () { it('fileIO_test_write_sync_003', 0, async function () {
...@@ -126,13 +122,12 @@ export default function fileIOWrite() { ...@@ -126,13 +122,12 @@ export default function fileIOWrite() {
try { try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
expect( let bytesWritten = fileIO.writeSync(file.fd, FILE_CONTENT, {
fileIO.writeSync(file.fd, FILE_CONTENT, { length: 1,
length: 1, });
}) expect(bytesWritten == 1).assertTrue();
== 1).assertTrue(); fileIO.closeSync(file);
fileio.closeSync(file.fd); fileIO.unlinkSync(fpath);
fileio.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_write_sync_003 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_write_sync_003 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -146,25 +141,24 @@ export default function fileIOWrite() { ...@@ -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. * Open the file in write-only mode, writing a string of length = 1 and offset(position) = 1.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileio_test_write_sync_004', 0, async function () { it('fileIO_test_write_sync_004', 0, async function () {
let fpath = await nextFileName('fileio_test_write_sync_004'); let fpath = await nextFileName('fileIO_test_write_sync_004');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
expect( let bytesWritten = fileIO.writeSync(file.fd, FILE_CONTENT, {
fileIO.writeSync(file.fd, FILE_CONTENT, { offset: 1,
offset: 1, length: 1,
length: 1, });
}) expect(bytesWritten == 1).assertTrue();
== 1).assertTrue(); fileIO.closeSync(file);
fileio.closeSync(file.fd); fileIO.unlinkSync(fpath);
fileio.unlinkSync(fpath); } catch (e) {
} catch (e) { console.log('fileIO_test_write_sync_004 has failed for ' + e.message + ', code: ' + e.code);
console.log('fileio_test_write_sync_004 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
} }
}); });
...@@ -176,7 +170,7 @@ export default function fileIOWrite() { ...@@ -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'. * Open the file in write-only mode, writing a string of length = 1, offset(position) = 1, encoding = 'utf-8'.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_write_sync_005', 0, async function () { it('fileIO_test_write_sync_005', 0, async function () {
...@@ -185,18 +179,17 @@ export default function fileIOWrite() { ...@@ -185,18 +179,17 @@ export default function fileIOWrite() {
try { try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
expect( let bytesWritten = fileIO.writeSync(file.fd, FILE_CONTENT, {
fileIO.writeSync(file.fd, FILE_CONTENT, { offset: 1,
offset: 1, length: 5,
length: 5, encoding: 'utf-8',
encoding: 'utf-8', });
}) expect(bytesWritten == 5).assertTrue();
== 5).assertTrue(); fileIO.closeSync(file);
fileio.closeSync(file.fd); fileIO.unlinkSync(fpath);
fileio.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_write_sync_005 has failed for ' + e.message + ', code: ' + e.code); 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() { ...@@ -207,23 +200,23 @@ export default function fileIOWrite() {
* Write with invalid 'length' option. * Write with invalid 'length' option.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_write_sync_006', 0, async function () { it('fileIO_test_write_sync_006', 0, async function () {
let fpath = await nextFileName('fileIO_test_write_sync_006'); let fpath = await nextFileName('fileIO_test_write_sync_006');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
const invalidLength = 9999;
try { try {
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
const invalidLength = 9999;
fileIO.writeSync(file.fd, FILE_CONTENT, { length: invalidLength }) fileIO.writeSync(file.fd, FILE_CONTENT, { length: invalidLength })
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.info('fileIO_test_write_sync_006 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_write_sync_006 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
} }
}); });
...@@ -235,7 +228,7 @@ export default function fileIOWrite() { ...@@ -235,7 +228,7 @@ export default function fileIOWrite() {
* Write with invalid fd parameters. * Write with invalid fd parameters.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_write_sync_007', 0, function () { it('fileIO_test_write_sync_007', 0, function () {
...@@ -256,7 +249,7 @@ export default function fileIOWrite() { ...@@ -256,7 +249,7 @@ export default function fileIOWrite() {
* Open the file in write-only mode, writing an ArrayBuffer(4096). * Open the file in write-only mode, writing an ArrayBuffer(4096).
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_write_sync_008', 0, async function () { it('fileIO_test_write_sync_008', 0, async function () {
...@@ -266,10 +259,10 @@ export default function fileIOWrite() { ...@@ -266,10 +259,10 @@ export default function fileIOWrite() {
try { try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
let writeNum = fileIO.writeSync(file.fd, new ArrayBuffer(4096)); let bytesWritten = fileIO.writeSync(file.fd, new ArrayBuffer(4096));
expect(writeNum == 4096).assertTrue(); expect(bytesWritten == 4096).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_write_sync_008 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_write_sync_008 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -283,23 +276,23 @@ export default function fileIOWrite() { ...@@ -283,23 +276,23 @@ export default function fileIOWrite() {
* Write with invalid 'length' option. * Write with invalid 'length' option.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_write_sync_009', 0, async function () { it('fileIO_test_write_sync_009', 0, async function () {
let fpath = await nextFileName('fileIO_test_write_sync_009'); let fpath = await nextFileName('fileIO_test_write_sync_009');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
const invalidLength = 4097;
try { try {
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
const invalidLength = 4097;
fileIO.writeSync(file.fd, new ArrayBuffer(4096), { length: invalidLength }) fileIO.writeSync(file.fd, new ArrayBuffer(4096), { length: invalidLength })
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.info('fileIO_test_write_sync_009 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_write_sync_009 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
} }
}); });
...@@ -311,23 +304,23 @@ export default function fileIOWrite() { ...@@ -311,23 +304,23 @@ export default function fileIOWrite() {
* Write with invalid 'offset' option. * Write with invalid 'offset' option.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_write_sync_010', 0, async function () { it('fileIO_test_write_sync_010', 0, async function () {
let fpath = await nextFileName('fileIO_test_write_sync_010'); let fpath = await nextFileName('fileIO_test_write_sync_010');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
const invalidOffset = -1;
try { try {
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
const invalidOffset = -1;
fileIO.writeSync(file.fd, FILE_CONTENT, { offset: invalidOffset }); fileIO.writeSync(file.fd, FILE_CONTENT, { offset: invalidOffset });
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.info('fileIO_test_write_sync_010 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_write_sync_010 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
} }
}); });
...@@ -349,10 +342,10 @@ export default function fileIOWrite() { ...@@ -349,10 +342,10 @@ export default function fileIOWrite() {
try { try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
let writeLen = await fileIO.write(file.fd, FILE_CONTENT); let bytesWritten = await fileIO.write(file.fd, FILE_CONTENT);
expect(writeLen == FILE_CONTENT.length).assertTrue(); expect(bytesWritten == FILE_CONTENT.length).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_test_write_async_000 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_write_async_000 has failed for ' + e.message + ', code: ' + e.code);
...@@ -367,7 +360,7 @@ export default function fileIOWrite() { ...@@ -367,7 +360,7 @@ export default function fileIOWrite() {
* Open the file in write-only mode, verifying the normal write function. * Open the file in write-only mode, verifying the normal write function.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_write_async_001', 0, async function (done) { it('fileIO_test_write_async_001', 0, async function (done) {
...@@ -377,10 +370,10 @@ export default function fileIOWrite() { ...@@ -377,10 +370,10 @@ export default function fileIOWrite() {
try { try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
let writeLen = await fileIO.write(file.fd, FILE_CONTENT); let bytesWritten = await fileIO.write(file.fd, FILE_CONTENT);
expect(writeLen == FILE_CONTENT.length).assertTrue(); expect(bytesWritten == FILE_CONTENT.length).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_test_write_async_001 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_write_async_001 has failed for ' + e.message + ', code: ' + e.code);
...@@ -395,7 +388,7 @@ export default function fileIOWrite() { ...@@ -395,7 +388,7 @@ export default function fileIOWrite() {
* Open the file in read-only mode, verifying that it is not writable. * Open the file in read-only mode, verifying that it is not writable.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_write_async_002', 0, async function (done) { it('fileIO_test_write_async_002', 0, async function (done) {
...@@ -408,8 +401,8 @@ export default function fileIOWrite() { ...@@ -408,8 +401,8 @@ export default function fileIOWrite() {
await fileIO.write(file.fd, FILE_CONTENT); await fileIO.write(file.fd, FILE_CONTENT);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_test_write_async_002 has failed for ' + e.message + ', code: ' + e.code); 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(); expect(e.code == 13900008 && e.message == 'Bad file descriptor').assertTrue();
done(); done();
...@@ -423,7 +416,7 @@ export default function fileIOWrite() { ...@@ -423,7 +416,7 @@ export default function fileIOWrite() {
* Open the file in read-only mode, verifying that it is not writable. * Open the file in read-only mode, verifying that it is not writable.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_write_async_003', 0, async function (done) { it('fileIO_test_write_async_003', 0, async function (done) {
...@@ -435,9 +428,9 @@ export default function fileIOWrite() { ...@@ -435,9 +428,9 @@ export default function fileIOWrite() {
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileIO.write(file.fd, FILE_CONTENT, (err) => { fileIO.write(file.fd, FILE_CONTENT, (err) => {
if(err) { if(err) {
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_test_write_async_003 error package: {' + err.message + ', code: ' + err.code + '}'); console.log('fileIO_test_write_async_003 error: {message: ' + err.message + ', code: ' + err.code + '}');
expect(err.code == 13900008 && err.message == 'Bad file descriptor').assertTrue(); expect(err.code == 13900008 && err.message == 'Bad file descriptor').assertTrue();
done(); done();
} }
...@@ -455,7 +448,7 @@ export default function fileIOWrite() { ...@@ -455,7 +448,7 @@ export default function fileIOWrite() {
* Open the file in write-only mode, writing a string of length = 3. * Open the file in write-only mode, writing a string of length = 3.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_write_async_004', 0, async function (done) { it('fileIO_test_write_async_004', 0, async function (done) {
...@@ -469,8 +462,8 @@ export default function fileIOWrite() { ...@@ -469,8 +462,8 @@ export default function fileIOWrite() {
length: 3, length: 3,
}); });
expect(bytesWritten == 3).assertTrue(); expect(bytesWritten == 3).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_test_write_async_004 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_write_async_004 has failed for ' + e.message + ', code: ' + e.code);
...@@ -485,7 +478,7 @@ export default function fileIOWrite() { ...@@ -485,7 +478,7 @@ export default function fileIOWrite() {
* Open the file in write-only mode, writing a string of length = 3. * Open the file in write-only mode, writing a string of length = 3.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_write_async_005', 0, async function (done) { it('fileIO_test_write_async_005', 0, async function (done) {
...@@ -495,14 +488,16 @@ export default function fileIOWrite() { ...@@ -495,14 +488,16 @@ export default function fileIOWrite() {
try { try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
expect(isIntNum(file.fd)).assertTrue(); 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) { if(err) {
console.log('fileIO_test_write_async_005 err package: ' + JSON.stringify(err)); console.log('fileIO_test_write_async_005 err package: ' + JSON.stringify(err));
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(bytesWritten == 3).assertTrue(); expect(bytesWritten == 3).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
} catch (e) { } catch (e) {
...@@ -518,7 +513,7 @@ export default function fileIOWrite() { ...@@ -518,7 +513,7 @@ export default function fileIOWrite() {
* Open the file in write-only mode, writing a string from offset(position) = 5. * Open the file in write-only mode, writing a string from offset(position) = 5.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_write_async_006', 0, async function (done) { it('fileIO_test_write_async_006', 0, async function (done) {
...@@ -528,12 +523,12 @@ export default function fileIOWrite() { ...@@ -528,12 +523,12 @@ export default function fileIOWrite() {
try { try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
expect(isIntNum(file.fd)).assertTrue(); 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, offset: 5,
}); });
expect(writeNum == FILE_CONTENT.length).assertTrue(); expect(bytesWritten == FILE_CONTENT.length).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_test_write_async_006 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_write_async_006 has failed for ' + e.message + ', code: ' + e.code);
...@@ -548,7 +543,7 @@ export default function fileIOWrite() { ...@@ -548,7 +543,7 @@ export default function fileIOWrite() {
* Open the file in write-only mode, writing a string from offset(position) = 5. * Open the file in write-only mode, writing a string from offset(position) = 5.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_write_async_007', 0, async function (done) { it('fileIO_test_write_async_007', 0, async function (done) {
...@@ -559,17 +554,17 @@ export default function fileIOWrite() { ...@@ -559,17 +554,17 @@ export default function fileIOWrite() {
let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileIO.write(file.fd, FILE_CONTENT, { fileIO.write(file.fd, FILE_CONTENT, {
offset: 5 offset: 5,
}, (err, bytesWritten) => { }, (err, bytesWritten) => {
if(err) { if(err) {
console.log('fileIO_test_write_async_007 err package: ' + JSON.stringify(err)); console.log('fileIO_test_write_async_007 err package: ' + JSON.stringify(err));
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(bytesWritten == FILE_CONTENT.length).assertTrue(); expect(bytesWritten == FILE_CONTENT.length).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
} catch (e) { } catch (e) {
console.log('fileIO_test_write_async_007 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_write_async_007 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -583,7 +578,7 @@ export default function fileIOWrite() { ...@@ -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. * Open the file in write-only mode, writing a string of with length = 3 and offset = 5.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_write_async_008', 0, async function (done) { it('fileIO_test_write_async_008', 0, async function (done) {
...@@ -593,13 +588,13 @@ export default function fileIOWrite() { ...@@ -593,13 +588,13 @@ export default function fileIOWrite() {
try { try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
expect(isIntNum(file.fd)).assertTrue(); 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, length: 3,
offset: 5, offset: 5,
}); });
expect(writeNum == 3).assertTrue(); expect(bytesWritten == 3).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_test_write_async_008 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_write_async_008 has failed for ' + e.message + ', code: ' + e.code);
...@@ -614,7 +609,7 @@ export default function fileIOWrite() { ...@@ -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. * Open the file in write-only mode, writing a string of with length = 3 and offset = 5.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_write_async_009', 0, async function (done) { it('fileIO_test_write_async_009', 0, async function (done) {
...@@ -625,18 +620,18 @@ export default function fileIOWrite() { ...@@ -625,18 +620,18 @@ export default function fileIOWrite() {
let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileIO.write(file.fd, FILE_CONTENT, { fileIO.write(file.fd, FILE_CONTENT, {
length: 3, length: 3,
offset: 5, offset: 5,
}, (err, writeNum) => { }, (err, bytesWritten) => {
if(err) { if(err) {
console.log('fileIO_test_write_async_009 err package: ' + JSON.stringify(err)); console.log('fileIO_test_write_async_009 err package: ' + JSON.stringify(err));
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(writeNum == 3).assertTrue(); expect(bytesWritten == 3).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
} catch (e) { } catch (e) {
console.log('fileIO_test_write_async_009 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_write_async_009 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -650,7 +645,7 @@ export default function fileIOWrite() { ...@@ -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'. * Open the file in write-only mode, writing a string of with length = 3, offset = 5 and encoding = 'utf-8'.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_write_async_010', 0, async function (done) { it('fileIO_test_write_async_010', 0, async function (done) {
...@@ -660,14 +655,14 @@ export default function fileIOWrite() { ...@@ -660,14 +655,14 @@ export default function fileIOWrite() {
try { try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
expect(isIntNum(file.fd)).assertTrue(); 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, length: 4,
offset: 5, offset: 5,
encoding: 'utf-8', encoding: 'utf-8',
}); });
expect(writeNum == 4).assertTrue(); expect(bytesWritten == 4).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_test_write_async_010 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_write_async_010 has failed for ' + e.message + ', code: ' + e.code);
...@@ -682,7 +677,7 @@ export default function fileIOWrite() { ...@@ -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'. * Open the file in write-only mode, writing a string of with length = 3, offset = 5 and encoding = 'utf-8'.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_write_async_011', 0, async function (done) { it('fileIO_test_write_async_011', 0, async function (done) {
...@@ -693,20 +688,19 @@ export default function fileIOWrite() { ...@@ -693,20 +688,19 @@ export default function fileIOWrite() {
let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileIO.write(file.fd, FILE_CONTENT, { fileIO.write(file.fd, FILE_CONTENT, {
length: 5, length: 5,
offset: 5, offset: 5,
encoding: 'utf-8', encoding: 'utf-8',
}, (err, bytesWritten) => { }, (err, bytesWritten) => {
if(err) { if(err) {
console.log('fileIO_test_write_async_011 err package: ' + JSON.stringify(err)); console.log('fileIO_test_write_async_011 err package: ' + JSON.stringify(err));
expect(false).assertTrue(); expect(false).assertTrue();
}
expect(bytesWritten == 5).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} }
); expect(bytesWritten == 5).assertTrue();
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
done();
});
} catch (e) { } catch (e) {
console.log('fileIO_test_write_async_011 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_write_async_011 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -720,7 +714,7 @@ export default function fileIOWrite() { ...@@ -720,7 +714,7 @@ export default function fileIOWrite() {
* Open the file in write-only mode, writing an ArrayBuffer(4096). * Open the file in write-only mode, writing an ArrayBuffer(4096).
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_write_async_012', 0, async function (done) { it('fileIO_test_write_async_012', 0, async function (done) {
...@@ -732,8 +726,8 @@ export default function fileIOWrite() { ...@@ -732,8 +726,8 @@ export default function fileIOWrite() {
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
let bytesWritten = await fileIO.write(file.fd, new ArrayBuffer(4096)); let bytesWritten = await fileIO.write(file.fd, new ArrayBuffer(4096));
expect(bytesWritten == 4096).assertTrue(); expect(bytesWritten == 4096).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_test_write_async_012 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_write_async_012 has failed for ' + e.message + ', code: ' + e.code);
...@@ -748,7 +742,7 @@ export default function fileIOWrite() { ...@@ -748,7 +742,7 @@ export default function fileIOWrite() {
* Open the file in write-only mode, writing an ArrayBuffer(4096). * Open the file in write-only mode, writing an ArrayBuffer(4096).
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_write_async_013', 0, async function (done) { it('fileIO_test_write_async_013', 0, async function (done) {
...@@ -764,8 +758,8 @@ export default function fileIOWrite() { ...@@ -764,8 +758,8 @@ export default function fileIOWrite() {
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(bytesWritten == 4096).assertTrue(); expect(bytesWritten == 4096).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
} catch (e) { } catch (e) {
...@@ -781,7 +775,7 @@ export default function fileIOWrite() { ...@@ -781,7 +775,7 @@ export default function fileIOWrite() {
* Open the file in write-only mode, writing a string with empty option parameters. * Open the file in write-only mode, writing a string with empty option parameters.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_write_async_014', 0, async function (done) { it('fileIO_test_write_async_014', 0, async function (done) {
...@@ -793,8 +787,8 @@ export default function fileIOWrite() { ...@@ -793,8 +787,8 @@ export default function fileIOWrite() {
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
let bytesWritten = await fileIO.write(file.fd, FILE_CONTENT, {}); let bytesWritten = await fileIO.write(file.fd, FILE_CONTENT, {});
expect(bytesWritten == FILE_CONTENT.length).assertTrue(); expect(bytesWritten == FILE_CONTENT.length).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_test_write_async_014 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_write_async_014 has failed for ' + e.message + ', code: ' + e.code);
...@@ -809,7 +803,7 @@ export default function fileIOWrite() { ...@@ -809,7 +803,7 @@ export default function fileIOWrite() {
* Open the file in write-only mode, writing a string with empty option parameters. * Open the file in write-only mode, writing a string with empty option parameters.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_write_async_015', 0, async function (done) { it('fileIO_test_write_async_015', 0, async function (done) {
...@@ -820,16 +814,16 @@ export default function fileIOWrite() { ...@@ -820,16 +814,16 @@ export default function fileIOWrite() {
let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileIO.write(file.fd, new ArrayBuffer(4096), { fileIO.write(file.fd, new ArrayBuffer(4096), {
}, (err, bytesWritten) => { }, (err, bytesWritten) => {
if(err) { if(err) {
console.log('fileIO_test_write_async_015 err package ' + JSON.stringify(err)); console.log('fileIO_test_write_async_015 err package ' + JSON.stringify(err));
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(bytesWritten == 4096).assertTrue(); expect(bytesWritten == 4096).assertTrue();
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
} catch (e) { } catch (e) {
console.log('fileIO_test_write_async_015 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_write_async_015 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -843,7 +837,7 @@ export default function fileIOWrite() { ...@@ -843,7 +837,7 @@ export default function fileIOWrite() {
* Write with invalid fd parameters. * Write with invalid fd parameters.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_write_async_016', 0, async function (done) { it('fileIO_test_write_async_016', 0, async function (done) {
...@@ -854,7 +848,7 @@ export default function fileIOWrite() { ...@@ -854,7 +848,7 @@ export default function fileIOWrite() {
await fileIO.write(-1, FILE_CONTENT); await fileIO.write(-1, FILE_CONTENT);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_test_write_async_016 has failed for ' + e.message + ', code: ' + e.code); 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(); expect(e.code == 13900008 && e.message == 'Bad file descriptor').assertTrue();
done(); done();
...@@ -868,7 +862,7 @@ export default function fileIOWrite() { ...@@ -868,7 +862,7 @@ export default function fileIOWrite() {
* Write with invalid fd parameters. * Write with invalid fd parameters.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_write_async_017', 0, async function (done) { it('fileIO_test_write_async_017', 0, async function (done) {
...@@ -878,8 +872,8 @@ export default function fileIOWrite() { ...@@ -878,8 +872,8 @@ export default function fileIOWrite() {
try { try {
fileIO.write(-1, FILE_CONTENT, (err) => { fileIO.write(-1, FILE_CONTENT, (err) => {
if(err) { if(err) {
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_test_open_async_020 error package: {' + err.message + ', code: ' + err.code + '}'); console.log('fileIO_test_open_async_020 error: {message: ' + err.message + ', code: ' + err.code + '}');
expect(err.code == 13900008 && err.message == 'Bad file descriptor').assertTrue(); expect(err.code == 13900008 && err.message == 'Bad file descriptor').assertTrue();
done(); done();
} }
...@@ -896,26 +890,26 @@ export default function fileIOWrite() { ...@@ -896,26 +890,26 @@ export default function fileIOWrite() {
* Write with invalid length parameters. * Write with invalid length parameters.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_write_async_018', 0, async function (done) { it('fileIO_test_write_async_018', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_write_async_018'); let fpath = await nextFileName('fileIO_test_write_async_018');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
const invalidLength = 9999;
try { try {
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
const invalidLength = 9999;
fileIO.write(file.fd, FILE_CONTENT, { fileIO.write(file.fd, FILE_CONTENT, {
length: invalidLength, length: invalidLength,
}, () => { }, (err) => {
expect(false).assertTrue(); expect(false).assertTrue();
}) });
} catch (e) { } catch (e) {
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.info('fileIO_test_write_async_018 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_write_async_018 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done(); done();
} }
...@@ -928,26 +922,26 @@ export default function fileIOWrite() { ...@@ -928,26 +922,26 @@ export default function fileIOWrite() {
* Write with invalid length parameters. * Write with invalid length parameters.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_write_async_019', 0, async function (done) { it('fileIO_test_write_async_019', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_write_async_019'); let fpath = await nextFileName('fileIO_test_write_async_019');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
const invalidLength = 4097;
try { try {
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
const invalidLength = 4097;
fileIO.write(file.fd, new ArrayBuffer(4096), { fileIO.write(file.fd, new ArrayBuffer(4096), {
length: invalidLength, length: invalidLength,
}, () => { }, (err) => {
expect(false).assertTrue(); expect(false).assertTrue();
}) });
} catch (e) { } catch (e) {
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.info('fileIO_test_write_async_019 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_write_async_019 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done(); done();
} }
...@@ -960,26 +954,26 @@ export default function fileIOWrite() { ...@@ -960,26 +954,26 @@ export default function fileIOWrite() {
* Write with invalid length parameters. * Write with invalid length parameters.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Functoin * @tc.type Functoin
* @tc.level Level 0 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_write_async_020', 0, async function (done) { it('fileIO_test_write_async_020', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_write_async_020'); let fpath = await nextFileName('fileIO_test_write_async_020');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY); let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
const invalidOffset = -1;
try { try {
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
const invalidOffset = -1;
fileIO.write(file.fd, FILE_CONTENT, { fileIO.write(file.fd, FILE_CONTENT, {
offset: invalidOffset, offset: invalidOffset,
}, () => { }, (err) => {
expect(false).assertTrue(); expect(false).assertTrue();
}) });
} catch (e) { } catch (e) {
fileio.closeSync(file.fd); fileIO.closeSync(file);
fileio.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.info('fileIO_test_write_async_020 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_write_async_020 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done(); done();
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册