提交 a235b282 编写于 作者: H hu0475

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

Signed-off-by: Nhu0475 <huyanqiang5@huawei.com>
上级 420efaa4
......@@ -125,22 +125,22 @@ export default function fileIOClose() {
* @tc.type : Function
* @tc.level : Level 2
*/
it("fileIO_test_close_async_003", 2, async function (done) {
let fpath = await nextFileName("fileIO_test_close_async_003");
it("fileIO_test_close_async_004", 2, async function (done) {
let fpath = await nextFileName("fileIO_test_close_async_004");
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
fileIO.close(file.fd, (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();
}
fileIO.unlinkSync(fpath);
done();
});
} 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();
}
});
......
......@@ -27,7 +27,7 @@ export default function fileIOFsync() {
* @tc.type : Function
* @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");
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
......@@ -50,9 +50,9 @@ export default function fileIOFsync() {
* Invalid fd parameter.
* @tc.size : MediumTest
* @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 {
await fileIO.fsync(-1);
expect(false).assertTrue();
......@@ -72,7 +72,7 @@ export default function fileIOFsync() {
* @tc.type : Function
* @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");
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
......@@ -100,9 +100,9 @@ export default function fileIOFsync() {
* Invalid fd parameter.
* @tc.size : MediumTest
* @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 {
fileIO.fsync(-1, (err) => {
if (err) {
......@@ -179,7 +179,7 @@ export default function fileIOFsync() {
* @tc.type : Function
* @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");
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
......@@ -201,9 +201,9 @@ export default function fileIOFsync() {
* Invalid fd parameter.
* @tc.size : MediumTest
* @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 {
fileIO.fsyncSync(-1);
expect(false).assertTrue();
......
......@@ -56,7 +56,7 @@ export default function fileIOMkdir() {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
await fileIO.mkdirSync(fpath);
await fileIO.mkdir(fpath);
expect(false).assertTrue();
} catch (e) {
console.log("fileIO_test_mkdir_async_001 has failed for " + e.message + ", code: " + e.code);
......
......@@ -30,9 +30,9 @@ export default function fileIOOpen() {
it("fileIO_test_open_async_000", 2, async function (done) {
let fpath = await nextFileName("fileIO_test_open_async_000");
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let file = await fileIO.open(fpath, fileIO.OpenMode.READ_ONLY);
try {
let file = await fileIO.open(fpath, fileIO.OpenMode.READ_ONLY);
expect(isIntNum(file.fd)).assertTrue();
fileIO.read(file.fd, new ArrayBuffer(4096)).then((readLen) => {
expect(readLen == FILE_CONTENT.length).assertTrue();
......@@ -40,6 +40,7 @@ export default function fileIOOpen() {
fileIO.writeSync(file.fd, new ArrayBuffer(4096));
expect(false).assertTrue();
} catch (e) {
fileIO.closeSync(file)
fileIO.unlinkSync(fpath);
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();
......@@ -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.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');
* you may not use this file except in compliance with the License.
* 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.
先完成此消息的编辑!
想要评论请 注册