提交 41d6fc06 编写于 作者: R raoxian

新增rmdir path为../的用例

Signed-off-by: Nraoxian <raoxian@huawei.com>
上级 00bc799e
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
"description": "Configuration for storage fileio Tests", "description": "Configuration for storage fileio Tests",
"driver": { "driver": {
"type": "OHJSUnitTest", "type": "OHJSUnitTest",
"test-timeout": "1800000", "test-timeout": "600000",
"shell-timeout": "1800000", "shell-timeout": "600000",
"bundle-name": "ohos.acts.storage.fileio", "bundle-name": "ohos.acts.storage.fileio",
"package-name": "ohos.acts.storage.fileio" "package-name": "ohos.acts.storage.fileio"
}, },
......
...@@ -108,45 +108,48 @@ describe('fileio_rmdir', function () { ...@@ -108,45 +108,48 @@ describe('fileio_rmdir', function () {
/** /**
* @tc.number SUB_STORAGE_FileIO_RMDIR_SYNC_0300 * @tc.number SUB_STORAGE_FileIO_RMDIR_SYNC_0300
* @tc.name fileio_test_rmdir_sync_003 * @tc.name fileio_test_rmdir_sync_003
* @tc.desc Test rmdirSync() interface. Invalid path. * @tc.desc Test rmdirSync() interface. The path contains ../, normal call.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 0
* @tc.require * @tc.require
*/ */
it('fileio_test_rmdir_sync_003', 0, async function () { it('fileio_test_rmdir_sync_003', 0, async function () {
let dpath = await nextFileName('fileio_test_rmdir_sync_003') + 'd'; let dpath = await nextFileName('../cache/fileio_test_rmdir_sync_003') + 'd';
try { try {
fileio.mkdirSync(dpath);
fileio.rmdirSync(dpath); fileio.rmdirSync(dpath);
} catch (err) { } catch (err) {
console.info('fileio_test_rmdir_sync_003 has failed for ' + err); console.info('fileio_test_rmdir_sync_003 has failed for ' + err);
expect(isInclude(err.message, 'No such file or directory')).assertTrue(); expect(null).assertFail();
} }
}); });
/** /**
* @tc.number SUB_STORAGE_FileIO_RMDIR_SYNC_0400 * @tc.number SUB_STORAGE_FileIO_RMDIR_SYNC_0400
* @tc.name fileio_test_rmdir_sync_004 * @tc.name fileio_test_rmdir_sync_004
* @tc.desc Test rmdirSync() interface. No parameters. * @tc.desc Test rmdirSync() interface. Invalid path.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 0
* @tc.require * @tc.require
*/ */
it('fileio_test_rmdir_sync_004', 0, async function () { it('fileio_test_rmdir_sync_004', 0, async function () {
let dpath = await nextFileName('fileio_test_rmdir_sync_004') + 'd';
try { try {
fileio.rmdirSync(); fileio.rmdirSync(dpath);
} catch (err) { } catch (err) {
console.info('fileio_test_rmdir_sync_004 has failed for ' + err); console.info('fileio_test_rmdir_sync_004 has failed for ' + err);
expect(isInclude(err.message, 'Number of arguments unmatched')).assertTrue(); expect(isInclude(err.message, 'No such file or directory')).assertTrue();
} }
}); });
/** /**
* @tc.number SUB_STORAGE_FileIO_RMDIR_SYNC_0500 * @tc.number SUB_STORAGE_FileIO_RMDIR_SYNC_0500
* @tc.name fileio_test_rmdir_sync_005 * @tc.name fileio_test_rmdir_sync_005
* @tc.desc Test rmdirSync() interface. Invalid path. * @tc.desc Test rmdirSync() interface. No parameters.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 0
...@@ -154,29 +157,47 @@ describe('fileio_rmdir', function () { ...@@ -154,29 +157,47 @@ describe('fileio_rmdir', function () {
*/ */
it('fileio_test_rmdir_sync_005', 0, async function () { it('fileio_test_rmdir_sync_005', 0, async function () {
try { try {
fileio.rmdirSync(''); fileio.rmdirSync();
} catch (err) { } catch (err) {
console.info('fileio_test_rmdir_sync_005 has failed for ' + err); console.info('fileio_test_rmdir_sync_005 has failed for ' + err);
expect(isInclude(err.message, 'No such file or directory')).assertTrue(); expect(isInclude(err.message, 'Number of arguments unmatched')).assertTrue();
} }
}); });
/** /**
* @tc.number SUB_STORAGE_FileIO_RMDIR_SYNC_0600 * @tc.number SUB_STORAGE_FileIO_RMDIR_SYNC_0600
* @tc.name fileio_test_rmdir_sync_006 * @tc.name fileio_test_rmdir_sync_006
* @tc.desc Test rmdirSync() interface. Not a directory. * @tc.desc Test rmdirSync() interface. Invalid path.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 0
* @tc.require * @tc.require
*/ */
it('fileio_test_rmdir_sync_006', 0, async function () { it('fileio_test_rmdir_sync_006', 0, async function () {
let fpath = await nextFileName('fileio_test_rmdir_sync_006'); try {
fileio.rmdirSync('');
} catch (err) {
console.info('fileio_test_rmdir_sync_006 has failed for ' + err);
expect(isInclude(err.message, 'No such file or directory')).assertTrue();
}
});
/**
* @tc.number SUB_STORAGE_FileIO_RMDIR_SYNC_0700
* @tc.name fileio_test_rmdir_sync_007
* @tc.desc Test rmdirSync() interface. Not a directory.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_rmdir_sync_007', 0, async function () {
let fpath = await nextFileName('fileio_test_rmdir_sync_007');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
fileio.rmdirSync(fpath); fileio.rmdirSync(fpath);
} catch (err) { } catch (err) {
console.info('fileio_test_rmdir_sync_006 has failed for ' + err); console.info('fileio_test_rmdir_sync_007 has failed for ' + err);
expect(isInclude(err.message, 'Not a directory')).assertTrue(); expect(isInclude(err.message, 'Not a directory')).assertTrue();
fileio.unlinkSync(fpath); fileio.unlinkSync(fpath);
} }
...@@ -282,10 +303,10 @@ describe('fileio_rmdir', function () { ...@@ -282,10 +303,10 @@ describe('fileio_rmdir', function () {
*/ */
it('fileio_test_rmdir_async_003', 0, async function (done) { it('fileio_test_rmdir_async_003', 0, async function (done) {
let dpath = await nextFileName('fileio_test_rmdir_async_003') + 'd'; let dpath = await nextFileName('fileio_test_rmdir_async_003') + 'd';
let fpath = dpath + '/rmdir_async_001'; let fpath = dpath + '/rmdir_async_003';
let ffpath = dpath + '/rmdir_async_001_1'; let ffpath = dpath + '/rmdir_async_003_1';
let ddpath = dpath + '/rmdir_async_001_1d'; let ddpath = dpath + '/rmdir_async_003_1d';
let fffpath = ddpath + '/rmdir_async_002'; let fffpath = ddpath + '/rmdir_async_003_2';
fileio.mkdirSync(dpath); fileio.mkdirSync(dpath);
fileio.mkdirSync(ddpath); fileio.mkdirSync(ddpath);
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
...@@ -305,28 +326,28 @@ describe('fileio_rmdir', function () { ...@@ -305,28 +326,28 @@ describe('fileio_rmdir', function () {
/** /**
* @tc.number SUB_STORAGE_FileIO_RMDIR_ASYNC_0400 * @tc.number SUB_STORAGE_FileIO_RMDIR_ASYNC_0400
* @tc.name fileio_test_rmdir_async_004 * @tc.name fileio_test_rmdir_async_004
* @tc.desc Test rmdir() interface. Invalid path. * @tc.desc Test rmdirSync() interface. The path contains ../, normal call.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 0
* @tc.require * @tc.require
*/ */
it('fileio_test_rmdir_async_004', 0, async function (done) { it('fileio_test_rmdir_async_004', 0, async function () {
let dpath = await nextFileName('fileio_test_rmdir_async_004') + 'd'; let dpath = await nextFileName('../cache/fileio_test_rmdir_async_004') + 'd';
try { try {
fileio.mkdirSync(dpath);
await fileio.rmdir(dpath); await fileio.rmdir(dpath);
} catch (err) { } catch (err) {
console.info('fileio_test_rmdir_async_004 has failed for ' + err); console.info('fileio_test_rmdir_async_004 has failed for ' + err);
expect(isInclude(err.message, 'No such file or directory')).assertTrue(); expect(null).assertFail();
done();
} }
}); });
/** /**
* @tc.number SUB_STORAGE_FileIO_RMDIR_ASYNC_0500 * @tc.number SUB_STORAGE_FileIO_RMDIR_ASYNC_0500
* @tc.name fileio_test_rmdir_async_005 * @tc.name fileio_test_rmdir_async_005
* @tc.desc Test rmdir() interface. Parameter mismatch. * @tc.desc Test rmdir() interface. Invalid path.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 0
...@@ -334,12 +355,12 @@ describe('fileio_rmdir', function () { ...@@ -334,12 +355,12 @@ describe('fileio_rmdir', function () {
*/ */
it('fileio_test_rmdir_async_005', 0, async function (done) { it('fileio_test_rmdir_async_005', 0, async function (done) {
let dpath = await nextFileName('fileio_test_rmdir_async_005') + 'd'; let dpath = await nextFileName('fileio_test_rmdir_async_005') + 'd';
try { try {
fileio.rmdir(dpath, '', function() { await fileio.rmdir(dpath);
});
} catch (err) { } catch (err) {
console.info('fileio_test_rmdir_async_005 has failed for ' + err); console.info('fileio_test_rmdir_async_005 has failed for ' + err);
expect(isInclude(err.message, 'Number of arguments unmatched')).assertTrue(); expect(isInclude(err.message, 'No such file or directory')).assertTrue();
done(); done();
} }
}); });
...@@ -347,18 +368,20 @@ describe('fileio_rmdir', function () { ...@@ -347,18 +368,20 @@ describe('fileio_rmdir', function () {
/** /**
* @tc.number SUB_STORAGE_FileIO_RMDIR_ASYNC_0600 * @tc.number SUB_STORAGE_FileIO_RMDIR_ASYNC_0600
* @tc.name fileio_test_rmdir_async_006 * @tc.name fileio_test_rmdir_async_006
* @tc.desc Test rmdir() interface. Invalid path. * @tc.desc Test rmdir() interface. Parameter mismatch.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 0
* @tc.require * @tc.require
*/ */
it('fileio_test_rmdir_async_006', 0, async function (done) { it('fileio_test_rmdir_async_006', 0, async function (done) {
let dpath = await nextFileName('fileio_test_rmdir_async_006') + 'd';
try { try {
await fileio.rmdir(''); fileio.rmdir(dpath, '', function() {
});
} catch (err) { } catch (err) {
console.info('fileio_test_rmdir_async_006 has failed for ' + err); console.info('fileio_test_rmdir_async_006 has failed for ' + err);
expect(isInclude(err.message, 'No such file or directory')).assertTrue(); expect(isInclude(err.message, 'Number of arguments unmatched')).assertTrue();
done(); done();
} }
}); });
...@@ -366,19 +389,38 @@ describe('fileio_rmdir', function () { ...@@ -366,19 +389,38 @@ describe('fileio_rmdir', function () {
/** /**
* @tc.number SUB_STORAGE_FileIO_RMDIR_ASYNC_0700 * @tc.number SUB_STORAGE_FileIO_RMDIR_ASYNC_0700
* @tc.name fileio_test_rmdir_async_007 * @tc.name fileio_test_rmdir_async_007
* @tc.desc Test rmdir() interface. Not a directory. * @tc.desc Test rmdir() interface. Invalid path.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 0
* @tc.require * @tc.require
*/ */
it('fileio_test_rmdir_async_007', 0, async function (done) { it('fileio_test_rmdir_async_007', 0, async function (done) {
let fpath = await nextFileName('fileio_test_rmdir_async_007'); try {
await fileio.rmdir('');
} catch (err) {
console.info('fileio_test_rmdir_async_007 has failed for ' + err);
expect(isInclude(err.message, 'No such file or directory')).assertTrue();
done();
}
});
/**
* @tc.number SUB_STORAGE_FileIO_RMDIR_ASYNC_0800
* @tc.name fileio_test_rmdir_async_008
* @tc.desc Test rmdir() interface. Not a directory.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_rmdir_async_008', 0, async function (done) {
let fpath = await nextFileName('fileio_test_rmdir_async_008');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
await fileio.rmdir(fpath); await fileio.rmdir(fpath);
} catch (err) { } catch (err) {
console.info('fileio_test_rmdir_async_007 has failed for ' + err); console.info('fileio_test_rmdir_async_008 has failed for ' + err);
expect(isInclude(err.message, 'Not a directory')).assertTrue(); expect(isInclude(err.message, 'Not a directory')).assertTrue();
fileio.unlinkSync(fpath); fileio.unlinkSync(fpath);
done(); done();
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
"description": "Configuration for storage file Tests", "description": "Configuration for storage file Tests",
"driver": { "driver": {
"type": "OHJSUnitTest", "type": "OHJSUnitTest",
"test-timeout": "600000", "test-timeout": "120000",
"shell-timeout": "600000", "shell-timeout": "120000",
"bundle-name": "ohos.acts.storage.file", "bundle-name": "ohos.acts.storage.file",
"package-name": "ohos.acts.storage.file" "package-name": "ohos.acts.storage.file"
}, },
......
...@@ -433,48 +433,45 @@ describe('fileTest', function () { ...@@ -433,48 +433,45 @@ describe('fileTest', function () {
text: 'hello,world', text: 'hello,world',
success: function () { success: function () {
console.info('File_writeText_005 call writeText success.'); console.info('File_writeText_005 call writeText success.');
done(); file.writeText({
}, uri: 'internal://cache/File_writeText_005',
fail: function (data, code) { text: 'hello',
console.info('File_writeText_005 call writeText fail, code: ' + code + ', data: ' + data); append: true,
expect(null).assertFail(); success: function () {
}, console.info('File_writeText_005 call writeText success.');
}); file.readText({
file.writeText({ uri: 'internal://cache/File_writeText_005',
uri: 'internal://cache/File_writeText_005', success: function (data) {
text: 'hello', console.info('File_writeText_005 call read success ' );
append: true, file.delete({
success: function () { uri: 'internal://cache/File_writeText_005',
console.info('File_writeText_005 call writeText success.'); success: function () {
done(); console.info('File_writeText_005 call delete success');
done();
},
fail: function (data, code) {
console.info('File_writeText_005 call delete fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
},
fail: function (data, code) {
console.info('File_writeText_005 call readText fail , code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
},
fail: function (data, code) {
console.info('File_writeText_005 call writeText fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
}, },
fail: function (data, code) { fail: function (data, code) {
console.info('File_writeText_005 call writeText fail, code: ' + code + ', data: ' + data); console.info('File_writeText_005 call writeText fail, code: ' + code + ', data: ' + data);
expect(null).assertFail(); expect(null).assertFail();
}, },
}); });
file.readText({
uri: 'internal://cache/File_writeText_005',
success: function (data) {
console.info('File_writeText_005 call read success ' );
done();
},
fail: function (data, code) {
console.info('File_writeText_005 call readText fail , code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
file.delete({
uri: 'internal://cache/File_writeText_005',
success: function () {
console.info('File_writeText_005 call delete success');
done();
},
fail: function (data, code) {
console.info('File_writeText_005 call delete fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
}); });
/** /**
...@@ -916,33 +913,31 @@ describe('fileTest', function () { ...@@ -916,33 +913,31 @@ describe('fileTest', function () {
buffer: buf, buffer: buf,
success: function () { success: function () {
console.info('File_writeArrayBuffer_006 call writeText success.'); console.info('File_writeArrayBuffer_006 call writeText success.');
done(); file.writeArrayBuffer({
}, uri: 'internal://cache/File_writeArrayBuffer_006',
fail: function (data, code) { buffer: buf,
console.info('File_writeArrayBuffer_006 , code: ' + code + ', data: ' + data); success: function () {
expect(null).assertFail(); console.info('File_writeArrayBuffer_006 call writeArrayBuffer success.');
}, file.readArrayBuffer({
}); uri: 'internal://cache/File_writeArrayBuffer_006',
file.writeArrayBuffer({ success: function () {
uri: 'internal://cache/File_writeArrayBuffer_006', console.info('File_writeArrayBuffer_006 call readArrayBuffer pass');
buffer: buf, done();
success: function () { },
console.info('File_writeArrayBuffer_006 call writeArrayBuffer success.'); fail: function (data, code) {
done(); console.info('File_writeArrayBuffer_006 readArrayBuffer fail, code: ' + code + ', data: ' + data);
}, expect(null).assertFail();
fail: function (data, code) { },
console.info('File_writeArrayBuffer_006 , code: ' + code + ', data: ' + data); });
expect(null).assertFail(); },
}, fail: function (data, code) {
}); console.info('File_writeArrayBuffer_006 writeArrayBuffer fail, code: ' + code + ', data: ' + data);
file.readArrayBuffer({ expect(null).assertFail();
uri: 'internal://cache/File_writeArrayBuffer_006', },
success: function () { });
console.info('File_writeArrayBuffer_006 pass');
done();
}, },
fail: function (data, code) { fail: function (data, code) {
console.info('File_writeArrayBuffer_006 , code: ' + code + ', data: ' + data); console.info('File_writeArrayBuffer_006 writeText fail, code: ' + code + ', data: ' + data);
expect(null).assertFail(); expect(null).assertFail();
}, },
}); });
...@@ -2213,7 +2208,7 @@ describe('fileTest', function () { ...@@ -2213,7 +2208,7 @@ describe('fileTest', function () {
*/ */
it('File_rmdir_005', 0, async function (done) { it('File_rmdir_005', 0, async function (done) {
file.rmdir({ file.rmdir({
uri: 'internal://app/test/123', uri: 'internal://app/notdir/123',
success: function () { success: function () {
console.info('File_rmdir_005 call rmdir success.'); console.info('File_rmdir_005 call rmdir success.');
expect(null).assertFail(); expect(null).assertFail();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册