提交 0de230e0 编写于 作者: F futurezhou

fixed a735454 from https://gitee.com/futurezhou/xts_acts/pulls/7165

bugfix for xts
Signed-off-by: Nfuturezhou <zhouweilai@huawei.com>
上级 4136ec77
...@@ -4054,7 +4054,7 @@ export default function fileIOTest() { ...@@ -4054,7 +4054,7 @@ export default function fileIOTest() {
let fpath = await nextFileName('fileio_test_stat_promise_011'); let fpath = await nextFileName('fileio_test_stat_promise_011');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
fileio.chmodSync(fpath, 0o640); fileio.chmodSync(fpath, 0o640);
await fileio.stat(fpath).then((stat)=> { fileio.stat(fpath).then((stat)=> {
expect((stat.mode & 0o777) == 0o640).assertTrue(); expect((stat.mode & 0o777) == 0o640).assertTrue();
fileio.unlinkSync(fpath); fileio.unlinkSync(fpath);
console.info('file stat Success'); console.info('file stat Success');
...@@ -4314,7 +4314,7 @@ export default function fileIOTest() { ...@@ -4314,7 +4314,7 @@ export default function fileIOTest() {
let fpath = await nextFileName('fileio_test_close_async_001'); let fpath = await nextFileName('fileio_test_close_async_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let fd = fileio.openSync(fpath); let fd = fileio.openSync(fpath);
await fileio.close(fd, function (err) { fileio.close(fd, function (err) {
fileio.unlinkSync(fpath); fileio.unlinkSync(fpath);
}); });
}); });
......
...@@ -84,8 +84,8 @@ describe('fileio_stream_close', function () { ...@@ -84,8 +84,8 @@ describe('fileio_stream_close', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let fd = await fileio.openSync(fpath, 0o2); let fd = fileio.openSync(fpath, 0o2);
let ss = await fileio.fdopenStreamSync(fd, 'r+'); let ss = fileio.fdopenStreamSync(fd, 'r+');
expect(ss !== null).assertTrue(); expect(ss !== null).assertTrue();
await ss.close(); await ss.close();
fileio.unlinkSync(fpath); fileio.unlinkSync(fpath);
...@@ -110,8 +110,8 @@ describe('fileio_stream_close', function () { ...@@ -110,8 +110,8 @@ describe('fileio_stream_close', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let fd = await fileio.openSync(fpath, 0o2); let fd = fileio.openSync(fpath, 0o2);
let ss = await fileio.fdopenStreamSync(fd, 'r+'); let ss = fileio.fdopenStreamSync(fd, 'r+');
expect(ss !== null).assertTrue(); expect(ss !== null).assertTrue();
ss.close(function (err) { ss.close(function (err) {
fileio.unlinkSync(fpath); fileio.unlinkSync(fpath);
......
...@@ -87,7 +87,7 @@ describe('fileio_stream_flush', function () { ...@@ -87,7 +87,7 @@ describe('fileio_stream_flush', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let ss = await fileio.createStreamSync(fpath, 'r+'); let ss = fileio.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue(); expect(ss !== null).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
ss.flush().then( ss.flush().then(
...@@ -116,7 +116,7 @@ describe('fileio_stream_flush', function () { ...@@ -116,7 +116,7 @@ describe('fileio_stream_flush', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let ss = await fileio.createStreamSync(fpath, 'r+'); let ss = fileio.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue(); expect(ss !== null).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
ss.flush(function (err) { ss.flush(function (err) {
......
...@@ -61,7 +61,7 @@ describe('fileio_createStream', function () { ...@@ -61,7 +61,7 @@ describe('fileio_createStream', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
await fileio.createStream(fpath, 'r+', function (err, stream) { fileio.createStream(fpath, 'r+', function (err, stream) {
expect(stream.closeSync() == null).assertTrue(); expect(stream.closeSync() == null).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue(); expect(fileio.unlinkSync(fpath) == null).assertTrue();
done(); done();
...@@ -86,7 +86,7 @@ describe('fileio_createStream', function () { ...@@ -86,7 +86,7 @@ describe('fileio_createStream', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
await fileio.createStream(fpath, 'r+', function (err, stream) { fileio.createStream(fpath, 'r+', function (err, stream) {
expect(stream.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); expect(stream.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(stream.closeSync() == null).assertTrue(); expect(stream.closeSync() == null).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue(); expect(fileio.unlinkSync(fpath) == null).assertTrue();
......
...@@ -57,7 +57,7 @@ describe('fileio_open', function () { ...@@ -57,7 +57,7 @@ describe('fileio_open', function () {
fileio.open(fpath, 0, 0o0400, function (err, fd) { fileio.open(fpath, 0, 0o0400, function (err, fd) {
fileio.read(fd, new ArrayBuffer(4096)) fileio.read(fd, new ArrayBuffer(4096))
.then(function (res) { .then(function (res) {
expect((String.fromCharCode.apply(null, new Uint8Array(res.buffer))) == FILE_CONTENT).assertTrue; expect((String.fromCharCode.apply(null, new Uint8Array(res.buffer))) == FILE_CONTENT).assertTrue();
expect(res.bytesRead == FILE_CONTENT.length).assertTrue(); expect(res.bytesRead == FILE_CONTENT.length).assertTrue();
fileio.closeSync(fd); fileio.closeSync(fd);
fileio.unlinkSync(fpath); fileio.unlinkSync(fpath);
...@@ -87,7 +87,7 @@ describe('fileio_open', function () { ...@@ -87,7 +87,7 @@ describe('fileio_open', function () {
await fileio.open(fpath, 0, 0o0400, function (err, fd) { await fileio.open(fpath, 0, 0o0400, function (err, fd) {
fileio.read(fd, new ArrayBuffer(4096)) fileio.read(fd, new ArrayBuffer(4096))
.then(function (res) { .then(function (res) {
expect((String.fromCharCode.apply(null, new Uint8Array(res.buffer))) == FILE_CONTENT).assertTrue; expect((String.fromCharCode.apply(null, new Uint8Array(res.buffer))) == FILE_CONTENT).assertTrue();
expect(res.bytesRead == FILE_CONTENT.length).assertTrue(); expect(res.bytesRead == FILE_CONTENT.length).assertTrue();
fileio.closeSync(fd); fileio.closeSync(fd);
fileio.unlinkSync(fpath); fileio.unlinkSync(fpath);
...@@ -116,7 +116,7 @@ describe('fileio_open', function () { ...@@ -116,7 +116,7 @@ describe('fileio_open', function () {
await fileio.open(fpath, 0, function (err, fd) { await fileio.open(fpath, 0, function (err, fd) {
fileio.read(fd, new ArrayBuffer(4096)) fileio.read(fd, new ArrayBuffer(4096))
.then(function (res) { .then(function (res) {
expect((String.fromCharCode.apply(null, new Uint8Array(res.buffer))) == FILE_CONTENT).assertTrue; expect((String.fromCharCode.apply(null, new Uint8Array(res.buffer))) == FILE_CONTENT).assertTrue();
expect(res.bytesRead == FILE_CONTENT.length).assertTrue(); expect(res.bytesRead == FILE_CONTENT.length).assertTrue();
fileio.closeSync(fd); fileio.closeSync(fd);
fileio.unlinkSync(fpath); fileio.unlinkSync(fpath);
...@@ -145,7 +145,7 @@ describe('fileio_open', function () { ...@@ -145,7 +145,7 @@ describe('fileio_open', function () {
fileio.open(fpath, 0o2, function (err, fd) { fileio.open(fpath, 0o2, function (err, fd) {
fileio.read(fd, new ArrayBuffer(4096)) fileio.read(fd, new ArrayBuffer(4096))
.then(function (res) { .then(function (res) {
expect((String.fromCharCode.apply(null, new Uint8Array(res.buffer))) == FILE_CONTENT).assertTrue; expect((String.fromCharCode.apply(null, new Uint8Array(res.buffer))) == FILE_CONTENT).assertTrue();
expect(res.bytesRead == FILE_CONTENT.length).assertTrue(); expect(res.bytesRead == FILE_CONTENT.length).assertTrue();
fileio.closeSync(fd); fileio.closeSync(fd);
fileio.unlinkSync(fpath); fileio.unlinkSync(fpath);
...@@ -175,7 +175,7 @@ describe('fileio_open', function () { ...@@ -175,7 +175,7 @@ describe('fileio_open', function () {
.then(function (fd) { .then(function (fd) {
fileio.read(fd, new ArrayBuffer(4096)) fileio.read(fd, new ArrayBuffer(4096))
.then(function (res) { .then(function (res) {
expect((String.fromCharCode.apply(null, new Uint8Array(res.buffer))) == FILE_CONTENT).assertTrue; expect((String.fromCharCode.apply(null, new Uint8Array(res.buffer))) == FILE_CONTENT).assertTrue();
expect(res.bytesRead == FILE_CONTENT.length).assertTrue(); expect(res.bytesRead == FILE_CONTENT.length).assertTrue();
fileio.closeSync(fd); fileio.closeSync(fd);
fileio.unlinkSync(fpath); fileio.unlinkSync(fpath);
...@@ -207,7 +207,7 @@ describe('fileio_open', function () { ...@@ -207,7 +207,7 @@ describe('fileio_open', function () {
.then(function (fd) { .then(function (fd) {
fileio.read(fd, new ArrayBuffer(4096)) fileio.read(fd, new ArrayBuffer(4096))
.then(function (res) { .then(function (res) {
expect((String.fromCharCode.apply(null, new Uint8Array(res.buffer))) == FILE_CONTENT).assertTrue; expect((String.fromCharCode.apply(null, new Uint8Array(res.buffer))) == FILE_CONTENT).assertTrue();
expect(res.bytesRead == FILE_CONTENT.length).assertTrue(); expect(res.bytesRead == FILE_CONTENT.length).assertTrue();
fileio.closeSync(fd); fileio.closeSync(fd);
fileio.unlinkSync(fpath); fileio.unlinkSync(fpath);
...@@ -239,7 +239,7 @@ describe('fileio_open', function () { ...@@ -239,7 +239,7 @@ describe('fileio_open', function () {
.then(function (fd) { .then(function (fd) {
fileio.read(fd, new ArrayBuffer(4096)) fileio.read(fd, new ArrayBuffer(4096))
.then(function (res) { .then(function (res) {
expect((String.fromCharCode.apply(null, new Uint8Array(res.buffer))) == FILE_CONTENT).assertTrue; expect((String.fromCharCode.apply(null, new Uint8Array(res.buffer))) == FILE_CONTENT).assertTrue();
expect(res.bytesRead == FILE_CONTENT.length).assertTrue(); expect(res.bytesRead == FILE_CONTENT.length).assertTrue();
fileio.closeSync(fd); fileio.closeSync(fd);
fileio.unlinkSync(fpath); fileio.unlinkSync(fpath);
......
...@@ -171,7 +171,7 @@ describe('fileio_readtext', function () { ...@@ -171,7 +171,7 @@ describe('fileio_readtext', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
await fileio.readText(fpath, { position: pos, length: len, encoding: 'UTF-8' }, function (err, str) { fileio.readText(fpath, { position: pos, length: len, encoding: 'UTF-8' }, function (err, str) {
expect(str == FILE_CONTENT.substr(pos, len)).assertTrue(); expect(str == FILE_CONTENT.substr(pos, len)).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue(); expect(fileio.unlinkSync(fpath) == null).assertTrue();
done(); done();
...@@ -198,7 +198,7 @@ describe('fileio_readtext', function () { ...@@ -198,7 +198,7 @@ describe('fileio_readtext', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
await fileio.readText(fpath, { position: 1 }, function (err, str) { fileio.readText(fpath, { position: 1 }, function (err, str) {
expect(str == FILE_CONTENT.substr(pos, len)).assertTrue(); expect(str == FILE_CONTENT.substr(pos, len)).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue(); expect(fileio.unlinkSync(fpath) == null).assertTrue();
done(); done();
...@@ -225,7 +225,7 @@ describe('fileio_readtext', function () { ...@@ -225,7 +225,7 @@ describe('fileio_readtext', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
await fileio.readText(fpath, { position: 1 }, function (err, str) { fileio.readText(fpath, { position: 1 }, function (err, str) {
expect(str == FILE_CONTENT.substr(pos, len)).assertTrue(); expect(str == FILE_CONTENT.substr(pos, len)).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue(); expect(fileio.unlinkSync(fpath) == null).assertTrue();
}); });
......
...@@ -35,7 +35,7 @@ describe('fileio_rename', function () { ...@@ -35,7 +35,7 @@ describe('fileio_rename', function () {
try { try {
let newf = fpath + '123'; let newf = fpath + '123';
await fileio.rename(fpath, newf) fileio.rename(fpath, newf)
.then(function (err) { .then(function (err) {
expect(fileio.accessSync(newf) == null).assertTrue(); expect(fileio.accessSync(newf) == null).assertTrue();
expect(err == null).assertTrue(); expect(err == null).assertTrue();
...@@ -65,7 +65,7 @@ describe('fileio_rename', function () { ...@@ -65,7 +65,7 @@ describe('fileio_rename', function () {
try { try {
let newf = fpath + 'aaa'; let newf = fpath + 'aaa';
await fileio.rename(fpath, newf, function (err) { fileio.rename(fpath, newf, function (err) {
expect(fileio.accessSync(newf) == null).assertTrue(); expect(fileio.accessSync(newf) == null).assertTrue();
expect(fileio.unlinkSync(newf) == null).assertTrue(); expect(fileio.unlinkSync(newf) == null).assertTrue();
done(); done();
...@@ -89,7 +89,7 @@ describe('fileio_rename', function () { ...@@ -89,7 +89,7 @@ describe('fileio_rename', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
await fileio.access(fpath).then(function (err) { fileio.access(fpath).then(function (err) {
let newf = fpath + '123'; let newf = fpath + '123';
fileio.rename(fpath, newf) fileio.rename(fpath, newf)
.then(function (err) { .then(function (err) {
......
...@@ -86,7 +86,7 @@ describe('fileio_symlink', function () { ...@@ -86,7 +86,7 @@ describe('fileio_symlink', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
await fileio.symlink(fpath, fpath + 'pass2', function (err) { fileio.symlink(fpath, fpath + 'pass2', function (err) {
fileio.accessSync(fpath + 'pass2'); fileio.accessSync(fpath + 'pass2');
fileio.unlinkSync(fpath); fileio.unlinkSync(fpath);
fileio.unlinkSync(fpath + 'pass2'); fileio.unlinkSync(fpath + 'pass2');
......
...@@ -435,7 +435,7 @@ describe('fileio_write', function () { ...@@ -435,7 +435,7 @@ describe('fileio_write', function () {
try { try {
let fd = fileio.openSync(fpath, 0o102, 0o666); let fd = fileio.openSync(fpath, 0o102, 0o666);
expect(isIntNum(fd)).assertTrue(); expect(isIntNum(fd)).assertTrue();
await fileio.write(fd, new ArrayBuffer(4096), function ( fileio.write(fd, new ArrayBuffer(4096), function (
error, error,
bytesWritten bytesWritten
) { ) {
...@@ -465,7 +465,7 @@ describe('fileio_write', function () { ...@@ -465,7 +465,7 @@ describe('fileio_write', function () {
try { try {
let fd = fileio.openSync(fpath, 0o102, 0o666); let fd = fileio.openSync(fpath, 0o102, 0o666);
expect(isIntNum(fd)).assertTrue(); expect(isIntNum(fd)).assertTrue();
await fileio.write( fileio.write(
fd, fd,
FILE_CONTENT, FILE_CONTENT,
{ {
...@@ -498,7 +498,7 @@ describe('fileio_write', function () { ...@@ -498,7 +498,7 @@ describe('fileio_write', function () {
try { try {
let fd = fileio.openSync(fpath, 0o102, 0o666); let fd = fileio.openSync(fpath, 0o102, 0o666);
expect(isIntNum(fd)).assertTrue(); expect(isIntNum(fd)).assertTrue();
await fileio.write( fileio.write(
fd, fd,
FILE_CONTENT, FILE_CONTENT,
{ {
...@@ -532,7 +532,7 @@ describe('fileio_write', function () { ...@@ -532,7 +532,7 @@ describe('fileio_write', function () {
try { try {
let fd = fileio.openSync(fpath, 0o102, 0o666); let fd = fileio.openSync(fpath, 0o102, 0o666);
expect(isIntNum(fd)).assertTrue(); expect(isIntNum(fd)).assertTrue();
await fileio.write( fileio.write(
fd, fd,
FILE_CONTENT, FILE_CONTENT,
{ {
...@@ -567,7 +567,7 @@ describe('fileio_write', function () { ...@@ -567,7 +567,7 @@ describe('fileio_write', function () {
try { try {
let fd = fileio.openSync(fpath, 0o102, 0o666); let fd = fileio.openSync(fpath, 0o102, 0o666);
expect(isIntNum(fd)).assertTrue(); expect(isIntNum(fd)).assertTrue();
await fileio.write( fileio.write(
fd, fd,
FILE_CONTENT, FILE_CONTENT,
{ {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册