提交 0edfcc10 编写于 作者: Z zhuhongtao66

修改用例标签

Signed-off-by: Nzhuhongtao66 <zhuhongtao12@huawei.com>
上级 c4fc77be
/* /*
* 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,
......
...@@ -21,7 +21,7 @@ export default function fileIOStreamClose() { ...@@ -21,7 +21,7 @@ export default function fileIOStreamClose() {
describe('fileIO_fs_stream_close', function () { describe('fileIO_fs_stream_close', function () {
/** /**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSESYNC_0000 * @tc.number SUB_DF_FILEIO_STREAM_CLOSE_SYNC_0000
* @tc.name fileIO_test_stream_close_sync_000 * @tc.name fileIO_test_stream_close_sync_000
* @tc.desc Test the closeSync() interface of class Stream. * @tc.desc Test the closeSync() interface of class Stream.
* Open a file stream, close file stream. * Open a file stream, close file stream.
...@@ -35,9 +35,9 @@ describe('fileIO_fs_stream_close', function () { ...@@ -35,9 +35,9 @@ describe('fileIO_fs_stream_close', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let ss = fileIO.createStreamSync(fpath, 'r'); let sr = fileIO.createStreamSync(fpath, 'r');
expect(ss !== null).assertTrue(); expect(sr !== null).assertTrue();
ss.closeSync(); sr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_stream_close_sync_000 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_stream_close_sync_000 has failed for ' + e.message + ', code: ' + e.code);
...@@ -46,7 +46,7 @@ describe('fileIO_fs_stream_close', function () { ...@@ -46,7 +46,7 @@ describe('fileIO_fs_stream_close', function () {
}) })
/** /**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSESYNC_0100 * @tc.number SUB_DF_FILEIO_STREAM_CLOSE_SYNC_0100
* @tc.name fileIO_test_stream_close_sync_001 * @tc.name fileIO_test_stream_close_sync_001
* @tc.desc Test the closeSync() interface of class Stream. * @tc.desc Test the closeSync() interface of class Stream.
* Invalid parameter, don't requrie any parameters. * Invalid parameter, don't requrie any parameters.
...@@ -58,14 +58,14 @@ describe('fileIO_fs_stream_close', function () { ...@@ -58,14 +58,14 @@ describe('fileIO_fs_stream_close', function () {
it('fileIO_test_stream_close_sync_001', 0, async function () { it('fileIO_test_stream_close_sync_001', 0, async function () {
let fpath = await nextFileName('fileIO_test_stream_close_sync_001'); let fpath = await nextFileName('fileIO_test_stream_close_sync_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let ss = fileIO.createStreamSync(fpath, 'r'); let sr = fileIO.createStreamSync(fpath, 'r');
try { try {
expect(ss !== null).assertTrue(); expect(sr !== null).assertTrue();
ss.closeSync(1); sr.closeSync(1);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
ss.closeSync(); sr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_test_stream_close_sync_001 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_stream_close_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
...@@ -73,7 +73,7 @@ describe('fileIO_fs_stream_close', function () { ...@@ -73,7 +73,7 @@ describe('fileIO_fs_stream_close', function () {
}) })
/** /**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSESYNC_0200 * @tc.number SUB_DF_FILEIO_STREAM_CLOSE_SYNC_0200
* @tc.name fileIO_test_stream_close_sync_002 * @tc.name fileIO_test_stream_close_sync_002
* @tc.desc Test the closeSync() interface of class Stream. * @tc.desc Test the closeSync() interface of class Stream.
* The file stream has been closed. * The file stream has been closed.
...@@ -85,12 +85,12 @@ describe('fileIO_fs_stream_close', function () { ...@@ -85,12 +85,12 @@ describe('fileIO_fs_stream_close', function () {
it('fileIO_test_stream_close_sync_002', 0, async function () { it('fileIO_test_stream_close_sync_002', 0, async function () {
let fpath = await nextFileName('fileIO_test_stream_close_sync_002'); let fpath = await nextFileName('fileIO_test_stream_close_sync_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let ss = fileIO.createStreamSync(fpath, 'r'); let sr = fileIO.createStreamSync(fpath, 'r');
try { try {
expect(ss !== null).assertTrue(); expect(sr !== null).assertTrue();
ss.closeSync(); sr.closeSync();
ss.closeSync(); sr.closeSync();
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
...@@ -100,7 +100,7 @@ describe('fileIO_fs_stream_close', function () { ...@@ -100,7 +100,7 @@ describe('fileIO_fs_stream_close', function () {
}) })
/** /**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSEASYNC_0000 * @tc.number SUB_DF_FILEIO_STREAM_CLOSE_ASYNC_0000
* @tc.name fileIO_test_stream_close_async_000 * @tc.name fileIO_test_stream_close_async_000
* @tc.desc Test the close() interface of class Stream. Promise. * @tc.desc Test the close() interface of class Stream. Promise.
* Open a file stream, close file stream. * Open a file stream, close file stream.
...@@ -114,9 +114,9 @@ describe('fileIO_fs_stream_close', function () { ...@@ -114,9 +114,9 @@ describe('fileIO_fs_stream_close', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let ss = fileIO.createStreamSync(fpath, 'r'); let sr = fileIO.createStreamSync(fpath, 'r');
expect(ss !== null).assertTrue(); expect(sr !== null).assertTrue();
await ss.close(); await sr.close();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
...@@ -126,7 +126,7 @@ describe('fileIO_fs_stream_close', function () { ...@@ -126,7 +126,7 @@ describe('fileIO_fs_stream_close', function () {
}); });
/** /**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSEASYNC_0100 * @tc.number SUB_DF_FILEIO_STREAM_CLOSE_ASYNC_0100
* @tc.name fileIO_test_stream_close_async_001 * @tc.name fileIO_test_stream_close_async_001
* @tc.desc Test the close() interface of class Stream. Callback. * @tc.desc Test the close() interface of class Stream. Callback.
* Open a file stream, close file stream. * Open a file stream, close file stream.
...@@ -140,9 +140,9 @@ describe('fileIO_fs_stream_close', function () { ...@@ -140,9 +140,9 @@ describe('fileIO_fs_stream_close', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let ss = fileIO.createStreamSync(fpath, 'r'); let sr = fileIO.createStreamSync(fpath, 'r');
expect(ss !== null).assertTrue(); expect(sr !== null).assertTrue();
ss.close((err) => { sr.close((err) => {
if (err) { if (err) {
console.log('fileIO_test_stream_close_async_001 error package: ' + JSON.stringify(err)); console.log('fileIO_test_stream_close_async_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -157,7 +157,7 @@ describe('fileIO_fs_stream_close', function () { ...@@ -157,7 +157,7 @@ describe('fileIO_fs_stream_close', function () {
}); });
/** /**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSEASYNC_0200 * @tc.number SUB_DF_FILEIO_STREAM_CLOSE_ASYNC_0200
* @tc.name fileIO_test_stream_close_async_002 * @tc.name fileIO_test_stream_close_async_002
* @tc.desc Test the close() interface of class Stream. Promise. * @tc.desc Test the close() interface of class Stream. Promise.
* The file stream has been closed. * The file stream has been closed.
...@@ -171,10 +171,10 @@ describe('fileIO_fs_stream_close', function () { ...@@ -171,10 +171,10 @@ describe('fileIO_fs_stream_close', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let ss = fileIO.createStreamSync(fpath, 'r'); let sr = fileIO.createStreamSync(fpath, 'r');
expect(ss !== null).assertTrue(); expect(sr !== null).assertTrue();
await ss.close(); await sr.close();
await ss.close(); await sr.close();
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
...@@ -185,7 +185,7 @@ describe('fileIO_fs_stream_close', function () { ...@@ -185,7 +185,7 @@ describe('fileIO_fs_stream_close', function () {
}); });
/** /**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSEASYNC_0300 * @tc.number SUB_DF_FILEIO_STREAM_CLOSE_ASYNC_0300
* @tc.name fileIO_test_stream_close_async_003 * @tc.name fileIO_test_stream_close_async_003
* @tc.desc Test the close() interface of class Stream. Promise. * @tc.desc Test the close() interface of class Stream. Promise.
* Invalid parameter, don't requrie any parameters. * Invalid parameter, don't requrie any parameters.
...@@ -199,9 +199,9 @@ describe('fileIO_fs_stream_close', function () { ...@@ -199,9 +199,9 @@ describe('fileIO_fs_stream_close', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let ss = fileIO.createStreamSync(fpath, 'r'); let sr = fileIO.createStreamSync(fpath, 'r');
expect(ss !== null).assertTrue(); expect(sr !== null).assertTrue();
await ss.close(1); await sr.close(1);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
......
...@@ -21,7 +21,7 @@ export default function fileIOStreamFlush() { ...@@ -21,7 +21,7 @@ export default function fileIOStreamFlush() {
describe('fileIO_fs_stream_flush', function () { describe('fileIO_fs_stream_flush', function () {
/** /**
* @tc.number SUB_DF_FILEIO_STREAM_FLUSHSYNC_0000 * @tc.number SUB_DF_FILEIO_STREAM_FLUSH_SYNC_0000
* @tc.name fileIO_test_stream_flush_sync_000 * @tc.name fileIO_test_stream_flush_sync_000
* @tc.desc Test the flushSync() interface of class Stream. * @tc.desc Test the flushSync() interface of class Stream.
* Refresh file stream. * Refresh file stream.
...@@ -35,11 +35,11 @@ describe('fileIO_fs_stream_flush', function () { ...@@ -35,11 +35,11 @@ describe('fileIO_fs_stream_flush', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let ss = fileIO.createStreamSync(fpath, 'r+'); let sr = fileIO.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue(); expect(sr !== null).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); expect(sr.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
ss.flushSync(); sr.flushSync();
ss.closeSync(); sr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_stream_flush_sync_000 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_stream_flush_sync_000 has failed for ' + e.message + ', code: ' + e.code);
...@@ -48,7 +48,7 @@ describe('fileIO_fs_stream_flush', function () { ...@@ -48,7 +48,7 @@ describe('fileIO_fs_stream_flush', function () {
}); });
/** /**
* @tc.number SUB_DF_FILEIO_STREAM_FLUSHSYNC_0100 * @tc.number SUB_DF_FILEIO_STREAM_FLUSH_SYNC_0100
* @tc.name fileIO_test_stream_flush_sync_001 * @tc.name fileIO_test_stream_flush_sync_001
* @tc.desc Test the flushSync() interface of class Stream. * @tc.desc Test the flushSync() interface of class Stream.
* Invalid parameter, don't requrie any parameters. * Invalid parameter, don't requrie any parameters.
...@@ -60,14 +60,14 @@ describe('fileIO_fs_stream_flush', function () { ...@@ -60,14 +60,14 @@ describe('fileIO_fs_stream_flush', function () {
it('fileIO_test_stream_flush_sync_001', 0, async function () { it('fileIO_test_stream_flush_sync_001', 0, async function () {
let fpath = await nextFileName('fileIO_test_stream_flush_sync_001'); let fpath = await nextFileName('fileIO_test_stream_flush_sync_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let ss = fileIO.createStreamSync(fpath, 'r+'); let sr = fileIO.createStreamSync(fpath, 'r+');
try { try {
expect(ss !== null).assertTrue(); expect(sr !== null).assertTrue();
ss.flushSync(1); sr.flushSync(1);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
ss.closeSync(); sr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_test_stream_flush_sync_001 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_stream_flush_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
...@@ -75,7 +75,7 @@ describe('fileIO_fs_stream_flush', function () { ...@@ -75,7 +75,7 @@ describe('fileIO_fs_stream_flush', function () {
}); });
/** /**
* @tc.number SUB_DF_FILEIO_STREAM_FLUSHASYNC_0000 * @tc.number SUB_DF_FILEIO_STREAM_FLUSH_ASYNC_0000
* @tc.name fileIO_test_stream_flush_async_000 * @tc.name fileIO_test_stream_flush_async_000
* @tc.desc Test the flush() interface of class Stream. Promise.then().catch() * @tc.desc Test the flush() interface of class Stream. Promise.then().catch()
* Refresh the file stream. * Refresh the file stream.
...@@ -89,11 +89,11 @@ describe('fileIO_fs_stream_flush', function () { ...@@ -89,11 +89,11 @@ describe('fileIO_fs_stream_flush', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let ss = await fileIO.createStreamSync(fpath, 'r+'); let sr = await fileIO.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue(); expect(sr !== null).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); expect(sr.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
ss.flush().then(() => { sr.flush().then(() => {
ss.closeSync(); sr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}).catch((err) => { }).catch((err) => {
...@@ -107,7 +107,7 @@ describe('fileIO_fs_stream_flush', function () { ...@@ -107,7 +107,7 @@ describe('fileIO_fs_stream_flush', function () {
}); });
/** /**
* @tc.number SUB_DF_FILEIO_STREAM_FLUSHASYNC_0100 * @tc.number SUB_DF_FILEIO_STREAM_FLUSH_ASYNC_0100
* @tc.name fileIO_test_stream_flush_async_001 * @tc.name fileIO_test_stream_flush_async_001
* @tc.desc Test the flush() interface of class Stream. Callback. * @tc.desc Test the flush() interface of class Stream. Callback.
* Refresh the file stream. * Refresh the file stream.
...@@ -121,15 +121,15 @@ describe('fileIO_fs_stream_flush', function () { ...@@ -121,15 +121,15 @@ describe('fileIO_fs_stream_flush', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let ss = await fileIO.createStreamSync(fpath, 'r+'); let sr = await fileIO.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue(); expect(sr !== null).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); expect(sr.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
ss.flush((err) => { sr.flush((err) => {
if (err) { if (err) {
console.log('fileIO_test_stream_flush_async_001 error package' + JSON.stringify(err)); console.log('fileIO_test_stream_flush_async_001 error package' + JSON.stringify(err));
expect(false).assertTrue(); expect(false).assertTrue();
} }
ss.closeSync(); sr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}) })
...@@ -140,7 +140,7 @@ describe('fileIO_fs_stream_flush', function () { ...@@ -140,7 +140,7 @@ describe('fileIO_fs_stream_flush', function () {
}); });
/** /**
* @tc.number SUB_DF_FILEIO_STREAM_FLUSHASYNC_0100 * @tc.number SUB_DF_FILEIO_STREAM_FLUSH_ASYNC_0100
* @tc.name fileIO_test_stream_flush_async_001 * @tc.name fileIO_test_stream_flush_async_001
* @tc.desc Test the flush() interface of class Stream. Promise. * @tc.desc Test the flush() interface of class Stream. Promise.
* Refresh the file stream. * Refresh the file stream.
...@@ -153,14 +153,14 @@ describe('fileIO_fs_stream_flush', function () { ...@@ -153,14 +153,14 @@ describe('fileIO_fs_stream_flush', function () {
it('fileIO_test_stream_flush_sync_001', 0, async function (done) { it('fileIO_test_stream_flush_sync_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_stream_flush_sync_001'); let fpath = await nextFileName('fileIO_test_stream_flush_sync_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let ss = fileIO.createStreamSync(fpath, 'r+'); let sr = fileIO.createStreamSync(fpath, 'r+');
try { try {
expect(ss !== null).assertTrue(); expect(sr !== null).assertTrue();
await ss.flush(1); await sr.flush(1);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
ss.closeSync(); sr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_test_stream_flush_sync_001 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_stream_flush_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
......
...@@ -35,11 +35,11 @@ describe('fileIO_fs_stream_read', function () { ...@@ -35,11 +35,11 @@ describe('fileIO_fs_stream_read', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let ss = fileIO.createStreamSync(fpath, 'r+'); let sr = fileIO.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue(); expect(sr !== null).assertTrue();
let readout = ss.readSync(new ArrayBuffer(4096)); let readLen = sr.readSync(new ArrayBuffer(4096));
expect(readout == FILE_CONTENT.length).assertTrue(); expect(readLen == FILE_CONTENT.length).assertTrue();
ss.closeSync(); sr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_stream_read_sync_000 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_stream_read_sync_000 has failed for ' + e.message + ', code: ' + e.code);
...@@ -62,11 +62,11 @@ describe('fileIO_fs_stream_read', function () { ...@@ -62,11 +62,11 @@ describe('fileIO_fs_stream_read', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let ss = fileIO.createStreamSync(fpath, 'r+'); let sr = fileIO.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue(); expect(sr !== null).assertTrue();
let readout = ss.readSync(new ArrayBuffer(4096), { length: 2 }); let readLen = sr.readSync(new ArrayBuffer(4096), { length: 2 });
expect(readout == 2).assertTrue(); expect(readLen == 2).assertTrue();
ss.closeSync(); sr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_stream_read_sync_001 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_stream_read_sync_001 has failed for ' + e.message + ', code: ' + e.code);
...@@ -89,11 +89,11 @@ describe('fileIO_fs_stream_read', function () { ...@@ -89,11 +89,11 @@ describe('fileIO_fs_stream_read', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let ss = fileIO.createStreamSync(fpath, 'r+'); let sr = fileIO.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue(); expect(sr !== null).assertTrue();
let readout = ss.readSync(new ArrayBuffer(4096), { offset: 2 }); let readLen = sr.readSync(new ArrayBuffer(4096), { offset: 2 });
expect(readout == FILE_CONTENT.length - 2).assertTrue(); expect(readLen == FILE_CONTENT.length - 2).assertTrue();
ss.closeSync(); sr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_stream_read_sync_002 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_stream_read_sync_002 has failed for ' + e.message + ', code: ' + e.code);
...@@ -116,14 +116,14 @@ describe('fileIO_fs_stream_read', function () { ...@@ -116,14 +116,14 @@ describe('fileIO_fs_stream_read', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let ss = fileIO.createStreamSync(fpath, 'r+'); let sr = fileIO.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue(); expect(sr !== null).assertTrue();
let readout = ss.readSync(new ArrayBuffer(4096), { let readLen = sr.readSync(new ArrayBuffer(4096), {
offset: 1, offset: 1,
length: FILE_CONTENT.length length: FILE_CONTENT.length
}); });
expect(readout == FILE_CONTENT.length - 1).assertTrue(); expect(readLen == FILE_CONTENT.length - 1).assertTrue();
ss.closeSync(); sr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_stream_read_sync_003 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_stream_read_sync_003 has failed for ' + e.message + ', code: ' + e.code);
...@@ -144,14 +144,14 @@ describe('fileIO_fs_stream_read', function () { ...@@ -144,14 +144,14 @@ describe('fileIO_fs_stream_read', function () {
it('fileIO_test_stream_read_sync_004', 0, async function () { it('fileIO_test_stream_read_sync_004', 0, async function () {
let fpath = await nextFileName('fileIO_test_stream_read_sync_004'); let fpath = await nextFileName('fileIO_test_stream_read_sync_004');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let ss = fileIO.createStreamSync(fpath, 'r+'); let sr = fileIO.createStreamSync(fpath, 'r+');
try { try {
expect(ss !== null).assertTrue(); expect(sr !== null).assertTrue();
ss.readSync(""); sr.readSync("");
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
ss.closeSync(); sr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_test_stream_read_sync_004 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_stream_read_sync_004 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
...@@ -171,15 +171,15 @@ describe('fileIO_fs_stream_read', function () { ...@@ -171,15 +171,15 @@ describe('fileIO_fs_stream_read', function () {
it('fileIO_test_stream_read_sync_005', 0, async function () { it('fileIO_test_stream_read_sync_005', 0, async function () {
let fpath = await nextFileName('fileIO_test_stream_read_sync_005'); let fpath = await nextFileName('fileIO_test_stream_read_sync_005');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let ss = fileIO.createStreamSync(fpath, 'r+'); let sr = fileIO.createStreamSync(fpath, 'r+');
const invalidLength = 4097;
try { try {
expect(ss !== null).assertTrue(); expect(sr !== null).assertTrue();
const invalidLength = 4097; sr.readSync(new ArrayBuffer(4096), { length: invalidLength });
ss.readSync(new ArrayBuffer(4096), { length: invalidLength });
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
ss.closeSync(); sr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_test_stream_read_sync_005 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_stream_read_sync_005 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
...@@ -199,15 +199,15 @@ describe('fileIO_fs_stream_read', function () { ...@@ -199,15 +199,15 @@ describe('fileIO_fs_stream_read', function () {
it('fileIO_test_stream_read_sync_006', 0, async function () { it('fileIO_test_stream_read_sync_006', 0, async function () {
let fpath = await nextFileName('fileIO_test_stream_read_sync_006'); let fpath = await nextFileName('fileIO_test_stream_read_sync_006');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let ss = fileIO.createStreamSync(fpath, 'r+'); let sr = fileIO.createStreamSync(fpath, 'r+');
const invalidOffset = -1;
try { try {
expect(ss !== null).assertTrue(); expect(sr !== null).assertTrue();
const invalidOffset = -1; sr.readSync(new ArrayBuffer(4096), { offset: invalidOffset });
ss.readSync(new ArrayBuffer(4096), { offset: invalidOffset });
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
ss.closeSync(); sr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_test_stream_read_sync_006 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_stream_read_sync_006 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
...@@ -229,11 +229,11 @@ describe('fileIO_fs_stream_read', function () { ...@@ -229,11 +229,11 @@ describe('fileIO_fs_stream_read', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let ss = fileIO.createStreamSync(fpath, 'r+'); let sr = fileIO.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue(); expect(sr !== null).assertTrue();
let readout = await ss.read(new ArrayBuffer(4096)); let readLen = await sr.read(new ArrayBuffer(4096));
expect(readout == FILE_CONTENT.length).assertTrue(); expect(readLen == FILE_CONTENT.length).assertTrue();
ss.closeSync(); sr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
...@@ -257,15 +257,15 @@ describe('fileIO_fs_stream_read', function () { ...@@ -257,15 +257,15 @@ describe('fileIO_fs_stream_read', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let ss = fileIO.createStreamSync(fpath, 'r+'); let sr = fileIO.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue(); expect(sr !== null).assertTrue();
ss.read(new ArrayBuffer(4096), (err, readout) => { sr.read(new ArrayBuffer(4096), (err, readLen) => {
if (err) { if (err) {
console.log('fileIO_test_stream_read_async_001 error package: ' + JSON.stringify(err)); console.log('fileIO_test_stream_read_async_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(readout == FILE_CONTENT.length).assertTrue(); expect(readLen == FILE_CONTENT.length).assertTrue();
ss.closeSync(); sr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
...@@ -290,13 +290,13 @@ describe('fileIO_fs_stream_read', function () { ...@@ -290,13 +290,13 @@ describe('fileIO_fs_stream_read', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let ss = fileIO.createStreamSync(fpath, 'r+'); let sr = fileIO.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue(); expect(sr !== null).assertTrue();
let readout = await ss.read(new ArrayBuffer(4096), { let readLen = await sr.read(new ArrayBuffer(4096), {
length: 5 length: 5
}); });
expect(readout == 5).assertTrue(); expect(readLen == 5).assertTrue();
ss.closeSync(); sr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
...@@ -320,17 +320,17 @@ describe('fileIO_fs_stream_read', function () { ...@@ -320,17 +320,17 @@ describe('fileIO_fs_stream_read', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let ss = fileIO.createStreamSync(fpath, 'r+'); let sr = fileIO.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue(); expect(sr !== null).assertTrue();
ss.read(new ArrayBuffer(4096), { sr.read(new ArrayBuffer(4096), {
length: 5 length: 5
}, (err, readout) => { }, (err, readLen) => {
if (err) { if (err) {
console.log('fileIO_test_stream_read_async_003 error package: ' + JSON.stringify(err)); console.log('fileIO_test_stream_read_async_003 error package: ' + JSON.stringify(err));
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(readout == 5).assertTrue(); expect(readLen == 5).assertTrue();
ss.closeSync(); sr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
...@@ -355,13 +355,13 @@ describe('fileIO_fs_stream_read', function () { ...@@ -355,13 +355,13 @@ describe('fileIO_fs_stream_read', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let ss = fileIO.createStreamSync(fpath, 'r+'); let sr = fileIO.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue(); expect(sr !== null).assertTrue();
let readout = await ss.read(new ArrayBuffer(4096), { let readLen = await sr.read(new ArrayBuffer(4096), {
offset: 5 offset: 5
}); });
expect(readout == FILE_CONTENT.length - 5).assertTrue(); expect(readLen == FILE_CONTENT.length - 5).assertTrue();
ss.closeSync(); sr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
...@@ -385,17 +385,17 @@ describe('fileIO_fs_stream_read', function () { ...@@ -385,17 +385,17 @@ describe('fileIO_fs_stream_read', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let ss = fileIO.createStreamSync(fpath, 'r+'); let sr = fileIO.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue(); expect(sr !== null).assertTrue();
ss.read(new ArrayBuffer(4096), { sr.read(new ArrayBuffer(4096), {
offset: 5 offset: 5
}, (err, readout) => { }, (err, readLen) => {
if (err) { if (err) {
console.log('fileIO_test_stream_read_async_005 error package: ' + JSON.stringify(err)); console.log('fileIO_test_stream_read_async_005 error package: ' + JSON.stringify(err));
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(readout == FILE_CONTENT.length - 5).assertTrue(); expect(readLen == FILE_CONTENT.length - 5).assertTrue();
ss.closeSync(); sr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
...@@ -418,15 +418,15 @@ describe('fileIO_fs_stream_read', function () { ...@@ -418,15 +418,15 @@ describe('fileIO_fs_stream_read', function () {
it('fileIO_test_stream_read_async_006', 0, async function (done) { it('fileIO_test_stream_read_async_006', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_stream_read_async_006'); let fpath = await nextFileName('fileIO_test_stream_read_async_006');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let ss = fileIO.createStreamSync(fpath, 'r+'); let sr = fileIO.createStreamSync(fpath, 'r+');
try { try {
expect(ss !== null).assertTrue(); expect(sr !== null).assertTrue();
const invalidLength = 4097; const invalidLength = 4097;
await ss.read(new ArrayBuffer(4096), { length: invalidLength }); await sr.read(new ArrayBuffer(4096), { length: invalidLength });
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
ss.closeSync(); sr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_test_stream_read_async_006 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_stream_read_async_006 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
...@@ -447,18 +447,18 @@ describe('fileIO_fs_stream_read', function () { ...@@ -447,18 +447,18 @@ describe('fileIO_fs_stream_read', function () {
it('fileIO_test_stream_read_async_007', 0, async function (done) { it('fileIO_test_stream_read_async_007', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_stream_read_async_007'); let fpath = await nextFileName('fileIO_test_stream_read_async_007');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let ss = fileIO.createStreamSync(fpath, 'r+'); let sr = fileIO.createStreamSync(fpath, 'r+');
try { try {
expect(ss !== null).assertTrue(); expect(sr !== null).assertTrue();
const invalidOffset = -1; const invalidOffset = -1;
ss.read(new ArrayBuffer(4096), { sr.read(new ArrayBuffer(4096), {
offset: invalidOffset offset: invalidOffset
}, (err) => { }, (err) => {
expect(false).assertTrue(); expect(false).assertTrue();
}); });
} catch (e) { } catch (e) {
ss.closeSync(); sr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_test_stream_read_async_007 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_stream_read_async_007 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
...@@ -481,14 +481,14 @@ describe('fileIO_fs_stream_read', function () { ...@@ -481,14 +481,14 @@ describe('fileIO_fs_stream_read', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let ss = fileIO.createStreamSync(fpath, 'r+'); let sr = fileIO.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue(); expect(sr !== null).assertTrue();
let readout = await ss.read(new ArrayBuffer(4096), { let readLen = await sr.read(new ArrayBuffer(4096), {
offset: 1, offset: 1,
length: FILE_CONTENT.length length: FILE_CONTENT.length
}); });
expect(readout == FILE_CONTENT.length - 1).assertTrue(); expect(readLen == FILE_CONTENT.length - 1).assertTrue();
ss.closeSync(); sr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
...@@ -512,18 +512,18 @@ describe('fileIO_fs_stream_read', function () { ...@@ -512,18 +512,18 @@ describe('fileIO_fs_stream_read', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let ss = fileIO.createStreamSync(fpath, 'r+'); let sr = fileIO.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue(); expect(sr !== null).assertTrue();
ss.read(new ArrayBuffer(4096), { sr.read(new ArrayBuffer(4096), {
offset: 1, offset: 1,
length: FILE_CONTENT.length length: FILE_CONTENT.length
}, (err, readout) => { }, (err, readLen) => {
if (err) { if (err) {
console.log('fileIO_test_stream_read_async_009 error package: ' + JSON.stringify(err)); console.log('fileIO_test_stream_read_async_009 error package: ' + JSON.stringify(err));
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(readout == FILE_CONTENT.length - 1).assertTrue(); expect(readLen == FILE_CONTENT.length - 1).assertTrue();
ss.closeSync(); sr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
...@@ -548,11 +548,11 @@ describe('fileIO_fs_stream_read', function () { ...@@ -548,11 +548,11 @@ describe('fileIO_fs_stream_read', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let ss = fileIO.createStreamSync(fpath, 'r+'); let sr = fileIO.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue(); expect(sr !== null).assertTrue();
let readout = await ss.read(new ArrayBuffer(4096), {}); let readLen = await sr.read(new ArrayBuffer(4096), {});
expect(readout == FILE_CONTENT.length).assertTrue(); expect(readLen == FILE_CONTENT.length).assertTrue();
ss.closeSync(); sr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
...@@ -576,16 +576,16 @@ describe('fileIO_fs_stream_read', function () { ...@@ -576,16 +576,16 @@ describe('fileIO_fs_stream_read', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let ss = fileIO.createStreamSync(fpath, 'r+'); let sr = fileIO.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue(); expect(sr !== null).assertTrue();
ss.read(new ArrayBuffer(4096), { sr.read(new ArrayBuffer(4096), {
}, (err, readout) => { }, (err, readLen) => {
if (err) { if (err) {
console.log('fileIO_test_stream_read_async_011 error package: ' + JSON.stringify(err)); console.log('fileIO_test_stream_read_async_011 error package: ' + JSON.stringify(err));
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(readout == FILE_CONTENT.length).assertTrue(); expect(readLen == FILE_CONTENT.length).assertTrue();
ss.closeSync(); sr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
...@@ -607,14 +607,14 @@ describe('fileIO_fs_stream_read', function () { ...@@ -607,14 +607,14 @@ describe('fileIO_fs_stream_read', function () {
it('fileIO_test_stream_read_async_012', 0, async function (done) { it('fileIO_test_stream_read_async_012', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_stream_read_async_012'); let fpath = await nextFileName('fileIO_test_stream_read_async_012');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let ss = fileIO.createStreamSync(fpath, 'r+'); let sr = fileIO.createStreamSync(fpath, 'r+');
try { try {
expect(ss !== null).assertTrue(); expect(sr !== null).assertTrue();
await ss.read(); await sr.read();
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
ss.closeSync(); sr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_test_stream_read_async_012 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_stream_read_async_012 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
...@@ -635,13 +635,14 @@ describe('fileIO_fs_stream_read', function () { ...@@ -635,13 +635,14 @@ describe('fileIO_fs_stream_read', function () {
it('fileIO_test_stream_read_async_013', 0, async function (done) { it('fileIO_test_stream_read_async_013', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_stream_read_async_013'); let fpath = await nextFileName('fileIO_test_stream_read_async_013');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let ss = fileIO.createStreamSync(fpath, 'r+'); let sr = fileIO.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue();
try { try {
await ss.read(""); expect(sr !== null).assertTrue();
await sr.read("");
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
ss.closeSync(); sr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_test_stream_read_async_013 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_stream_read_async_013 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
...@@ -662,15 +663,15 @@ describe('fileIO_fs_stream_read', function () { ...@@ -662,15 +663,15 @@ describe('fileIO_fs_stream_read', function () {
it('fileIO_test_stream_read_async_014', 0, async function (done) { it('fileIO_test_stream_read_async_014', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_stream_read_async_014'); let fpath = await nextFileName('fileIO_test_stream_read_async_014');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let ss = fileIO.createStreamSync(fpath, 'r+'); let sr = fileIO.createStreamSync(fpath, 'r+');
try { try {
expect(ss !== null).assertTrue(); expect(sr !== null).assertTrue();
ss.read("", (err) => { sr.read("", (err) => {
expect(false).assertTrue(); expect(false).assertTrue();
}); });
} catch (e) { } catch (e) {
ss.closeSync(); sr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_test_stream_read_async_014 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_stream_read_async_014 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
......
...@@ -21,7 +21,7 @@ export default function fileIOAccess() { ...@@ -21,7 +21,7 @@ export default function fileIOAccess() {
describe('fileIO_fs_access', function () { describe('fileIO_fs_access', function () {
/** /**
* @tc.number SUB_DF_FILEIO_ACCESSSYNC_0000 * @tc.number SUB_DF_FILEIO_ACCESS_SYNC_0000
* @tc.name fileIO_test_access_sync_000 * @tc.name fileIO_test_access_sync_000
* @tc.desc Test accessSync() interface. * @tc.desc Test accessSync() interface.
* This interface shall work properly in normal case. * This interface shall work properly in normal case.
...@@ -49,7 +49,7 @@ describe('fileIO_fs_access', function () { ...@@ -49,7 +49,7 @@ describe('fileIO_fs_access', function () {
}); });
/** /**
* @tc.number SUB_DF_FILEIO_ACCESSSYNC_0100 * @tc.number SUB_DF_FILEIO_ACCESS_SYNC_0100
* @tc.name fileIO_test_access_sync_001 * @tc.name fileIO_test_access_sync_001
* @tc.desc Test accessSync() interface. * @tc.desc Test accessSync() interface.
* The test file is not exist. * The test file is not exist.
...@@ -71,7 +71,7 @@ describe('fileIO_fs_access', function () { ...@@ -71,7 +71,7 @@ describe('fileIO_fs_access', function () {
}); });
/** /**
* @tc.number SUB_DF_FILEIO_ACCESSSYNC_0200 * @tc.number SUB_DF_FILEIO_ACCESS_SYNC_0200
* @tc.name fileIO_test_access_sync_002 * @tc.name fileIO_test_access_sync_002
* @tc.desc Test accessSync() interface. * @tc.desc Test accessSync() interface.
* The test file path is illegal. * The test file path is illegal.
...@@ -92,7 +92,7 @@ describe('fileIO_fs_access', function () { ...@@ -92,7 +92,7 @@ describe('fileIO_fs_access', function () {
}); });
/** /**
* @tc.number SUB_DF_FILEIO_ACCESSASYNC_0000 * @tc.number SUB_DF_FILEIO_ACCESS_ASYNC_0000
* @tc.name fileIO_test_access_async_000 * @tc.name fileIO_test_access_async_000
* @tc.desc Test access() interface. Promise. * @tc.desc Test access() interface. Promise.
* Use promise to test that the file is exist. Sync method reads data from file. * Use promise to test that the file is exist. Sync method reads data from file.
...@@ -122,7 +122,7 @@ describe('fileIO_fs_access', function () { ...@@ -122,7 +122,7 @@ describe('fileIO_fs_access', function () {
}); });
/** /**
* @tc.number SUB_DF_FILEIO_ACCESSASYNC_0100 * @tc.number SUB_DF_FILEIO_ACCESS_ASYNC_0100
* @tc.name fileIO_test_access_async_001 * @tc.name fileIO_test_access_async_001
* @tc.desc Test access() interface. Callback. * @tc.desc Test access() interface. Callback.
* Use callback to test that the file is exist. Sync method reads data from file. * Use callback to test that the file is exist. Sync method reads data from file.
...@@ -157,7 +157,7 @@ describe('fileIO_fs_access', function () { ...@@ -157,7 +157,7 @@ describe('fileIO_fs_access', function () {
}); });
/** /**
* @tc.number SUB_DF_FILEIO_ACCESSASYNC_0200 * @tc.number SUB_DF_FILEIO_ACCESS_ASYNC_0200
* @tc.name fileIO_test_access_async_002 * @tc.name fileIO_test_access_async_002
* @tc.desc Test access() interface. Promise. * @tc.desc Test access() interface. Promise.
* Async test file does not exist. * Async test file does not exist.
...@@ -180,7 +180,7 @@ describe('fileIO_fs_access', function () { ...@@ -180,7 +180,7 @@ describe('fileIO_fs_access', function () {
}); });
/** /**
* @tc.number SUB_DF_FILEIO_ACCESSASYNC_0300 * @tc.number SUB_DF_FILEIO_ACCESS_ASYNC_0300
* @tc.name fileIO_test_access_async_003 * @tc.name fileIO_test_access_async_003
* @tc.desc Test access() interface. Callback. * @tc.desc Test access() interface. Callback.
* Async test file does not exist. * Async test file does not exist.
...@@ -208,7 +208,7 @@ describe('fileIO_fs_access', function () { ...@@ -208,7 +208,7 @@ describe('fileIO_fs_access', function () {
}); });
/** /**
* @tc.number SUB_DF_FILEIO_ACCESSASYNC_0400 * @tc.number SUB_DF_FILEIO_ACCESS_ASYNC_0400
* @tc.name fileIO_test_access_async_004 * @tc.name fileIO_test_access_async_004
* @tc.desc Test access() interface. Promise. * @tc.desc Test access() interface. Promise.
* Invalid path parameter. * Invalid path parameter.
...@@ -230,7 +230,7 @@ describe('fileIO_fs_access', function () { ...@@ -230,7 +230,7 @@ describe('fileIO_fs_access', function () {
}); });
/** /**
* @tc.number SUB_DF_FILEIO_ACCESSASYNC_0500 * @tc.number SUB_DF_FILEIO_ACCESS_ASYNC_0500
* @tc.name fileIO_test_access_async_005 * @tc.name fileIO_test_access_async_005
* @tc.desc Test access() interface. Callback. * @tc.desc Test access() interface. Callback.
* Invalid path parameter. * Invalid path parameter.
......
...@@ -14,15 +14,14 @@ ...@@ -14,15 +14,14 @@
*/ */
import { import {
fileIO, FILE_CONTENT, nextFileName, prepareFile, fileIO, FILE_CONTENT, nextFileName, prepareFile, describe, it, expect,
describe, it, expect,
} from '../Common'; } from '../Common';
export default function fileIOClose() { export default function fileIOClose() {
describe('fileIO_fs_close', function () { describe('fileIO_fs_close', function () {
/** /**
* @tc.number SUB_DF_FILEIO_CLOSESYNC_0000 * @tc.number SUB_DF_FILEIO_CLOSE_SYNC_0000
* @tc.name fileIO_test_close_sync_000 * @tc.name fileIO_test_close_sync_000
* @tc.desc Test closeSync() interfaces. * @tc.desc Test closeSync() interfaces.
* Open file and close file by fd. * Open file and close file by fd.
...@@ -45,7 +44,7 @@ describe('fileIO_fs_close', function () { ...@@ -45,7 +44,7 @@ describe('fileIO_fs_close', function () {
}); });
/** /**
* @tc.number SUB_DF_FILEIO_CLOSESYNC_0100 * @tc.number SUB_DF_FILEIO_CLOSE_SYNC_0100
* @tc.name fileIO_test_close_sync_001 * @tc.name fileIO_test_close_sync_001
* @tc.desc Test closeSync() interfaces. * @tc.desc Test closeSync() interfaces.
* Open file and close file by file object. * Open file and close file by file object.
...@@ -68,7 +67,7 @@ describe('fileIO_fs_close', function () { ...@@ -68,7 +67,7 @@ describe('fileIO_fs_close', function () {
}); });
/** /**
* @tc.number SUB_DF_FILEIO_CLOSESYNC_0200 * @tc.number SUB_DF_FILEIO_CLOSE_SYNC_0200
* @tc.name fileIO_test_close_sync_002 * @tc.name fileIO_test_close_sync_002
* @tc.desc Test closeSync() interfaces. * @tc.desc Test closeSync() interfaces.
* Test fd has been closed. * Test fd has been closed.
...@@ -94,7 +93,7 @@ describe('fileIO_fs_close', function () { ...@@ -94,7 +93,7 @@ describe('fileIO_fs_close', function () {
}); });
/** /**
* @tc.number SUB_DF_FILEIO_CLOSESYNC_0300 * @tc.number SUB_DF_FILEIO_CLOSE_SYNC_0300
* @tc.name fileIO_test_close_sync_003 * @tc.name fileIO_test_close_sync_003
* @tc.desc Test closeSync() interfaces. * @tc.desc Test closeSync() interfaces.
* Test file has been closed. * Test file has been closed.
...@@ -120,7 +119,7 @@ describe('fileIO_fs_close', function () { ...@@ -120,7 +119,7 @@ describe('fileIO_fs_close', function () {
}); });
/** /**
* @tc.number SUB_DF_FILEIO_CLOSESYNC_0400 * @tc.number SUB_DF_FILEIO_CLOSE_SYNC_0400
* @tc.name fileIO_test_close_sync_004 * @tc.name fileIO_test_close_sync_004
* @tc.desc Test closeSync() interfaces. * @tc.desc Test closeSync() interfaces.
* No parameters. * No parameters.
...@@ -141,7 +140,7 @@ describe('fileIO_fs_close', function () { ...@@ -141,7 +140,7 @@ describe('fileIO_fs_close', function () {
}); });
/** /**
* @tc.number SUB_DF_FILEIO_CLOSESYNC_0500 * @tc.number SUB_DF_FILEIO_CLOSE_SYNC_0500
* @tc.name fileIO_test_close_sync_005 * @tc.name fileIO_test_close_sync_005
* @tc.desc Test closeSync() interfaces. * @tc.desc Test closeSync() interfaces.
* Illegal type of parameter. * Illegal type of parameter.
...@@ -301,7 +300,7 @@ describe('fileIO_fs_close', function () { ...@@ -301,7 +300,7 @@ describe('fileIO_fs_close', function () {
/** /**
* @tc.number SUB_DF_FILEIO_CLOSE_ASYNC_0500 * @tc.number SUB_DF_FILEIO_CLOSE_ASYNC_0500
* @tc.name fileIO_test_close_async_005 * @tc.name fileIO_test_close_async_005
* @tc.desc Test close() interfaces. Promise. * @tc.desc Test close() interfaces. Promise.
* Test file has been closed. * Test file has been closed.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
...@@ -315,12 +314,12 @@ describe('fileIO_fs_close', function () { ...@@ -315,12 +314,12 @@ describe('fileIO_fs_close', function () {
try { try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
await fileIO.close(file); await fileIO.close(file);
fileIO.close(file); await fileIO.close(file);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_test_close_async_005 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_close_async_005 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();
fileIO.unlinkSync(fpath);
done(); done();
} }
}); });
...@@ -335,7 +334,7 @@ describe('fileIO_fs_close', function () { ...@@ -335,7 +334,7 @@ describe('fileIO_fs_close', function () {
* @tc.level Level 3 * @tc.level Level 3
* @tc.require * @tc.require
*/ */
it('fileIO_test_close_async_006', 0, async function (done) { it('fileIO_test_close_async_006', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_close_async_006'); let fpath = await nextFileName('fileIO_test_close_async_006');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
......
...@@ -33,15 +33,15 @@ describe('fileIO_fs_createStream', function () { ...@@ -33,15 +33,15 @@ describe('fileIO_fs_createStream', function () {
it('fileIO_test_create_stream_sync_000', 0, async function () { it('fileIO_test_create_stream_sync_000', 0, async function () {
let fpath = await nextFileName('fileIO_test_create_stream_sync_000'); let fpath = await nextFileName('fileIO_test_create_stream_sync_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let ss = fileIO.createStreamSync(fpath, 'r'); let sr = fileIO.createStreamSync(fpath, 'r');
try { try {
expect(ss !== null).assertTrue(); expect(sr !== null).assertTrue();
expect(ss.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); expect(sr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
ss.writeSync(FILE_CONTENT); sr.writeSync(FILE_CONTENT);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
ss.closeSync(); sr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_test_create_stream_sync_000 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_create_stream_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900005 && e.message == 'I/O error').assertTrue(); expect(e.code == 13900005 && e.message == 'I/O error').assertTrue();
...@@ -85,11 +85,11 @@ describe('fileIO_fs_createStream', function () { ...@@ -85,11 +85,11 @@ describe('fileIO_fs_createStream', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let ss = fileIO.createStreamSync(fpath, 'r+'); let sr = fileIO.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue(); expect(sr !== null).assertTrue();
expect(ss.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); expect(sr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); expect(sr.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
ss.closeSync(); sr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_create_stream_sync_002 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_create_stream_sync_002 has failed for ' + e.message + ', code: ' + e.code);
...@@ -263,11 +263,11 @@ describe('fileIO_fs_createStream', function () { ...@@ -263,11 +263,11 @@ describe('fileIO_fs_createStream', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let ss = fileIO.createStreamSync(fpath, 'w+'); let sw = fileIO.createStreamSync(fpath, 'w+');
expect(ss !== null).assertTrue(); expect(sw !== null).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); expect(sw.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(ss.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); expect(sw.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
ss.closeSync(); sw.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_create_stream_sync_009 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_create_stream_sync_009 has failed for ' + e.message + ', code: ' + e.code);
...@@ -289,11 +289,11 @@ describe('fileIO_fs_createStream', function () { ...@@ -289,11 +289,11 @@ describe('fileIO_fs_createStream', function () {
let fpath = await nextFileName('fileIO_test_create_stream_sync_010'); let fpath = await nextFileName('fileIO_test_create_stream_sync_010');
try { try {
let ss = fileIO.createStreamSync(fpath, 'w+'); let sw = fileIO.createStreamSync(fpath, 'w+');
expect(ss !== null).assertTrue(); expect(sw !== null).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); expect(sw.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(ss.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); expect(sw.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
ss.closeSync(); sw.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_create_stream_sync_010 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_create_stream_sync_010 has failed for ' + e.message + ', code: ' + e.code);
...@@ -316,10 +316,10 @@ describe('fileIO_fs_createStream', function () { ...@@ -316,10 +316,10 @@ describe('fileIO_fs_createStream', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let ss = fileIO.createStreamSync(fpath, 'a'); let sa = fileIO.createStreamSync(fpath, 'a');
expect(ss !== null).assertTrue(); expect(sa !== null).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); expect(sa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
ss.closeSync(); sa.closeSync();
let sr = fileIO.createStreamSync(fpath, 'r'); let sr = fileIO.createStreamSync(fpath, 'r');
expect(sr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue(); expect(sr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue();
...@@ -345,10 +345,10 @@ describe('fileIO_fs_createStream', function () { ...@@ -345,10 +345,10 @@ describe('fileIO_fs_createStream', function () {
let fpath = await nextFileName('fileIO_test_create_stream_sync_012'); let fpath = await nextFileName('fileIO_test_create_stream_sync_012');
try { try {
let ss = fileIO.createStreamSync(fpath, 'a'); let sa = fileIO.createStreamSync(fpath, 'a');
expect(ss !== null).assertTrue(); expect(sa !== null).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); expect(sa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
ss.closeSync(); sa.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_create_stream_sync_012 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_create_stream_sync_012 has failed for ' + e.message + ', code: ' + e.code);
...@@ -369,15 +369,15 @@ describe('fileIO_fs_createStream', function () { ...@@ -369,15 +369,15 @@ describe('fileIO_fs_createStream', function () {
it('fileIO_test_create_stream_sync_013', 0, async function () { it('fileIO_test_create_stream_sync_013', 0, async function () {
let fpath = await nextFileName('fileIO_test_create_stream_sync_013'); let fpath = await nextFileName('fileIO_test_create_stream_sync_013');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let ss = fileIO.createStreamSync(fpath, 'a'); let sa = fileIO.createStreamSync(fpath, 'a');
try { try {
expect(ss !== null).assertTrue(); expect(sa !== null).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); expect(sa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
ss.readSync(new ArrayBuffer(4096)); sa.readSync(new ArrayBuffer(4096));
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
ss.closeSync(); sa.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_test_create_stream_sync_013 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_create_stream_sync_013 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900005 && e.message == 'I/O error').assertTrue(); expect(e.code == 13900005 && e.message == 'I/O error').assertTrue();
...@@ -399,11 +399,11 @@ describe('fileIO_fs_createStream', function () { ...@@ -399,11 +399,11 @@ describe('fileIO_fs_createStream', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let ss = fileIO.createStreamSync(fpath, 'a+'); let sa = fileIO.createStreamSync(fpath, 'a+');
expect(ss !== null).assertTrue(); expect(sa !== null).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); expect(sa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(ss.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue(); expect(sa.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue();
ss.closeSync(); sa.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_create_stream_sync_014 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_create_stream_sync_014 has failed for ' + e.message + ', code: ' + e.code);
...@@ -425,11 +425,11 @@ describe('fileIO_fs_createStream', function () { ...@@ -425,11 +425,11 @@ describe('fileIO_fs_createStream', function () {
let fpath = await nextFileName('fileIO_test_create_stream_sync_015'); let fpath = await nextFileName('fileIO_test_create_stream_sync_015');
try { try {
let ss = fileIO.createStreamSync(fpath, 'a+'); let sa = fileIO.createStreamSync(fpath, 'a+');
expect(ss !== null).assertTrue(); expect(sa !== null).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); expect(sa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(ss.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); expect(sa.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
ss.closeSync(); sa.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_create_stream_sync_015 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_create_stream_sync_015 has failed for ' + e.message + ', code: ' + e.code);
...@@ -450,15 +450,15 @@ describe('fileIO_fs_createStream', function () { ...@@ -450,15 +450,15 @@ describe('fileIO_fs_createStream', function () {
it('fileIO_test_create_stream_async_000', 0, async function (done) { it('fileIO_test_create_stream_async_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_create_stream_async_000'); let fpath = await nextFileName('fileIO_test_create_stream_async_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let ss = await fileIO.createStream(fpath, 'r'); let sr = await fileIO.createStream(fpath, 'r');
try { try {
expect(ss !== null).assertTrue(); expect(sr !== null).assertTrue();
expect(ss.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); expect(sr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
ss.writeSync(FILE_CONTENT); sr.writeSync(FILE_CONTENT);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
ss.closeSync(); sr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_test_create_stream_async_000 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_create_stream_async_000 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900005 && e.message == 'I/O error').assertTrue(); expect(e.code == 13900005 && e.message == 'I/O error').assertTrue();
...@@ -481,16 +481,16 @@ describe('fileIO_fs_createStream', function () { ...@@ -481,16 +481,16 @@ describe('fileIO_fs_createStream', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
fileIO.createStream(fpath, 'r', (err, ss) => { fileIO.createStream(fpath, 'r', (err, sr) => {
if (err) { if (err) {
console.log('fileIO_test_create_stream_async_001 error package: ' + JSON.stringify(err)); console.log('fileIO_test_create_stream_async_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(ss !== null).assertTrue(); expect(sr !== null).assertTrue();
expect(ss.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); expect(sr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
ss.write(FILE_CONTENT, (err) => { sr.write(FILE_CONTENT, (err) => {
if (err) { if (err) {
ss.closeSync(); sr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log( console.log(
'fileIO_test_create_stream_async_001 error: {message: ' + err.message + ', code: ' + err.code + '}' 'fileIO_test_create_stream_async_001 error: {message: ' + err.message + ', code: ' + err.code + '}'
...@@ -573,11 +573,11 @@ describe('fileIO_fs_createStream', function () { ...@@ -573,11 +573,11 @@ describe('fileIO_fs_createStream', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let ss = await fileIO.createStream(fpath, 'r+'); let sr = await fileIO.createStream(fpath, 'r+');
expect(ss !== null).assertTrue(); expect(sr !== null).assertTrue();
expect(ss.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); expect(sr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); expect(sr.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
ss.closeSync(); sr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
...@@ -601,15 +601,15 @@ describe('fileIO_fs_createStream', function () { ...@@ -601,15 +601,15 @@ describe('fileIO_fs_createStream', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
fileIO.createStream(fpath, 'r+', (err, ss) => { fileIO.createStream(fpath, 'r+', (err, sr) => {
if (err) { if (err) {
console.log('fileIO_test_create_stream_async_005 error package: ' + JSON.stringify(err)); console.log('fileIO_test_create_stream_async_005 error package: ' + JSON.stringify(err));
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(ss !== null).assertTrue(); expect(sr !== null).assertTrue();
expect(ss.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); expect(sr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); expect(sr.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
ss.closeSync(); sr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
...@@ -829,11 +829,11 @@ describe('fileIO_fs_createStream', function () { ...@@ -829,11 +829,11 @@ describe('fileIO_fs_createStream', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let ss = await fileIO.createStream(fpath, 'w+'); let sw = await fileIO.createStream(fpath, 'w+');
expect(ss !== null).assertTrue(); expect(sw !== null).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); expect(sw.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(ss.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); expect(sw.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
ss.closeSync(); sw.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
...@@ -856,11 +856,11 @@ describe('fileIO_fs_createStream', function () { ...@@ -856,11 +856,11 @@ describe('fileIO_fs_createStream', function () {
let fpath = await nextFileName('fileIO_test_create_stream_async_014'); let fpath = await nextFileName('fileIO_test_create_stream_async_014');
try { try {
let ss = await fileIO.createStream(fpath, 'w+'); let sw = await fileIO.createStream(fpath, 'w+');
expect(ss !== null).assertTrue(); expect(sw !== null).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); expect(sw.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(ss.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); expect(sw.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
ss.closeSync(); sw.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
...@@ -884,15 +884,15 @@ describe('fileIO_fs_createStream', function () { ...@@ -884,15 +884,15 @@ describe('fileIO_fs_createStream', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
fileIO.createStream(fpath, 'w+', (err, ss) => { fileIO.createStream(fpath, 'w+', (err, sw) => {
if (err) { if (err) {
console.log('fileIO_test_create_stream_async_015 error package: ' + JSON.stringify(err)); console.log('fileIO_test_create_stream_async_015 error package: ' + JSON.stringify(err));
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(ss !== null).assertTrue(); expect(sw !== null).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); expect(sw.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(ss.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); expect(sw.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
ss.closeSync(); sw.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
......
...@@ -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) {
......
...@@ -35,15 +35,15 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -35,15 +35,15 @@ describe('fileIO_fs_FdOpenStream', async function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
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 fp = fileIO.fdopenStreamSync(file.fd, 'r'); let fpr = fileIO.fdopenStreamSync(file.fd, 'r');
try { try {
expect(fp !== null).assertTrue(); expect(fpr !== null).assertTrue();
expect(fp.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); expect(fpr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
fp.writeSync(FILE_CONTENT); fpr.writeSync(FILE_CONTENT);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
fp.closeSync(); fpr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_test_fdopenstream_sync_000 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_fdopenstream_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900005 && e.message == 'I/O error').assertTrue(); expect(e.code == 13900005 && e.message == 'I/O error').assertTrue();
...@@ -88,11 +88,11 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -88,11 +88,11 @@ describe('fileIO_fs_FdOpenStream', async function () {
try { try {
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
let fp = fileIO.fdopenStreamSync(file.fd, 'r+'); let fpr = fileIO.fdopenStreamSync(file.fd, 'r+');
expect(fp !== null).assertTrue(); expect(fpr !== null).assertTrue();
expect(fp.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); expect(fpr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
expect(fp.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); expect(fpr.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
fp.closeSync(); fpr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_fdopenstream_sync_002 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_fdopenstream_sync_002 has failed for ' + e.message + ', code: ' + e.code);
...@@ -224,9 +224,9 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -224,9 +224,9 @@ describe('fileIO_fs_FdOpenStream', async function () {
fpw.closeSync(); fpw.closeSync();
let file2 = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY); let file2 = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY);
let sr = fileIO.fdopenStreamSync(file2.fd, 'r'); let fpr = fileIO.fdopenStreamSync(file2.fd, 'r');
expect(sr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); expect(fpr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
sr.closeSync(); fpr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_fdopenstream_sync_007 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_fdopenstream_sync_007 has failed for ' + e.message + ', code: ' + e.code);
...@@ -280,15 +280,15 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -280,15 +280,15 @@ describe('fileIO_fs_FdOpenStream', async function () {
try { try {
let file1 = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); let file1 = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file1.fd)).assertTrue(); expect(isIntNum(file1.fd)).assertTrue();
let fpw = fileIO.fdopenStreamSync(file1.fd, 'a'); let fpa = fileIO.fdopenStreamSync(file1.fd, 'a');
expect(fpw !== null).assertTrue(); expect(fpa !== null).assertTrue();
expect(fpw.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); expect(fpa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
fpw.closeSync(); fpa.closeSync();
let file2 = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); let file2 = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
let sr = fileIO.fdopenStreamSync(file2.fd, 'r'); let fpr = fileIO.fdopenStreamSync(file2.fd, 'r');
expect(sr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue(); expect(fpr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue();
sr.closeSync(); fpr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_fdopenstream_sync_009 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_fdopenstream_sync_009 has failed for ' + e.message + ', code: ' + e.code);
...@@ -311,15 +311,15 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -311,15 +311,15 @@ describe('fileIO_fs_FdOpenStream', async function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
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 sa = fileIO.fdopenStreamSync(file.fd, 'a'); let fpa = fileIO.fdopenStreamSync(file.fd, 'a');
try { try {
expect(sa !== null).assertTrue(); expect(fpa !== null).assertTrue();
expect(sa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); expect(fpa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
sa.readSync(new ArrayBuffer(4096)); fpa.readSync(new ArrayBuffer(4096));
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
sa.closeSync(); fpa.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_test_fdopenstream_sync_010 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_fdopenstream_sync_010 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900005 && e.message == 'I/O error').assertTrue(); expect(e.code == 13900005 && e.message == 'I/O error').assertTrue();
...@@ -343,11 +343,11 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -343,11 +343,11 @@ describe('fileIO_fs_FdOpenStream', async function () {
try { try {
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
let sa = fileIO.fdopenStreamSync(file.fd, 'a+'); let fpa = fileIO.fdopenStreamSync(file.fd, 'a+');
expect(sa !== null).assertTrue(); expect(fpa !== null).assertTrue();
expect(sa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); expect(fpa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(sa.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue(); expect(fpa.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue();
sa.closeSync(); fpa.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
} catch (e) { } catch (e) {
console.log('fileIO_test_fdopenstream_sync_011 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_fdopenstream_sync_011 has failed for ' + e.message + ', code: ' + e.code);
...@@ -369,16 +369,16 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -369,16 +369,16 @@ describe('fileIO_fs_FdOpenStream', async function () {
let fpath = await nextFileName('fileIO_test_fdopenstream_async_000'); let fpath = await nextFileName('fileIO_test_fdopenstream_async_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
let fp = await fileIO.fdopenStream(file.fd, 'r'); let fpr = await fileIO.fdopenStream(file.fd, 'r');
try { try {
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
expect(fp !== null).assertTrue(); expect(fpr !== null).assertTrue();
expect(fp.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); expect(fpr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
fp.writeSync(FILE_CONTENT); fpr.writeSync(FILE_CONTENT);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
fp.closeSync(); fpr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_test_fdopenstream_async_000 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_fdopenstream_async_000 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900005 && e.message == 'I/O error').assertTrue(); expect(e.code == 13900005 && e.message == 'I/O error').assertTrue();
...@@ -403,16 +403,16 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -403,16 +403,16 @@ describe('fileIO_fs_FdOpenStream', async function () {
try { try {
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileIO.fdopenStream(file.fd, 'r', (err, fp) => { fileIO.fdopenStream(file.fd, 'r', (err, fpr) => {
if (err) { if (err) {
console.log('fileIO_test_fdopenstream_async_001 error package: ' + JSON.stringify(err)); console.log('fileIO_test_fdopenstream_async_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(fp !== null).assertTrue(); expect(fpr !== null).assertTrue();
expect(fp.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); expect(fpr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
fp.write(FILE_CONTENT, (err) => { fpr.write(FILE_CONTENT, (err) => {
if (err) { if (err) {
fp.closeSync(); fpr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log( console.log(
'fileIO_test_fdopenstream_async_001 error: {message: ' + err.message + ', code: ' + err.code + '}' 'fileIO_test_fdopenstream_async_001 error: {message: ' + err.message + ', code: ' + err.code + '}'
...@@ -492,11 +492,11 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -492,11 +492,11 @@ describe('fileIO_fs_FdOpenStream', async function () {
try { try {
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
let fp = await fileIO.fdopenStream(file.fd, 'r+'); let fpr = await fileIO.fdopenStream(file.fd, 'r+');
expect(fp !== null).assertTrue(); expect(fpr !== null).assertTrue();
expect(fp.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); expect(fpr.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(fp.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); expect(fpr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
fp.closeSync(); fpr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
...@@ -522,15 +522,15 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -522,15 +522,15 @@ describe('fileIO_fs_FdOpenStream', async function () {
try { try {
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileIO.fdopenStream(file.fd, 'r+', (err, fp) => { fileIO.fdopenStream(file.fd, 'r+', (err, fpr) => {
if (err) { if (err) {
console.log('fileIO_test_fdopenstream_async_005 error package: ' + JSON.stringify(err)); console.log('fileIO_test_fdopenstream_async_005 error package: ' + JSON.stringify(err));
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(fp !== null).assertTrue(); expect(fpr !== null).assertTrue();
expect(fp.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); expect(fpr.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(fp.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); expect(fpr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
fp.closeSync(); fpr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
...@@ -689,9 +689,9 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -689,9 +689,9 @@ describe('fileIO_fs_FdOpenStream', async function () {
fpw.closeSync(); fpw.closeSync();
let file2 = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); let file2 = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
let sr = await fileIO.fdopenStream(file2.fd, 'r'); let fpr = await fileIO.fdopenStream(file2.fd, 'r');
expect(sr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue(); expect(fpr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
sr.closeSync(); fpr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
...@@ -781,15 +781,15 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -781,15 +781,15 @@ describe('fileIO_fs_FdOpenStream', async function () {
try { try {
let file1 = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); let file1 = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
let fpw = await fileIO.fdopenStream(file1.fd, 'a'); let fpa = await fileIO.fdopenStream(file1.fd, 'a');
expect(fpw !== null).assertTrue(); expect(fpa !== null).assertTrue();
expect(fpw.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); expect(fpa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
fpw.closeSync(); fpa.closeSync();
let file2 = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); let file2 = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
let sr = await fileIO.fdopenStream(file2.fd, 'r'); let fpr = await fileIO.fdopenStream(file2.fd, 'r');
expect(sr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue(); expect(fpr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue();
sr.closeSync(); fpr.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
...@@ -813,15 +813,15 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -813,15 +813,15 @@ describe('fileIO_fs_FdOpenStream', async function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
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 sa = await fileIO.fdopenStream(file.fd, 'a'); let fpa = await fileIO.fdopenStream(file.fd, 'a');
try { try {
expect(sa !== null).assertTrue(); expect(fpa !== null).assertTrue();
expect(sa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); expect(fpa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
sa.readSync(new ArrayBuffer(4096)); fpa.readSync(new ArrayBuffer(4096));
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
sa.closeSync(); fpa.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_test_fdopenstream_async_014 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_fdopenstream_async_014 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900005 && e.message == 'I/O error').assertTrue(); expect(e.code == 13900005 && e.message == 'I/O error').assertTrue();
...@@ -846,16 +846,16 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -846,16 +846,16 @@ describe('fileIO_fs_FdOpenStream', async function () {
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
try { try {
fileIO.fdopenStream(file.fd, 'a', (err, sa) => { fileIO.fdopenStream(file.fd, 'a', (err, fpa) => {
if (err) { if (err) {
console.log('fileIO_test_fdopenstream_async_015 error package: ' + JSON.stringify(err)); console.log('fileIO_test_fdopenstream_async_015 error package: ' + JSON.stringify(err));
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(sa !== null).assertTrue(); expect(fpa !== null).assertTrue();
expect(sa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); expect(fpa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
sa.read(new ArrayBuffer(4096), (err) => { fpa.read(new ArrayBuffer(4096), (err) => {
if (err) { if (err) {
sa.closeSync(); fpa.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log( console.log(
'fileIO_test_fdopenstream_async_015 error: {message: ' + err.message + ', code: ' + err.code + '}' 'fileIO_test_fdopenstream_async_015 error: {message: ' + err.message + ', code: ' + err.code + '}'
...@@ -890,11 +890,11 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -890,11 +890,11 @@ describe('fileIO_fs_FdOpenStream', async function () {
try { try {
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
let sa = await fileIO.fdopenStream(file.fd, 'a+'); let fpa = await fileIO.fdopenStream(file.fd, 'a+');
expect(sa !== null).assertTrue(); expect(fpa !== null).assertTrue();
expect(sa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); expect(fpa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(sa.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue(); expect(fpa.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue();
sa.closeSync(); fpa.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
...@@ -920,15 +920,15 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -920,15 +920,15 @@ describe('fileIO_fs_FdOpenStream', async function () {
try { try {
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileIO.fdopenStream(file.fd, 'a+', (err, sa) => { fileIO.fdopenStream(file.fd, 'a+', (err, fpa) => {
if (err) { if (err) {
console.log('fileIO_test_fdopenstream_async_017 error package: ' + JSON.stringify(err)); console.log('fileIO_test_fdopenstream_async_017 error package: ' + JSON.stringify(err));
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(sa !== null).assertTrue(); expect(fpa !== null).assertTrue();
expect(sa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); expect(fpa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(sa.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue(); expect(fpa.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue();
sa.closeSync(); fpa.closeSync();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
......
...@@ -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) {
......
...@@ -57,7 +57,7 @@ export default function fileIOListfile() { ...@@ -57,7 +57,7 @@ export default function fileIOListfile() {
* Do not have prop filter.Filter files by quantity only. * Do not have prop filter.Filter files by quantity only.
* @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_listfile_sync_001', 0, async function () { it('fileIO_test_listfile_sync_001', 0, async function () {
...@@ -90,7 +90,7 @@ export default function fileIOListfile() { ...@@ -90,7 +90,7 @@ export default function fileIOListfile() {
* Do not have prop listNum. * Do not have prop listNum.
* @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_listfile_sync_002', 0, async function () { it('fileIO_test_listfile_sync_002', 0, async function () {
...@@ -129,7 +129,7 @@ export default function fileIOListfile() { ...@@ -129,7 +129,7 @@ export default function fileIOListfile() {
* Do not have prop suffix. Not filter files by suffix. * Do not have prop suffix. Not filter files by suffix.
* @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_listfile_sync_003', 0, async function () { it('fileIO_test_listfile_sync_003', 0, async function () {
...@@ -168,7 +168,7 @@ export default function fileIOListfile() { ...@@ -168,7 +168,7 @@ export default function fileIOListfile() {
* Scanfile.Retain six files in the three-level directory. * Scanfile.Retain six files in the three-level directory.
* @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_listfile_sync_004', 0, async function () { it('fileIO_test_listfile_sync_004', 0, async function () {
...@@ -226,7 +226,7 @@ export default function fileIOListfile() { ...@@ -226,7 +226,7 @@ export default function fileIOListfile() {
* Filter out files whose suffix is not '. txt' and does not meet other conditions.Two files are retained. * Filter out files whose suffix is not '. txt' and does not meet other conditions.Two files are retained.
* @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_listfile_sync_005', 0, async function () { it('fileIO_test_listfile_sync_005', 0, async function () {
...@@ -268,7 +268,7 @@ export default function fileIOListfile() { ...@@ -268,7 +268,7 @@ export default function fileIOListfile() {
* Invalid file suffix name format. * Invalid file suffix name format.
* @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_listfile_sync_006', 0, async function () { it('fileIO_test_listfile_sync_006', 0, async function () {
...@@ -308,7 +308,7 @@ export default function fileIOListfile() { ...@@ -308,7 +308,7 @@ export default function fileIOListfile() {
* Filter out all files because the size of all files less than 12. * Filter out all files because the size of all files less than 12.
* @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_listfile_sync_007', 0, async function () { it('fileIO_test_listfile_sync_007', 0, async function () {
...@@ -348,7 +348,7 @@ export default function fileIOListfile() { ...@@ -348,7 +348,7 @@ export default function fileIOListfile() {
* listNum is 0.Traverse all files. * listNum is 0.Traverse all files.
* @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_listfile_sync_008', 0, async function () { it('fileIO_test_listfile_sync_008', 0, async function () {
...@@ -390,7 +390,7 @@ export default function fileIOListfile() { ...@@ -390,7 +390,7 @@ export default function fileIOListfile() {
* Missing all arguments. * Missing all arguments.
* @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_listfile_sync_009', 0, async function () { it('fileIO_test_listfile_sync_009', 0, async function () {
...@@ -411,7 +411,7 @@ export default function fileIOListfile() { ...@@ -411,7 +411,7 @@ export default function fileIOListfile() {
* Invalid option args. * Invalid option args.
* @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_listfile_sync_010', 0, async function () { it('fileIO_test_listfile_sync_010', 0, async function () {
...@@ -463,7 +463,7 @@ export default function fileIOListfile() { ...@@ -463,7 +463,7 @@ export default function fileIOListfile() {
fileIO.rmdirSync(dpath); fileIO.rmdirSync(dpath);
}); });
} catch (e) { } catch (e) {
console.info('fileIO_test_listfile_async_000 has failed for ' + e.message + ', code:' + e.code); console.log('fileIO_test_listfile_async_000 has failed for ' + e.message + ', code:' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
} }
}); });
...@@ -475,7 +475,7 @@ export default function fileIOListfile() { ...@@ -475,7 +475,7 @@ export default function fileIOListfile() {
* Only path, do not filter file. * Only path, do not filter file.
* @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_listfile_async_001', 0, async function (done) { it('fileIO_test_listfile_async_001', 0, async function (done) {
...@@ -494,7 +494,7 @@ export default function fileIOListfile() { ...@@ -494,7 +494,7 @@ export default function fileIOListfile() {
fileIO.rmdirSync(dpath); fileIO.rmdirSync(dpath);
done(); done();
} catch (err) { } catch (err) {
console.info('fileIO_test_listfile_async_001 has failed for ' + err.message + ', code:' + err.code); console.log('fileIO_test_listfile_async_001 has failed for ' + err.message + ', code:' + err.code);
expect(false).assertTrue(); expect(false).assertTrue();
} }
}); });
...@@ -506,7 +506,7 @@ export default function fileIOListfile() { ...@@ -506,7 +506,7 @@ export default function fileIOListfile() {
* Do not have prop filter.Filter files by quantity only. * Do not have prop filter.Filter files by quantity only.
* @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_listfile_async_002', 0, async function () { it('fileIO_test_listfile_async_002', 0, async function () {
...@@ -544,7 +544,7 @@ export default function fileIOListfile() { ...@@ -544,7 +544,7 @@ export default function fileIOListfile() {
* Do not have prop filter.Filter files by quantity only. * Do not have prop filter.Filter files by quantity only.
* @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_listfile_async_003', 0, async function (done) { it('fileIO_test_listfile_async_003', 0, async function (done) {
...@@ -578,7 +578,7 @@ export default function fileIOListfile() { ...@@ -578,7 +578,7 @@ export default function fileIOListfile() {
* Do not have prop listNum. * Do not have prop listNum.
* @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_listfile_async_004', 0, async function () { it('fileIO_test_listfile_async_004', 0, async function () {
...@@ -610,7 +610,7 @@ export default function fileIOListfile() { ...@@ -610,7 +610,7 @@ export default function fileIOListfile() {
fileIO.rmdirSync(dpath); fileIO.rmdirSync(dpath);
}); });
} catch (e) { } catch (e) {
console.info('fileIO_test_listfile_async_004 has failed for ' + e.message + ', code:' + e.code); console.log('fileIO_test_listfile_async_004 has failed for ' + e.message + ', code:' + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
} }
}); });
...@@ -622,7 +622,7 @@ export default function fileIOListfile() { ...@@ -622,7 +622,7 @@ export default function fileIOListfile() {
* Do not have prop listNum. * Do not have prop listNum.
* @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_listfile_async_005', 0, async function (done) { it('fileIO_test_listfile_async_005', 0, async function (done) {
...@@ -650,7 +650,7 @@ export default function fileIOListfile() { ...@@ -650,7 +650,7 @@ export default function fileIOListfile() {
fileIO.rmdirSync(dpath); fileIO.rmdirSync(dpath);
done(); done();
} catch (err) { } catch (err) {
console.info('fileIO_test_listfile_async_005 has failed for ' + err.message + ', code:' + err.code); console.log('fileIO_test_listfile_async_005 has failed for ' + err.message + ', code:' + err.code);
expect(false).assertTrue(); expect(false).assertTrue();
} }
}); });
...@@ -662,7 +662,7 @@ export default function fileIOListfile() { ...@@ -662,7 +662,7 @@ export default function fileIOListfile() {
* Do not have prop suffix. Not filter files by suffix. * Do not have prop suffix. Not filter files by suffix.
* @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_listfile_async_006', 0, async function () { it('fileIO_test_listfile_async_006', 0, async function () {
...@@ -706,7 +706,7 @@ export default function fileIOListfile() { ...@@ -706,7 +706,7 @@ export default function fileIOListfile() {
* Do not have prop suffix. Not filter files by suffix. * Do not have prop suffix. Not filter files by suffix.
* @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_listfile_async_007', 0, async function (done) { it('fileIO_test_listfile_async_007', 0, async function (done) {
...@@ -746,7 +746,7 @@ export default function fileIOListfile() { ...@@ -746,7 +746,7 @@ export default function fileIOListfile() {
* Scanfile.Retain six files in the three-level directory. * Scanfile.Retain six files in the three-level directory.
* @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_listfile_async_008', 0, async function () { it('fileIO_test_listfile_async_008', 0, async function () {
...@@ -809,7 +809,7 @@ export default function fileIOListfile() { ...@@ -809,7 +809,7 @@ export default function fileIOListfile() {
* Scanfile.Retain six files in the three-level directory. * Scanfile.Retain six files in the three-level directory.
* @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_listfile_async_009', 0, async function (done) { it('fileIO_test_listfile_async_009', 0, async function (done) {
...@@ -868,7 +868,7 @@ export default function fileIOListfile() { ...@@ -868,7 +868,7 @@ export default function fileIOListfile() {
* Filter out files whose suffix is not '. txt' and does not meet other conditions.Two files are retained. * Filter out files whose suffix is not '. txt' and does not meet other conditions.Two files are retained.
* @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_listfile_async_010', 0, async function () { it('fileIO_test_listfile_async_010', 0, async function () {
...@@ -915,7 +915,7 @@ export default function fileIOListfile() { ...@@ -915,7 +915,7 @@ export default function fileIOListfile() {
* Filter out files whose suffix is not '. txt' and does not meet other conditions.Two files are retained. * Filter out files whose suffix is not '. txt' and does not meet other conditions.Two files are retained.
* @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_listfile_async_011', 0, async function (done) { it('fileIO_test_listfile_async_011', 0, async function (done) {
...@@ -958,7 +958,7 @@ export default function fileIOListfile() { ...@@ -958,7 +958,7 @@ export default function fileIOListfile() {
* Invalid file suffix name format. * Invalid file suffix name format.
* @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_listfile_async_012', 0, async function () { it('fileIO_test_listfile_async_012', 0, async function () {
...@@ -1001,7 +1001,7 @@ export default function fileIOListfile() { ...@@ -1001,7 +1001,7 @@ export default function fileIOListfile() {
* Invalid file suffix name format. * Invalid file suffix name format.
* @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_listfile_async_013', 0, async function (done) { it('fileIO_test_listfile_async_013', 0, async function (done) {
...@@ -1044,7 +1044,7 @@ export default function fileIOListfile() { ...@@ -1044,7 +1044,7 @@ export default function fileIOListfile() {
* Filter out all files because the size of all files less than 12. * Filter out all files because the size of all files less than 12.
* @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_listfile_async_014', 0, async function () { it('fileIO_test_listfile_async_014', 0, async function () {
...@@ -1089,7 +1089,7 @@ export default function fileIOListfile() { ...@@ -1089,7 +1089,7 @@ export default function fileIOListfile() {
* Filter out all files because the size of all files less than 12. * Filter out all files because the size of all files less than 12.
* @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_listfile_async_015', 0, async function (done) { it('fileIO_test_listfile_async_015', 0, async function (done) {
...@@ -1130,7 +1130,7 @@ export default function fileIOListfile() { ...@@ -1130,7 +1130,7 @@ export default function fileIOListfile() {
* listNum is 0.Traverse all files. * listNum is 0.Traverse all files.
* @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_listfile_async_016', 0, async function () { it('fileIO_test_listfile_async_016', 0, async function () {
...@@ -1177,7 +1177,7 @@ export default function fileIOListfile() { ...@@ -1177,7 +1177,7 @@ export default function fileIOListfile() {
* listNum is 0.Traverse all files. * listNum is 0.Traverse all files.
* @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_listfile_async_017', 0, async function (done) { it('fileIO_test_listfile_async_017', 0, async function (done) {
...@@ -1220,7 +1220,7 @@ export default function fileIOListfile() { ...@@ -1220,7 +1220,7 @@ export default function fileIOListfile() {
* Missing all arguments. * Missing all arguments.
* @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_listfile_async_018', 0, async function (done) { it('fileIO_test_listfile_async_018', 0, async function (done) {
...@@ -1242,7 +1242,7 @@ export default function fileIOListfile() { ...@@ -1242,7 +1242,7 @@ export default function fileIOListfile() {
* Invalid option args. * Invalid option args.
* @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_listfile_async_019', 0, async function (done) { it('fileIO_test_listfile_async_019', 0, async function (done) {
......
...@@ -96,7 +96,7 @@ describe('fileIO_fs_mkdir', function () { ...@@ -96,7 +96,7 @@ describe('fileIO_fs_mkdir', function () {
* @tc.require * @tc.require
*/ */
it('fileIO_test_mkdir_sync_003', 0, async function () { it('fileIO_test_mkdir_sync_003', 0, async function () {
let fpath = await nextFileName('fileIO_test_open_sync_000'); let fpath = await nextFileName('fileIO_test_mkdir_sync_003');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
...@@ -198,7 +198,7 @@ describe('fileIO_fs_mkdir', function () { ...@@ -198,7 +198,7 @@ describe('fileIO_fs_mkdir', function () {
try { try {
fileIO.mkdir('/', (err) => { fileIO.mkdir('/', (err) => {
if(err) { if(err) {
console.log('fileIO_test_mkdir_async_003 error package: {' + err.message + ', code: ' + err.code + '}'); console.log('fileIO_test_mkdir_async_003 error: {message: ' + err.message + ', code: ' + err.code + '}');
expect(err.code == 13900015 && err.message == 'File exists').assertTrue(); expect(err.code == 13900015 && err.message == 'File exists').assertTrue();
done(); done();
} }
......
...@@ -21,7 +21,7 @@ export default function fileIOMoveFile() { ...@@ -21,7 +21,7 @@ export default function fileIOMoveFile() {
describe('fileIO_fs_moveFile', function () { describe('fileIO_fs_moveFile', function () {
/** /**
* @tc.number SUB_DF_FILEIO_MOVEFILESYNC_0000 * @tc.number SUB_DF_FILEIO_MOVEFILE_SYNC_0000
* @tc.name fileIO_test_moveFile_sync_000 * @tc.name fileIO_test_moveFile_sync_000
* @tc.desc Test moveFileSync() interface. * @tc.desc Test moveFileSync() interface.
* Move a single file, shall work properly in normal case. * Move a single file, shall work properly in normal case.
...@@ -51,13 +51,13 @@ export default function fileIOMoveFile() { ...@@ -51,13 +51,13 @@ export default function fileIOMoveFile() {
}); });
/** /**
* @tc.number SUB_DF_FILEIO_MOVEFILESYNC_0100 * @tc.number SUB_DF_FILEIO_MOVEFILE_SYNC_0100
* @tc.name fileIO_test_moveFile_sync_001 * @tc.name fileIO_test_moveFile_sync_001
* @tc.desc Test moveFileSync() interface. * @tc.desc Test moveFileSync() interface.
* A file with the same name already exists under the destination path. * A file with the same name already exists under the destination path.
* @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_moveFile_sync_001', 0, async function () { it('fileIO_test_moveFile_sync_001', 0, async function () {
...@@ -81,13 +81,13 @@ export default function fileIOMoveFile() { ...@@ -81,13 +81,13 @@ export default function fileIOMoveFile() {
}); });
/** /**
* @tc.number SUB_DF_FILEIO_MOVEFILESYNC_0200 * @tc.number SUB_DF_FILEIO_MOVEFILE_SYNC_0200
* @tc.name fileIO_test_moveFile_sync_002 * @tc.name fileIO_test_moveFile_sync_002
* @tc.desc Test moveFileSync() interface. * @tc.desc Test moveFileSync() interface.
* The path point to nothing, no such file. * The path point to nothing, no such file.
* @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_moveFile_sync_002', 0, async function () { it('fileIO_test_moveFile_sync_002', 0, async function () {
...@@ -109,13 +109,13 @@ export default function fileIOMoveFile() { ...@@ -109,13 +109,13 @@ export default function fileIOMoveFile() {
}); });
/** /**
* @tc.number SUB_DF_FILEIO_MOVEFILESYNC_0400 * @tc.number SUB_DF_FILEIO_MOVEFILE_SYNC_0400
* @tc.name fileIO_test_moveFile_sync_004 * @tc.name fileIO_test_moveFile_sync_004
* @tc.desc Test moveFileSync() interface. * @tc.desc Test moveFileSync() interface.
* The path point to a directory, not a file. * The path point to a directory, not a file.
* @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_moveFile_sync_004', 0, async function () { it('fileIO_test_moveFile_sync_004', 0, async function () {
...@@ -134,13 +134,13 @@ export default function fileIOMoveFile() { ...@@ -134,13 +134,13 @@ export default function fileIOMoveFile() {
}); });
/** /**
* @tc.number SUB_DF_FILEIO_MOVEFILESYNC_0500 * @tc.number SUB_DF_FILEIO_MOVEFILE_SYNC_0500
* @tc.name fileIO_test_moveFile_sync_005 * @tc.name fileIO_test_moveFile_sync_005
* @tc.desc Test moveFileSync() interface. * @tc.desc Test moveFileSync() interface.
* 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_moveFile_sync_005', 0, async function () { it('fileIO_test_moveFile_sync_005', 0, async function () {
...@@ -158,13 +158,13 @@ export default function fileIOMoveFile() { ...@@ -158,13 +158,13 @@ export default function fileIOMoveFile() {
}); });
/** /**
* @tc.number SUB_DF_FILEIO_MOVEFILESYNC_0600 * @tc.number SUB_DF_FILEIO_MOVEFILE_SYNC_0600
* @tc.name fileIO_test_moveFile_sync_006 * @tc.name fileIO_test_moveFile_sync_006
* @tc.desc Test moveFileSync() interface. * @tc.desc Test moveFileSync() interface.
* Entry parameters increase forced movement when mode = 0. * Entry parameters increase forced movement when mode = 0.
* @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_moveFile_sync_006', 0, async function () { it('fileIO_test_moveFile_sync_006', 0, async function () {
...@@ -189,7 +189,7 @@ export default function fileIOMoveFile() { ...@@ -189,7 +189,7 @@ export default function fileIOMoveFile() {
}); });
/** /**
* @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0000 * @tc.number SUB_DF_FILEIO_MOVEFILE_ASYNC_0000
* @tc.name fileIO_test_moveFile_async_000 * @tc.name fileIO_test_moveFile_async_000
* @tc.desc Test moveFile() interface. Promise. * @tc.desc Test moveFile() interface. Promise.
* Move a single file, shall work properly in normal case. * Move a single file, shall work properly in normal case.
...@@ -220,13 +220,13 @@ export default function fileIOMoveFile() { ...@@ -220,13 +220,13 @@ export default function fileIOMoveFile() {
}); });
/** /**
* @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0100 * @tc.number SUB_DF_FILEIO_MOVEFILE_ASYNC_0100
* @tc.name fileIO_test_moveFile_async_001 * @tc.name fileIO_test_moveFile_async_001
* @tc.desc Test moveFile() interface. Callback. * @tc.desc Test moveFile() interface. Callback.
* Move a single file, shall work properly in normal case. * Move a single file, shall work properly in normal case.
* @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_moveFile_async_001', 0, async function (done) { it('fileIO_test_moveFile_async_001', 0, async function (done) {
...@@ -256,13 +256,13 @@ export default function fileIOMoveFile() { ...@@ -256,13 +256,13 @@ export default function fileIOMoveFile() {
}); });
/** /**
* @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0200 * @tc.number SUB_DF_FILEIO_MOVEFILE_ASYNC_0200
* @tc.name fileIO_test_moveFile_async_002 * @tc.name fileIO_test_moveFile_async_002
* @tc.desc Test moveFile() interface. Promise. * @tc.desc Test moveFile() interface. Promise.
* A file with the same name already exists under the destination path. * A file with the same name already exists under the destination path.
* @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_moveFile_async_002', 0, async function (done) { it('fileIO_test_moveFile_async_002', 0, async function (done) {
...@@ -287,13 +287,13 @@ export default function fileIOMoveFile() { ...@@ -287,13 +287,13 @@ export default function fileIOMoveFile() {
}); });
/** /**
* @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0300 * @tc.number SUB_DF_FILEIO_MOVEFILE_ASYNC_0300
* @tc.name fileIO_test_moveFile_async_003 * @tc.name fileIO_test_moveFile_async_003
* @tc.desc Test moveFile() interface. Callback. * @tc.desc Test moveFile() interface. Callback.
* A file with the same name already exists under the destination path. * A file with the same name already exists under the destination path.
* @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_moveFile_async_003', 0, async function (done) { it('fileIO_test_moveFile_async_003', 0, async function (done) {
...@@ -310,7 +310,7 @@ export default function fileIOMoveFile() { ...@@ -310,7 +310,7 @@ export default function fileIOMoveFile() {
fileIO.moveFile(fpath, ffpath, 1, (err) => { fileIO.moveFile(fpath, ffpath, 1, (err) => {
if (err) { if (err) {
fileIO.rmdirSync(dpath); fileIO.rmdirSync(dpath);
console.log('fileIO_test_moveFile_async_003 error package: {' + err.message + ', code: ' + err.code + '}'); console.log('fileIO_test_moveFile_async_003 error: {message: ' + err.message + ', code: ' + err.code + '}');
expect(err.code == 13900015 && err.message == 'File exists').assertTrue(); expect(err.code == 13900015 && err.message == 'File exists').assertTrue();
done(); done();
} }
...@@ -322,13 +322,13 @@ export default function fileIOMoveFile() { ...@@ -322,13 +322,13 @@ export default function fileIOMoveFile() {
}); });
/** /**
* @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0400 * @tc.number SUB_DF_FILEIO_MOVEFILE_ASYNC_0400
* @tc.name fileIO_test_moveFile_async_004 * @tc.name fileIO_test_moveFile_async_004
* @tc.desc Test moveFile() interface. Promise. * @tc.desc Test moveFile() interface. Promise.
* The path point to nothing, no such file. * The path point to nothing, no such file.
* @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_moveFile_async_004', 0, async function (done) { it('fileIO_test_moveFile_async_004', 0, async function (done) {
...@@ -351,13 +351,13 @@ export default function fileIOMoveFile() { ...@@ -351,13 +351,13 @@ export default function fileIOMoveFile() {
}); });
/** /**
* @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0500 * @tc.number SUB_DF_FILEIO_MOVEFILE_ASYNC_0500
* @tc.name fileIO_test_moveFile_async_005 * @tc.name fileIO_test_moveFile_async_005
* @tc.desc Test moveFile() interface. Callback. * @tc.desc Test moveFile() interface. Callback.
* The path point to nothing, no such file. * The path point to nothing, no such file.
* @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_moveFile_async_005', 0, async function (done) { it('fileIO_test_moveFile_async_005', 0, async function (done) {
...@@ -372,7 +372,7 @@ export default function fileIOMoveFile() { ...@@ -372,7 +372,7 @@ export default function fileIOMoveFile() {
fileIO.moveFile(fpath, ffpath, (err) => { fileIO.moveFile(fpath, ffpath, (err) => {
if (err) { if (err) {
fileIO.rmdirSync(dpath); fileIO.rmdirSync(dpath);
console.log('fileIO_test_moveFile_async_005 error package: {' + err.message + ', code: ' + err.code + '}'); console.log('fileIO_test_moveFile_async_005 error: {message: ' + err.message + ', code: ' + err.code + '}');
expect(err.code == 13900002 && err.message == 'No such file or directory').assertTrue(); expect(err.code == 13900002 && err.message == 'No such file or directory').assertTrue();
done(); done();
} }
...@@ -384,13 +384,13 @@ export default function fileIOMoveFile() { ...@@ -384,13 +384,13 @@ export default function fileIOMoveFile() {
}); });
/** /**
* @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0600 * @tc.number SUB_DF_FILEIO_MOVEFILE_ASYNC_0600
* @tc.name fileIO_test_moveFile_async_006 * @tc.name fileIO_test_moveFile_async_006
* @tc.desc Test moveFile() interface. Promise. * @tc.desc Test moveFile() interface. Promise.
* The path point to a directory, not a file. * The path point to a directory, not a file.
* @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_moveFile_async_006', 0, async function (done) { it('fileIO_test_moveFile_async_006', 0, async function (done) {
...@@ -410,13 +410,13 @@ export default function fileIOMoveFile() { ...@@ -410,13 +410,13 @@ export default function fileIOMoveFile() {
}); });
/** /**
* @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0700 * @tc.number SUB_DF_FILEIO_MOVEFILE_ASYNC_0700
* @tc.name fileIO_test_moveFile_async_007 * @tc.name fileIO_test_moveFile_async_007
* @tc.desc Test moveFile() interface. Callback. * @tc.desc Test moveFile() interface. Callback.
* The path point to a directory, not a file. * The path point to a directory, not a file.
* @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_moveFile_async_007', 0, async function (done) { it('fileIO_test_moveFile_async_007', 0, async function (done) {
...@@ -440,13 +440,13 @@ export default function fileIOMoveFile() { ...@@ -440,13 +440,13 @@ export default function fileIOMoveFile() {
}); });
/** /**
* @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0800 * @tc.number SUB_DF_FILEIO_MOVEFILE_ASYNC_0800
* @tc.name fileIO_test_moveFile_async_008 * @tc.name fileIO_test_moveFile_async_008
* @tc.desc Test moveFile() interface. Promise. * @tc.desc Test moveFile() interface. 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_moveFile_async_008', 0, async function (done) { it('fileIO_test_moveFile_async_008', 0, async function (done) {
...@@ -465,13 +465,13 @@ export default function fileIOMoveFile() { ...@@ -465,13 +465,13 @@ export default function fileIOMoveFile() {
}); });
/** /**
* @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0900 * @tc.number SUB_DF_FILEIO_MOVEFILE_ASYNC_0900
* @tc.name fileIO_test_moveFile_async_009 * @tc.name fileIO_test_moveFile_async_009
* @tc.desc Test moveFile() interface. Promise. * @tc.desc Test moveFile() interface. Promise.
* Entry parameters increase forced movement when mode = 0. * Entry parameters increase forced movement when mode = 0.
* @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_moveFile_async_009', 0, async function (done) { it('fileIO_test_moveFile_async_009', 0, async function (done) {
...@@ -497,13 +497,13 @@ export default function fileIOMoveFile() { ...@@ -497,13 +497,13 @@ export default function fileIOMoveFile() {
}); });
/** /**
* @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_1000 * @tc.number SUB_DF_FILEIO_MOVEFILE_ASYNC_1000
* @tc.name fileIO_test_moveFile_async_010 * @tc.name fileIO_test_moveFile_async_010
* @tc.desc Test moveFile() interface. Callback. * @tc.desc Test moveFile() interface. Callback.
* Entry parameters increase forced movement when mode = 0. * Entry parameters increase forced movement when mode = 0.
* @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_moveFile_async_010', 0, async function (done) { it('fileIO_test_moveFile_async_010', 0, async function (done) {
......
...@@ -52,7 +52,7 @@ describe('fileIO_fs_symlink', function () { ...@@ -52,7 +52,7 @@ describe('fileIO_fs_symlink', function () {
* Missing parameter. * Missing 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_symlink_sync_001', 0, async function () { it('fileIO_test_symlink_sync_001', 0, async function () {
...@@ -84,10 +84,10 @@ describe('fileIO_fs_symlink', function () { ...@@ -84,10 +84,10 @@ describe('fileIO_fs_symlink', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
fileIO.symlink(fpath, fpath + 'link3').then(() => { fileIO.symlink(fpath, fpath + 'link1').then(() => {
expect(fileIO.accessSync(fpath + 'link3')).assertTrue(); expect(fileIO.accessSync(fpath + 'link1')).assertTrue();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
fileIO.unlinkSync(fpath + 'link3'); fileIO.unlinkSync(fpath + 'link1');
}).catch((err) => { }).catch((err) => {
console.log('fileIO_test_symlink_async_000 error package: ' + JSON.stringify(err)); console.log('fileIO_test_symlink_async_000 error package: ' + JSON.stringify(err));
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -106,7 +106,7 @@ describe('fileIO_fs_symlink', function () { ...@@ -106,7 +106,7 @@ describe('fileIO_fs_symlink', function () {
* Create a symbolic link to verify normal function. * Create a symbolic link to verify normal 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_symlink_async_001', 0, async function (done) { it('fileIO_test_symlink_async_001', 0, async function (done) {
...@@ -114,10 +114,10 @@ describe('fileIO_fs_symlink', function () { ...@@ -114,10 +114,10 @@ describe('fileIO_fs_symlink', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
await fileIO.symlink(fpath, fpath + 'link4'); await fileIO.symlink(fpath, fpath + 'link2');
expect(fileIO.accessSync(fpath + 'link4')).assertTrue(); expect(fileIO.accessSync(fpath + 'link2')).assertTrue();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
fileIO.unlinkSync(fpath + 'link4'); fileIO.unlinkSync(fpath + 'link2');
done(); done();
} catch (e) { } catch (e) {
console.log('fileIO_test_symlink_async_001 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_symlink_async_001 has failed for ' + e.message + ', code: ' + e.code);
...@@ -132,7 +132,7 @@ describe('fileIO_fs_symlink', function () { ...@@ -132,7 +132,7 @@ describe('fileIO_fs_symlink', function () {
* Create a symbolic link to verify normal function. * Create a symbolic link to verify normal 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_symlink_async_002', 0, async function (done) { it('fileIO_test_symlink_async_002', 0, async function (done) {
...@@ -140,14 +140,14 @@ describe('fileIO_fs_symlink', function () { ...@@ -140,14 +140,14 @@ describe('fileIO_fs_symlink', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
fileIO.symlink(fpath, fpath + 'link5', (err) => { fileIO.symlink(fpath, fpath + 'link3', (err) => {
if (err) { if (err) {
console.log('fileIO_test_symlink_async_002 error package: ' + JSON.stringify(err)); console.log('fileIO_test_symlink_async_002 error package: ' + JSON.stringify(err));
expect(false).assertTrue(); expect(false).assertTrue();
} }
expect(fileIO.accessSync(fpath + 'link5')).assertTrue(); expect(fileIO.accessSync(fpath + 'link3')).assertTrue();
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
fileIO.unlinkSync(fpath + 'link5'); fileIO.unlinkSync(fpath + 'link3');
done(); done();
}); });
} catch (e) { } catch (e) {
...@@ -163,7 +163,7 @@ describe('fileIO_fs_symlink', function () { ...@@ -163,7 +163,7 @@ describe('fileIO_fs_symlink', function () {
* Missing parameter. * Missing 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_symlink_async_003', 0, async function (done) { it('fileIO_test_symlink_async_003', 0, async function (done) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册