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

!7643 【file_api】统一修改用例注释标签,除去旧接口的引入

Merge pull request !7643 from zhuhongtao666/modefied_code
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Copyright (C) 2022-2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
......@@ -13,7 +13,6 @@
* limitations under the License.
*/
import fileio from '@ohos.fileio';
import fileIO from '@ohos.file.fs';
import util from '@ohos.util';
import featureAbility from '@ohos.ability.featureAbility';
......@@ -30,8 +29,8 @@ export function prepareFile(fpath, content) {
let file = fileIO.openSync(fpath, fileIO.OpenMode.CREATE | fileIO.OpenMode.READ_WRITE)
fileIO.truncateSync(file.fd)
fileIO.writeSync(file.fd, content)
fileio.fsyncSync(file.fd)
fileio.closeSync(file.fd)
fileIO.fsyncSync(file.fd)
fileIO.closeSync(file)
return true
}
catch (e) {
......@@ -40,46 +39,6 @@ export function prepareFile(fpath, content) {
}
}
export function prepareEmptyFile(fpath) {
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.CREATE | fileIO.OpenMode.READ_WRITE)
fileio.closeSync(file.fd)
return true
}
catch (e) {
console.log('Failed to prepareFile for ' + e)
return false
}
}
export function fileToReadOnly(fpath) {
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.CREATE)
fileio.fchmodSync(file.fd, 0o444)
fileio.fsyncSync(file.fd)
fileio.closeSync(file.fd)
return true
}
catch (e) {
console.log('Failed to fileToReadOnly for ' + e);
return false
}
}
export function fileToWriteOnly(fpath) {
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.CREATE | fileIO.OpenMode.WRITE_ONLY)
fileio.fchmodSync(file.fd, 0o222)
fileio.fsyncSync(file.fd)
fileio.closeSync(file.fd)
return true
}
catch (e) {
console.log('Failed to fileToWriteOnly ' + e)
return false
}
}
export async function nextFileName(testName) {
let context = featureAbility.getContext();
let data = await context.getCacheDir();
......@@ -105,15 +64,6 @@ export function randomString(num) {
return pwd;
}
export function forceRemoveDir(path, num) {
for (let i = num; i >= 0; i--) {
if (i < num) {
path = path.replace(`/d${i}`, "");
}
fileio.rmdirSync(path);
}
}
function isIntNum(val) {
return typeof val === 'number' && val % 1 === 0;
}
......@@ -126,22 +76,11 @@ function isString(str) {
return (typeof str == 'string') && str.constructor == String;
}
function isBoolean(val) {
return typeof val == 'boolean';
}
function isInclude(error, message) {
return error.toString().indexOf(message) != -1;
}
export {
fileio,
fileIO,
isIntNum,
isBigInt,
isString,
isBoolean,
isInclude,
describe,
it,
expect,
......
......@@ -21,7 +21,7 @@ export default function fileIOStreamClose() {
describe('fileIO_fs_stream_close', function () {
/**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSESYNC_0000
* @tc.number SUB_DF_FILEIO_STREAM_CLOSE_SYNC_0000
* @tc.name fileIO_test_stream_close_sync_000
* @tc.desc Test the closeSync() interface of class Stream.
* Open a file stream, close file stream.
......@@ -35,9 +35,9 @@ describe('fileIO_fs_stream_close', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ss = fileIO.createStreamSync(fpath, 'r');
expect(ss !== null).assertTrue();
ss.closeSync();
let sr = fileIO.createStreamSync(fpath, 'r');
expect(sr !== null).assertTrue();
sr.closeSync();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_stream_close_sync_000 has failed for ' + e.message + ', code: ' + e.code);
......@@ -46,7 +46,7 @@ describe('fileIO_fs_stream_close', function () {
})
/**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSESYNC_0100
* @tc.number SUB_DF_FILEIO_STREAM_CLOSE_SYNC_0100
* @tc.name fileIO_test_stream_close_sync_001
* @tc.desc Test the closeSync() interface of class Stream.
* Invalid parameter, don't requrie any parameters.
......@@ -58,14 +58,14 @@ describe('fileIO_fs_stream_close', function () {
it('fileIO_test_stream_close_sync_001', 0, async function () {
let fpath = await nextFileName('fileIO_test_stream_close_sync_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let ss = fileIO.createStreamSync(fpath, 'r');
let sr = fileIO.createStreamSync(fpath, 'r');
try {
expect(ss !== null).assertTrue();
ss.closeSync(1);
expect(sr !== null).assertTrue();
sr.closeSync(1);
expect(false).assertTrue();
} catch (e) {
ss.closeSync();
sr.closeSync();
fileIO.unlinkSync(fpath);
console.log('fileIO_test_stream_close_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
......@@ -73,7 +73,7 @@ describe('fileIO_fs_stream_close', function () {
})
/**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSESYNC_0200
* @tc.number SUB_DF_FILEIO_STREAM_CLOSE_SYNC_0200
* @tc.name fileIO_test_stream_close_sync_002
* @tc.desc Test the closeSync() interface of class Stream.
* The file stream has been closed.
......@@ -85,12 +85,12 @@ describe('fileIO_fs_stream_close', function () {
it('fileIO_test_stream_close_sync_002', 0, async function () {
let fpath = await nextFileName('fileIO_test_stream_close_sync_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let ss = fileIO.createStreamSync(fpath, 'r');
let sr = fileIO.createStreamSync(fpath, 'r');
try {
expect(ss !== null).assertTrue();
ss.closeSync();
ss.closeSync();
expect(sr !== null).assertTrue();
sr.closeSync();
sr.closeSync();
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
......@@ -100,7 +100,7 @@ describe('fileIO_fs_stream_close', function () {
})
/**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSEASYNC_0000
* @tc.number SUB_DF_FILEIO_STREAM_CLOSE_ASYNC_0000
* @tc.name fileIO_test_stream_close_async_000
* @tc.desc Test the close() interface of class Stream. Promise.
* Open a file stream, close file stream.
......@@ -114,9 +114,9 @@ describe('fileIO_fs_stream_close', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ss = fileIO.createStreamSync(fpath, 'r');
expect(ss !== null).assertTrue();
await ss.close();
let sr = fileIO.createStreamSync(fpath, 'r');
expect(sr !== null).assertTrue();
await sr.close();
fileIO.unlinkSync(fpath);
done();
} catch (e) {
......@@ -126,7 +126,7 @@ describe('fileIO_fs_stream_close', function () {
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSEASYNC_0100
* @tc.number SUB_DF_FILEIO_STREAM_CLOSE_ASYNC_0100
* @tc.name fileIO_test_stream_close_async_001
* @tc.desc Test the close() interface of class Stream. Callback.
* Open a file stream, close file stream.
......@@ -140,9 +140,9 @@ describe('fileIO_fs_stream_close', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ss = fileIO.createStreamSync(fpath, 'r');
expect(ss !== null).assertTrue();
ss.close((err) => {
let sr = fileIO.createStreamSync(fpath, 'r');
expect(sr !== null).assertTrue();
sr.close((err) => {
if (err) {
console.log('fileIO_test_stream_close_async_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
......@@ -157,7 +157,7 @@ describe('fileIO_fs_stream_close', function () {
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSEASYNC_0200
* @tc.number SUB_DF_FILEIO_STREAM_CLOSE_ASYNC_0200
* @tc.name fileIO_test_stream_close_async_002
* @tc.desc Test the close() interface of class Stream. Promise.
* The file stream has been closed.
......@@ -171,10 +171,10 @@ describe('fileIO_fs_stream_close', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ss = fileIO.createStreamSync(fpath, 'r');
expect(ss !== null).assertTrue();
await ss.close();
await ss.close();
let sr = fileIO.createStreamSync(fpath, 'r');
expect(sr !== null).assertTrue();
await sr.close();
await sr.close();
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
......@@ -185,7 +185,7 @@ describe('fileIO_fs_stream_close', function () {
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSEASYNC_0300
* @tc.number SUB_DF_FILEIO_STREAM_CLOSE_ASYNC_0300
* @tc.name fileIO_test_stream_close_async_003
* @tc.desc Test the close() interface of class Stream. Promise.
* Invalid parameter, don't requrie any parameters.
......@@ -199,9 +199,9 @@ describe('fileIO_fs_stream_close', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ss = fileIO.createStreamSync(fpath, 'r');
expect(ss !== null).assertTrue();
await ss.close(1);
let sr = fileIO.createStreamSync(fpath, 'r');
expect(sr !== null).assertTrue();
await sr.close(1);
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
......
......@@ -21,7 +21,7 @@ export default function fileIOStreamFlush() {
describe('fileIO_fs_stream_flush', function () {
/**
* @tc.number SUB_DF_FILEIO_STREAM_FLUSHSYNC_0000
* @tc.number SUB_DF_FILEIO_STREAM_FLUSH_SYNC_0000
* @tc.name fileIO_test_stream_flush_sync_000
* @tc.desc Test the flushSync() interface of class Stream.
* Refresh file stream.
......@@ -35,11 +35,11 @@ describe('fileIO_fs_stream_flush', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ss = fileIO.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
ss.flushSync();
ss.closeSync();
let sr = fileIO.createStreamSync(fpath, 'r+');
expect(sr !== null).assertTrue();
expect(sr.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
sr.flushSync();
sr.closeSync();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_stream_flush_sync_000 has failed for ' + e.message + ', code: ' + e.code);
......@@ -48,7 +48,7 @@ describe('fileIO_fs_stream_flush', function () {
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_FLUSHSYNC_0100
* @tc.number SUB_DF_FILEIO_STREAM_FLUSH_SYNC_0100
* @tc.name fileIO_test_stream_flush_sync_001
* @tc.desc Test the flushSync() interface of class Stream.
* Invalid parameter, don't requrie any parameters.
......@@ -60,14 +60,14 @@ describe('fileIO_fs_stream_flush', function () {
it('fileIO_test_stream_flush_sync_001', 0, async function () {
let fpath = await nextFileName('fileIO_test_stream_flush_sync_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let ss = fileIO.createStreamSync(fpath, 'r+');
let sr = fileIO.createStreamSync(fpath, 'r+');
try {
expect(ss !== null).assertTrue();
ss.flushSync(1);
expect(sr !== null).assertTrue();
sr.flushSync(1);
expect(false).assertTrue();
} catch (e) {
ss.closeSync();
sr.closeSync();
fileIO.unlinkSync(fpath);
console.log('fileIO_test_stream_flush_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
......@@ -75,7 +75,7 @@ describe('fileIO_fs_stream_flush', function () {
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_FLUSHASYNC_0000
* @tc.number SUB_DF_FILEIO_STREAM_FLUSH_ASYNC_0000
* @tc.name fileIO_test_stream_flush_async_000
* @tc.desc Test the flush() interface of class Stream. Promise.then().catch()
* Refresh the file stream.
......@@ -89,11 +89,11 @@ describe('fileIO_fs_stream_flush', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ss = await fileIO.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
ss.flush().then(() => {
ss.closeSync();
let sr = await fileIO.createStreamSync(fpath, 'r+');
expect(sr !== null).assertTrue();
expect(sr.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
sr.flush().then(() => {
sr.closeSync();
fileIO.unlinkSync(fpath);
done();
}).catch((err) => {
......@@ -107,7 +107,7 @@ describe('fileIO_fs_stream_flush', function () {
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_FLUSHASYNC_0100
* @tc.number SUB_DF_FILEIO_STREAM_FLUSH_ASYNC_0100
* @tc.name fileIO_test_stream_flush_async_001
* @tc.desc Test the flush() interface of class Stream. Callback.
* Refresh the file stream.
......@@ -121,15 +121,15 @@ describe('fileIO_fs_stream_flush', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ss = await fileIO.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
ss.flush((err) => {
let sr = await fileIO.createStreamSync(fpath, 'r+');
expect(sr !== null).assertTrue();
expect(sr.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
sr.flush((err) => {
if (err) {
console.log('fileIO_test_stream_flush_async_001 error package' + JSON.stringify(err));
expect(false).assertTrue();
}
ss.closeSync();
sr.closeSync();
fileIO.unlinkSync(fpath);
done();
})
......@@ -140,7 +140,7 @@ describe('fileIO_fs_stream_flush', function () {
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_FLUSHASYNC_0100
* @tc.number SUB_DF_FILEIO_STREAM_FLUSH_ASYNC_0100
* @tc.name fileIO_test_stream_flush_async_001
* @tc.desc Test the flush() interface of class Stream. Promise.
* Refresh the file stream.
......@@ -153,14 +153,14 @@ describe('fileIO_fs_stream_flush', function () {
it('fileIO_test_stream_flush_sync_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_stream_flush_sync_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let ss = fileIO.createStreamSync(fpath, 'r+');
let sr = fileIO.createStreamSync(fpath, 'r+');
try {
expect(ss !== null).assertTrue();
await ss.flush(1);
expect(sr !== null).assertTrue();
await sr.flush(1);
expect(false).assertTrue();
} catch (e) {
ss.closeSync();
sr.closeSync();
fileIO.unlinkSync(fpath);
console.log('fileIO_test_stream_flush_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
......
......@@ -35,11 +35,11 @@ describe('fileIO_fs_stream_read', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ss = fileIO.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue();
let readout = ss.readSync(new ArrayBuffer(4096));
expect(readout == FILE_CONTENT.length).assertTrue();
ss.closeSync();
let sr = fileIO.createStreamSync(fpath, 'r+');
expect(sr !== null).assertTrue();
let readLen = sr.readSync(new ArrayBuffer(4096));
expect(readLen == FILE_CONTENT.length).assertTrue();
sr.closeSync();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_stream_read_sync_000 has failed for ' + e.message + ', code: ' + e.code);
......@@ -62,11 +62,11 @@ describe('fileIO_fs_stream_read', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ss = fileIO.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue();
let readout = ss.readSync(new ArrayBuffer(4096), { length: 2 });
expect(readout == 2).assertTrue();
ss.closeSync();
let sr = fileIO.createStreamSync(fpath, 'r+');
expect(sr !== null).assertTrue();
let readLen = sr.readSync(new ArrayBuffer(4096), { length: 2 });
expect(readLen == 2).assertTrue();
sr.closeSync();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_stream_read_sync_001 has failed for ' + e.message + ', code: ' + e.code);
......@@ -89,11 +89,11 @@ describe('fileIO_fs_stream_read', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ss = fileIO.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue();
let readout = ss.readSync(new ArrayBuffer(4096), { offset: 2 });
expect(readout == FILE_CONTENT.length - 2).assertTrue();
ss.closeSync();
let sr = fileIO.createStreamSync(fpath, 'r+');
expect(sr !== null).assertTrue();
let readLen = sr.readSync(new ArrayBuffer(4096), { offset: 2 });
expect(readLen == FILE_CONTENT.length - 2).assertTrue();
sr.closeSync();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_stream_read_sync_002 has failed for ' + e.message + ', code: ' + e.code);
......@@ -116,14 +116,14 @@ describe('fileIO_fs_stream_read', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ss = fileIO.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue();
let readout = ss.readSync(new ArrayBuffer(4096), {
let sr = fileIO.createStreamSync(fpath, 'r+');
expect(sr !== null).assertTrue();
let readLen = sr.readSync(new ArrayBuffer(4096), {
offset: 1,
length: FILE_CONTENT.length
});
expect(readout == FILE_CONTENT.length - 1).assertTrue();
ss.closeSync();
expect(readLen == FILE_CONTENT.length - 1).assertTrue();
sr.closeSync();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_stream_read_sync_003 has failed for ' + e.message + ', code: ' + e.code);
......@@ -144,14 +144,14 @@ describe('fileIO_fs_stream_read', function () {
it('fileIO_test_stream_read_sync_004', 0, async function () {
let fpath = await nextFileName('fileIO_test_stream_read_sync_004');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let ss = fileIO.createStreamSync(fpath, 'r+');
let sr = fileIO.createStreamSync(fpath, 'r+');
try {
expect(ss !== null).assertTrue();
ss.readSync("");
expect(sr !== null).assertTrue();
sr.readSync("");
expect(false).assertTrue();
} catch (e) {
ss.closeSync();
sr.closeSync();
fileIO.unlinkSync(fpath);
console.log('fileIO_test_stream_read_sync_004 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
......@@ -171,15 +171,15 @@ describe('fileIO_fs_stream_read', function () {
it('fileIO_test_stream_read_sync_005', 0, async function () {
let fpath = await nextFileName('fileIO_test_stream_read_sync_005');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let ss = fileIO.createStreamSync(fpath, 'r+');
let sr = fileIO.createStreamSync(fpath, 'r+');
const invalidLength = 4097;
try {
expect(ss !== null).assertTrue();
const invalidLength = 4097;
ss.readSync(new ArrayBuffer(4096), { length: invalidLength });
expect(sr !== null).assertTrue();
sr.readSync(new ArrayBuffer(4096), { length: invalidLength });
expect(false).assertTrue();
} catch (e) {
ss.closeSync();
sr.closeSync();
fileIO.unlinkSync(fpath);
console.log('fileIO_test_stream_read_sync_005 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
......@@ -199,15 +199,15 @@ describe('fileIO_fs_stream_read', function () {
it('fileIO_test_stream_read_sync_006', 0, async function () {
let fpath = await nextFileName('fileIO_test_stream_read_sync_006');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let ss = fileIO.createStreamSync(fpath, 'r+');
let sr = fileIO.createStreamSync(fpath, 'r+');
const invalidOffset = -1;
try {
expect(ss !== null).assertTrue();
const invalidOffset = -1;
ss.readSync(new ArrayBuffer(4096), { offset: invalidOffset });
expect(sr !== null).assertTrue();
sr.readSync(new ArrayBuffer(4096), { offset: invalidOffset });
expect(false).assertTrue();
} catch (e) {
ss.closeSync();
sr.closeSync();
fileIO.unlinkSync(fpath);
console.log('fileIO_test_stream_read_sync_006 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
......@@ -229,11 +229,11 @@ describe('fileIO_fs_stream_read', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ss = fileIO.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue();
let readout = await ss.read(new ArrayBuffer(4096));
expect(readout == FILE_CONTENT.length).assertTrue();
ss.closeSync();
let sr = fileIO.createStreamSync(fpath, 'r+');
expect(sr !== null).assertTrue();
let readLen = await sr.read(new ArrayBuffer(4096));
expect(readLen == FILE_CONTENT.length).assertTrue();
sr.closeSync();
fileIO.unlinkSync(fpath);
done();
} catch (e) {
......@@ -257,15 +257,15 @@ describe('fileIO_fs_stream_read', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ss = fileIO.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue();
ss.read(new ArrayBuffer(4096), (err, readout) => {
let sr = fileIO.createStreamSync(fpath, 'r+');
expect(sr !== null).assertTrue();
sr.read(new ArrayBuffer(4096), (err, readLen) => {
if (err) {
console.log('fileIO_test_stream_read_async_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(readout == FILE_CONTENT.length).assertTrue();
ss.closeSync();
expect(readLen == FILE_CONTENT.length).assertTrue();
sr.closeSync();
fileIO.unlinkSync(fpath);
done();
});
......@@ -290,13 +290,13 @@ describe('fileIO_fs_stream_read', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ss = fileIO.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue();
let readout = await ss.read(new ArrayBuffer(4096), {
let sr = fileIO.createStreamSync(fpath, 'r+');
expect(sr !== null).assertTrue();
let readLen = await sr.read(new ArrayBuffer(4096), {
length: 5
});
expect(readout == 5).assertTrue();
ss.closeSync();
expect(readLen == 5).assertTrue();
sr.closeSync();
fileIO.unlinkSync(fpath);
done();
} catch (e) {
......@@ -320,17 +320,17 @@ describe('fileIO_fs_stream_read', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ss = fileIO.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue();
ss.read(new ArrayBuffer(4096), {
let sr = fileIO.createStreamSync(fpath, 'r+');
expect(sr !== null).assertTrue();
sr.read(new ArrayBuffer(4096), {
length: 5
}, (err, readout) => {
}, (err, readLen) => {
if (err) {
console.log('fileIO_test_stream_read_async_003 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(readout == 5).assertTrue();
ss.closeSync();
expect(readLen == 5).assertTrue();
sr.closeSync();
fileIO.unlinkSync(fpath);
done();
});
......@@ -355,13 +355,13 @@ describe('fileIO_fs_stream_read', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ss = fileIO.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue();
let readout = await ss.read(new ArrayBuffer(4096), {
let sr = fileIO.createStreamSync(fpath, 'r+');
expect(sr !== null).assertTrue();
let readLen = await sr.read(new ArrayBuffer(4096), {
offset: 5
});
expect(readout == FILE_CONTENT.length - 5).assertTrue();
ss.closeSync();
expect(readLen == FILE_CONTENT.length - 5).assertTrue();
sr.closeSync();
fileIO.unlinkSync(fpath);
done();
} catch (e) {
......@@ -385,17 +385,17 @@ describe('fileIO_fs_stream_read', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ss = fileIO.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue();
ss.read(new ArrayBuffer(4096), {
let sr = fileIO.createStreamSync(fpath, 'r+');
expect(sr !== null).assertTrue();
sr.read(new ArrayBuffer(4096), {
offset: 5
}, (err, readout) => {
}, (err, readLen) => {
if (err) {
console.log('fileIO_test_stream_read_async_005 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(readout == FILE_CONTENT.length - 5).assertTrue();
ss.closeSync();
expect(readLen == FILE_CONTENT.length - 5).assertTrue();
sr.closeSync();
fileIO.unlinkSync(fpath);
done();
});
......@@ -418,15 +418,15 @@ describe('fileIO_fs_stream_read', function () {
it('fileIO_test_stream_read_async_006', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_stream_read_async_006');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let ss = fileIO.createStreamSync(fpath, 'r+');
let sr = fileIO.createStreamSync(fpath, 'r+');
try {
expect(ss !== null).assertTrue();
expect(sr !== null).assertTrue();
const invalidLength = 4097;
await ss.read(new ArrayBuffer(4096), { length: invalidLength });
await sr.read(new ArrayBuffer(4096), { length: invalidLength });
expect(false).assertTrue();
} catch (e) {
ss.closeSync();
sr.closeSync();
fileIO.unlinkSync(fpath);
console.log('fileIO_test_stream_read_async_006 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
......@@ -447,18 +447,18 @@ describe('fileIO_fs_stream_read', function () {
it('fileIO_test_stream_read_async_007', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_stream_read_async_007');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let ss = fileIO.createStreamSync(fpath, 'r+');
let sr = fileIO.createStreamSync(fpath, 'r+');
try {
expect(ss !== null).assertTrue();
expect(sr !== null).assertTrue();
const invalidOffset = -1;
ss.read(new ArrayBuffer(4096), {
sr.read(new ArrayBuffer(4096), {
offset: invalidOffset
}, (err) => {
expect(false).assertTrue();
});
} catch (e) {
ss.closeSync();
sr.closeSync();
fileIO.unlinkSync(fpath);
console.log('fileIO_test_stream_read_async_007 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
......@@ -481,14 +481,14 @@ describe('fileIO_fs_stream_read', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ss = fileIO.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue();
let readout = await ss.read(new ArrayBuffer(4096), {
let sr = fileIO.createStreamSync(fpath, 'r+');
expect(sr !== null).assertTrue();
let readLen = await sr.read(new ArrayBuffer(4096), {
offset: 1,
length: FILE_CONTENT.length
});
expect(readout == FILE_CONTENT.length - 1).assertTrue();
ss.closeSync();
expect(readLen == FILE_CONTENT.length - 1).assertTrue();
sr.closeSync();
fileIO.unlinkSync(fpath);
done();
} catch (e) {
......@@ -512,18 +512,18 @@ describe('fileIO_fs_stream_read', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ss = fileIO.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue();
ss.read(new ArrayBuffer(4096), {
let sr = fileIO.createStreamSync(fpath, 'r+');
expect(sr !== null).assertTrue();
sr.read(new ArrayBuffer(4096), {
offset: 1,
length: FILE_CONTENT.length
}, (err, readout) => {
}, (err, readLen) => {
if (err) {
console.log('fileIO_test_stream_read_async_009 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(readout == FILE_CONTENT.length - 1).assertTrue();
ss.closeSync();
expect(readLen == FILE_CONTENT.length - 1).assertTrue();
sr.closeSync();
fileIO.unlinkSync(fpath);
done();
});
......@@ -548,11 +548,11 @@ describe('fileIO_fs_stream_read', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ss = fileIO.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue();
let readout = await ss.read(new ArrayBuffer(4096), {});
expect(readout == FILE_CONTENT.length).assertTrue();
ss.closeSync();
let sr = fileIO.createStreamSync(fpath, 'r+');
expect(sr !== null).assertTrue();
let readLen = await sr.read(new ArrayBuffer(4096), {});
expect(readLen == FILE_CONTENT.length).assertTrue();
sr.closeSync();
fileIO.unlinkSync(fpath);
done();
} catch (e) {
......@@ -576,16 +576,16 @@ describe('fileIO_fs_stream_read', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ss = fileIO.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue();
ss.read(new ArrayBuffer(4096), {
}, (err, readout) => {
let sr = fileIO.createStreamSync(fpath, 'r+');
expect(sr !== null).assertTrue();
sr.read(new ArrayBuffer(4096), {
}, (err, readLen) => {
if (err) {
console.log('fileIO_test_stream_read_async_011 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(readout == FILE_CONTENT.length).assertTrue();
ss.closeSync();
expect(readLen == FILE_CONTENT.length).assertTrue();
sr.closeSync();
fileIO.unlinkSync(fpath);
done();
});
......@@ -607,14 +607,14 @@ describe('fileIO_fs_stream_read', function () {
it('fileIO_test_stream_read_async_012', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_stream_read_async_012');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let ss = fileIO.createStreamSync(fpath, 'r+');
let sr = fileIO.createStreamSync(fpath, 'r+');
try {
expect(ss !== null).assertTrue();
await ss.read();
expect(sr !== null).assertTrue();
await sr.read();
expect(false).assertTrue();
} catch (e) {
ss.closeSync();
sr.closeSync();
fileIO.unlinkSync(fpath);
console.log('fileIO_test_stream_read_async_012 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
......@@ -635,13 +635,14 @@ describe('fileIO_fs_stream_read', function () {
it('fileIO_test_stream_read_async_013', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_stream_read_async_013');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let ss = fileIO.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue();
let sr = fileIO.createStreamSync(fpath, 'r+');
try {
await ss.read("");
expect(sr !== null).assertTrue();
await sr.read("");
expect(false).assertTrue();
} catch (e) {
ss.closeSync();
sr.closeSync();
fileIO.unlinkSync(fpath);
console.log('fileIO_test_stream_read_async_013 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
......@@ -662,15 +663,15 @@ describe('fileIO_fs_stream_read', function () {
it('fileIO_test_stream_read_async_014', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_stream_read_async_014');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let ss = fileIO.createStreamSync(fpath, 'r+');
let sr = fileIO.createStreamSync(fpath, 'r+');
try {
expect(ss !== null).assertTrue();
ss.read("", (err) => {
expect(sr !== null).assertTrue();
sr.read("", (err) => {
expect(false).assertTrue();
});
} catch (e) {
ss.closeSync();
sr.closeSync();
fileIO.unlinkSync(fpath);
console.log('fileIO_test_stream_read_async_014 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
......
......@@ -21,7 +21,7 @@ export default function fileIOAccess() {
describe('fileIO_fs_access', function () {
/**
* @tc.number SUB_DF_FILEIO_ACCESSSYNC_0000
* @tc.number SUB_DF_FILEIO_ACCESS_SYNC_0000
* @tc.name fileIO_test_access_sync_000
* @tc.desc Test accessSync() interface.
* This interface shall work properly in normal case.
......@@ -49,7 +49,7 @@ describe('fileIO_fs_access', function () {
});
/**
* @tc.number SUB_DF_FILEIO_ACCESSSYNC_0100
* @tc.number SUB_DF_FILEIO_ACCESS_SYNC_0100
* @tc.name fileIO_test_access_sync_001
* @tc.desc Test accessSync() interface.
* The test file is not exist.
......@@ -71,7 +71,7 @@ describe('fileIO_fs_access', function () {
});
/**
* @tc.number SUB_DF_FILEIO_ACCESSSYNC_0200
* @tc.number SUB_DF_FILEIO_ACCESS_SYNC_0200
* @tc.name fileIO_test_access_sync_002
* @tc.desc Test accessSync() interface.
* The test file path is illegal.
......@@ -92,7 +92,7 @@ describe('fileIO_fs_access', function () {
});
/**
* @tc.number SUB_DF_FILEIO_ACCESSASYNC_0000
* @tc.number SUB_DF_FILEIO_ACCESS_ASYNC_0000
* @tc.name fileIO_test_access_async_000
* @tc.desc Test access() interface. Promise.
* Use promise to test that the file is exist. Sync method reads data from file.
......@@ -122,7 +122,7 @@ describe('fileIO_fs_access', function () {
});
/**
* @tc.number SUB_DF_FILEIO_ACCESSASYNC_0100
* @tc.number SUB_DF_FILEIO_ACCESS_ASYNC_0100
* @tc.name fileIO_test_access_async_001
* @tc.desc Test access() interface. Callback.
* Use callback to test that the file is exist. Sync method reads data from file.
......@@ -157,7 +157,7 @@ describe('fileIO_fs_access', function () {
});
/**
* @tc.number SUB_DF_FILEIO_ACCESSASYNC_0200
* @tc.number SUB_DF_FILEIO_ACCESS_ASYNC_0200
* @tc.name fileIO_test_access_async_002
* @tc.desc Test access() interface. Promise.
* Async test file does not exist.
......@@ -180,7 +180,7 @@ describe('fileIO_fs_access', function () {
});
/**
* @tc.number SUB_DF_FILEIO_ACCESSASYNC_0300
* @tc.number SUB_DF_FILEIO_ACCESS_ASYNC_0300
* @tc.name fileIO_test_access_async_003
* @tc.desc Test access() interface. Callback.
* Async test file does not exist.
......@@ -208,7 +208,7 @@ describe('fileIO_fs_access', function () {
});
/**
* @tc.number SUB_DF_FILEIO_ACCESSASYNC_0400
* @tc.number SUB_DF_FILEIO_ACCESS_ASYNC_0400
* @tc.name fileIO_test_access_async_004
* @tc.desc Test access() interface. Promise.
* Invalid path parameter.
......@@ -230,7 +230,7 @@ describe('fileIO_fs_access', function () {
});
/**
* @tc.number SUB_DF_FILEIO_ACCESSASYNC_0500
* @tc.number SUB_DF_FILEIO_ACCESS_ASYNC_0500
* @tc.name fileIO_test_access_async_005
* @tc.desc Test access() interface. Callback.
* Invalid path parameter.
......
......@@ -14,15 +14,14 @@
*/
import {
fileIO, FILE_CONTENT, nextFileName, prepareFile,
describe, it, expect,
fileIO, FILE_CONTENT, nextFileName, prepareFile, describe, it, expect,
} from '../Common';
export default function fileIOClose() {
describe('fileIO_fs_close', function () {
/**
* @tc.number SUB_DF_FILEIO_CLOSESYNC_0000
* @tc.number SUB_DF_FILEIO_CLOSE_SYNC_0000
* @tc.name fileIO_test_close_sync_000
* @tc.desc Test closeSync() interfaces.
* Open file and close file by fd.
......@@ -45,7 +44,7 @@ describe('fileIO_fs_close', function () {
});
/**
* @tc.number SUB_DF_FILEIO_CLOSESYNC_0100
* @tc.number SUB_DF_FILEIO_CLOSE_SYNC_0100
* @tc.name fileIO_test_close_sync_001
* @tc.desc Test closeSync() interfaces.
* Open file and close file by file object.
......@@ -68,7 +67,7 @@ describe('fileIO_fs_close', function () {
});
/**
* @tc.number SUB_DF_FILEIO_CLOSESYNC_0200
* @tc.number SUB_DF_FILEIO_CLOSE_SYNC_0200
* @tc.name fileIO_test_close_sync_002
* @tc.desc Test closeSync() interfaces.
* Test fd has been closed.
......@@ -94,7 +93,7 @@ describe('fileIO_fs_close', function () {
});
/**
* @tc.number SUB_DF_FILEIO_CLOSESYNC_0300
* @tc.number SUB_DF_FILEIO_CLOSE_SYNC_0300
* @tc.name fileIO_test_close_sync_003
* @tc.desc Test closeSync() interfaces.
* Test file has been closed.
......@@ -120,7 +119,7 @@ describe('fileIO_fs_close', function () {
});
/**
* @tc.number SUB_DF_FILEIO_CLOSESYNC_0400
* @tc.number SUB_DF_FILEIO_CLOSE_SYNC_0400
* @tc.name fileIO_test_close_sync_004
* @tc.desc Test closeSync() interfaces.
* No parameters.
......@@ -141,7 +140,7 @@ describe('fileIO_fs_close', function () {
});
/**
* @tc.number SUB_DF_FILEIO_CLOSESYNC_0500
* @tc.number SUB_DF_FILEIO_CLOSE_SYNC_0500
* @tc.name fileIO_test_close_sync_005
* @tc.desc Test closeSync() interfaces.
* Illegal type of parameter.
......@@ -301,7 +300,7 @@ describe('fileIO_fs_close', function () {
/**
* @tc.number SUB_DF_FILEIO_CLOSE_ASYNC_0500
* @tc.name fileIO_test_close_async_005
* @tc.desc Test close() interfaces. Promise.
* @tc.desc Test close() interfaces. Promise.
* Test file has been closed.
* @tc.size MEDIUM
* @tc.type Function
......@@ -315,12 +314,12 @@ describe('fileIO_fs_close', function () {
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
await fileIO.close(file);
fileIO.close(file);
await fileIO.close(file);
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_test_close_async_005 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
fileIO.unlinkSync(fpath);
done();
}
});
......@@ -335,7 +334,7 @@ describe('fileIO_fs_close', function () {
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_close_async_006', 0, async function (done) {
it('fileIO_test_close_async_006', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_close_async_006');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
......
......@@ -33,15 +33,15 @@ describe('fileIO_fs_createStream', function () {
it('fileIO_test_create_stream_sync_000', 0, async function () {
let fpath = await nextFileName('fileIO_test_create_stream_sync_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let ss = fileIO.createStreamSync(fpath, 'r');
let sr = fileIO.createStreamSync(fpath, 'r');
try {
expect(ss !== null).assertTrue();
expect(ss.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
ss.writeSync(FILE_CONTENT);
expect(sr !== null).assertTrue();
expect(sr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
sr.writeSync(FILE_CONTENT);
expect(false).assertTrue();
} catch (e) {
ss.closeSync();
sr.closeSync();
fileIO.unlinkSync(fpath);
console.log('fileIO_test_create_stream_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900005 && e.message == 'I/O error').assertTrue();
......@@ -85,11 +85,11 @@ describe('fileIO_fs_createStream', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ss = fileIO.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue();
expect(ss.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
ss.closeSync();
let sr = fileIO.createStreamSync(fpath, 'r+');
expect(sr !== null).assertTrue();
expect(sr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
expect(sr.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
sr.closeSync();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_create_stream_sync_002 has failed for ' + e.message + ', code: ' + e.code);
......@@ -263,11 +263,11 @@ describe('fileIO_fs_createStream', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ss = fileIO.createStreamSync(fpath, 'w+');
expect(ss !== null).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(ss.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
ss.closeSync();
let sw = fileIO.createStreamSync(fpath, 'w+');
expect(sw !== null).assertTrue();
expect(sw.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(sw.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
sw.closeSync();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_create_stream_sync_009 has failed for ' + e.message + ', code: ' + e.code);
......@@ -289,11 +289,11 @@ describe('fileIO_fs_createStream', function () {
let fpath = await nextFileName('fileIO_test_create_stream_sync_010');
try {
let ss = fileIO.createStreamSync(fpath, 'w+');
expect(ss !== null).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(ss.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
ss.closeSync();
let sw = fileIO.createStreamSync(fpath, 'w+');
expect(sw !== null).assertTrue();
expect(sw.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(sw.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
sw.closeSync();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_create_stream_sync_010 has failed for ' + e.message + ', code: ' + e.code);
......@@ -316,10 +316,10 @@ describe('fileIO_fs_createStream', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ss = fileIO.createStreamSync(fpath, 'a');
expect(ss !== null).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
ss.closeSync();
let sa = fileIO.createStreamSync(fpath, 'a');
expect(sa !== null).assertTrue();
expect(sa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
sa.closeSync();
let sr = fileIO.createStreamSync(fpath, 'r');
expect(sr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue();
......@@ -345,10 +345,10 @@ describe('fileIO_fs_createStream', function () {
let fpath = await nextFileName('fileIO_test_create_stream_sync_012');
try {
let ss = fileIO.createStreamSync(fpath, 'a');
expect(ss !== null).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
ss.closeSync();
let sa = fileIO.createStreamSync(fpath, 'a');
expect(sa !== null).assertTrue();
expect(sa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
sa.closeSync();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_create_stream_sync_012 has failed for ' + e.message + ', code: ' + e.code);
......@@ -369,15 +369,15 @@ describe('fileIO_fs_createStream', function () {
it('fileIO_test_create_stream_sync_013', 0, async function () {
let fpath = await nextFileName('fileIO_test_create_stream_sync_013');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let ss = fileIO.createStreamSync(fpath, 'a');
let sa = fileIO.createStreamSync(fpath, 'a');
try {
expect(ss !== null).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
ss.readSync(new ArrayBuffer(4096));
expect(sa !== null).assertTrue();
expect(sa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
sa.readSync(new ArrayBuffer(4096));
expect(false).assertTrue();
} catch (e) {
ss.closeSync();
sa.closeSync();
fileIO.unlinkSync(fpath);
console.log('fileIO_test_create_stream_sync_013 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900005 && e.message == 'I/O error').assertTrue();
......@@ -399,11 +399,11 @@ describe('fileIO_fs_createStream', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ss = fileIO.createStreamSync(fpath, 'a+');
expect(ss !== null).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(ss.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue();
ss.closeSync();
let sa = fileIO.createStreamSync(fpath, 'a+');
expect(sa !== null).assertTrue();
expect(sa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(sa.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue();
sa.closeSync();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_create_stream_sync_014 has failed for ' + e.message + ', code: ' + e.code);
......@@ -425,11 +425,11 @@ describe('fileIO_fs_createStream', function () {
let fpath = await nextFileName('fileIO_test_create_stream_sync_015');
try {
let ss = fileIO.createStreamSync(fpath, 'a+');
expect(ss !== null).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(ss.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
ss.closeSync();
let sa = fileIO.createStreamSync(fpath, 'a+');
expect(sa !== null).assertTrue();
expect(sa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(sa.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
sa.closeSync();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_create_stream_sync_015 has failed for ' + e.message + ', code: ' + e.code);
......@@ -450,15 +450,15 @@ describe('fileIO_fs_createStream', function () {
it('fileIO_test_create_stream_async_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_create_stream_async_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let ss = await fileIO.createStream(fpath, 'r');
let sr = await fileIO.createStream(fpath, 'r');
try {
expect(ss !== null).assertTrue();
expect(ss.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
ss.writeSync(FILE_CONTENT);
expect(sr !== null).assertTrue();
expect(sr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
sr.writeSync(FILE_CONTENT);
expect(false).assertTrue();
} catch (e) {
ss.closeSync();
sr.closeSync();
fileIO.unlinkSync(fpath);
console.log('fileIO_test_create_stream_async_000 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900005 && e.message == 'I/O error').assertTrue();
......@@ -481,16 +481,16 @@ describe('fileIO_fs_createStream', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.createStream(fpath, 'r', (err, ss) => {
fileIO.createStream(fpath, 'r', (err, sr) => {
if (err) {
console.log('fileIO_test_create_stream_async_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(ss !== null).assertTrue();
expect(ss.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
ss.write(FILE_CONTENT, (err) => {
expect(sr !== null).assertTrue();
expect(sr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
sr.write(FILE_CONTENT, (err) => {
if (err) {
ss.closeSync();
sr.closeSync();
fileIO.unlinkSync(fpath);
console.log(
'fileIO_test_create_stream_async_001 error: {message: ' + err.message + ', code: ' + err.code + '}'
......@@ -573,11 +573,11 @@ describe('fileIO_fs_createStream', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ss = await fileIO.createStream(fpath, 'r+');
expect(ss !== null).assertTrue();
expect(ss.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
ss.closeSync();
let sr = await fileIO.createStream(fpath, 'r+');
expect(sr !== null).assertTrue();
expect(sr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
expect(sr.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
sr.closeSync();
fileIO.unlinkSync(fpath);
done();
} catch (e) {
......@@ -601,15 +601,15 @@ describe('fileIO_fs_createStream', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.createStream(fpath, 'r+', (err, ss) => {
fileIO.createStream(fpath, 'r+', (err, sr) => {
if (err) {
console.log('fileIO_test_create_stream_async_005 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(ss !== null).assertTrue();
expect(ss.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
ss.closeSync();
expect(sr !== null).assertTrue();
expect(sr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
expect(sr.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
sr.closeSync();
fileIO.unlinkSync(fpath);
done();
});
......@@ -829,11 +829,11 @@ describe('fileIO_fs_createStream', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ss = await fileIO.createStream(fpath, 'w+');
expect(ss !== null).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(ss.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
ss.closeSync();
let sw = await fileIO.createStream(fpath, 'w+');
expect(sw !== null).assertTrue();
expect(sw.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(sw.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
sw.closeSync();
fileIO.unlinkSync(fpath);
done();
} catch (e) {
......@@ -856,11 +856,11 @@ describe('fileIO_fs_createStream', function () {
let fpath = await nextFileName('fileIO_test_create_stream_async_014');
try {
let ss = await fileIO.createStream(fpath, 'w+');
expect(ss !== null).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(ss.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
ss.closeSync();
let sw = await fileIO.createStream(fpath, 'w+');
expect(sw !== null).assertTrue();
expect(sw.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(sw.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
sw.closeSync();
fileIO.unlinkSync(fpath);
done();
} catch (e) {
......@@ -884,15 +884,15 @@ describe('fileIO_fs_createStream', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.createStream(fpath, 'w+', (err, ss) => {
fileIO.createStream(fpath, 'w+', (err, sw) => {
if (err) {
console.log('fileIO_test_create_stream_async_015 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(ss !== null).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(ss.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
ss.closeSync();
expect(sw !== null).assertTrue();
expect(sw.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(sw.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
sw.closeSync();
fileIO.unlinkSync(fpath);
done();
});
......
......@@ -14,8 +14,7 @@
*/
import {
fileio, fileIO, FILE_CONTENT, prepareFile, nextFileName,
describe, it, expect,
fileIO, FILE_CONTENT, prepareFile, nextFileName, describe, it, expect,
} from '../Common';
export default function fileIOFdatasync() {
......@@ -38,8 +37,8 @@ export default function fileIOFdatasync() {
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
fileIO.fdatasyncSync(file.fd);
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_fdatasync_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
......@@ -47,12 +46,12 @@ export default function fileIOFdatasync() {
});
/**
* @tc.number SUB_DF_FILEIO_FDATASYNC_SYNC_0010
* @tc.number SUB_DF_FILEIO_FDATASYNC_SYNC_0100
* @tc.name fileIO_test_fdatasync_sync_001
* @tc.desc Test fdatasyncSync() interfaces. Invalid fd parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_fdatasync_sync_001', 0, async function () {
......@@ -67,12 +66,12 @@ export default function fileIOFdatasync() {
});
/**
* @tc.number SUB_DF_FILEIO_FDATASYNC_SYNC_0020
* @tc.number SUB_DF_FILEIO_FDATASYNC_SYNC_0200
* @tc.name fileIO_test_fdatasync_sync_002
* @tc.desc Test fdatasyncSync() interfaces. Missing parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_fdatasync_sync_002', 0, async function () {
......@@ -107,8 +106,8 @@ export default function fileIOFdatasync() {
console.log('fileIO_test_fdatasync_async_000 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
done();
});
} catch (e) {
......@@ -118,13 +117,13 @@ export default function fileIOFdatasync() {
});
/**
* @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0010
* @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0100
* @tc.name fileIO_test_fdatasync_async_001
* @tc.desc Test fdatasync() interfaces. Promise.then().catch().
* Open the file in read-write mode, and synchronize the file content data.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_fdatasync_async_001', 0, async function (done) {
......@@ -133,9 +132,9 @@ export default function fileIOFdatasync() {
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
fileio.fdatasync(file.fd).then(() => {
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
fileIO.fdatasync(file.fd).then(() => {
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
done();
}).catch((err) => {
console.log('fileIO_test_fdatasync_async_001 error package: ' + JSON.stringify(err));
......@@ -148,13 +147,13 @@ export default function fileIOFdatasync() {
});
/**
* @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0020
* @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0200
* @tc.name fileIO_test_fdatasync_async_002
* @tc.desc Test fdatasync() interfaces. await Promise.
* Open the file in read-write mode, and synchronize the file content data.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_fdatasync_async_002', 0, async function (done) {
......@@ -163,9 +162,9 @@ export default function fileIOFdatasync() {
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
await fileio.fdatasync(file.fd);
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
await fileIO.fdatasync(file.fd);
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_test_fdatasync_async_002 has failed for ' + e.message + ', code: ' + e.code);
......@@ -174,13 +173,13 @@ export default function fileIOFdatasync() {
});
/**
* @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0030
* @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0300
* @tc.name fileIO_test_fdatasync_async_003
* @tc.desc Test fdatasync() interfaces. await Promise.
* Invalid fd parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_fdatasync_async_003', 0, async function (done) {
......@@ -196,13 +195,13 @@ export default function fileIOFdatasync() {
});
/**
* @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0040
* @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0400
* @tc.name fileIO_test_fdatasync_async_004
* @tc.desc Test fdatasync() interfaces. Callback.
* Invalid fd parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_fdatasync_async_004', 0, async function (done) {
......@@ -210,7 +209,7 @@ export default function fileIOFdatasync() {
try {
fileIO.fdatasync(-1, (err) => {
if (err) {
console.log('fileIO_test_fdatasync_async_004 error package: {' + err.message + ', code: ' + err.code + '}');
console.log('fileIO_test_fdatasync_async_004 error: {message: ' + err.message + ', code: ' + err.code + '}');
expect(err.code == 13900008 && err.message == 'Bad file descriptor').assertTrue();
done();
}
......@@ -222,13 +221,13 @@ export default function fileIOFdatasync() {
});
/**
* @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0050
* @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0500
* @tc.name fileIO_test_fdatasync_async_005
* @tc.desc Test fdatasync() interfaces. Promise.then().catch()
* Invalid fd parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_fdatasync_async_005', 0, async function (done) {
......@@ -237,7 +236,7 @@ export default function fileIOFdatasync() {
fileIO.fdatasync(-1).then(() => {
expect(false).assertTrue();
}).catch((err) => {
console.log('fileIO_test_fdatasync_async_005 error package: {' + err.message + ', code: ' + err.code + '}');
console.log('fileIO_test_fdatasync_async_005 error: {message: ' + err.message + ', code: ' + err.code + '}');
expect(err.code == 13900008 && err.message == 'Bad file descriptor').assertTrue();
done();
});
......@@ -248,13 +247,13 @@ export default function fileIOFdatasync() {
});
/**
* @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0060
* @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0600
* @tc.name fileIO_test_fdatasync_async_006
* @tc.desc Test fdatasync() interfaces. Promise.
* Missing parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_fdatasync_async_006', 0, async function (done) {
......@@ -270,19 +269,19 @@ export default function fileIOFdatasync() {
});
/**
* @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0070
* @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0700
* @tc.name fileIO_test_fdatasync_async_007
* @tc.desc Test fdatasync() interfaces. Callback.
* Missing parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_fdatasync_async_007', 0, async function (done) {
try {
fileIO.fdatasync(() => {
fileIO.fdatasync((err) => {
expect(false).assertTrue();
});
} catch (e) {
......
......@@ -35,15 +35,15 @@ describe('fileIO_fs_FdOpenStream', async function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file.fd)).assertTrue();
let fp = fileIO.fdopenStreamSync(file.fd, 'r');
let fpr = fileIO.fdopenStreamSync(file.fd, 'r');
try {
expect(fp !== null).assertTrue();
expect(fp.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
fp.writeSync(FILE_CONTENT);
expect(fpr !== null).assertTrue();
expect(fpr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
fpr.writeSync(FILE_CONTENT);
expect(false).assertTrue();
} catch (e) {
fp.closeSync();
fpr.closeSync();
fileIO.unlinkSync(fpath);
console.log('fileIO_test_fdopenstream_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900005 && e.message == 'I/O error').assertTrue();
......@@ -88,11 +88,11 @@ describe('fileIO_fs_FdOpenStream', async function () {
try {
expect(isIntNum(file.fd)).assertTrue();
let fp = fileIO.fdopenStreamSync(file.fd, 'r+');
expect(fp !== null).assertTrue();
expect(fp.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
expect(fp.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
fp.closeSync();
let fpr = fileIO.fdopenStreamSync(file.fd, 'r+');
expect(fpr !== null).assertTrue();
expect(fpr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
expect(fpr.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
fpr.closeSync();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_fdopenstream_sync_002 has failed for ' + e.message + ', code: ' + e.code);
......@@ -224,9 +224,9 @@ describe('fileIO_fs_FdOpenStream', async function () {
fpw.closeSync();
let file2 = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY);
let sr = fileIO.fdopenStreamSync(file2.fd, 'r');
expect(sr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
sr.closeSync();
let fpr = fileIO.fdopenStreamSync(file2.fd, 'r');
expect(fpr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
fpr.closeSync();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_fdopenstream_sync_007 has failed for ' + e.message + ', code: ' + e.code);
......@@ -280,15 +280,15 @@ describe('fileIO_fs_FdOpenStream', async function () {
try {
let file1 = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file1.fd)).assertTrue();
let fpw = fileIO.fdopenStreamSync(file1.fd, 'a');
expect(fpw !== null).assertTrue();
expect(fpw.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
fpw.closeSync();
let fpa = fileIO.fdopenStreamSync(file1.fd, 'a');
expect(fpa !== null).assertTrue();
expect(fpa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
fpa.closeSync();
let file2 = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
let sr = fileIO.fdopenStreamSync(file2.fd, 'r');
expect(sr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue();
sr.closeSync();
let fpr = fileIO.fdopenStreamSync(file2.fd, 'r');
expect(fpr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue();
fpr.closeSync();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_fdopenstream_sync_009 has failed for ' + e.message + ', code: ' + e.code);
......@@ -311,15 +311,15 @@ describe('fileIO_fs_FdOpenStream', async function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file.fd)).assertTrue();
let sa = fileIO.fdopenStreamSync(file.fd, 'a');
let fpa = fileIO.fdopenStreamSync(file.fd, 'a');
try {
expect(sa !== null).assertTrue();
expect(sa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
sa.readSync(new ArrayBuffer(4096));
expect(fpa !== null).assertTrue();
expect(fpa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
fpa.readSync(new ArrayBuffer(4096));
expect(false).assertTrue();
} catch (e) {
sa.closeSync();
fpa.closeSync();
fileIO.unlinkSync(fpath);
console.log('fileIO_test_fdopenstream_sync_010 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900005 && e.message == 'I/O error').assertTrue();
......@@ -343,11 +343,11 @@ describe('fileIO_fs_FdOpenStream', async function () {
try {
expect(isIntNum(file.fd)).assertTrue();
let sa = fileIO.fdopenStreamSync(file.fd, 'a+');
expect(sa !== null).assertTrue();
expect(sa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(sa.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue();
sa.closeSync();
let fpa = fileIO.fdopenStreamSync(file.fd, 'a+');
expect(fpa !== null).assertTrue();
expect(fpa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(fpa.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue();
fpa.closeSync();
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_fdopenstream_sync_011 has failed for ' + e.message + ', code: ' + e.code);
......@@ -369,16 +369,16 @@ describe('fileIO_fs_FdOpenStream', async function () {
let fpath = await nextFileName('fileIO_test_fdopenstream_async_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
let fp = await fileIO.fdopenStream(file.fd, 'r');
let fpr = await fileIO.fdopenStream(file.fd, 'r');
try {
expect(isIntNum(file.fd)).assertTrue();
expect(fp !== null).assertTrue();
expect(fp.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
fp.writeSync(FILE_CONTENT);
expect(fpr !== null).assertTrue();
expect(fpr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
fpr.writeSync(FILE_CONTENT);
expect(false).assertTrue();
} catch (e) {
fp.closeSync();
fpr.closeSync();
fileIO.unlinkSync(fpath);
console.log('fileIO_test_fdopenstream_async_000 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900005 && e.message == 'I/O error').assertTrue();
......@@ -403,16 +403,16 @@ describe('fileIO_fs_FdOpenStream', async function () {
try {
expect(isIntNum(file.fd)).assertTrue();
fileIO.fdopenStream(file.fd, 'r', (err, fp) => {
fileIO.fdopenStream(file.fd, 'r', (err, fpr) => {
if (err) {
console.log('fileIO_test_fdopenstream_async_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(fp !== null).assertTrue();
expect(fp.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
fp.write(FILE_CONTENT, (err) => {
expect(fpr !== null).assertTrue();
expect(fpr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
fpr.write(FILE_CONTENT, (err) => {
if (err) {
fp.closeSync();
fpr.closeSync();
fileIO.unlinkSync(fpath);
console.log(
'fileIO_test_fdopenstream_async_001 error: {message: ' + err.message + ', code: ' + err.code + '}'
......@@ -492,11 +492,11 @@ describe('fileIO_fs_FdOpenStream', async function () {
try {
expect(isIntNum(file.fd)).assertTrue();
let fp = await fileIO.fdopenStream(file.fd, 'r+');
expect(fp !== null).assertTrue();
expect(fp.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(fp.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
fp.closeSync();
let fpr = await fileIO.fdopenStream(file.fd, 'r+');
expect(fpr !== null).assertTrue();
expect(fpr.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(fpr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
fpr.closeSync();
fileIO.unlinkSync(fpath);
done();
} catch (e) {
......@@ -522,15 +522,15 @@ describe('fileIO_fs_FdOpenStream', async function () {
try {
expect(isIntNum(file.fd)).assertTrue();
fileIO.fdopenStream(file.fd, 'r+', (err, fp) => {
fileIO.fdopenStream(file.fd, 'r+', (err, fpr) => {
if (err) {
console.log('fileIO_test_fdopenstream_async_005 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(fp !== null).assertTrue();
expect(fp.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(fp.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
fp.closeSync();
expect(fpr !== null).assertTrue();
expect(fpr.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(fpr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
fpr.closeSync();
fileIO.unlinkSync(fpath);
done();
});
......@@ -689,9 +689,9 @@ describe('fileIO_fs_FdOpenStream', async function () {
fpw.closeSync();
let file2 = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
let sr = await fileIO.fdopenStream(file2.fd, 'r');
expect(sr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
sr.closeSync();
let fpr = await fileIO.fdopenStream(file2.fd, 'r');
expect(fpr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
fpr.closeSync();
fileIO.unlinkSync(fpath);
done();
} catch (e) {
......@@ -781,15 +781,15 @@ describe('fileIO_fs_FdOpenStream', async function () {
try {
let file1 = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
let fpw = await fileIO.fdopenStream(file1.fd, 'a');
expect(fpw !== null).assertTrue();
expect(fpw.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
fpw.closeSync();
let fpa = await fileIO.fdopenStream(file1.fd, 'a');
expect(fpa !== null).assertTrue();
expect(fpa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
fpa.closeSync();
let file2 = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
let sr = await fileIO.fdopenStream(file2.fd, 'r');
expect(sr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue();
sr.closeSync();
let fpr = await fileIO.fdopenStream(file2.fd, 'r');
expect(fpr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue();
fpr.closeSync();
fileIO.unlinkSync(fpath);
done();
} catch (e) {
......@@ -813,15 +813,15 @@ describe('fileIO_fs_FdOpenStream', async function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file.fd)).assertTrue();
let sa = await fileIO.fdopenStream(file.fd, 'a');
let fpa = await fileIO.fdopenStream(file.fd, 'a');
try {
expect(sa !== null).assertTrue();
expect(sa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
sa.readSync(new ArrayBuffer(4096));
expect(fpa !== null).assertTrue();
expect(fpa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
fpa.readSync(new ArrayBuffer(4096));
expect(false).assertTrue();
} catch (e) {
sa.closeSync();
fpa.closeSync();
fileIO.unlinkSync(fpath);
console.log('fileIO_test_fdopenstream_async_014 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900005 && e.message == 'I/O error').assertTrue();
......@@ -846,16 +846,16 @@ describe('fileIO_fs_FdOpenStream', async function () {
expect(isIntNum(file.fd)).assertTrue();
try {
fileIO.fdopenStream(file.fd, 'a', (err, sa) => {
fileIO.fdopenStream(file.fd, 'a', (err, fpa) => {
if (err) {
console.log('fileIO_test_fdopenstream_async_015 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(sa !== null).assertTrue();
expect(sa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
sa.read(new ArrayBuffer(4096), (err) => {
expect(fpa !== null).assertTrue();
expect(fpa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
fpa.read(new ArrayBuffer(4096), (err) => {
if (err) {
sa.closeSync();
fpa.closeSync();
fileIO.unlinkSync(fpath);
console.log(
'fileIO_test_fdopenstream_async_015 error: {message: ' + err.message + ', code: ' + err.code + '}'
......@@ -890,11 +890,11 @@ describe('fileIO_fs_FdOpenStream', async function () {
try {
expect(isIntNum(file.fd)).assertTrue();
let sa = await fileIO.fdopenStream(file.fd, 'a+');
expect(sa !== null).assertTrue();
expect(sa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(sa.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue();
sa.closeSync();
let fpa = await fileIO.fdopenStream(file.fd, 'a+');
expect(fpa !== null).assertTrue();
expect(fpa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(fpa.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue();
fpa.closeSync();
fileIO.unlinkSync(fpath);
done();
} catch (e) {
......@@ -920,15 +920,15 @@ describe('fileIO_fs_FdOpenStream', async function () {
try {
expect(isIntNum(file.fd)).assertTrue();
fileIO.fdopenStream(file.fd, 'a+', (err, sa) => {
fileIO.fdopenStream(file.fd, 'a+', (err, fpa) => {
if (err) {
console.log('fileIO_test_fdopenstream_async_017 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(sa !== null).assertTrue();
expect(sa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(sa.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue();
sa.closeSync();
expect(fpa !== null).assertTrue();
expect(fpa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(fpa.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue();
fpa.closeSync();
fileIO.unlinkSync(fpath);
done();
});
......
......@@ -14,8 +14,7 @@
*/
import {
fileio, fileIO, FILE_CONTENT, prepareFile, nextFileName,
describe, it, expect,
fileIO, FILE_CONTENT, prepareFile, nextFileName, describe, it, expect,
} from '../Common';
export default function fileIOFsync() {
......@@ -38,8 +37,8 @@ describe('fileIO_fs_fsync', function () {
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
fileIO.fsyncSync(file.fd);
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_fsync_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
......@@ -47,12 +46,12 @@ describe('fileIO_fs_fsync', function () {
});
/**
* @tc.number SUB_DF_FILEIO_FSYNC_SYNC_0010
* @tc.number SUB_DF_FILEIO_FSYNC_SYNC_0100
* @tc.name fileIO_test_fsync_sync_001
* @tc.desc Test fsyncSync() interface. Invalid fd parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_fsync_sync_001', 0, function () {
......@@ -67,12 +66,12 @@ describe('fileIO_fs_fsync', function () {
});
/**
* @tc.number SUB_DF_FILEIO_FSYNC_SYNC_0020
* @tc.number SUB_DF_FILEIO_FSYNC_SYNC_0200
* @tc.name fileIO_test_fsync_sync_002
* @tc.desc Test fsyncSync() interface. Missing parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_fsync_sync_002', 0, function () {
......@@ -103,8 +102,8 @@ describe('fileIO_fs_fsync', function () {
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
await fileIO.fsync(file.fd);
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_test_fsync_async_000 has failed for ' + e.message + ', code: ' + e.code);
......@@ -113,13 +112,13 @@ describe('fileIO_fs_fsync', function () {
});
/**
* @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_0010
* @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_0100
* @tc.name fileIO_test_fsync_async_001
* @tc.desc Test fsync() interface. Promise.then().catch()
* Open the file in read-write mode, and synchronize the file content data.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_fsync_async_001', 0, async function (done) {
......@@ -129,8 +128,8 @@ describe('fileIO_fs_fsync', function () {
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
fileIO.fsync(file.fd).then(() => {
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
done();
}).catch((err) => {
console.log('fileIO_test_fsync_async_001 error package: ' + JSON.stringify(err));
......@@ -143,13 +142,13 @@ describe('fileIO_fs_fsync', function () {
});
/**
* @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_002
* @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_0200
* @tc.name fileIO_test_fsync_async_002
* @tc.desc Test fsync() interface. Callback.
* Open the file in read-write mode, and synchronize the file content data.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_fsync_async_002', 0, async function (done) {
......@@ -163,8 +162,8 @@ describe('fileIO_fs_fsync', function () {
console.log('fileIO_test_fsync_async_002 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
});
done();
} catch (e) {
......@@ -174,13 +173,13 @@ describe('fileIO_fs_fsync', function () {
});
/**
* @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_003
* @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_0300
* @tc.name fileIO_test_fsync_async_003
* @tc.desc Test fsync() interface. await Promise.
* Invalid fd parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_fsync_async_003', 0, async function (done) {
......@@ -196,13 +195,13 @@ describe('fileIO_fs_fsync', function () {
});
/**
* @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_004
* @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_0400
* @tc.name fileIO_test_fsync_async_004
* @tc.desc Test fsync() interface. Callback.
* Invalid fd parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_fsync_async_004', 0, async function (done) {
......@@ -210,7 +209,7 @@ describe('fileIO_fs_fsync', function () {
try {
fileIO.fsync(-1, (err) => {
if (err) {
console.log('fileIO_test_fsync_async_004 error package: {' + err.message + ', code: ' + err.code + '}');
console.log('fileIO_test_fsync_async_004 error: {message: ' + err.message + ', code: ' + err.code + '}');
expect(err.code == 13900008 && err.message == 'Bad file descriptor').assertTrue();
done();
}
......@@ -222,13 +221,13 @@ describe('fileIO_fs_fsync', function () {
});
/**
* @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_005
* @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_0500
* @tc.name fileIO_test_fsync_async_005
* @tc.desc Test fsync() interface. Promise.then().catch()
* Missing parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_fsync_async_005', 0, async function (done) {
......@@ -237,7 +236,7 @@ describe('fileIO_fs_fsync', function () {
fileIO.fsync(-1).then(() => {
expect(false).assertTrue();
}).catch((err) => {
console.log('fileIO_test_fsync_async_005 error package: {' + err.message + ', code: ' + err.code + '}');
console.log('fileIO_test_fsync_async_005 error: {message: ' + err.message + ', code: ' + err.code + '}');
expect(err.code == 13900008 && err.message == 'Bad file descriptor').assertTrue();
done();
});
......@@ -248,13 +247,13 @@ describe('fileIO_fs_fsync', function () {
});
/**
* @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_006
* @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_0600
* @tc.name fileIO_test_fsync_async_006
* @tc.desc Test fsync() interface. await Promise.
* Missing parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_fsync_async_006', 0, async function (done) {
......@@ -270,19 +269,19 @@ describe('fileIO_fs_fsync', function () {
});
/**
* @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_006
* @tc.name fileIO_test_fsync_async_006
* @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_0700
* @tc.name fileIO_test_fsync_async_007
* @tc.desc Test fsync() interface. Callback.
* Missing parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_fsync_async_007', 0, async function (done) {
try {
fileIO.fsync(() => {
fileIO.fsync((err) => {
expect(false).assertTrue();
});
} catch (e) {
......
......@@ -57,7 +57,7 @@ export default function fileIOListfile() {
* Do not have prop filter.Filter files by quantity only.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_listfile_sync_001', 0, async function () {
......@@ -90,7 +90,7 @@ export default function fileIOListfile() {
* Do not have prop listNum.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_listfile_sync_002', 0, async function () {
......@@ -129,7 +129,7 @@ export default function fileIOListfile() {
* Do not have prop suffix. Not filter files by suffix.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_listfile_sync_003', 0, async function () {
......@@ -168,7 +168,7 @@ export default function fileIOListfile() {
* Scanfile.Retain six files in the three-level directory.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_listfile_sync_004', 0, async function () {
......@@ -226,7 +226,7 @@ export default function fileIOListfile() {
* Filter out files whose suffix is not '. txt' and does not meet other conditions.Two files are retained.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_listfile_sync_005', 0, async function () {
......@@ -268,7 +268,7 @@ export default function fileIOListfile() {
* Invalid file suffix name format.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_listfile_sync_006', 0, async function () {
......@@ -308,7 +308,7 @@ export default function fileIOListfile() {
* Filter out all files because the size of all files less than 12.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_listfile_sync_007', 0, async function () {
......@@ -348,7 +348,7 @@ export default function fileIOListfile() {
* listNum is 0.Traverse all files.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_listfile_sync_008', 0, async function () {
......@@ -390,7 +390,7 @@ export default function fileIOListfile() {
* Missing all arguments.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_listfile_sync_009', 0, async function () {
......@@ -411,7 +411,7 @@ export default function fileIOListfile() {
* Invalid option args.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_listfile_sync_010', 0, async function () {
......@@ -463,7 +463,7 @@ export default function fileIOListfile() {
fileIO.rmdirSync(dpath);
});
} catch (e) {
console.info('fileIO_test_listfile_async_000 has failed for ' + e.message + ', code:' + e.code);
console.log('fileIO_test_listfile_async_000 has failed for ' + e.message + ', code:' + e.code);
expect(false).assertTrue();
}
});
......@@ -475,7 +475,7 @@ export default function fileIOListfile() {
* Only path, do not filter file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_listfile_async_001', 0, async function (done) {
......@@ -494,7 +494,7 @@ export default function fileIOListfile() {
fileIO.rmdirSync(dpath);
done();
} catch (err) {
console.info('fileIO_test_listfile_async_001 has failed for ' + err.message + ', code:' + err.code);
console.log('fileIO_test_listfile_async_001 has failed for ' + err.message + ', code:' + err.code);
expect(false).assertTrue();
}
});
......@@ -506,7 +506,7 @@ export default function fileIOListfile() {
* Do not have prop filter.Filter files by quantity only.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_listfile_async_002', 0, async function () {
......@@ -544,7 +544,7 @@ export default function fileIOListfile() {
* Do not have prop filter.Filter files by quantity only.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_listfile_async_003', 0, async function (done) {
......@@ -578,7 +578,7 @@ export default function fileIOListfile() {
* Do not have prop listNum.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_listfile_async_004', 0, async function () {
......@@ -610,7 +610,7 @@ export default function fileIOListfile() {
fileIO.rmdirSync(dpath);
});
} catch (e) {
console.info('fileIO_test_listfile_async_004 has failed for ' + e.message + ', code:' + e.code);
console.log('fileIO_test_listfile_async_004 has failed for ' + e.message + ', code:' + e.code);
expect(false).assertTrue();
}
});
......@@ -622,7 +622,7 @@ export default function fileIOListfile() {
* Do not have prop listNum.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_listfile_async_005', 0, async function (done) {
......@@ -650,7 +650,7 @@ export default function fileIOListfile() {
fileIO.rmdirSync(dpath);
done();
} catch (err) {
console.info('fileIO_test_listfile_async_005 has failed for ' + err.message + ', code:' + err.code);
console.log('fileIO_test_listfile_async_005 has failed for ' + err.message + ', code:' + err.code);
expect(false).assertTrue();
}
});
......@@ -662,7 +662,7 @@ export default function fileIOListfile() {
* Do not have prop suffix. Not filter files by suffix.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_listfile_async_006', 0, async function () {
......@@ -706,7 +706,7 @@ export default function fileIOListfile() {
* Do not have prop suffix. Not filter files by suffix.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_listfile_async_007', 0, async function (done) {
......@@ -746,7 +746,7 @@ export default function fileIOListfile() {
* Scanfile.Retain six files in the three-level directory.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_listfile_async_008', 0, async function () {
......@@ -809,7 +809,7 @@ export default function fileIOListfile() {
* Scanfile.Retain six files in the three-level directory.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_listfile_async_009', 0, async function (done) {
......@@ -868,7 +868,7 @@ export default function fileIOListfile() {
* Filter out files whose suffix is not '. txt' and does not meet other conditions.Two files are retained.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_listfile_async_010', 0, async function () {
......@@ -915,7 +915,7 @@ export default function fileIOListfile() {
* Filter out files whose suffix is not '. txt' and does not meet other conditions.Two files are retained.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_listfile_async_011', 0, async function (done) {
......@@ -958,7 +958,7 @@ export default function fileIOListfile() {
* Invalid file suffix name format.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_listfile_async_012', 0, async function () {
......@@ -1001,7 +1001,7 @@ export default function fileIOListfile() {
* Invalid file suffix name format.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_listfile_async_013', 0, async function (done) {
......@@ -1044,7 +1044,7 @@ export default function fileIOListfile() {
* Filter out all files because the size of all files less than 12.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_listfile_async_014', 0, async function () {
......@@ -1089,7 +1089,7 @@ export default function fileIOListfile() {
* Filter out all files because the size of all files less than 12.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_listfile_async_015', 0, async function (done) {
......@@ -1130,7 +1130,7 @@ export default function fileIOListfile() {
* listNum is 0.Traverse all files.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_listfile_async_016', 0, async function () {
......@@ -1177,7 +1177,7 @@ export default function fileIOListfile() {
* listNum is 0.Traverse all files.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_listfile_async_017', 0, async function (done) {
......@@ -1220,7 +1220,7 @@ export default function fileIOListfile() {
* Missing all arguments.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_listfile_async_018', 0, async function (done) {
......@@ -1242,7 +1242,7 @@ export default function fileIOListfile() {
* Invalid option args.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_listfile_async_019', 0, async function (done) {
......
......@@ -96,7 +96,7 @@ describe('fileIO_fs_mkdir', function () {
* @tc.require
*/
it('fileIO_test_mkdir_sync_003', 0, async function () {
let fpath = await nextFileName('fileIO_test_open_sync_000');
let fpath = await nextFileName('fileIO_test_mkdir_sync_003');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
......@@ -198,7 +198,7 @@ describe('fileIO_fs_mkdir', function () {
try {
fileIO.mkdir('/', (err) => {
if(err) {
console.log('fileIO_test_mkdir_async_003 error package: {' + err.message + ', code: ' + err.code + '}');
console.log('fileIO_test_mkdir_async_003 error: {message: ' + err.message + ', code: ' + err.code + '}');
expect(err.code == 13900015 && err.message == 'File exists').assertTrue();
done();
}
......
......@@ -21,7 +21,7 @@ export default function fileIOMoveFile() {
describe('fileIO_fs_moveFile', function () {
/**
* @tc.number SUB_DF_FILEIO_MOVEFILESYNC_0000
* @tc.number SUB_DF_FILEIO_MOVEFILE_SYNC_0000
* @tc.name fileIO_test_moveFile_sync_000
* @tc.desc Test moveFileSync() interface.
* Move a single file, shall work properly in normal case.
......@@ -51,13 +51,13 @@ export default function fileIOMoveFile() {
});
/**
* @tc.number SUB_DF_FILEIO_MOVEFILESYNC_0100
* @tc.number SUB_DF_FILEIO_MOVEFILE_SYNC_0100
* @tc.name fileIO_test_moveFile_sync_001
* @tc.desc Test moveFileSync() interface.
* A file with the same name already exists under the destination path.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_moveFile_sync_001', 0, async function () {
......@@ -81,13 +81,13 @@ export default function fileIOMoveFile() {
});
/**
* @tc.number SUB_DF_FILEIO_MOVEFILESYNC_0200
* @tc.number SUB_DF_FILEIO_MOVEFILE_SYNC_0200
* @tc.name fileIO_test_moveFile_sync_002
* @tc.desc Test moveFileSync() interface.
* The path point to nothing, no such file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_moveFile_sync_002', 0, async function () {
......@@ -109,13 +109,13 @@ export default function fileIOMoveFile() {
});
/**
* @tc.number SUB_DF_FILEIO_MOVEFILESYNC_0400
* @tc.number SUB_DF_FILEIO_MOVEFILE_SYNC_0400
* @tc.name fileIO_test_moveFile_sync_004
* @tc.desc Test moveFileSync() interface.
* The path point to a directory, not a file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_moveFile_sync_004', 0, async function () {
......@@ -134,13 +134,13 @@ export default function fileIOMoveFile() {
});
/**
* @tc.number SUB_DF_FILEIO_MOVEFILESYNC_0500
* @tc.number SUB_DF_FILEIO_MOVEFILE_SYNC_0500
* @tc.name fileIO_test_moveFile_sync_005
* @tc.desc Test moveFileSync() interface.
* Missing parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_moveFile_sync_005', 0, async function () {
......@@ -158,13 +158,13 @@ export default function fileIOMoveFile() {
});
/**
* @tc.number SUB_DF_FILEIO_MOVEFILESYNC_0600
* @tc.number SUB_DF_FILEIO_MOVEFILE_SYNC_0600
* @tc.name fileIO_test_moveFile_sync_006
* @tc.desc Test moveFileSync() interface.
* Entry parameters increase forced movement when mode = 0.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_moveFile_sync_006', 0, async function () {
......@@ -189,7 +189,7 @@ export default function fileIOMoveFile() {
});
/**
* @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0000
* @tc.number SUB_DF_FILEIO_MOVEFILE_ASYNC_0000
* @tc.name fileIO_test_moveFile_async_000
* @tc.desc Test moveFile() interface. Promise.
* Move a single file, shall work properly in normal case.
......@@ -220,13 +220,13 @@ export default function fileIOMoveFile() {
});
/**
* @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0100
* @tc.number SUB_DF_FILEIO_MOVEFILE_ASYNC_0100
* @tc.name fileIO_test_moveFile_async_001
* @tc.desc Test moveFile() interface. Callback.
* Move a single file, shall work properly in normal case.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_moveFile_async_001', 0, async function (done) {
......@@ -256,13 +256,13 @@ export default function fileIOMoveFile() {
});
/**
* @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0200
* @tc.number SUB_DF_FILEIO_MOVEFILE_ASYNC_0200
* @tc.name fileIO_test_moveFile_async_002
* @tc.desc Test moveFile() interface. Promise.
* A file with the same name already exists under the destination path.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_moveFile_async_002', 0, async function (done) {
......@@ -287,13 +287,13 @@ export default function fileIOMoveFile() {
});
/**
* @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0300
* @tc.number SUB_DF_FILEIO_MOVEFILE_ASYNC_0300
* @tc.name fileIO_test_moveFile_async_003
* @tc.desc Test moveFile() interface. Callback.
* A file with the same name already exists under the destination path.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_moveFile_async_003', 0, async function (done) {
......@@ -310,7 +310,7 @@ export default function fileIOMoveFile() {
fileIO.moveFile(fpath, ffpath, 1, (err) => {
if (err) {
fileIO.rmdirSync(dpath);
console.log('fileIO_test_moveFile_async_003 error package: {' + err.message + ', code: ' + err.code + '}');
console.log('fileIO_test_moveFile_async_003 error: {message: ' + err.message + ', code: ' + err.code + '}');
expect(err.code == 13900015 && err.message == 'File exists').assertTrue();
done();
}
......@@ -322,13 +322,13 @@ export default function fileIOMoveFile() {
});
/**
* @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0400
* @tc.number SUB_DF_FILEIO_MOVEFILE_ASYNC_0400
* @tc.name fileIO_test_moveFile_async_004
* @tc.desc Test moveFile() interface. Promise.
* The path point to nothing, no such file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_moveFile_async_004', 0, async function (done) {
......@@ -351,13 +351,13 @@ export default function fileIOMoveFile() {
});
/**
* @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0500
* @tc.number SUB_DF_FILEIO_MOVEFILE_ASYNC_0500
* @tc.name fileIO_test_moveFile_async_005
* @tc.desc Test moveFile() interface. Callback.
* The path point to nothing, no such file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_moveFile_async_005', 0, async function (done) {
......@@ -372,7 +372,7 @@ export default function fileIOMoveFile() {
fileIO.moveFile(fpath, ffpath, (err) => {
if (err) {
fileIO.rmdirSync(dpath);
console.log('fileIO_test_moveFile_async_005 error package: {' + err.message + ', code: ' + err.code + '}');
console.log('fileIO_test_moveFile_async_005 error: {message: ' + err.message + ', code: ' + err.code + '}');
expect(err.code == 13900002 && err.message == 'No such file or directory').assertTrue();
done();
}
......@@ -384,13 +384,13 @@ export default function fileIOMoveFile() {
});
/**
* @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0600
* @tc.number SUB_DF_FILEIO_MOVEFILE_ASYNC_0600
* @tc.name fileIO_test_moveFile_async_006
* @tc.desc Test moveFile() interface. Promise.
* The path point to a directory, not a file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_moveFile_async_006', 0, async function (done) {
......@@ -410,13 +410,13 @@ export default function fileIOMoveFile() {
});
/**
* @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0700
* @tc.number SUB_DF_FILEIO_MOVEFILE_ASYNC_0700
* @tc.name fileIO_test_moveFile_async_007
* @tc.desc Test moveFile() interface. Callback.
* The path point to a directory, not a file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_moveFile_async_007', 0, async function (done) {
......@@ -440,13 +440,13 @@ export default function fileIOMoveFile() {
});
/**
* @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0800
* @tc.number SUB_DF_FILEIO_MOVEFILE_ASYNC_0800
* @tc.name fileIO_test_moveFile_async_008
* @tc.desc Test moveFile() interface. Promise.
* Missing parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_moveFile_async_008', 0, async function (done) {
......@@ -465,13 +465,13 @@ export default function fileIOMoveFile() {
});
/**
* @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0900
* @tc.number SUB_DF_FILEIO_MOVEFILE_ASYNC_0900
* @tc.name fileIO_test_moveFile_async_009
* @tc.desc Test moveFile() interface. Promise.
* Entry parameters increase forced movement when mode = 0.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_moveFile_async_009', 0, async function (done) {
......@@ -497,13 +497,13 @@ export default function fileIOMoveFile() {
});
/**
* @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_1000
* @tc.number SUB_DF_FILEIO_MOVEFILE_ASYNC_1000
* @tc.name fileIO_test_moveFile_async_010
* @tc.desc Test moveFile() interface. Callback.
* Entry parameters increase forced movement when mode = 0.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_moveFile_async_010', 0, async function (done) {
......
......@@ -52,7 +52,7 @@ describe('fileIO_fs_symlink', function () {
* Missing parameter.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_symlink_sync_001', 0, async function () {
......@@ -84,10 +84,10 @@ describe('fileIO_fs_symlink', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.symlink(fpath, fpath + 'link3').then(() => {
expect(fileIO.accessSync(fpath + 'link3')).assertTrue();
fileIO.symlink(fpath, fpath + 'link1').then(() => {
expect(fileIO.accessSync(fpath + 'link1')).assertTrue();
fileIO.unlinkSync(fpath);
fileIO.unlinkSync(fpath + 'link3');
fileIO.unlinkSync(fpath + 'link1');
}).catch((err) => {
console.log('fileIO_test_symlink_async_000 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
......@@ -106,7 +106,7 @@ describe('fileIO_fs_symlink', function () {
* Create a symbolic link to verify normal function.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_symlink_async_001', 0, async function (done) {
......@@ -114,10 +114,10 @@ describe('fileIO_fs_symlink', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
await fileIO.symlink(fpath, fpath + 'link4');
expect(fileIO.accessSync(fpath + 'link4')).assertTrue();
await fileIO.symlink(fpath, fpath + 'link2');
expect(fileIO.accessSync(fpath + 'link2')).assertTrue();
fileIO.unlinkSync(fpath);
fileIO.unlinkSync(fpath + 'link4');
fileIO.unlinkSync(fpath + 'link2');
done();
} catch (e) {
console.log('fileIO_test_symlink_async_001 has failed for ' + e.message + ', code: ' + e.code);
......@@ -132,7 +132,7 @@ describe('fileIO_fs_symlink', function () {
* Create a symbolic link to verify normal function.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_symlink_async_002', 0, async function (done) {
......@@ -140,14 +140,14 @@ describe('fileIO_fs_symlink', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.symlink(fpath, fpath + 'link5', (err) => {
fileIO.symlink(fpath, fpath + 'link3', (err) => {
if (err) {
console.log('fileIO_test_symlink_async_002 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(fileIO.accessSync(fpath + 'link5')).assertTrue();
expect(fileIO.accessSync(fpath + 'link3')).assertTrue();
fileIO.unlinkSync(fpath);
fileIO.unlinkSync(fpath + 'link5');
fileIO.unlinkSync(fpath + 'link3');
done();
});
} catch (e) {
......@@ -163,7 +163,7 @@ describe('fileIO_fs_symlink', function () {
* Missing parameter.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_symlink_async_003', 0, async function (done) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册