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

!8247 fileapi 增加write接口入参检查,原有错误码调整

Merge pull request !8247 from zhuhongtao666/bugfix1
...@@ -751,14 +751,13 @@ export default function fileIORead() { ...@@ -751,14 +751,13 @@ export default function fileIORead() {
try { try {
fileIO.read(-1, new ArrayBuffer(4096), (err) => { fileIO.read(-1, new ArrayBuffer(4096), (err) => {
if(err) { if(err) {
console.log('fileIO_test_read_async_013 error: {message: ' + err.message + ', code: ' + err.code + '}'); expect(false).assertTrue();
expect(err.code == 13900020 && err.message == 'Invalid argument').assertTrue();
done();
} }
}); });
} catch (e) { } catch (e) {
console.log('fileIO_test_read_async_013 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_read_async_013 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue(); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
} }
}); });
......
...@@ -238,7 +238,7 @@ export default function fileIOWrite() { ...@@ -238,7 +238,7 @@ export default function fileIOWrite() {
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
console.log('fileIO_test_write_sync_007 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_write_sync_007 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900008 && e.message == 'Bad file descriptor').assertTrue(); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
} }
}); });
...@@ -850,7 +850,7 @@ export default function fileIOWrite() { ...@@ -850,7 +850,7 @@ export default function fileIOWrite() {
} catch (e) { } catch (e) {
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_test_write_async_016 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_write_async_016 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900008 && e.message == 'Bad file descriptor').assertTrue(); expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done(); done();
} }
}); });
...@@ -871,15 +871,13 @@ export default function fileIOWrite() { ...@@ -871,15 +871,13 @@ export default function fileIOWrite() {
try { try {
fileIO.write(-1, FILE_CONTENT, (err) => { fileIO.write(-1, FILE_CONTENT, (err) => {
if(err) { expect(false).assertTrue();
fileIO.unlinkSync(fpath);
console.log('fileIO_test_open_async_020 error: {message: ' + err.message + ', code: ' + err.code + '}');
expect(err.code == 13900008 && err.message == 'Bad file descriptor').assertTrue();
done();
}
}); });
} catch (e) { } catch (e) {
fileIO.unlinkSync(fpath);
console.log('fileIO_test_write_async_017 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_write_async_017 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
} }
}); });
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册