提交 5a4cd7d3 编写于 作者: R raoxian

fileio新增close,fdatasyncSync测试用例

Signed-off-by: Nraoxian <raoxian@huawei.com>
上级 fa849d09
......@@ -15,7 +15,7 @@
import {
fileio,
describe, it, expect,
describe, it, expect, nextFileName, prepareFile, FILE_CONTENT
} from '../../Common';
describe('fileio_close', function () {
......@@ -55,4 +55,74 @@ describe('fileio_close', function () {
console.log('fileio_test_close_sync_001 has failed for ' + e);
}
})
/**
* @tc.number SUB_DF_FILEIO_CLOSE_ASYNC_0000
* @tc.name fileio_test_close_async_000
* @tc.desc Test close() interfaces
* @tc.size MEDIUM(中型)
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_close_async_000', 0, async function (done) {
let fpath = await nextFileName('fileio_test_close_async_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let fd = fileio.openSync(fpath, 0o102, 0o666);
fileio.close(fd, function (err) {
expect(fileio.unlinkSync(fpath) == null).assertTrue();
done();
});
} catch (e) {
console.log('fileio_test_close_async_000 has failed for ' + e);
expect(null).assertFail();
}
})
/**
* @tc.number SUB_DF_FILEIO_CLOSE_ASYNC_0010
* @tc.name fileio_test_close_async_001
* @tc.desc Test close() interfaces
* @tc.size MEDIUM(中型)
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_close_async_001', 0, async function (done) {
let fpath = await nextFileName('fileio_test_close_async_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let fd = fileio.openSync(fpath, 0o102, 0o666);
expect(await fileio.close(fd) == null).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue();
done();
} catch (e) {
console.log('fileio_test_close_async_001 has failed for ' + e);
expect(null).assertFail();
}
})
/**
* @tc.number SUB_DF_FILEIO_CLOSE_ASYNC_0020
* @tc.name fileio_test_close_async_002
* @tc.desc Test close() interfaces
* @tc.size MEDIUM(中型)
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_close_async_002', 0, async function (done) {
try {
await fileio.close(-1);
expect(null).assertFail();
done();
} catch (e) {
expect(!!e).assertTrue();
console.log('fileio_test_close_async_002 has failed for ' + e);
done();
}
})
})
......@@ -48,7 +48,7 @@ describe('fileio_fdatasync', async function () {
/**
* @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0010
* @tc.name fileio_test_fdatasync_async_001
* @tc.desc Test fdatasyncSync() interfaces.
* @tc.desc Test fdatasync() interfaces.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
......@@ -60,11 +60,17 @@ describe('fileio_fdatasync', async function () {
try {
let fd = fileio.openSync(fpath, 0o102, 0o666);
fileio.write(fd, FILE_CONTENT);
fileio
.fdatasync(fd)
.then(function (err) {
expect(fileio.closeSync(fd) == null).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue();
})
.catch(function (err) {
expect(null).assertFail();
});
} catch (e) {
console.log('fileio_test_fdatasync_async_001 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -78,46 +84,61 @@ describe('fileio_fdatasync', async function () {
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_fdatasync_async_002', 0, async function () {
it('fileio_test_fdatasync_async_002', 0, async function (done) {
let fpath = await nextFileName('fileio_test_fdatasync_async_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let fd = fileio.openSync(fpath, 0o102, 0o666);
fileio
.fdatasync(fd)
.then(function (err) {
expect(fileio.closeSync(fd) == null).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue();
})
.catch(function (err) {
let fd = -1;
await fileio.fdatasync(fd);
expect(null).assertFail();
});
done()
} catch (e) {
expect(!!e).assertTrue();
console.log('fileio_test_fdatasync_async_002 has failed for ' + e);
expect(null).assertFail();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0030
* @tc.name fileio_test_fdatasync_async_003
* @tc.desc Test fdatasync() interfaces.
* @tc.number SUB_DF_FILEIO_FDATASYNC_SYNC_0000
* @tc.name fileio_test_fdatasync_sync_000
* @tc.desc Test fdatasyncSync() interfaces.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_fdatasync_async_003', 0, async function () {
let fpath = await nextFileName('fileio_test_fdatasync_async_003');
it('fileio_test_fdatasync_sync_000', 0, async function () {
let fpath = await nextFileName('fileio_test_fdatasync_sync_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let fd = -1;
await fileio.fdatasync(fd);
let fd = fileio.openSync(fpath, 0o102, 0o666);
expect(fileio.fdatasyncSync(fd) == null).assertTrue();
expect(fileio.closeSync(fd) == null).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue();
} catch (e) {
console.log('fileio_test_fdatasync_sync_000 has failed for ' + e);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEIO_FDATASYNC_SYNC_0010
* @tc.name fileio_test_fdatasync_sync_001
* @tc.desc Test fdatasyncSync() interfaces.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_fdatasync_sync_001', 0, async function () {
try {
fileio.fdatasyncSync(-1);
expect(null).assertFail();
} catch (e) {
console.log('fileio_test_fdatasync_async_003 has failed for ' + e);
console.log('fileio_test_fdatasync_sync_001 has failed for ' + e);
}
});
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册