提交 a235b282 编写于 作者: H hu0475

修改storage子系统fs模块的代码

Signed-off-by: Nhu0475 <huyanqiang5@huawei.com>
上级 420efaa4
...@@ -125,22 +125,22 @@ export default function fileIOClose() { ...@@ -125,22 +125,22 @@ export default function fileIOClose() {
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it("fileIO_test_close_async_003", 2, async function (done) { it("fileIO_test_close_async_004", 2, async function (done) {
let fpath = await nextFileName("fileIO_test_close_async_003"); let fpath = await nextFileName("fileIO_test_close_async_004");
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
fileIO.close(file.fd, (err) => { fileIO.close(file.fd, (err) => {
if (err) { if (err) {
console.log("fileIO_test_close_async_003 error package: " + JSON.stringify(err)); console.log("fileIO_test_close_async_004 error package: " + JSON.stringify(err));
expect(false).assertTrue(); expect(false).assertTrue();
} }
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
}); });
} catch (e) { } catch (e) {
console.log("fileIO_test_close_async_003 has failed for " + e.message + ", code: " + e.code); console.log("fileIO_test_close_async_004 has failed for " + e.message + ", code: " + e.code);
expect(false).assertTrue(); expect(false).assertTrue();
} }
}); });
......
...@@ -27,7 +27,7 @@ export default function fileIOFsync() { ...@@ -27,7 +27,7 @@ export default function fileIOFsync() {
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it("fileIO_test_fsync_async_000", 0, async function (done) { it("fileIO_test_fsync_async_000", 2, async function (done) {
let fpath = await nextFileName("fileIO_test_fsync_async_000"); let fpath = await nextFileName("fileIO_test_fsync_async_000");
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
...@@ -50,9 +50,9 @@ export default function fileIOFsync() { ...@@ -50,9 +50,9 @@ export default function fileIOFsync() {
* Invalid fd parameter. * Invalid fd parameter.
* @tc.size : MediumTest * @tc.size : MediumTest
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 2 * @tc.level : Level 3
*/ */
it("fileIO_test_fsync_async_001", 0, async function (done) { it("fileIO_test_fsync_async_001", 3, async function (done) {
try { try {
await fileIO.fsync(-1); await fileIO.fsync(-1);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -72,7 +72,7 @@ export default function fileIOFsync() { ...@@ -72,7 +72,7 @@ export default function fileIOFsync() {
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it("fileIO_test_fsync_async_002", 0, async function (done) { it("fileIO_test_fsync_async_002", 2, async function (done) {
let fpath = await nextFileName("fileIO_test_fsync_async_002"); let fpath = await nextFileName("fileIO_test_fsync_async_002");
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
...@@ -100,9 +100,9 @@ export default function fileIOFsync() { ...@@ -100,9 +100,9 @@ export default function fileIOFsync() {
* Invalid fd parameter. * Invalid fd parameter.
* @tc.size : MediumTest * @tc.size : MediumTest
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 2 * @tc.level : Level 3
*/ */
it("fileIO_test_fsync_async_003", 0, async function (done) { it("fileIO_test_fsync_async_003", 3, async function (done) {
try { try {
fileIO.fsync(-1, (err) => { fileIO.fsync(-1, (err) => {
if (err) { if (err) {
...@@ -179,7 +179,7 @@ export default function fileIOFsync() { ...@@ -179,7 +179,7 @@ export default function fileIOFsync() {
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it("fileIO_test_fsync_sync_000", 0, async function () { it("fileIO_test_fsync_sync_000", 2, async function () {
let fpath = await nextFileName("fileIO_test_fsync_sync_000"); let fpath = await nextFileName("fileIO_test_fsync_sync_000");
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
...@@ -201,9 +201,9 @@ export default function fileIOFsync() { ...@@ -201,9 +201,9 @@ export default function fileIOFsync() {
* Invalid fd parameter. * Invalid fd parameter.
* @tc.size : MediumTest * @tc.size : MediumTest
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 2 * @tc.level : Level 3
*/ */
it("fileIO_test_fsync_sync_001", 0, function () { it("fileIO_test_fsync_sync_001", 3, function () {
try { try {
fileIO.fsyncSync(-1); fileIO.fsyncSync(-1);
expect(false).assertTrue(); expect(false).assertTrue();
......
...@@ -56,7 +56,7 @@ export default function fileIOMkdir() { ...@@ -56,7 +56,7 @@ export default function fileIOMkdir() {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
await fileIO.mkdirSync(fpath); await fileIO.mkdir(fpath);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
console.log("fileIO_test_mkdir_async_001 has failed for " + e.message + ", code: " + e.code); console.log("fileIO_test_mkdir_async_001 has failed for " + e.message + ", code: " + e.code);
......
...@@ -30,9 +30,9 @@ export default function fileIOOpen() { ...@@ -30,9 +30,9 @@ export default function fileIOOpen() {
it("fileIO_test_open_async_000", 2, async function (done) { it("fileIO_test_open_async_000", 2, async function (done) {
let fpath = await nextFileName("fileIO_test_open_async_000"); let fpath = await nextFileName("fileIO_test_open_async_000");
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let file = await fileIO.open(fpath, fileIO.OpenMode.READ_ONLY);
try { try {
let file = await fileIO.open(fpath, fileIO.OpenMode.READ_ONLY);
expect(isIntNum(file.fd)).assertTrue(); expect(isIntNum(file.fd)).assertTrue();
fileIO.read(file.fd, new ArrayBuffer(4096)).then((readLen) => { fileIO.read(file.fd, new ArrayBuffer(4096)).then((readLen) => {
expect(readLen == FILE_CONTENT.length).assertTrue(); expect(readLen == FILE_CONTENT.length).assertTrue();
...@@ -40,6 +40,7 @@ export default function fileIOOpen() { ...@@ -40,6 +40,7 @@ export default function fileIOOpen() {
fileIO.writeSync(file.fd, new ArrayBuffer(4096)); fileIO.writeSync(file.fd, new ArrayBuffer(4096));
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
fileIO.closeSync(file)
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log("fileIO_test_open_async_000 has failed for " + e.message + ", code: " + e.code); console.log("fileIO_test_open_async_000 has failed for " + e.message + ", code: " + e.code);
expect(e.code == 13900008 && e.message == "Bad file descriptor").assertTrue(); expect(e.code == 13900008 && e.message == "Bad file descriptor").assertTrue();
...@@ -1024,32 +1025,6 @@ export default function fileIOOpen() { ...@@ -1024,32 +1025,6 @@ export default function fileIOOpen() {
} }
}); });
// /**
// * @tc.number : TEST_FILEIO_OPEN_SYNC_011
// * @tc.name : testFileIoOpenSync011
// * @tc.desc : Test openSync() interfaces. mode=0o400002.
// * The path points to a symbolic link, throw error.
// * @tc.size : MediumTest
// * @tc.type : Function
// * @tc.level : Level 2
// */
// it('testFileIoOpenSync011', 0, async function () {
// let fpath = await nextFileName('testFileIoOpenSync011');
// let ffpath = fpath + 'aaaa';
// expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
// try {
// fileIO.symlinkSync(fpath, ffpath);
// fileIO.openSync(ffpath, fileIO.OpenMode.NOFOLLOW | fileIO.OpenMode.READ_WRITE);
// expect(false).assertTrue();
// } catch (e) {
// fileIO.unlinkSync(fpath);
// // fileIO.unlinkSync(ffpath);
// console.log('testFileIoOpenSync011 has failed for ' + e.message + ', code: ' + e.code);
// expect(e.code == 13900033 && e.message == 'Too many symbolic links encountered').assertTrue();
// }
// });
/** /**
* @tc.number : SUB_FM_TEST_FILEFS_OPEN_SYNC_1000 * @tc.number : SUB_FM_TEST_FILEFS_OPEN_SYNC_1000
* @tc.name : fileIO_test_open_sync_010 * @tc.name : fileIO_test_open_sync_010
......
/* /*
* Copyright (C) 2022 Huawei Device Co., Ltd. * Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License'); * Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册