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

!3589 update fileio testcase

Merge pull request !3589 from raoxian/master
......@@ -29,6 +29,7 @@ require('./module_fileio/members/chown.test.js');
require('./module_fileio/members/close.test.js');
require('./module_fileio/members/copyFile.test.js');
require('./module_fileio/members/createStream.test.js');
require('./module_fileio/members/fchmod.test.js');
require('./module_fileio/members/fchown.test.js');
require('./module_fileio/members/fdatasync.test.js');
require('./module_fileio/members/fdopenStream.test.js');
......
......@@ -23,8 +23,8 @@ describe('fileio_chmod', function () {
/**
* @tc.number SUB_DF_FILEIO_CHMODSYNC_0000
* @tc.name fileio_test_chmod_sync_000
* @tc.desc Test chmodSync() interfaces
* @tc.size MEDIUM(中型)
* @tc.desc Test chmodSync() interfaces, mode = 0o660. Test file permissions modified successfully.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
......@@ -34,20 +34,20 @@ describe('fileio_chmod', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
expect(fileio.chmodSync(fpath, 0o660) == null).assertTrue();
fileio.chmodSync(fpath, 0o660);
expect((fileio.statSync(fpath).mode & 0o777) == 0o660).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue();
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileio_test_chmod_sync_000 has failed for ' + e);
console.info('fileio_test_chmod_sync_000 has failed for ' + e);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEIO_CHMODSYNC_0010
* @tc.number SUB_DF_FILEIO_CHMODSYNC_0100
* @tc.name fileio_test_chmod_sync_001
* @tc.desc Test chmodSync() interfaces
* @tc.size MEDIUM(中型)
* @tc.desc Test chmodSync() interfaces, mode = 0o0700. Test file permissions modified successfully.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
......@@ -57,52 +57,71 @@ describe('fileio_chmod', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
expect(fileio.chmodSync(fpath, 0o0700) == null).assertTrue();
fileio.chmodSync(fpath, 0o0700);
expect((fileio.statSync(fpath).mode & 0o777) == 0o0700).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue();
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileio_test_chmod_sync_001 has failed for ' + e);
console.info('fileio_test_chmod_sync_001 has failed for ' + e);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEIO_CHMODSYNC_0200
* @tc.name fileio_test_chmod_sync_002
* @tc.desc Test chmodSync() interfaces, invalid path. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_chmod_sync_002', 0, async function () {
let fpath = await nextFileName('fileio_test_chmod_sync_002');
try {
fileio.chmodSync(fpath, 0o0700);
} catch (e) {
console.info('fileio_test_chmod_sync_002 has failed for ' + e);
expect(e.message == "No such file or directory").assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_CHMODASYNC_0000
* @tc.name fileio_test_chmod_async_000
* @tc.desc Test chmodAsync() interfaces
* @tc.size MEDIUM(中型)
* @tc.desc Test the chmodAsync() interface with promise, mode = 0o660. Test file permissions modified successfully.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_chmod_async_000', 0, async function (done) {
let fpath = await nextFileName('fileio_test_chmod_async_001');
let fpath = await nextFileName('fileio_test_chmod_async_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileio
.chmod(fpath, 0o660)
.then(function (err) {
expect(!err).assertTrue();
expect((fileio.statSync(fpath).mode & 0o777) == 0o660).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue();
fileio.unlinkSync(fpath);
done();
})
.catch(function (e) {
console.log(e);
console.info(e);
});
done();
} catch (e) {
console.log('fileio_test_chmod_async_000 has failed for ' + e);
console.info('fileio_test_chmod_async_000 has failed for ' + e);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEIO_CHMODASYNC_0010
* @tc.number SUB_DF_FILEIO_CHMODASYNC_0100
* @tc.name fileio_test_chmod_async_001
* @tc.desc Test chmodAsync() interfaces
* @tc.size MEDIUM(中型)
* @tc.desc Test the chmodAsync() interface with promise, mode = 0o0700. Test file permissions modified successfully.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
......@@ -115,68 +134,88 @@ describe('fileio_chmod', function () {
fileio
.chmod(fpath, 0o0700)
.then(function (err) {
expect(!err).assertTrue();
expect((fileio.statSync(fpath).mode & 0o777) == 0o0700).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue();
fileio.unlinkSync(fpath);
done();
})
.catch(function (e) {
console.log(e);
console.info(e);
});
done();
} catch (e) {
console.log('fileio_test_chmod_async_001 has failed for ' + e);
console.info('fileio_test_chmod_async_001 has failed for ' + e);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEIO_CHMODASYNC_0020
* @tc.number SUB_DF_FILEIO_CHMODASYNC_0200
* @tc.name fileio_test_chmod_async_002
* @tc.desc Test chmodAsync() interfaces
* @tc.size MEDIUM(中型)
* @tc.desc Test the chmodAsync() interface with callback, mode = 0o660. Test file permissions modified successfully.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_chmod_async_002', 0, async function (done) {
let fpath = await nextFileName('fileio_test_chmod_async_000');
let fpath = await nextFileName('fileio_test_chmod_async_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
await fileio.chmod(fpath, 0o660, function () {
fileio.chmod(fpath, 0o660, function () {
expect((fileio.statSync(fpath).mode & 0o777) == 0o660).assertTrue();
fileio.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileio_test_chmod_async_002 has failed for ' + e);
console.info('fileio_test_chmod_async_002 has failed for ' + e);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEIO_CHMODASYNC_0030
* @tc.number SUB_DF_FILEIO_CHMODASYNC_0300
* @tc.name fileio_test_chmod_async_003
* @tc.desc Test chmodAsync() interfaces
* @tc.size MEDIUM(中型)
* @tc.desc Test the chmodAsync() interface with callback, mode = 0o0700. Test file permissions modified successfully.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_chmod_async_003', 0, async function (done) {
let fpath = await nextFileName('fileio_test_chmod_async_000');
let fpath = await nextFileName('fileio_test_chmod_async_003');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
await fileio.chmod(fpath, 0o0700, function () {
fileio.chmod(fpath, 0o0700, function () {
expect((fileio.statSync(fpath).mode & 0o777) == 0o0700).assertTrue();
fileio.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileio_test_chmod_async_003 has failed for ' + e);
console.info('fileio_test_chmod_async_003 has failed for ' + e);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEIO_CHMODASYNC_0400
* @tc.name fileio_test_chmod_async_004
* @tc.desc Test the chmodAsync() interface with promise, invalid path. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_chmod_async_004', 0, async function (done) {
let fpath = await nextFileName('fileio_test_chmod_async_004');
try {
await fileio.chmod(fpath, 0o660);
} catch (e) {
console.info('fileio_test_chmod_async_004 has failed for ' + e);
expect(e.message == "No such file or directory").assertTrue();
done();
}
});
});
......@@ -21,10 +21,10 @@ import {
describe('fileio_chown', function () {
/**
* @tc.number SUB_DF_FILEIO_CHOWNSYNC_000
* @tc.number SUB_DF_FILEIO_CHOWNSYNC_0000
* @tc.name fileio_test_chown_sync_000
* @tc.desc Test chownSync() interface
* @tc.size MEDIUM(中型)
* @tc.desc Test chownSync() interface. The test file was modified successfully.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
......@@ -33,58 +33,243 @@ describe('fileio_chown', function () {
let fpath = await nextFileName('fileio_test_chown_sync_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileio.chmodSync(fpath, 0o777);
let stat = fileio.statSync(fpath);
expect(fileio.chownSync(fpath, stat.uid, stat.gid));
expect(fileio.unlinkSync(fpath) == null).assertTrue();
fileio.chownSync(fpath, stat.uid, stat.gid);
fileio.unlinkSync(fpath);
} catch (e) {
console.info('fileio_test_chown_sync_000 has failed for ' + e);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEIO_CHOWNASYNC_000
* @tc.number SUB_DF_FILEIO_CHOWNSYNC_0100
* @tc.name fileio_test_chown_sync_001
* @tc.desc Test chownSync() interface, wrong uid, gid. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_chown_sync_001', 0, async function () {
let fpath = await nextFileName('fileio_test_chown_sync_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileio.chownSync(fpath, 0, 0);
} catch (e) {
console.info('fileio_test_chown_sync_001 has failed for ' + e);
expect(e.message == "Operation not permitted").assertTrue();
fileio.unlinkSync(fpath);
}
});
/**
* @tc.number SUB_DF_FILEIO_CHOWNSYNC_0200
* @tc.name fileio_test_chown_sync_002
* @tc.desc Test chownSync() interface, wrong owner. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_chown_sync_002', 0, async function () {
let fpath = await nextFileName('fileio_test_chown_sync_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileio.statSync(fpath);
fileio.chownSync(fpath, null, stat.gid);
} catch (e) {
console.info('fileio_test_chown_sync_002 has failed for ' + e);
expect(e.message == "Invalid owner").assertTrue();
fileio.unlinkSync(fpath);
}
});
/**
* @tc.number SUB_DF_FILEIO_CHOWNSYNC_0300
* @tc.name fileio_test_chown_sync_003
* @tc.desc Test chownSync() interface, wrong group. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_chown_sync_003', 0, async function () {
let fpath = await nextFileName('fileio_test_chown_sync_003');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileio.statSync(fpath);
fileio.chownSync(fpath, stat.uid, null);
} catch (e) {
console.info('fileio_test_chown_sync_003 has failed for ' + e);
expect(e.message == "Invalid group").assertTrue();
fileio.unlinkSync(fpath);
}
});
/**
* @tc.number SUB_DF_FILEIO_CHOWNSYNC_0400
* @tc.name fileio_test_chown_sync_004
* @tc.desc Test chownSync() interface, file does not exist. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_chown_sync_004', 0, async function () {
let fpath = await nextFileName('fileio_test_chown_sync_004');
let ffpath = await nextFileName('fileio_test_chown_sync_004_1');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileio.statSync(fpath);
fileio.chownSync(ffpath, stat.uid, stat.gid);
} catch (e) {
console.info('fileio_test_chown_sync_004 has failed for ' + e);
expect(e.message == "No such file or directory").assertTrue();
fileio.unlinkSync(fpath);
}
});
/**
* @tc.number SUB_DF_FILEIO_CHOWNASYNC_0000
* @tc.name fileio_test_chown_async_00
* @tc.desc Test chownASync() interface
* @tc.size MEDIUM(中型)
* @tc.desc Test the chownAsync() interface with promise. The test file was modified successfully.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_chown_async_000', 0, async function (done) {
let fpath = await nextFileName('fileio_chown_Async_000');
it('fileio_test_chown_async_000', 0, async function (done) {
let fpath = await nextFileName('fileio_test_chown_async_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileio.chmodSync(fpath, 0o777);
let stat = fileio.statSync(fpath);
expect(await fileio.chown(fpath, stat.uid, stat.gid) == null).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue();
await fileio.chown(fpath, stat.uid, stat.gid);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileio_test_chown_async_000 has failed for ' + e);
console.info('fileio_test_chown_async_000 has failed for ' + e);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEIO_CHOWNASYNC_001
* @tc.name fileio_test_chown_async_00
* @tc.desc Test chownASync() interface
* @tc.size MEDIUM(中型)
* @tc.number SUB_DF_FILEIO_CHOWNASYNC_0100
* @tc.name fileio_test_chown_async_001
* @tc.desc Test the chownAsync() interface with callback. The test file was modified successfully.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_chown_async_001', 0, async function (done) {
let fpath = await nextFileName('fileio_chown_Async_001');
it('fileio_test_chown_async_001', 0, async function (done) {
let fpath = await nextFileName('fileio_test_chown_async_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileio.chmodSync(fpath, 0o777);
let stat = fileio.statSync(fpath);
fileio.chown(fpath, stat.uid, stat.gid, function (error) {
expect(fileio.unlinkSync(fpath) == null).assertTrue();
fileio.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileio_chown_Async_001 has failed for ' + e);
console.info('fileio_test_chown_async_001 has failed for ' + e);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEIO_CHOWNASYNC_0200
* @tc.name fileio_test_chown_async_002
* @tc.desc Test the chownAsync() interface with promise, wrong uid, gid. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_chown_async_002', 0, async function (done) {
let fpath = await nextFileName('fileio_test_chown_async_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
await fileio.chown(fpath, 0, 0);
} catch (e) {
console.info('fileio_test_chown_async_002 has failed for ' + e);
expect(e.message == "Operation not permitted").assertTrue();
fileio.unlinkSync(fpath);
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_CHOWNASYNC_0300
* @tc.name fileio_test_chown_async_003
* @tc.desc Test the chownAsync() interface with promise, wrong owner. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_chown_async_003', 0, async function (done) {
let fpath = await nextFileName('fileio_test_chown_async_003');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileio.statSync(fpath);
await fileio.chown(fpath, null, stat.gid);
} catch (e) {
console.info('fileio_test_chown_async_003 has failed for ' + e);
expect(e.message == "Invalid owner").assertTrue();
fileio.unlinkSync(fpath);
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_CHOWNASYNC_0400
* @tc.name fileio_test_chown_async_004
* @tc.desc Test the chownAsync() interface with callback, wrong group. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_chown_async_004', 0, async function (done) {
let fpath = await nextFileName('fileio_test_chown_async_004');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileio.statSync(fpath);
fileio.chown(fpath, stat.uid, null, function (error) {
});
} catch (e) {
console.info('fileio_test_chown_async_004 has failed for ' + e);
expect(e.message == "Invalid group").assertTrue();
fileio.unlinkSync(fpath);
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_CHOWNASYNC_0500
* @tc.name fileio_test_chown_async_005
* @tc.desc Test the chownAsync() interface with promise, file does not exist. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_chown_async_005', 0, async function (done) {
let fpath = await nextFileName('fileio_test_chown_async_005');
let ffpath = await nextFileName('fileio_test_chown_async_005_1');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileio.statSync(fpath);
await fileio.chown(ffpath, stat.uid, stat.gid);
} catch (e) {
console.info('fileio_test_chown_async_005 has failed for ' + e);
expect(e.message == "No such file or directory").assertTrue();
fileio.unlinkSync(fpath);
done();
}
});
});
......@@ -21,120 +21,105 @@ import {
describe('fileio_fchmod', function () {
/**
* @tc.number SUB_DF_FILEIO_FCHMOD_ASYNC_0000
* @tc.name fileio_test_fchmod_async_000
* @tc.desc Test fchmodAsync()interfaces.
* @tc.number SUB_DF_FILEIO_FCHMOD_SYNC_0000
* @tc.name fileio_test_fchmod_sync_000
* @tc.desc Test fchmodSync() interfaces, mode = 0o660. Test file permissions modified successfully.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_fchmod_async_000', 0, async function (done) {
let fpath = await nextFileName('fileio_test_fchmod_async_000');
it('fileio_test_fchmod_sync_000', 0, async function () {
let fpath = await nextFileName('fileio_test_fchmod_sync_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
await fileio
.open(fpath, 0o1, 0o0200)
.then(function (fd) {
fileio.fchmod(fd, 1002, function (err) {
fileio.statSync(fpath);
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
done();
});
})
.catch(function (err) {
expect(err == null).assertTrue();
});
let fd = fileio.openSync(fpath, 0o2);
fileio.fchmodSync(fd, 0o660);
expect((fileio.statSync(fpath).mode & 0o777) == 0o660).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.info('fileio_test_fchmod_sync_000 has failed for ' + e);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEIO_FCHMOD_ASYNC_0010
* @tc.name fileio_test_fchmod_async_001
* @tc.desc Test fchmodAsync()interfaces.
* @tc.number SUB_DF_FILEIO_FCHMOD_SYNC_0100
* @tc.name fileio_test_fchmod_sync_001
* @tc.desc Test fchmodSync() interfaces, invalid fd. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_fchmod_async_001', 0, async function (done) {
let fpath = await nextFileName('fileio_test_fchmod_async_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
it('fileio_test_fchmod_sync_001', 0, function () {
try {
await fileio
.open(fpath, 0o0, 0o0200)
.then(function (fd) {
fileio
.fchmod(fd, 1003)
.then(function (err) {
fileio.statSync(fpath);
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
})
.catch(function (err) {
expect(err == null).assertTrue();
});
})
.catch(function (err) {
expect(err == null).assertTrue();
});
done();
fileio.fchmodSync(-1, 0o660);
} catch (e) {
expect(null).assertFail();
console.info('fileio_test_fchmod_sync_001 has failed for ' + e);
expect(e.message == "Bad file descriptor").assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_FCHMOD_SYNC_0000
* @tc.name fileio_test_fchmod_sync_000
* @tc.desc Test fchmodSync()interfaces.
* @tc.number SUB_DF_FILEIO_FCHMOD_ASYNC_0000
* @tc.name fileio_test_fchmod_async_000
* @tc.desc Test the fchmodAsync() interface with callback, mode = 1002. Test file permissions modified successfully.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_fchmod_sync_000', 0, async function () {
let fpath = await nextFileName('fileio_test_fchmod_sync_000');
it('fileio_test_fchmod_async_000', 0, async function (done) {
let fpath = await nextFileName('fileio_test_fchmod_async_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let fd = fileio.openSync(fpath, 0o2);
expect(fileio.fchmodSync(fd, 0o660) == null).assertTrue();
expect((fileio.statSync(fpath).mode & 0o777) == 0o660).assertTrue();
expect(fileio.closeSync(fd) == null).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue();
let fd = fileio.openSync(fpath, 0o1, 0o0200);
fileio.fchmod(fd, 1002, function (err) {
expect((fileio.statSync(fpath).mode & 0o777) == 0o752).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileio_test_fchmod_sync_000 has failed for ' + e);
console.info('fileio_test_fchmod_async_000 has failed for ' + e);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEIO_FCHMOD_SYNC_0010
* @tc.name fileio_test_fchmod_sync_001
* @tc.desc Test fchmodSync() interfaces.
* @tc.number SUB_DF_FILEIO_FCHMOD_ASYNC_0100
* @tc.name fileio_test_fchmod_async_001
* @tc.desc Test the fchmodAsync() interface with callback, mode = 1003. Test file permissions modified successfully.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_fchmod_sync_001', 0, function () {
it('fileio_test_fchmod_async_001', 0, async function (done) {
let fpath = await nextFileName('fileio_test_fchmod_async_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
expect(fileio.fchmodSync(-1, 0o660) == null).assertTrue();
expect(null).assertFail();
let fd = fileio.openSync(fpath, 0o0, 0o0200);
fileio.fchmod(fd, 1003).then(function (err) {
expect((fileio.statSync(fpath).mode & 0o777) == 0o753).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
done();
})
} catch (e) {
console.log('fileio_test_fchmod_sync_001 has failed for ' + e);
console.info('fileio_test_fchmod_async_001 has failed for ' + e);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEIO_FCHMOD_ASYNC_0020
* @tc.number SUB_DF_FILEIO_FCHMOD_ASYNC_0200
* @tc.name fileio_test_fchmod_async_002
* @tc.desc Test fchmod() interfaces.
* @tc.desc Test the fchmodAsync() interface with callback, mode = 0o100. Test file permissions modified successfully.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
......@@ -144,23 +129,23 @@ describe('fileio_fchmod', function () {
let fpath = await nextFileName('fileio_test_fchmod_async_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
await fileio.open(fpath, 0o1, 0o020).then(function (fd) {
fileio.fchmod(fd, 0o100, function (err) {
expect(fileio.closeSync(fd) == null).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue();
done();
});
let fd = fileio.openSync(fpath, 0o1, 0o020);
fileio.fchmod(fd, 0o100, function (err) {
expect((fileio.statSync(fpath).mode & 0o777) == 0o100).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileio_test_fchmod_async_002 has failed for ' + e);
console.info('fileio_test_fchmod_async_002 has failed for ' + e);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEIO_FCHMOD_ASYNC_0030
* @tc.number SUB_DF_FILEIO_FCHMOD_ASYNC_0300
* @tc.name fileio_test_fchmod_async_003
* @tc.desc Test fchmod() interfaces.
* @tc.desc Test the fchmodAsync() interface with promise, mode = 0o400. Test file permissions modified successfully.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
......@@ -170,16 +155,34 @@ describe('fileio_fchmod', function () {
let fpath = await nextFileName('fileio_test_fchmod_async_003');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let fd = await fileio.open(fpath, 0o1, 0o020);
expect((await fileio.fchmod(fd, 0o400)) == null).assertTrue();
expect(fileio.closeSync(fd) == null).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue();
let fd = fileio.openSync(fpath, 0o1, 0o020);
await fileio.fchmod(fd, 0o400);
expect((fileio.statSync(fpath).mode & 0o777) == 0o400).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileio_test_fchmod_async_003 has failed for ' + e);
console.info('fileio_test_fchmod_async_003 has failed for ' + e);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEIO_FCHMOD_ASYNC_0400
* @tc.name fileio_test_fchmod_async_004
* @tc.desc Test the fchmodAsync() interface with promise, invalid fd. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_fchmod_async_004', 0, async function (done) {
try {
await fileio.fchmod(-1, 0o666);
} catch (e) {
console.info('fileio_test_fchmod_async_004 has failed for ' + e);
expect(e.message == "Bad file descriptor").assertTrue();
done();
}
});
});
......@@ -23,7 +23,7 @@ describe('fileio_fchown', async function () {
/**
* @tc.number SUB_DF_FILEIO_FCHOWN_ASYNC_0000
* @tc.name fileio_test_fchown_async_000
* @tc.desc Test fchown() and open() and statSync() interfaces.
* @tc.desc Test the fchownAsync() interface with callback. The test file was modified successfully.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
......@@ -36,20 +36,22 @@ describe('fileio_fchown', async function () {
let stat = fileio.statSync(fpath);
expect(isIntNum(stat.uid)).assertTrue();
let fd = fileio.openSync(fpath, 0o102, 0o666);
fileio.fchmodSync(fd, 0o777);
fileio.fchown(fd, stat.uid, stat.gid, function (err) {
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
done();
});
} catch (e) {
console.info('fileio_test_fchown_async_000 has failed for ' + e);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEIO_FCHOWN_ASYNC_0010
* @tc.number SUB_DF_FILEIO_FCHOWN_ASYNC_0100
* @tc.name fileio_test_fchown_async_001
* @tc.desc Test fchown() and open() and statSync() interfaces.
* @tc.desc Test the fchownAsync() interface with promise. The test file was modified successfully.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
......@@ -62,19 +64,21 @@ describe('fileio_fchown', async function () {
let stat = fileio.statSync(fpath);
expect(isIntNum(stat.uid)).assertTrue();
let fd = fileio.openSync(fpath, 0o102, 0o666);
fileio.fchown(fd, stat.uid, stat.gid);
expect(fileio.closeSync(fd) == null).assertTrue();
fileio.fchmodSync(fd, 0o777);
await fileio.fchown(fd, stat.uid, stat.gid);
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.info('fileio_test_fchown_async_001 has failed for ' + e);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEIO_FCHOWN_ASYNC_0020
* @tc.number SUB_DF_FILEIO_FCHOWN_ASYNC_0200
* @tc.name fileio_test_fchown_async_002
* @tc.desc Test fchown() and open() and statSync() interfaces.
* @tc.desc Test the fchownAsync() interface with promise, invalid fd. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
......@@ -85,14 +89,82 @@ describe('fileio_fchown', async function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileio.statSync(fpath);
expect(isIntNum(stat.uid)).assertTrue();
fileio.fchown(-1, stat.uid, stat.gid);
expect(null).assertFail();
await fileio.fchown(-1, stat.uid, stat.gid);
} catch (e) {
console.info('fileio_test_fchown_async_002 has failed for ' + e);
expect(e.message == "Bad file descriptor").assertTrue();
fileio.unlinkSync(fpath);
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_FCHOWN_ASYNC_0300
* @tc.name fileio_test_fchown_async_003
* @tc.desc Test the fchownAsync() interface with promise, wrong uid, gid. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_fchown_async_003', 0, async function (done) {
let fpath = await nextFileName('fileio_test_fchown_async_003');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let fd = fileio.openSync(fpath);
await fileio.fchown(fd, 0, 0);
} catch (e) {
console.info('fileio_test_fchown_async_003 has failed for ' + e);
expect(e.message == "Operation not permitted").assertTrue();
fileio.unlinkSync(fpath);
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_FCHOWN_ASYNC_0400
* @tc.name fileio_test_fchown_async_004
* @tc.desc Test the fchownAsync() interface with promise, wrong owner. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_fchown_async_004', 0, async function (done) {
let fpath = await nextFileName('fileio_test_fchown_async_004');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let fd = fileio.openSync(fpath);
let stat = fileio.statSync(fpath);
await fileio.fchown(fd, null, stat.gid);
} catch (e) {
console.log('fileio_test_fchown_003 has failed for ' + e);
expect(!!e).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue();
console.info('fileio_test_fchown_async_004 has failed for ' + e);
expect(e.message == "Operation not permitted" || e.message == "Invalid owner").assertTrue();
fileio.unlinkSync(fpath);
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_FCHOWN_ASYNC_0500
* @tc.name fileio_test_fchown_async_005
* @tc.desc Test the fchownAsync() interface with promise, wrong group. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_fchown_async_005', 0, async function (done) {
let fpath = await nextFileName('fileio_test_fchown_async_005');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let fd = fileio.openSync(fpath);
let stat = fileio.statSync(fpath);
await fileio.fchown(fd, stat.uid, null);
} catch (e) {
console.info('fileio_test_fchown_async_005 has failed for ' + e);
expect(e.message == "Invalid group").assertTrue();
fileio.unlinkSync(fpath);
done();
}
});
......@@ -100,7 +172,7 @@ describe('fileio_fchown', async function () {
/**
* @tc.number SUB_DF_FILEIO_FCHOWN_SYNC_0000
* @tc.name fileio_test_fchown_sync_000
* @tc.desc Test fchownSync() interface.
* @tc.desc Test fchownSync() interface. The test file was modified successfully.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
......@@ -113,11 +185,80 @@ describe('fileio_fchown', async function () {
let stat = fileio.statSync(fpath);
expect(isIntNum(stat.uid)).assertTrue();
let fd = fileio.openSync(fpath, 0o102, 0o666);
fileio.fchmodSync(fd, 0o777);
fileio.fchownSync(fd, stat.uid, stat.gid);
expect(fileio.closeSync(fd) == null).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.info('fileio_test_fchown_sync_000 has failed for ' + e);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEIO_FCHOWN_SYNC_0100
* @tc.name fileio_test_fchown_sync_001
* @tc.desc Test fchownSync() interface, invalid fd. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_fchown_sync_001', 0, async function () {
let fpath = await nextFileName('fileio_test_fchown_sync_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileio.statSync(fpath);
fileio.fchownSync(-1, stat.uid, stat.gid);
} catch (e) {
console.info('fileio_test_fchown_sync_001 has failed for ' + e);
expect(e.message == "Bad file descriptor").assertTrue();
fileio.unlinkSync(fpath);
}
});
/**
* @tc.number SUB_DF_FILEIO_FCHOWN_SYNC_0200
* @tc.name fileio_test_fchown_sync_002
* @tc.desc Test fchownSync() interface, wrong uid, gid. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_fchown_sync_002', 0, async function () {
let fpath = await nextFileName('fileio_test_fchown_sync_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let fd = fileio.openSync(fpath);
fileio.fchownSync(fd, 0, 0);
} catch (e) {
console.info('fileio_test_fchown_sync_002 has failed for ' + e);
expect(e.message == "Operation not permitted").assertTrue();
fileio.unlinkSync(fpath);
}
});
/**
* @tc.number SUB_DF_FILEIO_FCHOWN_SYNC_0300
* @tc.name fileio_test_fchown_sync_003
* @tc.desc Test fchownSync() interface, wrong owner. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_fchown_sync_003', 0, async function () {
let fpath = await nextFileName('fileio_test_fchown_sync_003');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let fd = fileio.openSync(fpath);
let stat = fileio.statSync(fpath);
fileio.fchownSync(fd, null, stat.gid);
} catch (e) {
console.info('fileio_test_fchown_sync_003 has failed for ' + e);
expect(e.message == "Operation not permitted").assertTrue();
fileio.unlinkSync(fpath);
}
});
});
......@@ -21,9 +21,9 @@ import {
describe('fileio_lchown', function () {
/**
* @tc.number SUB_DF_FILEIO_LSEEK_SYNC_000
* @tc.number SUB_DF_FILEIO_LSEEK_SYNC_0000
* @tc.name fileio_test_lchown_sync_000
* @tc.desc Test lchownSync() interface.
* @tc.desc Test lchownSync() interface. The test file was modified successfully.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
......@@ -31,86 +31,268 @@ describe('fileio_lchown', function () {
*/
it('fileio_test_lchown_sync_000', 0, async function () {
let fpath = await nextFileName('fileio_test_lchown_sync_000');
let ffpath = fpath + 'aaaa';
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileio.symlinkSync(fpath, ffpath);
let stat = fileio.statSync(fpath);
expect(fileio.lchownSync(fpath, stat.uid, stat.gid) == null).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue();
fileio.lchownSync(ffpath, stat.uid, stat.gid);
fileio.unlinkSync(fpath);
fileio.unlinkSync(ffpath);
} catch (e) {
console.info('fileio_test_lchown_sync_000 has failed for ' + e);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSEEK_SYNC_001
* @tc.number SUB_DF_FILEIO_LSEEK_SYNC_0100
* @tc.name fileio_test_lchown_sync_001
* @tc.desc Test lchownSync() interface.
* @tc.desc Test lchownSync() interface, invalid path. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_lchown_sync_001', 0, async function () {
it('fileio_test_lchown_sync_001', 0, async function () {
let fpath = await nextFileName('fileio_test_lchown_sync_001');
let ffpath = await nextFileName('fileio_test_lchown_sync_001_1');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileio.statSync(fpath);
expect(isIntNum(stat.uid)).assertTrue();
expect(fileio.lchownSync('/', stat.uid, stat.gid));
expect(null).assertFail();
fileio.lchownSync(ffpath, stat.uid, stat.gid);
} catch (e) {
console.info('fileio_test_lchown_sync_001 has failed for ' + e);
expect(e.message == "No such file or directory").assertTrue();
fileio.unlinkSync(fpath);
}
});
/**
* @tc.number SUB_DF_FILEIO_LSEEK_SYNC_0200
* @tc.name fileio_test_lchown_sync_002
* @tc.desc Test lchownSync() interface, wrong uid, gid. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_lchown_sync_002', 0, async function () {
let fpath = await nextFileName('fileio_test_lchown_sync_002');
let ffpath = fpath + 'aaaa';
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileio.symlinkSync(fpath, ffpath);
fileio.lchownSync(ffpath, 0, 0);
} catch (e) {
console.info('fileio_test_lchown_sync_002 has failed for ' + e);
expect(e.message == "Operation not permitted").assertTrue();
fileio.unlinkSync(fpath);
fileio.unlinkSync(ffpath);
}
});
/**
* @tc.number SUB_DF_FILEIO_LSEEK_SYNC_0300
* @tc.name fileio_test_lchown_sync_003
* @tc.desc Test lchownSync() interface, wrong owner. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_lchown_sync_003', 0, async function () {
let fpath = await nextFileName('fileio_test_lchown_sync_003');
let ffpath = fpath + 'aaaa';
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileio.symlinkSync(fpath, ffpath);
let stat = fileio.statSync(fpath);
fileio.lchownSync(ffpath, null, stat.gid);
} catch (e) {
console.info('fileio_test_lchown_sync_003 has failed for ' + e);
expect(e.message == "Invalid owner").assertTrue();
fileio.unlinkSync(fpath);
fileio.unlinkSync(ffpath);
}
});
/**
* @tc.number SUB_DF_FILEIO_LSEEK_SYNC_0400
* @tc.name fileio_test_lchown_sync_004
* @tc.desc Test lchownSync() interface, wrong group. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_lchown_sync_004', 0, async function () {
let fpath = await nextFileName('fileio_test_lchown_sync_004');
let ffpath = fpath + 'aaaa';
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileio.symlinkSync(fpath, ffpath);
let stat = fileio.statSync(fpath);
fileio.lchownSync(ffpath, stat.uid, null);
} catch (e) {
expect(!!e).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue();
console.info('fileio_test_lchown_sync_004 has failed for ' + e);
expect(e.message == "Invalid group").assertTrue();
fileio.unlinkSync(fpath);
fileio.unlinkSync(ffpath);
}
});
/**
* @tc.number SUB_DF_FILEIO_LCHOWN_ASYNC_000
* @tc.name fileio_test_lchown_async_00
* @tc.desc Test lchownASync() interface.
* @tc.number SUB_DF_FILEIO_LCHOWN_ASYNC_0000
* @tc.name fileio_test_lchown_async_000
* @tc.desc Test the lchownASync() interface with promise. The test file was modified successfully.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_lchown_Async_000', 0, async function (done) {
let fpath = await nextFileName('fileio_lchown_Async_000');
it('fileio_test_lchown_async_000', 0, async function (done) {
let fpath = await nextFileName('fileio_test_lchown_async_000');
let ffpath = fpath + 'aaaa';
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileio.symlinkSync(fpath, ffpath);
let stat = fileio.statSync(fpath);
expect(await fileio.lchown(fpath, stat.uid, stat.gid) == null).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue();
await fileio.lchown(ffpath, stat.uid, stat.gid);
fileio.unlinkSync(fpath);
fileio.unlinkSync(ffpath);
done();
} catch (e) {
console.log('fileio_test_lchown_async_000 has failed for ' + e);
console.info('fileio_test_lchown_async_000 has failed for ' + e);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEIO_LCHOWN_ASYNC_001
* @tc.name fileio_test_lchown_async_00
* @tc.desc Test lchownASync() interface.
* @tc.number SUB_DF_FILEIO_LCHOWN_ASYNC_0100
* @tc.name fileio_test_lchown_async_001
* @tc.desc Test the lchownASync() interface with callback. The test file was modified successfully.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_lchown_Async_001', 0, async function (done) {
let fpath = await nextFileName('fileio_lchown_Async_001');
it('fileio_test_lchown_async_001', 0, async function (done) {
let fpath = await nextFileName('fileio_test_lchown_async_001');
let ffpath = fpath + 'aaaa';
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileio.symlinkSync(fpath, ffpath);
let stat = fileio.statSync(fpath);
fileio.lchown(fpath, stat.uid, stat.gid, function (error) {
expect(fileio.unlinkSync(fpath) == null).assertTrue();
fileio.lchown(ffpath, stat.uid, stat.gid, function (error) {
fileio.unlinkSync(fpath);
fileio.unlinkSync(ffpath);
done();
});
} catch (e) {
console.log('fileio_lchown_Async_001 has failed for ' + e);
console.info('fileio_test_lchown_async_001 has failed for ' + e);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEIO_LCHOWN_ASYNC_0200
* @tc.name fileio_test_lchown_async_002
* @tc.desc Test the lchownASync() interface with promise, invalid path. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_lchown_async_002', 0, async function (done) {
let fpath = await nextFileName('fileio_test_lchown_async_002');
let ffpath = await nextFileName('fileio_test_lchown_sync_001_1');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileio.statSync(fpath);
await fileio.lchown(ffpath, stat.uid, stat.gid);
} catch (e) {
console.info('fileio_test_lchown_async_002 has failed for ' + e);
expect(e.message == "No such file or directory").assertTrue();
fileio.unlinkSync(fpath);
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_LCHOWN_ASYNC_0300
* @tc.name fileio_test_lchown_async_003
* @tc.desc Test the lchownASync() interface with promise, wrong uid, gid. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_lchown_async_003', 0, async function (done) {
let fpath = await nextFileName('fileio_test_lchown_async_003');
let ffpath = fpath + 'aaaa';
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileio.symlinkSync(fpath, ffpath);
await fileio.lchown(ffpath, 0, 0);
} catch (e) {
console.info('fileio_test_lchown_async_003 has failed for ' + e);
expect(e.message == "Operation not permitted").assertTrue();
fileio.unlinkSync(fpath);
fileio.unlinkSync(ffpath);
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_LCHOWN_ASYNC_0400
* @tc.name fileio_test_lchown_async_004
* @tc.desc Test the lchownASync() interface with promise, wrong owner. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_lchown_async_004', 0, async function (done) {
let fpath = await nextFileName('fileio_test_lchown_async_004');
let ffpath = fpath + 'aaaa';
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileio.symlinkSync(fpath, ffpath);
let stat = fileio.statSync(fpath);
await fileio.lchown(ffpath, null, stat.gid);
} catch (e) {
console.info('fileio_test_lchown_async_004 has failed for ' + e);
expect(e.message == "Invalid owner").assertTrue();
fileio.unlinkSync(fpath);
fileio.unlinkSync(ffpath);
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_LCHOWN_ASYNC_0500
* @tc.name fileio_test_lchown_async_005
* @tc.desc Test the lchownASync() interface with promise, wrong group. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_lchown_async_005', 0, async function (done) {
let fpath = await nextFileName('fileio_test_lchown_async_005');
let ffpath = fpath + 'aaaa';
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileio.symlinkSync(fpath, ffpath);
let stat = fileio.statSync(fpath);
await fileio.lchown(ffpath, stat.uid, null);
} catch (e) {
console.info('fileio_test_lchown_async_005 has failed for ' + e);
expect(e.message == "Invalid group").assertTrue();
fileio.unlinkSync(fpath);
fileio.unlinkSync(ffpath);
done();
}
});
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册