提交 bf532ca1 编写于 作者: F futurezhou

Modified XTS for stat

Signed-off-by: Nfuturezhou <zhouweilai@huawei.com>
上级 eb82e5a8
/*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
fileio, fileIO, FILE_CONTENT, prepareFile, nextFileName,
describe, it, expect,
} from '../Common';
export default function fileIOFdatasync() {
describe('fileIO_fs_fdatasync', async function () {
/**
* @tc.number SUB_DF_FILEIO_FDATASYNC_SYNC_0000
* @tc.name fileIO_test_fdatasync_sync_000
* @tc.desc Test fdatasyncSync() interfaces.
* Open the file in read-write mode, and synchronize the file content data.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
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 file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
fileIO.fdatasyncSync(file.fd);
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_fdatasync_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_FDATASYNC_SYNC_0010
* @tc.name fileIO_test_fdatasync_sync_001
* @tc.desc Test fdatasyncSync() interfaces. Invalid fd parameter.
* @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(false).assertTrue();
} catch (e) {
console.log('fileIO_test_fdatasync_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900008 && e.message == 'Bad file descriptor').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_FDATASYNC_SYNC_0020
* @tc.name fileIO_test_fdatasync_sync_002
* @tc.desc Test fdatasyncSync() interfaces. Missing parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_fdatasync_sync_002', 0, async function () {
try {
fileIO.fdatasyncSync();
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_fdatasync_sync_002 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0000
* @tc.name fileIO_test_fdatasync_async_000
* @tc.desc Test fdatasync() interfaces. Callback.
* Open the file in read-write mode, and synchronize the file content data.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_fdatasync_async_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_fdatasync_async_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
fileIO.fdatasync(file.fd, (err) => {
if (err) {
console.log('fileIO_test_fdatasync_async_000 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_test_fdatasync_async_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0010
* @tc.name fileIO_test_fdatasync_async_001
* @tc.desc Test fdatasync() interfaces. Promise.then().catch().
* Open the file in read-write mode, and synchronize the file content data.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_fdatasync_async_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_fdatasync_async_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
fileio.fdatasync(file.fd).then(() => {
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
}).catch((err) => {
console.log('fileIO_test_fdatasync_async_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
});
} catch (e) {
console.log('fileIO_test_fdatasync_async_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0020
* @tc.name fileIO_test_fdatasync_async_002
* @tc.desc Test fdatasync() interfaces. await Promise.
* Open the file in read-write mode, and synchronize the file content data.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
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 file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
await fileio.fdatasync(file.fd);
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_test_fdatasync_async_002 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0030
* @tc.name fileIO_test_fdatasync_async_003
* @tc.desc Test fdatasync() interfaces. await Promise.
* Invalid fd parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_fdatasync_async_003', 0, async function (done) {
try {
await fileIO.fdatasync(-1);
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_fdatasync_async_003 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900008 && e.message == 'Bad file descriptor').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0040
* @tc.name fileIO_test_fdatasync_async_004
* @tc.desc Test fdatasync() interfaces. Callback.
* Invalid fd parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_fdatasync_async_004', 0, async function (done) {
try {
fileIO.fdatasync(-1, (err) => {
if (err) {
console.log('fileIO_test_fdatasync_async_004 error package: {' + err.message + ', code: ' + err.code + '}');
expect(err.code == 13900008 && err.message == 'Bad file descriptor').assertTrue();
done();
}
});
} catch (e) {
console.log('fileIO_test_fdatasync_async_004 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0050
* @tc.name fileIO_test_fdatasync_async_005
* @tc.desc Test fdatasync() interfaces. Promise.then().catch()
* Invalid fd parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_fdatasync_async_005', 0, async function (done) {
try {
fileIO.fdatasync(-1).then(() => {
expect(false).assertTrue();
}).catch((err) => {
console.log('fileIO_test_fdatasync_async_005 error package: {' + err.message + ', code: ' + err.code + '}');
expect(err.code == 13900008 && err.message == 'Bad file descriptor').assertTrue();
done();
});
} catch (e) {
console.log('fileIO_test_fdatasync_async_005 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0060
* @tc.name fileIO_test_fdatasync_async_006
* @tc.desc Test fdatasync() interfaces. Promise.
* Missing parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_fdatasync_async_006', 0, async function (done) {
try {
await fileIO.fdatasync();
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_fdatasync_async_006 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0070
* @tc.name fileIO_test_fdatasync_async_007
* @tc.desc Test fdatasync() interfaces. Callback.
* Missing parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_fdatasync_async_007', 0, async function (done) {
try {
fileIO.fdatasync(() => {
expect(false).assertTrue();
});
} catch (e) {
console.log('fileIO_test_fdatasync_async_007 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
}
});
})
}
/*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
fileio, fileIO, FILE_CONTENT, prepareFile, nextFileName,
describe, it, expect,
} from '../Common';
export default function fileIOFsync() {
describe('fileIO_fs_fsync', function () {
/**
* @tc.number SUB_DF_FILEIO_FSYNC_SYNC_0000
* @tc.name fileIO_test_fsync_sync_000
* @tc.desc Test fsyncSync() interface.
* Open the file in read-write mode, and synchronize the file content data.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_fsync_sync_000', 0, async function () {
let fpath = await nextFileName('fileIO_test_fsync_sync_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
fileIO.fsyncSync(file.fd);
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_fsync_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_FSYNC_SYNC_0010
* @tc.name fileIO_test_fsync_sync_001
* @tc.desc Test fsyncSync() interface. Invalid fd parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_fsync_sync_001', 0, function () {
try {
fileIO.fsyncSync(-1);
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_fsync_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900008 && e.message == 'Bad file descriptor').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_FSYNC_SYNC_0020
* @tc.name fileIO_test_fsync_sync_002
* @tc.desc Test fsyncSync() interface. Missing parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_fsync_sync_002', 0, function () {
try {
fileIO.fsyncSync();
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_fsync_sync_002 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_0000
* @tc.name fileIO_test_fsync_async_000
* @tc.desc Test fsync() interface. await Promise.
* Open the file in read-write mode, and synchronize the file content data.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_fsync_async_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_fsync_async_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
await fileIO.fsync(file.fd);
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_test_fsync_async_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_0010
* @tc.name fileIO_test_fsync_async_001
* @tc.desc Test fsync() interface. Promise.then().catch()
* Open the file in read-write mode, and synchronize the file content data.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_fsync_async_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_fsync_async_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
fileIO.fsync(file.fd).then(() => {
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
}).catch((err) => {
console.log('fileIO_test_fsync_async_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
});
} catch (e) {
console.log('fileIO_test_fsync_async_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_002
* @tc.name fileIO_test_fsync_async_002
* @tc.desc Test fsync() interface. Callback.
* Open the file in read-write mode, and synchronize the file content data.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_fsync_async_002', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_fsync_sync_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
fileIO.fsync(file.fd, (err) => {
if (err) {
console.log('fileIO_test_fsync_async_002 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
});
done();
} catch (e) {
console.log('fileIO_test_fsync_async_002 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_003
* @tc.name fileIO_test_fsync_async_003
* @tc.desc Test fsync() interface. await Promise.
* Invalid fd parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_fsync_async_003', 0, async function (done) {
try {
await fileIO.fsync(-1);
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_fsync_async_003 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900008 && e.message == 'Bad file descriptor').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_004
* @tc.name fileIO_test_fsync_async_004
* @tc.desc Test fsync() interface. Callback.
* Invalid fd parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_fsync_async_004', 0, async function (done) {
try {
fileIO.fsync(-1, (err) => {
if (err) {
console.log('fileIO_test_fsync_async_004 error package: {' + err.message + ', code: ' + err.code + '}');
expect(err.code == 13900008 && err.message == 'Bad file descriptor').assertTrue();
done();
}
});
} catch (e) {
console.log('fileIO_test_fsync_async_004 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_005
* @tc.name fileIO_test_fsync_async_005
* @tc.desc Test fsync() interface. Promise.then().catch()
* Missing parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_fsync_async_005', 0, async function (done) {
try {
fileIO.fsync(-1).then(() => {
expect(false).assertTrue();
}).catch((err) => {
console.log('fileIO_test_fsync_async_005 error package: {' + err.message + ', code: ' + err.code + '}');
expect(err.code == 13900008 && err.message == 'Bad file descriptor').assertTrue();
done();
});
} catch (e) {
console.log('fileIO_test_fsync_async_005 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_006
* @tc.name fileIO_test_fsync_async_006
* @tc.desc Test fsync() interface. await Promise.
* Missing parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_fsync_async_006', 0, async function (done) {
try {
await fileIO.fsync();
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_fsync_async_006 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_006
* @tc.name fileIO_test_fsync_async_006
* @tc.desc Test fsync() interface. Callback.
* Missing parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_fsync_async_007', 0, async function (done) {
try {
fileIO.fsync(() => {
expect(false).assertTrue();
});
} catch (e) {
console.log('fileIO_test_fsync_async_007 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
}
});
})
}
......@@ -14,7 +14,7 @@
*/
import {
fileio, fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum, isBoolean,
fileio, fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum, isBigInt,
describe, it, expect,
} from '../Common';
......@@ -24,8 +24,8 @@ describe('fileIO_fs_stat', function () {
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_0000
* @tc.name fileIO_stat_sync_000
* @tc.desc Test Stat.statSync() interfaces.
* This interface shall work properly in normal case.
* @tc.desc Test statSync() interfaces.
* Enter the path or fd parameter to get the file stat.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -53,8 +53,8 @@ describe('fileIO_fs_stat', function () {
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_0100
* @tc.name fileIO_stat_sync_001
* @tc.desc Test Stat.statSync() interfaces.
* This interface shall throw an exception when the file isnt's exist.
* @tc.desc Test statSync() interfaces.
* The path point to nothing, no such file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -67,39 +67,36 @@ describe('fileIO_fs_stat', function () {
fileIO.statSync(fpath);
expect(false).assertTrue();
} catch (e) {
expect(e.code == 13900002 && e.message == 'No such file or directory').assertTrue();
console.log('fileIO_stat_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900002 && e.message == 'No such file or directory').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_0200
* @tc.name fileIO_stat_sync_002
* @tc.desc Test Stat.statSync() interfaces.
* This interface shall throw an exception when the file isnt's exist.
* @tc.desc Test statSync() interfaces. Missing parameters.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_002', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_002');
try {
fileIO.statSync();
expect(false).assertTrue();
} catch (e) {
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
console.log('fileIO_stat_sync_002 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_INO_0000
* @tc.name fileIO_stat_sync_ino_000
* @tc.desc Test Stat.statSync_Ino() interfaces.
* @tc.desc Test the ino member of class Stat
* @tc.desc Test the ino member of class Stat.
* Enter the path or fd parameter to get stat.ino of the file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -111,11 +108,11 @@ describe('fileIO_fs_stat', function () {
try {
let stat = fileIO.statSync(fpath);
expect(isIntNum(stat.ino)).assertTrue();
expect(isBigInt(stat.ino)).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(isIntNum(stat2.ino)).assertTrue();
expect(isBigInt(stat2.ino)).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
......@@ -127,8 +124,8 @@ describe('fileIO_fs_stat', function () {
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_MODE_0000
* @tc.name fileIO_stat_sync_mode_000
* @tc.desc Test Stat.statSync_Mode() interfaces.
* @tc.desc Test the mode member of class Stat
* @tc.desc Test the mode member of class Stat.
* Enter the path or fd parameter to get stat.mode of the file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -156,8 +153,8 @@ describe('fileIO_fs_stat', function () {
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_UID_0000
* @tc.name fileIO_stat_sync_uid_000
* @tc.desc Test Stat.statSync_Uid() interfaces.
* @tc.desc Test the uid member of class Stat
* @tc.desc Test the uid member of class Stat.
* Enter the path or fd parameter to get stat.uid of the file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -185,8 +182,8 @@ describe('fileIO_fs_stat', function () {
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_GID_0000
* @tc.name fileIO_stat_sync_gid_000
* @tc.desc Test Stat.statSync_Gid() interfaces.
* @tc.desc Test the gid member of class Stat
* @tc.desc Test the gid member of class Stat.
* Enter the path or fd parameter to get stat.gid of the file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -214,8 +211,8 @@ describe('fileIO_fs_stat', function () {
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_SIZE_0000
* @tc.name fileIO_stat_sync_size_000
* @tc.desc Test Stat.statSync_Size() interfaces.
* @tc.desc Test the size member of class Stat
* @tc.desc Test the size member of class Stat.
* Enter the path or fd parameter to get stat.size of the file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -240,40 +237,11 @@ describe('fileIO_fs_stat', function () {
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_BLKSIZE_0000
* @tc.name fileIO_stat_sync_blksize_000
* @tc.desc Test Stat.statSync_Blksize() interfaces.
* @tc.desc Test the blksize member of class Stat
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_blksize_000', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_blksize_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.statSync(fpath);
expect(isIntNum(stat.blksize)).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(isIntNum(stat2.blksize)).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_stat_sync_blksize_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ATIME_0000
* @tc.name fileIO_stat_sync_atime_000
* @tc.desc Test Stat.statSync_Atime() interfaces.
* @tc.desc Test the atime member of class Stat
* @tc.desc Test the atime member of class Stat.
* Enter the path or fd parameter to get stat.atime of the file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -301,8 +269,8 @@ describe('fileIO_fs_stat', function () {
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_MTIME_0000
* @tc.name fileIO_stat_sync_mtime_000
* @tc.desc Test Stat.statSync_Mtime() interfaces.
* @tc.desc Test the mtime member of class Stat
* @tc.desc Test the mtime member of class Stat.
* Enter the path or fd parameter to get stat.mtime of the file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -330,8 +298,8 @@ describe('fileIO_fs_stat', function () {
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_CTIME_0000
* @tc.name fileIO_stat_sync_ctime_000
* @tc.desc Test Stat.statSync_Ctime() interfaces.
* @tc.desc Test the ctime member of class Stat
* @tc.desc Test the ctime member of class Stat.
* Enter the path or fd parameter to get stat.ctime of the file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -359,9 +327,8 @@ describe('fileIO_fs_stat', function () {
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISBLOCKDEVICE_0000
* @tc.name fileIO_stat_sync_is_block_device_000
* @tc.desc Test Stat.statSync_IsBlockDevice() interfaces.
* @tc.desc Test the isBlockDevice() method of class Stat.
* This interface shall return a boolean variable.
* This interface shall not treat a normal file as a block special device.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -373,11 +340,11 @@ describe('fileIO_fs_stat', function () {
try {
let stat = fileIO.statSync(fpath);
expect(isBoolean(stat.isBlockDevice())).assertTrue();
expect(stat.isBlockDevice() === false).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(isBoolean(stat2.isBlockDevice())).assertTrue();
expect(stat2.isBlockDevice() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
......@@ -389,9 +356,8 @@ describe('fileIO_fs_stat', function () {
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISBLOCKDEVICE_0100
* @tc.name fileIO_stat_sync_is_block_device_001
* @tc.desc Test Stat.statSync_IsBlockDevice() interfaces.
* @tc.desc Test the isBlockDevice() method of class Stat.
* This interface shall not treat a normal file as a block special device.
* This interface does not require parameters.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -402,25 +368,20 @@ describe('fileIO_fs_stat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.statSync(fpath);
expect(stat.isBlockDevice() === false).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(stat2.isBlockDevice() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_stat_sync_is_block_device_001 has failed for ' + e.message + ', code: ' + e.code);
fileIO.statSync(fpath).isBlockDevice(-1);
expect(false).assertTrue();
} catch (e) {
fileio.unlinkSync(fpath);
console.info('fileIO_stat_sync_is_block_device_001 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISBLOCKDEVICE_0200
* @tc.name fileIO_stat_sync_is_block_device_002
* @tc.desc Test Stat.statSync_IsBlockDevice() interfaces.
* @tc.desc Test the isBlockDevice() method of class Stat.
* This interface does not require parameters.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -429,51 +390,25 @@ describe('fileIO_fs_stat', function () {
it('fileIO_stat_sync_is_block_device_002', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_is_block_device_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let file = fileIO.openSync(fpath);
try {
let stat = fileIO.statSync(fpath);
expect(stat.isBlockDevice(-1) === false).assertTrue();
expect(false).assertTrue();
} catch (e) {
console.info('fileIO_stat_sync_is_block_device_002 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
fileio.unlinkSync(fpath);
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISBLOCKDEVICE_0300
* @tc.name fileIO_stat_sync_is_block_device_003
* @tc.desc Test Stat.statSync_IsBlockDevice() interfaces.
* @tc.desc Test the isBlockDevice() method of class Stat.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_block_device_003', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_is_block_device_003');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let file;
try {
file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(stat2.isBlockDevice(-1) === false).assertTrue();
fileIO.statSync(file.fd).isBlockDevice(-1);
expect(false).assertTrue();
} catch (e) {
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
console.info('fileIO_stat_sync_is_block_device_003 has failed for ' + e.message + ', code: ' + e.code);
console.info('fileIO_stat_sync_is_block_device_002 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISCHARACTER_DEVICE_0000
* @tc.name fileIO_stat_sync_is_character_device_000
* @tc.desc Test Stat.statsync_IsCharacterDevice() interfaces.
* This interface shall return a boolean variable.
* @tc.desc Test the isCharacterDevice() method of class Stat.
* This interface shall not treat a normal file as a character special device.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -485,11 +420,11 @@ describe('fileIO_fs_stat', function () {
try {
let stat = fileIO.statSync(fpath);
expect(isBoolean(stat.isCharacterDevice())).assertTrue();
expect(stat.isCharacterDevice() === false).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(isBoolean(stat2.isCharacterDevice())).assertTrue();
expect(stat2.isCharacterDevice() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
......@@ -501,8 +436,8 @@ describe('fileIO_fs_stat', function () {
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISCHARACTER_DEVICE_0100
* @tc.name fileIO_stat_sync_is_character_device_001
* @tc.desc Test Stat.statsync_IsCharacterDevice() interfaces.
* This interface shall not treat a normal file as a character special device.
* @tc.desc Test the isCharacterDevice() method of class Stat.
* This interface does not require parameters.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -513,24 +448,20 @@ describe('fileIO_fs_stat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.statSync(fpath);
expect(stat.isCharacterDevice() === false).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(stat2.isCharacterDevice() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
fileIO.statSync(fpath).isCharacterDevice(-1);
expect(false).assertTrue();
} catch (e) {
fileio.unlinkSync(fpath);
console.log('fileIO_stat_sync_is_character_device_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISCHARACTER_DEVICE_0200
* @tc.name fileIO_stat_sync_is_character_device_002
* @tc.desc Test Stat.statsync_IsCharacterDevice() interfaces.
* @tc.desc Test the isCharacterDevice() method of class Stat.
* This interface does not require parameters.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -539,39 +470,15 @@ describe('fileIO_fs_stat', function () {
it('fileIO_stat_sync_is_character_device_002', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_is_character_device_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let file = fileIO.openSync(fpath);
try {
let stat = fileIO.statSync(fpath);
expect(stat.isCharacterDevice(-1) === false).assertTrue();
expect(false).assertTrue();
} catch (e) {
fileio.unlinkSync(fpath);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISCHARACTER_DEVICE_0300
* @tc.name fileIO_stat_sync_is_character_device_003
* @tc.desc Test Stat.statsync_IsCharacterDevice() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_character_device_003', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_is_character_device_003');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let file;
try {
file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(stat2.isCharacterDevice(-1) === false).assertTrue();
fileIO.statSync(file.fd).isCharacterDevice(-1);
expect(false).assertTrue();
} catch (e) {
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
console.log('fileIO_stat_sync_is_character_device_002 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
......@@ -579,8 +486,8 @@ describe('fileIO_fs_stat', function () {
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISDIRECTORY_0000
* @tc.name fileIO_stat_sync_is_directory_000
* @tc.desc Test Stat.statsync_isDirectory() interfaces.
* This interface shall return a boolean variable.
* @tc.desc Test the isDirectory() method of class Stat.
* This interface shall not treat a normal file as a directory.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -592,11 +499,11 @@ describe('fileIO_fs_stat', function () {
try {
let stat = fileIO.statSync(fpath);
expect(isBoolean(stat.isDirectory())).assertTrue();
expect(stat.isDirectory() === false).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(isBoolean(stat2.isDirectory())).assertTrue();
expect(stat2.isDirectory() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
......@@ -608,26 +515,26 @@ describe('fileIO_fs_stat', function () {
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISDIRECTORY_0100
* @tc.name fileIO_stat_sync_is_directory_001
* @tc.desc Test Stat.statsync_isDirectory() interfaces.
* This interface shall not treat a normal file as a directory.
* @tc.desc Test the isDirectory() method of class Stat.
* This interface shall treat a directory as a directory.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_directory_001', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_is_directory_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let dpath = await nextFileName('fileIO_stat_sync_is_directory_001');
try {
let stat = fileIO.statSync(fpath);
expect(stat.isDirectory() === false).assertTrue();
fileio.mkdirSync(dpath);
let stat = fileIO.statSync(dpath);
expect(stat.isDirectory() === true).assertTrue();
let file = fileIO.openSync(fpath);
let file = fileIO.openSync(dpath, fileIO.OpenMode.DIR);
let stat2 = fileIO.statSync(file.fd);
expect(stat2.isDirectory() === false).assertTrue();
expect(stat2.isDirectory() === true).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
fileio.rmdirSync(dpath);
} catch (e) {
console.log('fileIO_stat_sync_is_directory_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
......@@ -637,36 +544,32 @@ describe('fileIO_fs_stat', function () {
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISDIRECTORY_0200
* @tc.name fileIO_stat_sync_is_directory_002
* @tc.desc Test Stat.statsync_isDirectory() interfaces.
* This interface shall treat a directory as a directory.
* @tc.desc Test the isDirectory() method of class Stat.
* This interface does not require parameters.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_directory_002', 0, async function () {
let dpath = await nextFileName('fileIO_stat_sync_is_directory_002');
let dpath = await nextFileName('fileIO_stat_sync_is_directory_002') + 'd';
try {
fileio.mkdirSync(dpath);
let stat = fileIO.statSync(dpath);
expect(stat.isDirectory()).assertTrue();
let file = fileIO.openSync(dpath);
let stat2 = fileIO.statSync(file.fd);
expect(stat2.isDirectory()).assertTrue();
fileio.closeSync(file.fd);
fileio.rmdirSync(dpath);
fileIO.statSync(dpath).isDirectory(-1);
expect(false).assertTrue();
} catch (e) {
fileio.rmdirSync(dpath);
console.log('fileIO_stat_sync_is_directory_002 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISDIRECTORY_0300
* @tc.name fileIO_stat_sync_is_directory_003
* @tc.desc Test Stat.statsync_isDirectory() interfaces.
* @tc.desc Test the isDirectory() method of class Stat.
* This interface does not require parameters.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -674,40 +577,16 @@ describe('fileIO_fs_stat', function () {
*/
it('fileIO_stat_sync_is_directory_003', 0, async function () {
let dpath = await nextFileName('fileIO_stat_sync_is_directory_003') + 'd';
fileio.mkdirSync(dpath);
let file = fileIO.openSync(dpath, fileIO.OpenMode.DIR);
try {
fileio.mkdirSync(dpath);
let stat = fileIO.statSync(dpath);
expect(stat.isDirectory(-1) === false).assertTrue();
expect(false).assertTrue();
} catch (e) {
fileio.rmdirSync(dpath);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISDIRECTORY_0400
* @tc.name fileIO_stat_sync_is_directory_004
* @tc.desc Test Stat.statsync_isDirectory() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_directory_004', 0, async function () {
let dpath = await nextFileName('fileIO_stat_sync_is_directory_004') + 'd';
let file;
try {
fileio.mkdirSync(dpath);
file = fileIO.openSync(dpath);
let stat2 = fileIO.statSync(file.fd);
expect(stat2.isDirectory(-1) === false).assertTrue();
fileIO.statSync(file.fd).isDirectory(-1);
expect(false).assertTrue();
} catch (e) {
fileio.closeSync(file.fd);
fileio.rmdirSync(dpath);
console.log('fileIO_stat_sync_is_directory_003 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
......@@ -715,8 +594,8 @@ describe('fileIO_fs_stat', function () {
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISFIFO_0000
* @tc.name fileIO_stat_sync_is_fifo_000
* @tc.desc Test Stat.statsync_isFIFO() interfaces.
* This interface shall return a boolean variable.
* @tc.desc Test the isFIFO() method of class Stat.
* This interface shall not treat a normal file as a FIFO.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -728,11 +607,11 @@ describe('fileIO_fs_stat', function () {
try {
let stat = fileIO.statSync(fpath);
expect(isBoolean(stat.isFIFO())).assertTrue();
expect(stat.isFIFO() === false).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(isBoolean(stat2.isFIFO())).assertTrue();
expect(stat2.isFIFO() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
......@@ -744,8 +623,8 @@ describe('fileIO_fs_stat', function () {
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISFIFO_0100
* @tc.name fileIO_stat_sync_is_fifo_001
* @tc.desc Test Stat.statsync_isFIFO() interfaces.
* This interface shall not treat a normal file as a FIFO.
* @tc.desc Test the isFIFO() method of class Stat.
* This interface does not require parameters.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -756,24 +635,20 @@ describe('fileIO_fs_stat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.statSync(fpath);
expect(stat.isFIFO() === false).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(stat2.isFIFO() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
fileIO.statSync(fpath).isFile(-1);
expect(false).assertTrue();
} catch (e) {
fileio.unlinkSync(fpath);
console.log('fileIO_stat_sync_is_fifo_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISFIFO_0200
* @tc.name fileIO_stat_sync_is_fifo_002
* @tc.desc Test Stat.statsync_isFIFO() interfaces.
* @tc.desc Test the isFIFO() method of class Stat.
* This interface does not require parameters.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -782,46 +657,23 @@ describe('fileIO_fs_stat', function () {
it('fileIO_stat_sync_is_fifo_002', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_is_fifo_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let file = fileIO.openSync(fpath);
try {
let stat = fileIO.statSync(fpath);
expect(stat.isFile(-1) === false).assertTrue();
fileIO.statSync(file.fd).isFile(-1);
expect(false).assertTrue();
} catch (e) {
fileio.unlinkSync(fpath);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISFIFO_0300
* @tc.name fileIO_stat_sync_is_fifo_003
* @tc.desc Test Stat.statsync_isFIFO() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_fifo_003', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_is_fifo_003');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(stat2.isFile(-1) === false).assertTrue();
fileio.closeSync(file.fd);
expect(false).assertTrue();
} catch (e) {
fileio.unlinkSync(fpath);
console.log('fileIO_stat_sync_is_fifo_002 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISFILE_0000
* @tc.name fileIO_stat_sync_is_file_000
* @tc.desc Test Stat.statsync_isFile() interfaces.
* This interface shall return a boolean variable.
* @tc.desc Test the isFile() method of class Stat.
* This interface shall treat a normal file as a normal file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -833,11 +685,11 @@ describe('fileIO_fs_stat', function () {
try {
let stat = fileIO.statSync(fpath);
expect(isBoolean(stat.isFile())).assertTrue();
expect(stat.isFile() === true).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(isBoolean(stat2.isFile())).assertTrue();
expect(stat2.isFile() === true).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
......@@ -848,27 +700,27 @@ describe('fileIO_fs_stat', function () {
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISFILE_0100
* @tc.name fileIO_stat_sync_is_file_001
* @tc.desc Test Stat.statsync_isFile() interfaces.
* This interface shall treat a normal file as a normal file.
* @tc.name fileIO_stat_sync_is_file_002
* @tc.desc Test the isFile() method of class Stat.
* This interface shall not treat a directory as a normal file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_file_001', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_is_file_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let dpath = await nextFileName('fileIO_stat_sync_is_file_001');
try {
let stat = fileIO.statSync(fpath);
expect(stat.isFile()).assertTrue();
fileio.mkdirSync(dpath);
let stat = fileIO.statSync(dpath);
expect(stat.isFile() === false).assertTrue();
let file = fileIO.openSync(fpath);
let file = fileIO.openSync(dpath, fileIO.OpenMode.DIR);
let stat2 = fileIO.statSync(file.fd);
expect(stat2.isFile()).assertTrue();
expect(stat2.isFile() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
fileio.rmdirSync(dpath);
} catch (e) {
console.log('fileIO_stat_sync_is_file_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
......@@ -878,8 +730,8 @@ describe('fileIO_fs_stat', function () {
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISFILE_0200
* @tc.name fileIO_stat_sync_is_file_002
* @tc.desc Test Stat.statsync_isFile() interfaces.
* This interface shall not treat a directory as a normal file.
* @tc.desc Test the isFile() method of class Stat.
* This interface does not require parameters.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -890,24 +742,20 @@ describe('fileIO_fs_stat', function () {
try {
fileio.mkdirSync(dpath);
let stat = fileIO.statSync(dpath);
expect(stat.isFile() === false).assertTrue();
let file = fileIO.openSync(dpath);
let stat2 = fileIO.statSync(file.fd);
expect(stat2.isFile() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.rmdirSync(dpath);
fileIO.statSync(dpath).isFile(-1);
expect(false).assertTrue();
} catch (e) {
fileio.rmdirSync(dpath);
console.log('fileIO_stat_sync_is_file_002 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISFILE_0300
* @tc.name fileIO_stat_sync_is_file_003
* @tc.desc Test Stat.statsync_isFile() interfaces.
* @tc.desc Test the isFile() method of class Stat.
* This interface does not require parameters.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -915,48 +763,25 @@ describe('fileIO_fs_stat', function () {
*/
it('fileIO_stat_sync_is_file_003', 0, async function () {
let dpath = await nextFileName('fileIO_stat_sync_is_file_003');
fileio.mkdirSync(dpath);
let file = fileIO.openSync(dpath, fileIO.OpenMode.DIR);
try {
fileio.mkdirSync(dpath);
let stat = fileIO.statSync(dpath);
expect(stat.isFile(-1) === false).assertTrue();
expect(false).assertTrue();
} catch (e) {
fileio.rmdirSync(dpath);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISFILE_0400
* @tc.name fileIO_stat_sync_is_file_004
* @tc.desc Test Stat.statsync_isFile() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_file_004', 0, async function () {
let dpath = await nextFileName('fileIO_stat_sync_is_file_004');
let file;
try {
fileio.mkdirSync(dpath);
file = fileIO.openSync(dpath);
let stat2 = fileIO.statSync(file.fd);
expect(stat2.isFile(-1) === false).assertTrue();
fileIO.statSync(file.fd).isFile(-1);
expect(false).assertTrue();
} catch (e) {
fileio.closeSync(file.fd);
fileio.rmdirSync(dpath);
console.log('fileIO_stat_sync_is_file_003 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISSOCKET_0000
* @tc.name fileIO_stat_sync_is_socket_000
* @tc.desc Test Stat.statsync_isSocket() interfaces.
* This interface shall return a boolean variable.
* @tc.desc Test the isSocket() method of class Stat.
* This interface shall not treat a file as a socket.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -968,11 +793,11 @@ describe('fileIO_fs_stat', function () {
try {
let stat = fileIO.statSync(fpath);
expect(isBoolean(stat.isSocket())).assertTrue();
expect(stat.isSocket() === false).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(isBoolean(stat2.isSocket())).assertTrue();
expect(stat2.isSocket() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
......@@ -984,8 +809,8 @@ describe('fileIO_fs_stat', function () {
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISSOCKET_0100
* @tc.name fileIO_stat_sync_is_socket_001
* @tc.desc Test Stat.statsync_isSocket() interfaces.
* This interface shall not treat a file as a socket.
* @tc.desc Test the isSocket() method of class Stat.
* This interface does not require parameters.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -996,24 +821,20 @@ describe('fileIO_fs_stat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.statSync(fpath);
expect(stat.isSocket() === false).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(stat2.isSocket() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
fileIO.statSync(fpath).isSocket(-1);
expect(false).assertTrue();
} catch (e) {
fileio.unlinkSync(fpath);
console.log('fileIO_stat_sync_is_socket_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISSOCKET_0200
* @tc.name fileIO_stat_sync_is_socket_002
* @tc.desc Test Stat.statsync_isSocket() interfaces.
* @tc.desc Test the isSocket() method of class Stat.
* This interface does not require parameters.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -1022,63 +843,39 @@ describe('fileIO_fs_stat', function () {
it('fileIO_stat_sync_is_socket_002', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_is_socket_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let file = fileIO.openSync(fpath);
try {
let stat = fileIO.statSync(fpath);
expect(stat.isSocket(-1) === false).assertTrue();
fileIO.statSync(file.fd).isSocket(-1);
expect(false).assertTrue();
} catch (e) {
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
console.log('fileIO_stat_sync_is_socket_002 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISSOCKET_0300
* @tc.name fileIO_stat_sync_is_socket_003
* @tc.desc Test Stat.statsync_isSocket() interfaces.
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISSYMBOLICLINK_0000
* @tc.name fileIO_stat_sync_is_symbolic_link_000
* @tc.desc Test the isSymbolicLink() method of class Stat.
* This interface shall not treat a normal file as a symbolic link.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_socket_003', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_is_socket_003');
it('fileIO_stat_sync_is_symbolic_link_000', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_is_symbolic_link_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let file;
try {
file = fileIO.openSync(fpath);
let stat = fileIO.statSync(fpath);
expect(stat.isSymbolicLink() === false).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(stat2.isSocket(-1) === false).assertTrue();
expect(false).assertTrue();
} catch (e) {
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISSYMBOLICLINK_0000
* @tc.name fileIO_stat_sync_is_symbolic_link_000
* @tc.desc Test Stat.statasync_isSymbolicLink() interfaces.
* This interface shall return a boolean variable.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_symbolic_link_000', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_is_symbolic_link_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.statSync(fpath);
expect(isBoolean(stat.isSymbolicLink())).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(isBoolean(stat2.isSymbolicLink())).assertTrue();
expect(stat2.isSymbolicLink() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
......@@ -1090,8 +887,8 @@ describe('fileIO_fs_stat', function () {
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISSYMBOLICLINK_0100
* @tc.name fileIO_stat_sync_is_symbolic_link_001
* @tc.desc Test Stat.statasync_isSymbolicLink() interfaces.
* This interface shall not treat a normal file as a symbolic link.
* @tc.desc Test the isSymbolicLink() method of class Stat.
* This interface does not require parameters.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -1102,24 +899,20 @@ describe('fileIO_fs_stat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.statSync(fpath);
expect(stat.isSymbolicLink() === false).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(stat2.isSymbolicLink() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
fileIO.statSync(fpath).isSymbolicLink(-1);
expect(false).assertTrue();
} catch (e) {
fileio.unlinkSync(fpath);
console.log('fileIO_stat_sync_is_symbolic_link_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISSYMBOLICLINK_0200
* @tc.name fileIO_stat_sync_is_symbolic_link_002
* @tc.desc Test Stat.isSymbolicLink() interfaces.
* @tc.desc Test the isSymbolicLink() method of class Stat.
* This interface does not require parameters.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -1128,47 +921,24 @@ describe('fileIO_fs_stat', function () {
it('fileIO_stat_sync_is_symbolic_link_002', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_is_symbolic_link_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let file = fileIO.openSync(fpath);
try {
let stat = fileIO.statSync(fpath);
expect(stat.isSymbolicLink(-1) === false).assertTrue();
expect(false).assertTrue();
} catch (e) {
fileio.unlinkSync(fpath);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISSYMBOLICLINK_0300
* @tc.name fileIO_stat_sync_is_symbolic_link_003
* @tc.desc Test Stat.isSymbolicLink() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_symbolic_link_003', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_is_symbolic_link_003');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let file;
try {
file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(stat2.isSymbolicLink(-1) === false).assertTrue();
fileIO.statSync(file.fd).isSymbolicLink(-1);
expect(false).assertTrue();
} catch (e) {
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
console.log('fileIO_stat_sync_is_symbolic_link_001 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_0000
* @tc.name fileIO_stat_async_000
* @tc.desc Test Stat.statAsync() interface.
* This interface shall work properly in normal case when providing the promise async model.
* @tc.desc Test stat() interface. Promise.then().catch()
* Enter the path or fd parameter to get the file stat.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -1181,12 +951,18 @@ describe('fileIO_fs_stat', function () {
try {
fileIO.stat(fpath).then((stat) => {
expect(stat !== null).assertTrue();
}).catch((err) => {
console.log('fileIO_stat_async_000 error package1: ' + JSON.stringify(err));
expect(false).assertTrue();
});
let file = fileIO.openSync(fpath);
fileIO.stat(file.fd).then((stat2) => {
expect(stat2 !== null).assertTrue();
fileio.closeSync(file.fd);
}).catch((err) => {
console.log('fileIO_stat_async_000 error package2: ' + JSON.stringify(err));
expect(false).assertTrue();
});
fileio.unlinkSync(fpath);
done();
......@@ -1199,8 +975,8 @@ describe('fileIO_fs_stat', function () {
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_0100
* @tc.name fileIO_stat_async_001
* @tc.desc Test Stat.statAsync() interface.
* This interface shall work properly in normal case when providing the callback async model.
* @tc.desc Test stat() interface. Promise.
* Enter the path or fd parameter to get the file stat.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -1211,22 +987,26 @@ describe('fileIO_fs_stat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.stat(fpath, function (error) {
fileio.unlinkSync(fpath);
done();
});
let stat = await fileIO.stat(fpath);
expect(stat !== null).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd);
expect(stat2 !== null).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_stat_async_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_0200
* @tc.name fileIO_stat_async_002
* @tc.desc Test Stat.statAsync() interface.
* This interface shall work properly in normal case when providing the callback async model.
* @tc.desc Test stat() interface. Callback.
* Enter the path or fd parameter to get the file stat.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -1237,8 +1017,21 @@ describe('fileIO_fs_stat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.stat(fpath, (err, stat) => {
if(err) {
console.log('fileIO_stat_async_002 error package1: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(stat !== null).assertTrue();
});
let file = fileIO.openSync(fpath);
fileIO.stat(file.fd, function (error) {
fileIO.stat(file.fd, (err, stat2) => {
if(err) {
console.log('fileIO_stat_async_002 error package2: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(stat2 !== null).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
......@@ -1248,10 +1041,106 @@ describe('fileIO_fs_stat', function () {
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_0300
* @tc.name fileIO_stat_async_003
* @tc.desc Test stat() interface. Promise.
* The path point to nothing, no such file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_003', 0, async function (done) {
let fpath = await nextFileName('fileIO_stat_async_003');
try {
await fileIO.stat(fpath)
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_stat_async_003 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900002 && e.message == 'No such file or directory').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_0400
* @tc.name fileIO_stat_async_004
* @tc.desc Test stat() interface. Callback.
* The path point to nothing, no such file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_004', 0, async function (done) {
let fpath = await nextFileName('fileIO_stat_async_004');
try {
fileIO.stat(fpath, (err) => {
if (err) {
console.log('fileIO_stat_async_004 error package: {' + err.message + ', code: ' + err.code + '}');
expect(err.code == 13900002 && err.message == 'No such file or directory').assertTrue();
done();
}
});
} catch (e) {
console.log('fileIO_stat_async_004 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_0500
* @tc.name fileIO_stat_async_005
* @tc.desc Test stat() interface. Promise.
* Invalid path or fd parameter.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_005', 0, async function (done) {
try {
await fileIO.stat(-1)
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_stat_async_005 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_0600
* @tc.name fileIO_stat_async_006
* @tc.desc Test stat() interface. Callback.
* Invalid path or fd parameter.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_006', 0, async function (done) {
try {
fileIO.stat(-1, () => {
expect(false).assertTrue();
});
} catch (e) {
console.log('fileIO_stat_async_006 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_INO_0000
* @tc.name fileIO_stat_async_ino_000
* @tc.desc Test the ino member of class Stat.
* @tc.desc Test the ino member of class Stat. Promise.
* Enter the path or fd parameter to get stat.ino of the file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -1263,11 +1152,11 @@ describe('fileIO_fs_stat', function () {
try {
let stat = await fileIO.stat(fpath);
expect(isIntNum(stat.ino)).assertTrue();
expect(isBigInt(stat.ino)).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd);
expect(isIntNum(stat2.ino)).assertTrue();
expect(isBigInt(stat2.ino)).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
......@@ -1277,10 +1166,51 @@ describe('fileIO_fs_stat', function () {
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_INO_0100
* @tc.name fileIO_stat_async_ino_001
* @tc.desc Test the ino member of class Stat. Callback.
* Enter the path or fd parameter to get stat.atime of the file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_ino_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_stat_async_ino_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.stat(fpath, (err, stat) => {
if(err) {
console.log('fileIO_stat_async_ino_001 error package1: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(isBigInt(stat.ino)).assertTrue();
});
let file = fileIO.openSync(fpath);
fileIO.stat(file.fd, (err, stat2) => {
if(err) {
console.log('fileIO_stat_async_ino_001 error package2: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(isBigInt(stat2.ino)).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_stat_async_ino_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_MODE_0000
* @tc.name fileIO_stat_async_mode_000
* @tc.desc Test the mode member of class Stat.
* @tc.desc Test the mode member of class Stat. Promise.
* Enter the path or fd parameter to get stat.mode of the file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -1306,10 +1236,51 @@ describe('fileIO_fs_stat', function () {
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_MODE_0100
* @tc.name fileIO_stat_async_mode_001
* @tc.desc Test the mode member of class Stat. Callback.
* Enter the path or fd parameter to get stat.mode of the file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_mode_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_stat_async_mode_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.stat(fpath, (err, stat) => {
if(err) {
console.log('fileIO_stat_async_mode_001 error package1: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(isIntNum(stat.mode)).assertTrue();
});
let file = fileIO.openSync(fpath);
fileIO.stat(file.fd, (err, stat2) => {
if(err) {
console.log('fileIO_stat_async_mode_001 error package2: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(isIntNum(stat2.mode)).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_stat_async_mode_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_UID_0000
* @tc.name fileIO_stat_async_uid_000
* @tc.desc Test the uid member of class Stat.
* @tc.desc Test the uid member of class Stat. Promise.
* Enter the path or fd parameter to get stat.uid of the file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -1335,10 +1306,52 @@ describe('fileIO_fs_stat', function () {
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_UID_0100
* @tc.name fileIO_stat_async_uid_001
* @tc.desc Test the uid member of class Stat. Callback.
* Enter the path or fd parameter to get stat.uid of the file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_uid_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_stat_async_uid_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.stat(fpath, (err, stat) => {
if(err) {
console.log('fileIO_stat_async_uid_001 error package1: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(isIntNum(stat.uid)).assertTrue();
});
let file = fileIO.openSync(fpath);
fileIO.stat(file.fd, (err, stat2) => {
if(err) {
console.log('fileIO_stat_async_uid_001 error package2: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(isIntNum(stat2.uid)).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_stat_async_uid_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_GID_0000
* @tc.name fileIO_stat_async_gid_000
* @tc.desc Test the gid member of class Stat.
* @tc.desc Test the gid member of class Stat. Promise.
* Enter the path or fd parameter to get stat.gid of the file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -1364,10 +1377,51 @@ describe('fileIO_fs_stat', function () {
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_GID_0100
* @tc.name fileIO_stat_async_gid_001
* @tc.desc Test the gid member of class Stat. Callback.
* Enter the path or fd parameter to get stat.gid of the file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_gid_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_stat_async_gid_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.stat(fpath, (err, stat) => {
if(err) {
console.log('fileIO_stat_async_gid_001 error package1: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(isIntNum(stat.gid)).assertTrue();
});
let file = fileIO.openSync(fpath);
fileIO.stat(file.fd, (err, stat2) => {
if(err) {
console.log('fileIO_stat_async_gid_001 error package2: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(isIntNum(stat2.gid)).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_stat_async_gid_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_SIZE_0000
* @tc.name fileIO_stat_async_size_000
* @tc.desc Test the size member of class Stat.
* @tc.desc Test the size member of class Stat. Promise.
* Enter the path or fd parameter to get stat.size of the file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -1393,11 +1447,51 @@ describe('fileIO_fs_stat', function () {
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_SIZE_0100
* @tc.name fileIO_stat_async_size_001
* @tc.desc Test the size member of class Stat. Callback.
* Enter the path or fd parameter to get stat.size of the file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_size_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_stat_async_size_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.stat(fpath, (err, stat) => {
if(err) {
console.log('fileIO_stat_async_size_001 error package1: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(isIntNum(stat.size)).assertTrue();
});
let file = fileIO.openSync(fpath);
fileIO.stat(file.fd, (err, stat2) => {
if(err) {
console.log('fileIO_stat_async_size_001 error package2: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(isIntNum(stat2.size)).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_stat_async_size_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_ATIME_0000
* @tc.name fileIO_stat_async_atime_000
* @tc.desc Test Stat.atime() interface.
* @tc.desc Test the atime member of class Stat.
* @tc.desc Test the atime member of class Stat. Promise.
* Enter the path or fd parameter to get stat.atime of the file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -1423,11 +1517,51 @@ describe('fileIO_fs_stat', function () {
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_ATIME_0100
* @tc.name fileIO_stat_async_atime_001
* @tc.desc Test the atime member of class Stat. Callback.
* Enter the path or fd parameter to get stat.atime of the file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_atime_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_stat_async_atime_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.stat(fpath, (err, stat) => {
if(err) {
console.log('fileIO_stat_async_atime_001 error package1: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(isIntNum(stat.atime)).assertTrue();
});
let file = fileIO.openSync(fpath);
fileIO.stat(file.fd, (err, stat2) => {
if(err) {
console.log('fileIO_stat_async_atime_001 error package2: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(isIntNum(stat2.atime)).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_stat_async_atime_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_MTIME_0000
* @tc.name fileIO_stat_async_mtime_000
* @tc.desc Test Stat.mtime() interface.
* @tc.desc Test the mtime member of class Stat.
* @tc.desc Test the mtime member of class Stat. Promise.
* Enter the path or fd parameter to get stat.mtime of the file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -1453,10 +1587,51 @@ describe('fileIO_fs_stat', function () {
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_MTIME_0100
* @tc.name fileIO_stat_async_mtime_001
* @tc.desc Test the mtime member of class Stat. Callback.
* Enter the path or fd parameter to get stat.mtime of the file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_mtime_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_stat_async_mtime_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.stat(fpath, (err, stat) => {
if(err) {
console.log('fileIO_stat_async_mtime_001 error package1: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(isIntNum(stat.mtime)).assertTrue();
});
let file = fileIO.openSync(fpath);
fileIO.stat(file.fd, (err, stat2) => {
if(err) {
console.log('fileIO_stat_async_mtime_001 error package2: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(isIntNum(stat2.mtime)).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_stat_async_mtime_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_CTIME_0000
* @tc.name fileIO_stat_async_ctime_000
* @tc.desc Test the ctime member of class Stat.
* @tc.desc Test the ctime member of class Stat. Promise.
* Enter the path or fd parameter to get stat.ctime of the file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -1482,10 +1657,51 @@ describe('fileIO_fs_stat', function () {
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_CTIME_0100
* @tc.name fileIO_stat_async_ctime_001
* @tc.desc Test the ctime member of class Stat. Callback.
* Enter the path or fd parameter to get stat.ctime of the file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_ctime_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_stat_async_ctime_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.stat(fpath, (err, stat) => {
if(err) {
console.log('fileIO_stat_async_ctime_001 error package1: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(isIntNum(stat.ctime)).assertTrue();
});
let file = fileIO.openSync(fpath);
fileIO.stat(file.fd, (err, stat2) => {
if(err) {
console.log('fileIO_stat_async_ctime_001 error package2: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(isIntNum(stat2.ctime)).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_stat_async_ctime_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISBLOCKDEVICE_0000
* @tc.name fileIO_stat_async_is_block_device_000
* @tc.desc Test the isBlockDevice method of class Stat.
* @tc.desc Test the isBlockDevice() method of class Stat. Promise.
* This interface shall not treat a normal file as a block special device.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -1497,11 +1713,11 @@ describe('fileIO_fs_stat', function () {
try {
let stat = await fileIO.stat(fpath);
expect(isBoolean(stat.isBlockDevice())).assertTrue();
expect(stat.isBlockDevice() === false).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd);
expect(isBoolean(stat2.isBlockDevice())).assertTrue();
expect(stat2.isBlockDevice() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
......@@ -1514,7 +1730,8 @@ describe('fileIO_fs_stat', function () {
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISBLOCKDEVICE_0100
* @tc.name fileIO_stat_async_is_block_device_001
* @tc.desc Test the isBlockDevice method of class Stat.
* @tc.desc Test the isBlockDevice() method of class Stat. Callback.
* This interface shall not treat a normal file as a block special device.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -1525,15 +1742,25 @@ describe('fileIO_fs_stat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.stat(fpath);
expect(stat.isBlockDevice() === false).assertTrue();
fileIO.stat(fpath, (err, stat) => {
if(err) {
console.log('fileIO_stat_async_is_block_device_001 error package1: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(stat.isBlockDevice() === false).assertTrue();
});
let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd);
expect(stat2.isBlockDevice() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
fileIO.stat(file.fd, (err, stat2) => {
if(err) {
console.log('fileIO_stat_async_is_block_device_001 error package2: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(stat2.isBlockDevice() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_stat_async_is_block_device_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
......@@ -1543,7 +1770,8 @@ describe('fileIO_fs_stat', function () {
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISCHARACTERDEVICE_0000
* @tc.name fileIO_stat_async_is_character_device_000
* @tc.desc Test the isCharacterDevice method of class Stat.
* @tc.desc Test the isCharacterDevice() method of class Stat. Promise.
* This interface shall not treat a normal file as a character special device.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -1555,11 +1783,11 @@ describe('fileIO_fs_stat', function () {
try {
let stat = await fileIO.stat(fpath);
expect(isBoolean(stat.isCharacterDevice())).assertTrue();
expect(stat.isCharacterDevice() === false).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd);
expect(isBoolean(stat2.isCharacterDevice())).assertTrue();
expect(stat2.isCharacterDevice() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
......@@ -1572,7 +1800,8 @@ describe('fileIO_fs_stat', function () {
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISCHARACTERDEVICE_0100
* @tc.name fileIO_stat_async_is_character_device_001
* @tc.desc Test the isCharacterDevice method of class Stat.
* @tc.desc Test the isCharacterDevice() method of class Stat. Callback.
* This interface shall not treat a normal file as a character special device.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -1583,15 +1812,25 @@ describe('fileIO_fs_stat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.stat(fpath);
expect(stat.isCharacterDevice() === false).assertTrue();
fileIO.stat(fpath, (err, stat) => {
if(err) {
console.log('fileIO_stat_async_is_character_device_001 error package1: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(stat.isCharacterDevice() === false).assertTrue();
});
let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd);
expect(stat2.isCharacterDevice() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
fileIO.stat(file.fd, (err, stat2) => {
if(err) {
console.log('fileIO_stat_async_is_character_device_001 error package2: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(stat2.isCharacterDevice() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_stat_async_is_character_device_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
......@@ -1601,7 +1840,8 @@ describe('fileIO_fs_stat', function () {
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISDIRECTORY_0000
* @tc.name fileIO_stat_async_is_directory_000
* @tc.desc Test Stat.isDirectory() interface.
* @tc.desc Test the isDirectory() method of class Stat. Promise.
* This interface shall not treat a normal file as a directory.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -1613,11 +1853,11 @@ describe('fileIO_fs_stat', function () {
try {
let stat = await fileIO.stat(fpath);
expect(isBoolean(stat.isDirectory())).assertTrue();
expect(stat.isDirectory() === false).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd);
expect(isBoolean(stat2.isDirectory())).assertTrue();
expect(stat2.isDirectory() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
......@@ -1630,25 +1870,26 @@ describe('fileIO_fs_stat', function () {
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISDIRECTORY_0100
* @tc.name fileIO_stat_async_is_directory_001
* @tc.desc Test Stat.isDirectory() interface.
* @tc.desc Test the isDirectory() method of class Stat. Promise.
* This interface shall not treat a directory as a directory.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_is_directory_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_stat_async_is_directory_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let dpath = await nextFileName('fileIO_stat_async_is_directory_001') + 'd';
try {
let stat = await fileIO.stat(fpath);
expect(stat.isDirectory() === false).assertTrue();
fileio.mkdirSync(dpath);
let stat = await fileIO.stat(dpath);
expect(stat.isDirectory() === true).assertTrue();
let file = fileIO.openSync(fpath);
let file = fileIO.openSync(dpath, fileIO.OpenMode.DIR);
let stat2 = await fileIO.stat(file.fd);
expect(stat2.isDirectory() === false).assertTrue();
expect(stat2.isDirectory() === true).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
fileio.rmdirSync(dpath);
done();
} catch (e) {
console.log('fileIO_stat_async_is_directory_001 has failed for ' + e.message + ', code: ' + e.code);
......@@ -1659,7 +1900,8 @@ describe('fileIO_fs_stat', function () {
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISDIRECTORY_0200
* @tc.name fileIO_stat_async_is_directory_002
* @tc.desc Test Stat.isDirectory() interface.
* @tc.desc Test the isDirectory() method of class Stat. Callback.
* This interface shall not treat a directory as a directory.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -1670,15 +1912,25 @@ describe('fileIO_fs_stat', function () {
try {
fileio.mkdirSync(dpath);
let stat = await fileIO.stat(dpath);
expect(stat.isDirectory()).assertTrue();
fileIO.stat(dpath, (err, stat) => {
if(err) {
console.log('fileIO_stat_async_is_directory_002 error package1: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(stat.isDirectory() === true).assertTrue();
});
let file = fileIO.openSync(dpath);
let stat2 = await fileIO.stat(file.fd);
expect(stat2.isDirectory()).assertTrue();
fileio.closeSync(file.fd);
fileio.rmdirSync(dpath);
done();
let file = fileIO.openSync(dpath, fileIO.OpenMode.DIR);
fileIO.stat(file.fd, (err, stat2) => {
if(err) {
console.log('fileIO_stat_async_is_directory_002 error package2: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(stat2.isDirectory() === true).assertTrue();
fileio.closeSync(file.fd);
fileio.rmdirSync(dpath);
done();
});
} catch (e) {
console.log('fileIO_stat_async_is_directory_002 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
......@@ -1688,7 +1940,8 @@ describe('fileIO_fs_stat', function () {
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISFIFO_0000
* @tc.name fileIO_stat_async_is_fifo_000
* @tc.desc Test Stat.isFIFO() interface.
* @tc.desc Test the isFIFO() method of class Stat. Promise.
* This interface shall not treat a normal file as a FIFO.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -1700,11 +1953,11 @@ describe('fileIO_fs_stat', function () {
try {
let stat = await fileIO.stat(fpath);
expect(isBoolean(stat.isFIFO())).assertTrue();
expect(stat.isFIFO() === false).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd);
expect(isBoolean(stat2.isFIFO())).assertTrue();
expect(stat2.isFIFO() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
......@@ -1717,7 +1970,8 @@ describe('fileIO_fs_stat', function () {
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISFIFO_0100
* @tc.name fileIO_stat_async_is_fifo_001
* @tc.desc Test Stat.isFIFO() interface.
* @tc.desc Test the isFIFO() method of class Stat. Callback.
* This interface shall not treat a normal file as a FIFO.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -1728,15 +1982,25 @@ describe('fileIO_fs_stat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.stat(fpath);
expect(stat.isFIFO() === false).assertTrue();
fileIO.stat(fpath, (err, stat) => {
if(err) {
console.log('fileIO_stat_async_is_fifo_001 error package1: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(stat.isFIFO() === false).assertTrue();
});
let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd);
expect(stat2.isFIFO() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
fileIO.stat(file.fd, (err, stat2) => {
if(err) {
console.log('fileIO_stat_async_is_fifo_001 error package2: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(stat2.isFIFO() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_stat_async_is_fifo_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
......@@ -1746,7 +2010,8 @@ describe('fileIO_fs_stat', function () {
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISFILE_0000
* @tc.name fileIO_stat_async_is_file_000
* @tc.desc Test Stat.isFile() interface.
* @tc.desc Test the isFile() method of class Stat. Promise.
* This interface shall treat a normal file as a normal file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -1758,11 +2023,11 @@ describe('fileIO_fs_stat', function () {
try {
let stat = await fileIO.stat(fpath);
expect(isBoolean(stat.isFile())).assertTrue();
expect(stat.isFile() === true).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd);
expect(isBoolean(stat2.isFile())).assertTrue();
expect(stat2.isFile() === true).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
......@@ -1775,7 +2040,8 @@ describe('fileIO_fs_stat', function () {
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISFILE_0100
* @tc.name fileIO_stat_async_is_file_001
* @tc.desc Test Stat.isFile() interface.
* @tc.desc Test the isFile() method of class Stat. Callback.
* This interface shall treat a normal file as a normal file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -1786,15 +2052,25 @@ describe('fileIO_fs_stat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.stat(fpath);
expect(stat.isFile()).assertTrue();
fileIO.stat(fpath, (err, stat) => {
if(err) {
console.log('fileIO_stat_async_is_file_001 error package1: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(stat.isFile() === true).assertTrue();
});
let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd);
expect(stat2.isFile()).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
fileIO.stat(file.fd, (err, stat2) => {
if(err) {
console.log('fileIO_stat_async_is_file_001 error package2: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(stat2.isFile() === true).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_stat_async_is_file_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
......@@ -1804,7 +2080,8 @@ describe('fileIO_fs_stat', function () {
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISFILE_0200
* @tc.name fileIO_stat_async_is_file_002
* @tc.desc Test Stat.isFile() interface.
* @tc.desc Test the isFile() method of class Stat. Promise.
* This interface shall not treat a directory as a normal file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -1818,7 +2095,7 @@ describe('fileIO_fs_stat', function () {
let stat = await fileIO.stat(dpath);
expect(stat.isFile() === false).assertTrue();
let file = fileIO.openSync(dpath);
let file = fileIO.openSync(dpath, fileIO.OpenMode.DIR);
let stat2 = await fileIO.stat(file.fd);
expect(stat2.isFile() === false).assertTrue();
fileio.closeSync(file.fd);
......@@ -1833,7 +2110,8 @@ describe('fileIO_fs_stat', function () {
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISSOCKET_0000
* @tc.name fileIO_stat_async_is_socket_000
* @tc.desc Test Stat.isSocket() interface.
* @tc.desc Test the isSocket() method of class Stat. Promise.
* This interface shall not treat a file as a socket.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -1845,13 +2123,12 @@ describe('fileIO_fs_stat', function () {
try {
let stat = await fileIO.stat(fpath);
expect(isBoolean(stat.isSocket())).assertTrue();
expect(stat.isSocket() === false).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd);
expect(isBoolean(stat2.isSocket())).assertTrue();
expect(stat2.isSocket() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_stat_async_is_socket_000 has failed for ' + e.message + ', code: ' + e.code);
......@@ -1862,7 +2139,8 @@ describe('fileIO_fs_stat', function () {
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISSOCKET_0100
* @tc.name fileIO_stat_async_is_socket_001
* @tc.desc Test Stat.isSocket() interface.
* @tc.desc Test the isSocket() method of class Stat. Callback.
* This interface shall not treat a file as a socket.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -1873,14 +2151,25 @@ describe('fileIO_fs_stat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.stat(fpath);
expect(stat.isSocket() === false).assertTrue();
fileIO.stat(fpath, (err, stat) => {
if(err) {
console.log('fileIO_stat_async_is_socket_001 error package1: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(stat.isSocket() === false).assertTrue();
});
let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd);
expect(stat2.isSocket() === false).assertTrue();
fileio.closeSync(file.fd);
done();
fileIO.stat(file.fd, (err, stat2) => {
if(err) {
console.log('fileIO_stat_async_is_socket_001 error package2: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(stat2.isSocket() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_stat_async_is_socket_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
......@@ -1890,7 +2179,8 @@ describe('fileIO_fs_stat', function () {
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISSYMBOLICLINK_0000
* @tc.name fileIO_stat_async_is_symbolic_link_000
* @tc.desc Test Stat.isSymbolicLink() interface.
* @tc.desc Test the isSymbolicLink() method of class Stat. Promise.
* This interface shall not treat a normal file as a symbolic link.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -1902,11 +2192,11 @@ describe('fileIO_fs_stat', function () {
try {
let stat = await fileIO.stat(fpath);
expect(isBoolean(stat.isSymbolicLink())).assertTrue();
expect(stat.isSymbolicLink() === false).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd);
expect(isBoolean(stat2.isSymbolicLink())).assertTrue();
expect(stat2.isSymbolicLink() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
......@@ -1919,7 +2209,8 @@ describe('fileIO_fs_stat', function () {
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISSYMBOLICLINK_0100
* @tc.name fileIO_stat_async_is_symbolic_link_001
* @tc.desc Test Stat.isSymbolicLink() interface.
* @tc.desc Test the isSymbolicLink() method of class Stat. Callback.
* This interface shall not treat a normal file as a symbolic link.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -1930,15 +2221,25 @@ describe('fileIO_fs_stat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.stat(fpath);
expect(stat.isSymbolicLink() === false).assertTrue();
fileIO.stat(fpath, (err, stat) => {
if(err) {
console.log('fileIO_stat_async_is_symbolic_link_001 error package1: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(stat.isSymbolicLink() === false).assertTrue();
});
let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd);
expect(stat2.isSymbolicLink() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
fileIO.stat(file.fd, (err, stat2) => {
if(err) {
console.log('fileIO_stat_async_is_symbolic_link_001 error package2: ' + JSON.stringify(err));
expect(false).assertTrue();
}
expect(stat2.isSymbolicLink() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_stat_async_is_symbolic_link_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
......@@ -1948,7 +2249,8 @@ describe('fileIO_fs_stat', function () {
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_APPEND_FILE_SYNC_0000
* @tc.name fileIO_stat_sync_append_file_sync_000
* @tc.desc Test Stat.statSync() interface.
* @tc.desc Test statSync() interface.
* Modify the file, view the file status changes by path.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -1970,17 +2272,18 @@ describe('fileIO_fs_stat', function () {
stat = fileIO.statSync(fpath);
expect(stat.size == FILE_CONTENT.length * 2).assertTrue();
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_test_append_file_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
done();
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_APPEND_FILE_SYNC_0100
* @tc.name fileIO_stat_sync_append_file_sync_001
* @tc.desc Test Stat.statSync() interface.
* @tc.desc Test statSync() interface.
* Modify the file, view the file status changes by fd.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
......@@ -2003,11 +2306,11 @@ describe('fileIO_fs_stat', function () {
expect(stat.size == FILE_CONTENT.length * 2).assertTrue();
fileio.closeSync(file2.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_test_append_file_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
done();
});
});
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册