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

!8321 Add XTS for Errno

Merge pull request !8321 from 冯俊青/Errno_add
......@@ -363,7 +363,7 @@ export default function fileIOOpen() {
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_open_sync_013', 0, async function (done) {
it('fileIO_test_open_sync_013', 0, async function () {
try {
fileIO.openSync(-1, fileIO.OpenMode.READ_WRITE);
......@@ -371,7 +371,30 @@ export default function fileIOOpen() {
} catch (e) {
console.log('fileIO_test_open_sync_013 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_OPEN_SYNC_1400
* @tc.name fileIO_test_open_sync_014
* @tc.desc Test openSync() interfaces. mode=0o200000.
* The path refers to a directory, not a file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_open_sync_014', 0, async function () {
let dpath = await nextFileName('fileIO_test_open_sync_012');
fileIO.mkdirSync(dpath);
try {
fileIO.openSync(dpath, fileIO.OpenMode.READ_WRITE);
expect(false).assertTrue();
} catch (e) {
fileIO.rmdirSync(dpath);
console.log('fileIO_test_open_sync_014 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900019 && e.message == 'Is a directory').assertTrue();
}
});
......@@ -1218,5 +1241,59 @@ export default function fileIOOpen() {
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_OPEN_ASYNC_2900
* @tc.name fileIO_test_open_async_029
* @tc.desc Test open() interfaces. Promise.
* The path refers to a file, not a directory.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_open_async_029', 0, async function (done) {
let dpath = await nextFileName('fileIO_test_open_async_029');
fileIO.mkdirSync(dpath);
try {
await fileIO.open(dpath, fileIO.OpenMode.READ_WRITE);
expect(false).assertTrue();
} catch (e) {
fileIO.rmdirSync(dpath);
console.log('fileIO_test_open_async_029 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900019 && e.message == 'Is a directory').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_OPEN_ASYNC_3000
* @tc.name fileIO_test_open_async_030
* @tc.desc Test open() interfaces. Callback.
* The path refers to a file, not a directory.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_open_async_030', 0, async function (done) {
let dpath = await nextFileName('fileIO_test_open_async_030');
fileIO.mkdirSync(dpath);
try {
fileIO.open(dpath, fileIO.OpenMode.READ_WRITE, (err, file) => {
if (err) {
fileIO.rmdirSync(dpath);
console.log('fileIO_test_open_async_030 error: {message: ' + err.message + ', code: ' + err.code + '}');
expect(err.code == 13900019 && err.message == 'Is a directory').assertTrue();
done();
}
});
} catch (e) {
console.log('fileIO_test_open_async_030 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
});
}
......@@ -13,6 +13,7 @@
* limitations under the License.
*/
import featureAbility from '@ohos.ability.featureAbility';
import {
fileIO, FILE_CONTENT, prepareFile, nextFileName, describe, it, expect, randomString
} from '../Common';
......@@ -176,18 +177,64 @@ describe('fileIO_fs_rename', function () {
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_rename_sync_006', 0, async function (done) {
it('fileIO_test_rename_sync_006', 0, async function () {
let fpath = await nextFileName('fileIO_test_rename_sync_006');
let fpathTarget = fpath + randomString(250);
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
await fileIO.rename(fpath, fpathTarget);
fileIO.renameSync(fpath, fpathTarget);
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_test_rename_sync_006 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900030 && e.message == 'File name too long').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_RENAME_SYNC_0700
* @tc.name fileIO_test_rename_sync_007
* @tc.desc Test rename() interfaces.
* Don't have permission to operate on the root directory.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_rename_sync_007', 0, async function () {
try {
fileIO.renameSync('/data', '/data_new');
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_rename_sync_007 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900012 && e.message == 'Permission denied').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_RENAME_SYNC_0800
* @tc.name fileIO_test_rename_sync_008
* @tc.desc Test rename() interfaces.
* Can't modify file names across devices.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_rename_sync_008', 0, async function () {
let dstDir = await featureAbility.getContext().getOrCreateDistributedDir();
let fpath = await nextFileName('fileIO_test_rename_sync_008');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.renameSync(fpath, dstDir + '/data_new');
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_test_rename_sync_008 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900016 && e.message == 'Cross-device link').assertTrue();
}
});
......@@ -453,6 +500,7 @@ describe('fileIO_fs_rename', function () {
await fileIO.rename(fpath, fpathTarget);
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_test_rename_async_009 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900030 && e.message == 'File name too long').assertTrue();
done();
......@@ -488,5 +536,83 @@ describe('fileIO_fs_rename', function () {
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_RENAME_ASYNC_1100
* @tc.name fileIO_test_rename_async_011
* @tc.desc Test rename() interfaces. Promise.
* Don't have permission to operate on the root directory.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_rename_async_011', 0, async function (done) {
try {
await fileIO.rename('/data', '/data_new');
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_rename_async_011 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900012 && e.message == 'Permission denied').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_RENAME_ASYNC_1200
* @tc.name fileIO_test_rename_async_012
* @tc.desc Test rename() interfaces.
* Can't modify file names across devices.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_rename_async_012', 0, async function (done) {
let dstDir = await featureAbility.getContext().getOrCreateDistributedDir();
let fpath = await nextFileName('fileIO_test_rename_async_012');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
await fileIO.rename(fpath, dstDir + '/data_new');
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_test_rename_async_012 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900016 && e.message == 'Cross-device link').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_RENAME_ASYNC_1300
* @tc.name fileIO_test_rename_async_013
* @tc.desc Test rename() interfaces.
* Can't modify file names across devices.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_rename_async_013', 0, async function (done) {
let dstDir = await featureAbility.getContext().getOrCreateDistributedDir();
let fpath = await nextFileName('fileIO_test_rename_async_013');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.rename(fpath, dstDir + '/data_new', (err) => {
if (err) {
fileIO.unlinkSync(fpath);
console.log('fileIO_test_symlink_async_005 error: {message: ' + err.message + ', code: ' + err.code + '}');
expect(err.code == 13900016 && err.message == 'Cross-device link').assertTrue();
done();
}
});
} catch (e) {
console.log('fileIO_test_rename_async_013 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
});
}
......@@ -13,6 +13,7 @@
* limitations under the License.
*/
import featureAbility from '@ohos.ability.featureAbility';
import {
fileIO, FILE_CONTENT, prepareFile, nextFileName, describe, it, expect,
} from '../Common';
......@@ -69,6 +70,31 @@ describe('fileIO_fs_symlink', function () {
}
});
/**
* @tc.number SUB_DF_FILEIO_SYMLINK_SYNC_0200
* @tc.name fileIO_test_symlink_sync_002
* @tc.desc Test symlinkSync() interfaces.
* Can't create a symbolic links in distributed directories.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_symlink_sync_002', 0, async function () {
let dstDir = await featureAbility.getContext().getOrCreateDistributedDir();
let fpath = await nextFileName('fileIO_test_symlink_sync_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.symlinkSync(fpath, dstDir + '/link_000');
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_test_symlink_sync_002 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900001 && e.message == 'Operation not permitted').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_SYMLINK_ASYNC_0000
* @tc.name fileIO_test_symlink_async_000
......@@ -180,5 +206,61 @@ describe('fileIO_fs_symlink', function () {
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_SYMLINK_ASYNC_0400
* @tc.name fileIO_test_symlink_async_004
* @tc.desc Test symlink() interfaces.
* Can't create a symbolic links in distributed directories.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_symlink_async_004', 0, async function (done) {
let dstDir = await featureAbility.getContext().getOrCreateDistributedDir();
let fpath = await nextFileName('fileIO_test_symlink_async_004');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
await fileIO.symlink(fpath, dstDir + '/link_001');
expect(false).assertTrue();
} catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_test_symlink_async_004 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900001 && e.message == 'Operation not permitted').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_SYMLINK_ASYNC_0500
* @tc.name fileIO_test_symlink_async_005
* @tc.desc Test symlink() interfaces.
* Can't create a symbolic links in distributed directories.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_symlink_async_005', 0, async function (done) {
let dstDir = await featureAbility.getContext().getOrCreateDistributedDir();
let fpath = await nextFileName('fileIO_test_symlink_async_005');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.symlink(fpath, dstDir + '/link_002', (err) => {
if (err) {
fileIO.unlinkSync(fpath);
console.log('fileIO_test_symlink_async_005 error: {message: ' + err.message + ', code: ' + err.code + '}');
expect(err.code == 13900001 && err.message == 'Operation not permitted').assertTrue();
done();
}
});
} catch (e) {
console.log('fileIO_test_symlink_async_005 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
});
}
......@@ -86,6 +86,31 @@ describe('fileIO_fs_unlink', function () {
}
});
/**
* @tc.number SUB_DF_FILEIO_UNLINK_SYNC_0300
* @tc.name fileIO_test_unlink_sync_003
* @tc.desc Test unlinkSync() interfaces.
* The path refers to a directory, not a file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_unlink_sync_003', 0, async function () {
let dpath = await nextFileName('fileIO_test_unlink_sync_003');
fileIO.mkdirSync(dpath);
try {
expect(fileIO.accessSync(dpath)).assertTrue();
fileIO.unlinkSync(dpath);
expect(false).assertTrue();
} catch (e) {
fileIO.rmdirSync(dpath);
console.log('fileIO_test_unlink_sync_003 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900019 && e.message == 'Is a directory').assertTrue();
}
});
/**
* @tc.number SUB_DF_FileIO_UNLINK_ASYNC_0000
* @tc.name fileIO_test_unlink_async_000
......@@ -212,5 +237,61 @@ describe('fileIO_fs_unlink', function () {
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_UNLINK_ASYNC_0500
* @tc.name fileIO_test_unlink_async_005
* @tc.desc Test unlink() interfaces. Promise.
* The path refers to a directory, not a file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_unlink_async_005', 0, async function (done) {
let dpath = await nextFileName('fileIO_test_unlink_async_005');
fileIO.mkdirSync(dpath);
try {
expect(fileIO.accessSync(dpath)).assertTrue();
await fileIO.unlink(dpath);
expect(false).assertTrue();
} catch (e) {
fileIO.rmdirSync(dpath);
console.log('fileIO_test_unlink_async_005 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900019 && e.message == 'Is a directory').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_UNLINK_ASYNC_0600
* @tc.name fileIO_test_unlink_async_006
* @tc.desc Test unlink() interfaces. Callback.
* The path refers to a directory, not a file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 3
* @tc.require
*/
it('fileIO_test_unlink_async_006', 0, async function (done) {
let dpath = await nextFileName('fileIO_test_unlink_async_006');
fileIO.mkdirSync(dpath);
try {
expect(fileIO.accessSync(dpath)).assertTrue();
fileIO.unlink(dpath, (err) => {
if (err) {
fileIO.rmdirSync(dpath);
console.log('fileIO_test_unlink_async_006 error: {message: ' + err.message + ', code: ' + err.code + '}');
expect(err.code == 13900019 && err.message == 'Is a directory').assertTrue();
done();
}
});
} catch (e) {
console.log('fileIO_test_unlink_async_006 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
});
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册